S
S
sp-megamen2018-04-16 13:23:53
Laravel
sp-megamen, 2018-04-16 13:23:53

How to organize a similar validation of a multidimensional array in laravel?

Hey!
I want to validate a multidimensional array in laravel.
The request comes with bundles that have fields:

Бандл 1
---Поле 1
---Поле 2
Бандл 2
---Поле 1

Within a bundle, the field names must be unique, but the field names of different bundles can be the same.
I make a loop to get an array like this:
"bundles.0.fields.*.name" => "distinct"
"bundles.1.fields.*.name" => "distinct"

At the same time,
Bundle 1
---Field 1
---Field 1
successfully passes validation, which is unacceptable.
If instead of putting the creation of the rule in a subloop, something like this would happen:
"bundles.0.fields.0.name" => "distinct"
"bundles.0.fields.1.name" => "distinct"
"bundles.1.fields.0.name" => "distinct"

Then the following data does not pass validation (two "Field 1", albeit in different bundles):
Bundle 1
---Field 1
---Field 2
Bundle 2
---Field 1
Please tell me how to do it right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tesla, 2018-04-16
@Tesla

There is also array validation . If this is not enough, then you can always file a custom rule .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question