Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with integer validator #368

Open
demiancy opened this issue Nov 23, 2022 · 0 comments
Open

Problem with integer validator #368

demiancy opened this issue Nov 23, 2022 · 0 comments

Comments

@demiancy
Copy link

demiancy commented Nov 23, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant