I'm having a bit of a weird issue and i'm not quite sure why its happening or if i'm just missing something.
I have multiple validation rules on a input 'postcode' field, like so
'postcode' => [
'required',
'min:5',
'max:8',
'regex:/^[a-z]/i'
],
And i've also wrote custom messages for the rules like so
return [
'postcode.min' => 'The postcode must be at least 5 characters',
'postcode.regex' => 'Sorry, the postcode must start with a letter',
];
All of my errors are being looped and displayed like this
<div class="error-block {{ (count($errors) > 0) ? '' : 'hide' }}">
<div class="col-12">
<ul>
@if(count($errors) > 0)
@foreach($errors->all() as $error)
<li>{{$error}}</li>
@endforeach
@endif
</ul>
</div>
</div>
But when both rules are hit for the postcode, for example with the input '123', then it pushes both errors out on the same line, but all other errors show correctly, like this
- The postcode must be at least 5 characters,Sorry, the postcode must start with a letter.
- The username field is required.
- The address line 1 field is required.
Why is laravel pushing the min and regex rule messages out on the same line?
var_dump($errors); exit;
and see what you get. – delboy1978uk