svelte-forms icon indicating copy to clipboard operation
svelte-forms copied to clipboard

[REQUEST] Documentation of min and max validators should mention behavior in case of non-number input

Open omer-g opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe. Currently the documentation of min and max validators does not specify what is the behavior when a non-number value (NaN) is provided. Users may think these validators accept only numbers as valid input, but in case of a non-number the function validates its length.

Describe the solution you'd like It would be helpful to have this explicitly stated in the documentation of min and max.

Additional context On a side not, it might be nice to have a validator for "input is a number" (though one can get that with a pattern validator).

omer-g avatar Feb 28 '22 19:02 omer-g

On second thought, it could be useful to have an optional parameter that allows explicitly choosing if min should check length or numerical value. There are several cases where one would want to check for a length of a number (for example a zip code with at least 5 digits, an ID number etc.).

omer-g avatar Feb 28 '22 20:02 omer-g

Hi @omer-g,

Indeed the documentation doesn't specifically point out that in case of a non numeric value (here: string) the validators consider the length of the value. I am going to add that asap.

Considering your comment, in a lot of cases ZIP code have to be (most of the time) considered as string and not numbers. Almost every countries have their zip code regex validation online and can have non numerical characters in them.

chainlist avatar Mar 16 '22 20:03 chainlist