Skip to content

Commit

Permalink
Merge pull request #13025 from themsaid/validator-dependents
Browse files Browse the repository at this point in the history
[5.2] Add after and before to dependent rules array
  • Loading branch information
taylorotwell committed Apr 6, 2016
2 parents 8495627 + 2e0dd6a commit d30ff2b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Illuminate/Validation/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class Validator implements ValidatorContract
protected $dependentRules = [
'RequiredWith', 'RequiredWithAll', 'RequiredWithout', 'RequiredWithoutAll',
'RequiredIf', 'RequiredUnless', 'Confirmed', 'Same', 'Different', 'Unique',
'Before', 'After',
];

/**
Expand Down
25 changes: 25 additions & 0 deletions tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2647,6 +2647,31 @@ public function testValidateImplicitEachWithAsterisksRequiredWithoutAll()
$this->assertTrue($v->messages()->has('foo.0.bar.1.name'));
}

public function testValidateImplicitEachWithAsterisksBeforeAndAfter()
{
$trans = $this->getRealTranslator();

$v = new Validator($trans, ['foo' => [
['start' => '2016-04-19', 'end' => '2046-04-19'],
]], ['foo.*.start' => ['before:foo.*.end']]);
$this->assertTrue($v->passes());

$v = new Validator($trans, ['foo' => [
['start' => '2016-04-19', 'end' => '2046-04-19'],
]], ['foo.*.end' => ['before:foo.*.start']]);
$this->assertTrue($v->fails());

$v = new Validator($trans, ['foo' => [
['start' => '2016-04-19', 'end' => '2046-04-19'],
]], ['foo.*.end' => ['after:foo.*.start']]);
$this->assertTrue($v->passes());

$v = new Validator($trans, ['foo' => [
['start' => '2016-04-19', 'end' => '2046-04-19'],
]], ['foo.*.start' => ['after:foo.*.end']]);
$this->assertTrue($v->fails());
}

public function testValidateEachWithNonIndexedArray()
{
$trans = $this->getRealTranslator();
Expand Down

0 comments on commit d30ff2b

Please sign in to comment.