diff --git a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php index cb37e462980b..660818ed0d08 100644 --- a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php @@ -217,7 +217,10 @@ protected function replaceMissingIf($message, $attribute, $rule, $parameters) */ protected function replaceMissingUnless($message, $attribute, $rule, $parameters) { - return $this->replaceMissingIf($message, $attribute, $rule, $parameters); + return str_replace([':other', ':value'], [ + $this->getDisplayableAttribute($parameters[0]), + $this->getDisplayableValue($parameters[0], $parameters[1]), + ], $message); } /** diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index ecc9cd18e534..6a35a0a72b21 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -2324,23 +2324,23 @@ public function testValidateMissingUnless() $v = new Validator($trans, ['foo' => 'yes', 'bar' => '2'], ['foo' => 'missing_unless:bar,1']); $this->assertFalse($v->passes()); - $this->assertSame('The foo field must be missing unless bar is 2.', $v->errors()->first('foo')); + $this->assertSame('The foo field must be missing unless bar is 1.', $v->errors()->first('foo')); $v = new Validator($trans, ['foo' => '', 'bar' => '2'], ['foo' => 'missing_unless:bar,1']); $this->assertFalse($v->passes()); - $this->assertSame('The foo field must be missing unless bar is 2.', $v->errors()->first('foo')); + $this->assertSame('The foo field must be missing unless bar is 1.', $v->errors()->first('foo')); $v = new Validator($trans, ['foo' => ' ', 'bar' => '2'], ['foo' => 'missing_unless:bar,1']); $this->assertFalse($v->passes()); - $this->assertSame('The foo field must be missing unless bar is 2.', $v->errors()->first('foo')); + $this->assertSame('The foo field must be missing unless bar is 1.', $v->errors()->first('foo')); $v = new Validator($trans, ['foo' => null, 'bar' => '2'], ['foo' => 'missing_unless:bar,1']); $this->assertFalse($v->passes()); - $this->assertSame('The foo field must be missing unless bar is 2.', $v->errors()->first('foo')); + $this->assertSame('The foo field must be missing unless bar is 1.', $v->errors()->first('foo')); $v = new Validator($trans, ['foo' => [], 'bar' => '2'], ['foo' => 'missing_unless:bar,1']); $this->assertFalse($v->passes()); - $this->assertSame('The foo field must be missing unless bar is 2.', $v->errors()->first('foo')); + $this->assertSame('The foo field must be missing unless bar is 1.', $v->errors()->first('foo')); $v = new Validator($trans, ['foo' => new class implements Countable { @@ -2350,7 +2350,7 @@ public function count(): int } }, 'bar' => '2', ], ['foo' => 'missing_unless:bar,1']); $this->assertFalse($v->passes()); - $this->assertSame('The foo field must be missing unless bar is 2.', $v->errors()->first('foo')); + $this->assertSame('The foo field must be missing unless bar is 1.', $v->errors()->first('foo')); $v = new Validator($trans, ['foo' => 'foo', 'bar' => '1'], ['foo' => 'missing_unless:bar,1']); $this->assertTrue($v->passes());