Skip to content
This repository
Browse code

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

…ting test to reflect.
  • Loading branch information...
commit 1bb901c8047fd673166daba2fb12f1afea139f3f 1 parent 31c2945
Joe Beeson joebeeson authored
1  tests/cases/util/ValidatorTest.php
@@ -253,6 +253,7 @@ public function testBooleanValidation() {
253 253 $this->assertTrue(Validator::isBoolean('off'));
254 254 $this->assertTrue(Validator::isBoolean('yes'));
255 255 $this->assertTrue(Validator::isBoolean('no'));
  256 + $this->assertTrue(Validator::isBoolean(''));
256 257
257 258 $this->assertFalse(Validator::isBoolean('11'));
258 259 $this->assertFalse(Validator::isBoolean('-1'));
2  util/Validator.php
@@ -246,7 +246,7 @@ public static function __init() {
246 246 'boolean' => function($value) {
247 247 $bool = is_bool($value);
248 248 $filter = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
249   - return ($bool || $filter !== null);
  249 + return ($bool || $filter !== null || empty($value));
250 250 },
251 251 'decimal' => function($value, $format = null, array $options = array()) {
252 252 if (isset($options['precision'])) {

0 comments on commit 1bb901c

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