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

[6.x] Fix exclude validation rules for nested data #31006

Merged
merged 4 commits into from Jan 3, 2020

Conversation

@SjorsO
Copy link
Contributor

SjorsO commented Jan 2, 2020

PR #30835 added the exclude_if and exclude_unless validation rules. The following example currently doesn't work, this PR fixes that:

$request->validate([
    'vehicles.*.type' => 'required|in:car,boat',
    'vehicles.*.wheels' => 'exclude_if:vehicles.*.type,boat|required|numeric',
]);

The tests in this PR also contains an example of fields nested 2 levels deep getting included in the validated data, even though they don't have a validation rule. There has been discussion about this bug/feature in the past: laravel/ideas#1993 (comment). This is unrelated to the exclude validation rules, but I ran into it and thought it would be a useful addition to the test suite.


This PR came from trying to replicate the weird behavior I encountered while making the original PR (see: #30835 (comment)). I couldn't replicate it, I must have been doing something wrong.

SjorsO added 4 commits Jan 2, 2020
cs
wip
@taylorotwell taylorotwell merged commit 523c0fb into laravel:6.x Jan 3, 2020
2 checks passed
2 checks passed
continuous-integration/styleci/pr The analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@SjorsO SjorsO deleted the SjorsO:tests-for-validation-nesting branch Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.