vlucas / valitron

Valitron is a simple, elegant, stand-alone validation library with NO dependencies
BSD 3-Clause "New" or "Revised" License
1.57k stars 250 forks source link

Problem with integer validator #368

Open demiancy opened 1 year ago

demiancy commented 1 year ago

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.