We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
The text was updated successfully, but these errors were encountered:
Hi,
is this covered by the A More Complex Example? There is a field "postings" which is an array of objects.
Sorry, something went wrong.
I got it now: Using a collection also requires a "nested" element. But still no luck...
$validator = new Validator(); $rules = RulesBuilder::create() ->rule('collection', $validator, RulesBuilder::create() ->rule('nested', $validator, RulesBuilder::create() ->field('foo', 'required') ->field('bar', 'required') ->field('baz', 'required') ->build() ) ->build() ) ->build();
I can work with named elements... Yeah. But it will just not work with "unnamed" sequences for me. The above example works, when i use:
$rules = RulesBuilder::create() ->field('namedItem', 'collection', $validator, RulesBuilder::create() ->rule('nested', $validator, RulesBuilder::create() ...
No branches or pull requests
Requirement:
I want to validate an array of objects, like:
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.
The text was updated successfully, but these errors were encountered: