Skip to content

Problem with integer validator #368

@demiancy

Description

@demiancy

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions