diff --git a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php index f5c3eb00c4e0..d645dbd6d5a6 100644 --- a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php @@ -104,6 +104,20 @@ protected function replaceMax($message, $attribute, $rule, $parameters) return str_replace(':max', $parameters[0], $message); } + /** + * Replace all place-holders for the multiple_of rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceMultipleOf($message, $attribute, $rule, $parameters) + { + return str_replace(':value', $parameters[0], $message); + } + /** * Replace all place-holders for the in rule. * diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index d016b0193e7b..215cf431c122 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -1857,9 +1857,16 @@ public function testValidateMax() public function testValidateMutlpleOf($input, $allowed, $passes) { $trans = $this->getIlluminateArrayTranslator(); + $trans->addLines(['validation.multiple_of' => 'The :attribute must be a multiple of :value'], 'en'); $v = new Validator($trans, ['foo' => $input], ['foo' => "multiple_of:{$allowed}"]); + $this->assertSame($passes, $v->passes()); + if ($v->fails()) { + $this->assertSame("The foo must be a multiple of {$allowed}", $v->messages()->first('foo')); + } else { + $this->assertSame('', $v->messages()->first('foo')); + } } public function multipleOfDataProvider() @@ -1920,6 +1927,8 @@ public function multipleOfDataProvider() ['foo', 1, false], // invalid values [1, 'foo', false], ['foo', 'foo', false], + [1, '', false], + [1, null, false], ]; }