From 7a509492d41b99351841bd515cde8197fa96dd73 Mon Sep 17 00:00:00 2001 From: Dees Oomens Date: Thu, 18 Nov 2021 12:18:33 +0100 Subject: [PATCH 1/3] Added Prohibits validation rule to dependentRules property --- src/Illuminate/Validation/Validator.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Illuminate/Validation/Validator.php b/src/Illuminate/Validation/Validator.php index 9d9624e3a9eb..8d9a875d7b23 100755 --- a/src/Illuminate/Validation/Validator.php +++ b/src/Illuminate/Validation/Validator.php @@ -247,6 +247,7 @@ class Validator implements ValidatorContract 'Prohibited', 'ProhibitedIf', 'ProhibitedUnless', + 'Prohibits', 'Same', 'Unique', ]; From b029f594095769ae1487d071b143a39a5f149807 Mon Sep 17 00:00:00 2001 From: Dees Oomens Date: Thu, 18 Nov 2021 13:21:05 +0100 Subject: [PATCH 2/3] Test if prohibits validation rule depends on other fields --- tests/Validation/ValidationValidatorTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index edb9e4cdeb52..dc66805bf258 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -1509,6 +1509,17 @@ public function testProhibits() $v = new Validator($trans, ['email' => 'foo', 'emails' => 'bar', 'email_address' => 'baz'], ['email' => 'prohibits:emails,email_address']); $this->assertFalse($v->passes()); $this->assertSame('The email field prohibits emails / email address being present.', $v->messages()->first('email')); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, [ + 'foo' => [ + ['email' => 'foo', 'emails' => 'foo'], + ['emails' => 'foo'], + ] + ], ['foo.*.email' => 'prohibits:foo.*.emails']); + $this->assertFalse($v->passes()); + $this->assertTrue($v->messages()->has('foo.0.email')); + $this->assertFalse($v->messages()->has('foo.1.email')); } public function testFailedFileUploads() From e0ac9c73266ce7180886e37320198de64b16f610 Mon Sep 17 00:00:00 2001 From: Dees Oomens Date: Thu, 18 Nov 2021 13:22:33 +0100 Subject: [PATCH 3/3] Fixed code style --- tests/Validation/ValidationValidatorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index dc66805bf258..99880973fc10 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -1515,7 +1515,7 @@ public function testProhibits() 'foo' => [ ['email' => 'foo', 'emails' => 'foo'], ['emails' => 'foo'], - ] + ], ], ['foo.*.email' => 'prohibits:foo.*.emails']); $this->assertFalse($v->passes()); $this->assertTrue($v->messages()->has('foo.0.email'));