Closed andrew-3kb closed 2 months ago
I agree that the current implementation of decimal
can be confusing. Maybe we should rename decimal
to digits
and add a new decimal
action that accepts any base ten number (even non-integer).
Was fixed by https://github.com/fabian-hiller/valibot/pull/823
The
decimal
validation action will only pass on integers, and not on decimals that aren't integers.I've seen issue #665 on here where someone raised the same thing, which had a explanation that valibot actually means "base ten integer" instead of decimal. I want to make a case that we should consider changing this for the following reasons:
baseTenNumberIncludingNonIntegers
or something else really long.If we want to keep the behaviour of decimal as it is (and backwards compatibility is a great reason) I think the documentation should be updated to be clear it only will validate base ten integers and remove the link to the wikipedia article. It would be nice to add a
baseTenNumberIncludingNonIntegers
action in this case, hopefully someone can think of a better name though.Otherwise I propose that
decimal
is updated to pass on non-integers, and we add a new validation action for the old behaviour called something likebaseTenInteger
.I'm happy to do the work and make a pull request for either if you agree with one of the above.