valitron icon indicating copy to clipboard operation
valitron copied to clipboard

Problem with integer validator

Open demiancy opened this issue 2 years ago • 0 comments

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.

demiancy avatar Nov 23 '22 14:11 demiancy