Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

isimelek's avatar

Array field validation

How can I validate array field?

Text::make($lang->name,  'translation[]')->rules(['translation.*'=>'required']);

In the model is

    protected $casts = [
        'translation'=>'array'
    ];

always get validation.required error for filled out input

I also tried without [] in the name of the field, but in this case is not recognized as an array

0 likes
3 replies
isimelek's avatar

Thank you for your reply, but it isn't solve my problem of validating array input

m7vm7v's avatar

@isimelek have you tried the package? The field can be validated by -

->rules([
    'translation.*' => 'required',
])

Please or to participate in this conversation.