Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,15 @@ protected function validateDifferent($attribute, $value, $parameters)
{
$this->requireParameterCount(1, $parameters, 'different');

$other = Arr::get($this->data, $parameters[0]);
foreach ($parameters as $parameter) {
$other = Arr::get($this->data, $parameter);

if (is_null($other) || $value === $other) {
return false;
}
}

return isset($other) && $value !== $other;
return true;
}

/**
Expand Down
9 changes: 9 additions & 0 deletions tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,15 @@ public function testValidateDifferent()

$v = new Validator($trans, ['foo' => '1e2', 'baz' => '100'], ['foo' => 'Different:baz']);
$this->assertTrue($v->passes());

$v = new Validator($trans, ['foo' => 'bar', 'fuu' => 'baa', 'baz' => 'boom'], ['foo' => 'Different:fuu,baz']);
$this->assertTrue($v->passes());

$v = new Validator($trans, ['foo' => 'bar', 'baz' => 'boom'], ['foo' => 'Different:fuu,baz']);
$this->assertFalse($v->passes());

$v = new Validator($trans, ['foo' => 'bar', 'fuu' => 'bar', 'baz' => 'boom'], ['foo' => 'Different:fuu,baz']);
$this->assertFalse($v->passes());
}

public function testValidateAccepted()
Expand Down