I made a few small adjustments to allow it to validate non-strings.
I changed line 64
from:
if (isset($data[$table][$field_name]) &&
to:
if ( array_key_exists($field_name, $data[$table]) &&
so a null field value then may be (in)validated too. I also changed line 71
from:
if (isset($data[$table][$field_name]) &&
to:
if (!array_key_exists($field_name, $data[$table]) || !is_string( $data[$table][$field_name]) ||
I also threw the following check into the top of any validation functions expecting a string:
if (!is_string($val)) {
return false;
}
There might be something wrong with my code, but it works so far (in concert with isType/nonNull validation funcs I added). Also, you may want nulls to go unvalidated, but the controller should be able to handle that logic by popping null fields into the disabledValidate array.
I made a few small adjustments to allow it to validate non-strings.
I changed line 64
from:
if (isset($data[$table][$field_name]) &&
to:
if ( array_key_exists($field_name, $data[$table]) &&
so a null field value then may be (in)validated too. I also changed line 71
from:
if (isset($data[$table][$field_name]) &&
to:
if (!array_key_exists($field_name, $data[$table]) || !is_string( $data[$table][$field_name]) ||
I also threw the following check into the top of any validation functions expecting a string:
if (!is_string($val)) {
return false;
}
There might be something wrong with my code, but it works so far (in concert with isType/nonNull validation funcs I added). Also, you may want nulls to go unvalidated, but the controller should be able to handle that logic by popping null fields into the disabledValidate array.