I have this validation:
'users.first_name' => 'required|min:2|regex:/[A-Za-z. -]/|max:255',
Why this validation pass this name: John[][]
I have this validation:
'users.first_name' => 'required|min:2|regex:/[A-Za-z. -]/|max:255',
Why this validation pass this name: John[][]
Someone in comments also pointed to this issue that by /[A-Za-z. -]/
you don't care about all characters but saying that's enough for me if field under validation has only the least of that characters.
To have only those characters you should specify beginning and ending of the input text by using a caret ^
and $
:
regex:/^[A-Za-z. -]+$/
'users.first_name' => 'required|min:2|alpha_dash|max:255',