Validation is put in an error bag. If I have an er" /> Validation is put in an error bag. If I have an er" /> Validation is put in an error bag. If I have an er"/>

Check if error bag of input array has a particular index

165 Views Asked by At

Version of Laravel: 5.5.*

Form

<input name="name[]"/>
<input name="name[]"/>
<input name="name[]"/>

Validation is put in an error bag.

If I have an error on the second input, I will get an array of error messages with

name.1 => "error message"

What I want to do is check if the bag has any error for the index name.i

How can I do that?

1

There are 1 best solutions below

0
Ruben On BEST ANSWER

You can check the error at the index i with

$errors->bagname->has('*.i')