valitron
valitron copied to clipboard
Problem with integer validator
Hi, I validate a integer field with the next rules
$rules = [
'field-name' => [
'integer',
['min', 1]
]
];
$data = [
'field-name' => '' // Empty string
];
but the validations pass without errors, for the error to be detected I had to add the following rules
$rules = [
'field-name' => [
'optional',
['required', true],
'integer',
['min', 1]
]
];
this generates confusing code, and as more fields are added it gets even more confusing
Note: sorry for my english and thanks for your time.