Skip to content

Validation fails on negative decimal. #692

@resident0

Description

@resident0

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'
}

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions