Closed lonnelars closed 8 years ago
The fix is fine but I question the initial bug report. If you define a size
constraint for a field that uses type="number"
in the markup hasn't something else gone wrong fundamentally? Why should valdr try to silently cope with this?
Hm, you might be right. I just saw the open bug report, and figured I'd send in a PR. However, on some occasions I think it makes sense to speak of the length of numbers. In our case, we need to validate a postal code (zip code). To me it makes more sense to say that the postal code should be four digits, than saying that it should be less than 10000.
Be that as it may, size
is defined to constrain the length of strings: https://github.com/netceteragroup/valdr#size. I really don't see a compelling reason to merge this and unless you find a convincing argument (who knows, there may be one 😉 ) I'm also gonna close the initial bug report.
Sounds good to me :ok_hand:
We're using valdr in our project, and I came across the bug that is described in issue #59, where an input field with
type="number"
is always in error. This PR solves it by converting the input value insizeValidator
to a string before checking the length.