Skip to content

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