mercredi 24 janvier 2018

Laravel L5 complex validation of array data

In my application, have a form that could (theoretically) have infinite task and I want to define a validation rule in my Request that checks that none of them is equals to each others:

From:

<select name="task[1][id][]" class="form-control">

..

<select name="task[2][id][]" class="form-control">

..
..

<select name="task[n][id][]" class="form-control">

Since I am still not familiar enough with Laravel validations, I was naiv and tried things like:

'task[1][qrtaskid][]' => 'different:task[2][qrtaskid][]', 'task[2][qrtaskid][]' => 'different:task[1][qrtaskid][]'

or:

'task[1][qrtaskid][*]' => 'different:task[2][qrtaskid][*]', 'task[2][qrtaskid][*]' => 'different:task[1][qrtaskid][*]'

or:

'task[*][qrtaskid][*]' => 'different:task[*][qrtaskid][*]'

I do not get any error, but the validation always passes. I am pretty sure, that there is a good way to get this thing running, but I think that I am on the wrong way..



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire