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'm not 100% sure that this is a bug or intended behaviour but I've been validating an array of values as follows:
$array = [ ['id' => 1], ['id' => 2], ]; $rules = [ '*' => 'array', '*.id' => 'required', ]; Validator::make($array, $rules)->validate();
Now if I use the distinct rule on the '*.id' column it doesn't work. However if I put it into a non-top-level property, it does eg
distinct
$array = [ 'items' => [ ['id' => 1], ['id' => 2], ], ]; $rules = [ 'items' => 'array', 'items.*.id' => 'required|distinct', ];
I guess the question is, are top-level array validation rules supposed to work like this?
Using the following code, the Validator instance will not fire a validation error.
$array = [ ['id' => 1], ['id' => 1], ]; $rules = [ '*' => 'array', '*.id' => 'required|distinct', ]; Validator::make($array, $rules)->validate();
The text was updated successfully, but these errors were encountered:
@driesvints This is still an issue in 5.8.29.
Sorry, something went wrong.
I reproduced it in laravel 5.8 and without '*' => 'array', it works fine!
'*' => 'array',
$array = [ ['id' => 1], ['id' => 1], ]; $rules = [ '*.id' => 'required|distinct', ]; Validator::make($array, $rules)->validate();
and also it works by changing the order of rules! :
$rules = [ '*.id' => 'required|distinct', '*' => 'array', ];
Successfully merging a pull request may close this issue.
Description:
I'm not 100% sure that this is a bug or intended behaviour but I've been validating an array of values as follows:
Now if I use the
distinct
rule on the '*.id' column it doesn't work. However if I put it into a non-top-level property, it does egI guess the question is, are top-level array validation rules supposed to work like this?
Steps To Reproduce:
Using the following code, the Validator instance will not fire a validation error.
The text was updated successfully, but these errors were encountered: