-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Description
When submitting negative values to "decimal" type fields validation fails because ctype_digit
interprets "-" as a non-numeric value. Because (int)
, is_int
, abs
, and is_numeric
would all allow for potentially invalid data to be passed on to the database I think there are only two choices: regular expression, something like preg_match('/^(-?\d+)$/', $whole)
or add a test for "-" at the beginning of the $whole
variable maybe like
if (strlen($whole) > 0 && !((substr($whole,0,1) === '-') ? ctype_digit(substr($whole,1)) : ctype_digit($whole))) {
return 'invalid decimal'
}
mevdscheemevdschee