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

[10.x] Fix validation of attributes that depend on previous excluded attribute #48122

Merged
merged 7 commits into from
Aug 27, 2023
Merged

[10.x] Fix validation of attributes that depend on previous excluded attribute #48122

merged 7 commits into from
Aug 27, 2023

Conversation

hans-thomas
Copy link
Contributor

Hi, I finished #47622 PR and fixed the problem. As @onlime said, there was a problem when we use a validation rule that depends on another attribute while the other attribute has exclude validation rule.
In that situation, the excluded attribute must be placed after the attribute with dependent validation rule.
This PR fixed this problem and there is no need to consider the ordering.

// WORKING:
[
    'profile_id' => ['nullable', 'required_if:type,profile', 'integer'],
    'type'       => ['required', 'string', 'exclude'],
],

// NON-WORKING, as 'type' is excluded before 'required_if' is checked in 'profile_id':
[
    'type'       => ['required', 'string', 'exclude'],
    'profile_id' => ['nullable', 'required_if:type,profile', 'integer'],
],

@hans-thomas hans-thomas marked this pull request as ready for review August 19, 2023 19:25
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.

3 participants