Skip to content
New issue

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

Passes method of custom validation rule receives array keys with dotPlaceholder #34263

Closed
PiranhaGeorge opened this issue Sep 10, 2020 · 7 comments
Assignees

Comments

@PiranhaGeorge
Copy link

  • Laravel Version: 8
  • PHP Version: 7.4
  • Database Driver & Version: n/a

Description:

When validating an array with a custom validation Rule, the $value param of the rule's passes() method receives the array with dot placeholders included in keys. This makes it impossible to validate array keys containing dots.

Related to #33357

Steps To Reproduce:

Send a request with an array query parameter that has keys containing dots e.g. foo[foo.bar]=baz

Validate with a custom validation rule e.g. ['foo' => new CustomRule()]

dd() the $value param of the passes() method and the result will be something like: ['fooP0gffDX4ilGw68H6bar' => 'baz']

@taylorotwell
Copy link
Member

I don't believe we allow dots in input variables during validation because dots have special meaning with array depth validation in Laravel.

@taylorotwell
Copy link
Member

Ping @themsaid

@PiranhaGeorge
Copy link
Author

I don't believe we allow dots in input variables during validation because dots have special meaning with array depth validation in Laravel.

This worked just fine prior to version 7 with the -> replacement. I realise this was probably undocumented functionality but we found it really useful for creating APIs with relational filters e.g. filter[posts.category.id][is]=5

@taylorotwell
Copy link
Member

Fixed in upcoming patch release.

@BenWalters
Copy link
Contributor

@taylorotwell is this being patched in v7 also?

@driesvints
Copy link
Member

@BenWalters #34355

@airgrim
Copy link

airgrim commented Dec 16, 2020

Issue is still actual for 6.x
@taylorotwell will fix be ported there too ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants