-
-
Notifications
You must be signed in to change notification settings - Fork 230
United client- and server-side validation of float (closes #1430) #1462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hmmm, so it will fail on numbers written in 1,999.99 format? |
|
Yes. Just like the server-side validation does from the beginning (see docs). Of course it would be better to implement some kind of locale support in Nette. This pull request, however, just fixes a filed issue. |
|
This is more a workaround than a solution. On the server side validator float changes the value, so the following rules are already working with the changed value. Thus not only the range. |
|
Not sure what you mean. What would be your proposed solution? |
|
You don't have to fix validator 'range', just 'float'. |
|
This would mean bigger refactoring since the validators on the client-side can't change values in the current implementation. |
|
Exactly. |
|
I found out pretty questionable feature - server-side range validator can handle string values as well (all comparable types in fact), eg. It is evident in the description of bug #1430, where you need to add rule float so the comma and thousand separators are handled and value is changed. But if you omit the float rule, server-side validator just compares the given values as they are, but the client side parses it as float (no matter if the float rule was added). |
|
Bump |
|
Yes, |
|
What is missing for completing this issue? |
|
see #1462 (comment) |
|
Thanks, is there any workaround? Ideally without modifying original script. |
991ba1a to
e23de7a
Compare
…nds 'http://' [Closes nette/nette#1430][Closes nette/nette#1462]
|
@dg Great, thanks for resolving! |
…nds 'http://' [Closes nette/nette#1430][Closes nette/nette#1462]
…nds 'http://' [Closes nette/nette#1430][Closes nette/nette#1462]
…nds 'http://' [Closes nette/nette#1430][Closes nette/nette#1462]
…nds 'http://' [Closes nette/nette#1430][Closes nette/nette#1462]
This pull request unites client-side validation of the 'float' rule with the server-side counterpart.
The problem was in failing validation when a comma was used as a decimal point and/or spaces used as thousand separators. Both are handled on the server side by stripping spaces and replacing comma with period.