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

[9.x] Fixed missing_with and missing_with_all validation #45913

Merged
merged 1 commit into from
Feb 2, 2023

Conversation

erik-perri
Copy link
Contributor

The missing_with and missing_with_all rules are failing validation whether or not the specified field is in the data array. This brings the logic in line with the other missing validators to match the documentation.

Reproduction steps:

$ composer create-project laravel/laravel test-app
$ cd test-app/
$ php artisan tinker
Psy Shell v0.11.12 (PHP 8.1.2-1ubuntu2.9 — cli) by Justin Hileman
> Validator::make(['baz' => '1'], ['foo' => 'missing_with:baz'])->errors()->toArray()
= [
    "foo" => [
      "The foo field must be missing when baz is present.",
    ],
  ]

> Validator::make(['bar' => '1', 'baz' => '1'], ['foo' => 'missing_with_all:bar,baz'])->errors()->toArray()
= [
    "foo" => [
      "The foo field must be missing when bar / baz are present.",
    ],
  ]

Copy link
Member

@timacdonald timacdonald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @erik-perri

@taylorotwell taylorotwell merged commit 3d92fd1 into laravel:9.x Feb 2, 2023
@erik-perri erik-perri deleted the missing-with-fix branch February 2, 2023 13:10
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