Skip to content

Commit 89ac58a

Browse files
committed
fix replace missing_unless
1 parent 5f30445 commit 89ac58a

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/Illuminate/Validation/Concerns/ReplacesAttributes.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,10 @@ protected function replaceMissingIf($message, $attribute, $rule, $parameters)
217217
*/
218218
protected function replaceMissingUnless($message, $attribute, $rule, $parameters)
219219
{
220-
return $this->replaceMissingIf($message, $attribute, $rule, $parameters);
220+
return str_replace([':other', ':value'], [
221+
$this->getDisplayableAttribute($parameters[0]),
222+
$this->getDisplayableValue($parameters[0], $parameters[1]),
223+
], $message);
221224
}
222225

223226
/**

tests/Validation/ValidationValidatorTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2324,23 +2324,23 @@ public function testValidateMissingUnless()
23242324

23252325
$v = new Validator($trans, ['foo' => 'yes', 'bar' => '2'], ['foo' => 'missing_unless:bar,1']);
23262326
$this->assertFalse($v->passes());
2327-
$this->assertSame('The foo field must be missing unless bar is 2.', $v->errors()->first('foo'));
2327+
$this->assertSame('The foo field must be missing unless bar is 1.', $v->errors()->first('foo'));
23282328

23292329
$v = new Validator($trans, ['foo' => '', 'bar' => '2'], ['foo' => 'missing_unless:bar,1']);
23302330
$this->assertFalse($v->passes());
2331-
$this->assertSame('The foo field must be missing unless bar is 2.', $v->errors()->first('foo'));
2331+
$this->assertSame('The foo field must be missing unless bar is 1.', $v->errors()->first('foo'));
23322332

23332333
$v = new Validator($trans, ['foo' => ' ', 'bar' => '2'], ['foo' => 'missing_unless:bar,1']);
23342334
$this->assertFalse($v->passes());
2335-
$this->assertSame('The foo field must be missing unless bar is 2.', $v->errors()->first('foo'));
2335+
$this->assertSame('The foo field must be missing unless bar is 1.', $v->errors()->first('foo'));
23362336

23372337
$v = new Validator($trans, ['foo' => null, 'bar' => '2'], ['foo' => 'missing_unless:bar,1']);
23382338
$this->assertFalse($v->passes());
2339-
$this->assertSame('The foo field must be missing unless bar is 2.', $v->errors()->first('foo'));
2339+
$this->assertSame('The foo field must be missing unless bar is 1.', $v->errors()->first('foo'));
23402340

23412341
$v = new Validator($trans, ['foo' => [], 'bar' => '2'], ['foo' => 'missing_unless:bar,1']);
23422342
$this->assertFalse($v->passes());
2343-
$this->assertSame('The foo field must be missing unless bar is 2.', $v->errors()->first('foo'));
2343+
$this->assertSame('The foo field must be missing unless bar is 1.', $v->errors()->first('foo'));
23442344

23452345
$v = new Validator($trans, ['foo' => new class implements Countable
23462346
{
@@ -2350,7 +2350,7 @@ public function count(): int
23502350
}
23512351
}, 'bar' => '2', ], ['foo' => 'missing_unless:bar,1']);
23522352
$this->assertFalse($v->passes());
2353-
$this->assertSame('The foo field must be missing unless bar is 2.', $v->errors()->first('foo'));
2353+
$this->assertSame('The foo field must be missing unless bar is 1.', $v->errors()->first('foo'));
23542354

23552355
$v = new Validator($trans, ['foo' => 'foo', 'bar' => '1'], ['foo' => 'missing_unless:bar,1']);
23562356
$this->assertTrue($v->passes());

0 commit comments

Comments
 (0)