Skip to content

Conversation

@redhead
Copy link
Contributor

@redhead redhead commented Mar 21, 2014

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.

@pavelkouril
Copy link
Contributor

Hmmm, so it will fail on numbers written in 1,999.99 format?

@redhead
Copy link
Contributor Author

redhead commented Mar 22, 2014

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.

@dg
Copy link
Member

dg commented Mar 22, 2014

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.

@redhead
Copy link
Contributor Author

redhead commented Mar 22, 2014

Not sure what you mean. What would be your proposed solution?

@dg
Copy link
Member

dg commented Mar 23, 2014

You don't have to fix validator 'range', just 'float'.

@redhead
Copy link
Contributor Author

redhead commented Mar 25, 2014

This would mean bigger refactoring since the validators on the client-side can't change values in the current implementation.

@dg
Copy link
Member

dg commented Mar 25, 2014

Exactly.

@redhead
Copy link
Contributor Author

redhead commented Mar 31, 2014

I found out pretty questionable feature - server-side range validator can handle string values as well (all comparable types in fact), eg. array('a', 'g'), however, javascript range validator forces the value to be parsed as float. The current inconsistency makes it harder to unite the two.

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).

@redhead
Copy link
Contributor Author

redhead commented Apr 10, 2014

Bump

@dg
Copy link
Member

dg commented Apr 13, 2014

Yes, parseFloat should be removed from JS function range.

@janedbal
Copy link

What is missing for completing this issue?

@dg
Copy link
Member

dg commented Jul 11, 2014

see #1462 (comment)

@janedbal
Copy link

Thanks, is there any workaround? Ideally without modifying original script.

@dg dg force-pushed the master branch 3 times, most recently from 991ba1a to e23de7a Compare August 26, 2014 15:04
dg added a commit to nette/forms that referenced this pull request Feb 17, 2015
@janedbal
Copy link

@dg Great, thanks for resolving!

dg added a commit to nette/forms that referenced this pull request Feb 18, 2015
dg added a commit to nette/forms that referenced this pull request Feb 18, 2015
dg added a commit to nette/forms that referenced this pull request Feb 19, 2015
dg added a commit to nette/forms that referenced this pull request Feb 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants