Closed fairbairn closed 8 years ago
I don't have time to look into this too much but I suspect it's something to do with this line it should check on the rule if it's numeric based, not simply against the typeof
.
@fairbairn Can you cast it to a number before passing it to Validator?
It's not convenient simply because we're embedded in redux-forms and all of our inputs are form based, so they will always be strings. We can if we have to, but it's not a one-liner in our case.
@garygreen @fairbairn Do either of you know how Laravel handles this? If input looks like a number, does it treat it as a number? If not, I'll have to spin up a Laravel project and see how they handle it.
@skaterdav85 like I said in previous comment, it just needs to check if the value is tested against a "numeric-like" rule, and if so use the numeric template when generating the error message. Laravel does something similar. At the moment it does a simple typeof
-- it also needs to make use of the internal function _hasNumericRule
, which it doesn't at the moment, hence the incorrect error message.
I'll fix it quickly now.
Fixed in 5d6752b6def9d1b17d9b07b59e20c7b6e0f50391 @skaterdav85 would you mind releasing a new version?
@fairbairn @garygreen released in 2.0.3!
Fantastic, thanks guys! Works like a champ.
Similar to another numeric issue, but this is different... (using version 2.0.2)
I can't tell when min, max is checking length or the actual numeric value.
In our cases, we're using web forms so it's always a string... we think it's trying to check value which is fine, we can set it like this instead...
but it's default error message makes no sense because it still thinks it's failing on "characters" instead of a value out of range.
I think the BUG is that when the type is numeric and min and max are value ranges, the error message is incorrect.