Requirement:
I want to validate an array of objects, like:
[
{
"foo": "foo1",
"bar": "bar1",
"baz": "baz1"
},
{
"foo": "foo2",
"bar": "bar2",
"baz": "baz2"
},
{
"foo": "foo3",
"bar": "bar3",
"baz": "baz3"
}
]
So I tried this:
$validator = new Validator();
$rules = RulesBuilder::create()
->rule('collection', RulesBuilder::create()
->field('foo', 'required')
->field('bar', 'required')
->field('baz', 'required')
->build()
)->build();
But I get the error:
array_shift() expects parameter 1 to be array, string given
vendor/philiplb/valdi/src/Valdi/Validator.php:131
It would be nice, to get an example on how to validate "unnamed" collections.
Requirement:
I want to validate an array of objects, like:
[ { "foo": "foo1", "bar": "bar1", "baz": "baz1" }, { "foo": "foo2", "bar": "bar2", "baz": "baz2" }, { "foo": "foo3", "bar": "bar3", "baz": "baz3" } ]So I tried this:
But I get the error:
array_shift() expects parameter 1 to be array, string given
vendor/philiplb/valdi/src/Valdi/Validator.php:131
It would be nice, to get an example on how to validate "unnamed" collections.