Skip to content
Browse files

Adding empty() check in boolean validator to allow empty values. Upda…

…ting test to reflect.
  • Loading branch information...
1 parent 31c2945 commit 1bb901c8047fd673166daba2fb12f1afea139f3f @joebeeson joebeeson committed Dec 29, 2011
Showing with 2 additions and 1 deletion.
  1. +1 −0 tests/cases/util/ValidatorTest.php
  2. +1 −1 util/Validator.php
View
1 tests/cases/util/ValidatorTest.php
@@ -253,6 +253,7 @@ public function testBooleanValidation() {
$this->assertTrue(Validator::isBoolean('off'));
$this->assertTrue(Validator::isBoolean('yes'));
$this->assertTrue(Validator::isBoolean('no'));
+ $this->assertTrue(Validator::isBoolean(''));
$this->assertFalse(Validator::isBoolean('11'));
$this->assertFalse(Validator::isBoolean('-1'));
View
2 util/Validator.php
@@ -246,7 +246,7 @@ public static function __init() {
'boolean' => function($value) {
$bool = is_bool($value);
$filter = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
- return ($bool || $filter !== null);
+ return ($bool || $filter !== null || empty($value));
},
'decimal' => function($value, $format = null, array $options = array()) {
if (isset($options['precision'])) {

0 comments on commit 1bb901c

Please sign in to comment.
Something went wrong with that request. Please try again.