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

Error in lengthBetween and lengthMin rule #356

Open Sleon4 opened 2 years ago

Sleon4 commented 2 years ago

I have been implementing these normal for the validations of a registration form where we depend on the minimum length of a specific string, For example: identification: "1000000001"

This, when used in standards as the documentation dictates, is as follows:

$rules = [
    'required' => [
        ['identification']
    ],
    'lengthMin' => [
        ['identification', 2]
    ]
];

If we look at the rules structure that we are going to use it is correct, but when the information comes in with a string '' it takes it as true and ignores this. The error implies that lengthBetween and lengthMin are not taking the expected minimum length, accepting that input '' is true when in fact it should be false.