model validationRules for nullable fields? |
Is there a way of setting up model validation (for example "integer" or "numeric") for fields that are not required and also can be null?
I'm aware of the "if_exist" (doesn't allow null values) and "permit_empty" (permits also some non-null invalid values) rules, and also I figured "callback_" probably can't be used for this (unless I recreate all needed validation rules with callbacks that would allow null, for example callback_nullableInteger, callback_nullableNumeric, callback_nullableAlphaNumeric etc)
You could always wrap your rules in normal PHP logic... I'm not sure what rules you could apply in this case, but this might be what you're looking for:
PHP Code: $post = $this->request->getPost(); |
Welcome Guest, Not a member yet? Register Sign In |