Using the following validation rules:
'somefield' => 'required|min:20',
An input value of "Extra space."
will pass min:20
validation.
What is the best way to ignore more than single spaces in the middle of a string when applying the min validation rule so the above input value would fail? Not looking for a client-side solution.
2
Answers
Use method prepareForValidation() in FormRequeet, try:
References:
https://laravel.com/docs/9.x/validation#preparing-input-for-validation
https://laravel.com/docs/9.x/helpers#method-str-squish
You can use this simple validation.