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

[8.x] Replace escaped dot with place holder in dependent rules parameters #39935

Merged
merged 4 commits into from
Dec 8, 2021
Merged

[8.x] Replace escaped dot with place holder in dependent rules parameters #39935

merged 4 commits into from
Dec 8, 2021

Conversation

glamax13
Copy link
Contributor

@glamax13 glamax13 commented Dec 8, 2021

Hi,
While using the validation tool i stumbled upon an issue with the "required_without" rule.
My use case was somewhat unusual but i needed to check that a field was required if a key was present in an array.
The catch is that the key had a dot in it and i couldn't escape it.

Example:
data: ["country" => ["country_code" => "FR"], "city" => ["iata.alternate_name" => "ORY"]]
rules: ['country.country_code' => ['required_without:city.iata\.alternate_name', 'size:2'], 'city.iata\.alternate_name' => ['required_without:country.country_code', 'size:3'],];

Issue:
The rule wouldn't passe because the dot was interpreted as a nested array.

Solution:
I replaced the dot with the dot placeholder for dependent rules.

@GrahamCampbell GrahamCampbell changed the title Replace escaped dot with place holder in dependent rules parameters [8.x] Replace escaped dot with place holder in dependent rules parameters Dec 8, 2021
@taylorotwell taylorotwell merged commit 6fb7c44 into laravel:8.x Dec 8, 2021
@taylorotwell
Copy link
Member

Thanks for contributing to Laravel! ❤️

@glamax13 glamax13 deleted the bugfix/escaped-dot-with-dependent-validation branch December 8, 2021 20:54
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

Successfully merging this pull request may close these issues.

2 participants