Skip to content
Advertisement

How to validate array with RegExr laravel

I am using laravel and I want to validate request like this

      'specification' => 'min:1|max:100000|regex:/^[ا-یa-zA-Z0-9- ]+$/u',

but it is as a array like this

enter image description here

it works well with string but not validate array

Advertisement

Answer

Try this

'specification.*' => 'min:1|max:100000|regex:/^[ا-یa-zA-Z0-9- ]+$/u'

when you have an array from input then the .* applies the validation rule to every item in that array

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement