File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Expand file tree Collapse file tree 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)
361361 }
362362 }
363363
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+
364379 /**
365380 * runs data filteration on the given value
366381 *
@@ -425,7 +440,7 @@ protected function filterValue($value, array $filters)
425440 break ;
426441
427442 case 'bool ' :
428- if (preg_match ( ' /^(false|off|0|nil|null|no|undefined)$/i ' , $ value ) || $ value === '' )
443+ if ($ this -> valueIsFalsy ( $ value ))
429444 $ value = false ;
430445 else
431446 $ value = true ;
@@ -699,12 +714,12 @@ protected function processRules()
699714 switch (strtolower ($ condition ))
700715 {
701716 case 'checked ' :
702- if (!is_null ($ _field_value ))
717+ if (!$ this -> valueIsFalsy ($ _field_value ))
703718 $ required = true ;
704719 break ;
705720
706721 case 'notchecked ' :
707- if (is_null ($ _field_value ))
722+ if ($ this -> valueIsFalsy ($ _field_value ))
708723 $ required = true ;
709724 break ;
710725
You can’t perform that action at this time.
0 commit comments