Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0c9a905

Browse files
committed
Merge pull request #4070 from Feld0/4.1
Fix #4067: Acceptance validation not boolean true
2 parents dab9d2d + b6ec77b commit 0c9a905

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Illuminate/Validation/Validator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ protected function validateDifferent($attribute, $value, $parameters)
648648
*/
649649
protected function validateAccepted($attribute, $value)
650650
{
651-
$acceptable = array('yes', 'on', '1', 1);
651+
$acceptable = array('yes', 'on', '1', 1, true, 'true');
652652

653653
return ($this->validateRequired($attribute, $value) && in_array($value, $acceptable, true));
654654
}

tests/Validation/ValidationValidatorTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,12 @@ public function testValidateAccepted()
403403
$v = new Validator($trans, array('foo' => 0), array('foo' => 'Accepted'));
404404
$this->assertFalse($v->passes());
405405

406+
$v = new Validator($trans, array('foo' => false), array('foo' => 'Accepted'));
407+
$this->assertFalse($v->passes());
408+
409+
$v = new Validator($trans, array('foo' => 'false'), array('foo' => 'Accepted'));
410+
$this->assertFalse($v->passes());
411+
406412
$v = new Validator($trans, array('foo' => 'yes'), array('foo' => 'Accepted'));
407413
$this->assertTrue($v->passes());
408414

@@ -414,6 +420,12 @@ public function testValidateAccepted()
414420

415421
$v = new Validator($trans, array('foo' => 1), array('foo' => 'Accepted'));
416422
$this->assertTrue($v->passes());
423+
424+
$v = new Validator($trans, array('foo' => true), array('foo' => 'Accepted'));
425+
$this->assertTrue($v->passes());
426+
427+
$v = new Validator($trans, array('foo' => 'true'), array('foo' => 'Accepted'));
428+
$this->assertTrue($v->passes());
417429
}
418430

419431

0 commit comments

Comments
 (0)