I have a input field as:
<input type="email" name="email" />
And it works fine with the laravel validation rules as:
$rules = [
'email' => 'email|required',
]
But if someone changes the HTML input field name using console something like:
<input type="email" name="email[]" />
Laravel does not catch the validation and returns an error:
Is there any better way to handle such input manipulation in laravel?
Thanks for the help!
you can use
$rules = [
'email.*' => 'email|required',
]
this will validate each items in array
refer https://laravel.com/docs/5.6/validation#validating-arrays