File tree 1 file changed +18
-3
lines changed
1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -361,6 +361,21 @@ protected function validateFields(array $fields, bool $required)
361
361
}
362
362
}
363
363
364
+ /**
365
+ * tests if a value is falsy
366
+ *
367
+ *@param $value - the value to test
368
+ */
369
+ protected function valueIsFalsy ($ value )
370
+ {
371
+ $ value = strval ($ value );
372
+
373
+ if (preg_match ('/^(false|off|0|nil|null|no|undefined)$/i ' , $ value ) || $ value === '' )
374
+ return true ;
375
+ else
376
+ return false ;
377
+ }
378
+
364
379
/**
365
380
* runs data filteration on the given value
366
381
*
@@ -425,7 +440,7 @@ protected function filterValue($value, array $filters)
425
440
break ;
426
441
427
442
case 'bool ' :
428
- if (preg_match ( ' /^(false|off|0|nil|null|no|undefined)$/i ' , $ value ) || $ value === '' )
443
+ if ($ this -> valueIsFalsy ( $ value ))
429
444
$ value = false ;
430
445
else
431
446
$ value = true ;
@@ -699,12 +714,12 @@ protected function processRules()
699
714
switch (strtolower ($ condition ))
700
715
{
701
716
case 'checked ' :
702
- if (!is_null ($ _field_value ))
717
+ if (!$ this -> valueIsFalsy ($ _field_value ))
703
718
$ required = true ;
704
719
break ;
705
720
706
721
case 'notchecked ' :
707
- if (is_null ($ _field_value ))
722
+ if ($ this -> valueIsFalsy ($ _field_value ))
708
723
$ required = true ;
709
724
break ;
710
725
You can’t perform that action at this time.
0 commit comments