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. -]+$/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With