Skip to content
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

maxLength validation secretly trims string #134

Closed
bazwilliams opened this issue May 30, 2013 · 0 comments
Closed

maxLength validation secretly trims string #134

bazwilliams opened this issue May 30, 2013 · 0 comments

Comments

@bazwilliams
Copy link

The length of the string is trimmed before being checked for length. This means a string "1234 " is reported with a length of 4 passing our validation check and sent onto our server which fails because it has 5 characters.

Whilst ultimately we don't want spaces after our part numbers, the discrepancy between the string stored in the Backbone model (5 chars) and what is reported back from backbone.validation is not ideal. If we trim the text before sending to the server then it will have been generated from a different code path. If we trim the text before validation, then the trim is performed twice.

Turns out this is the case with Length and minLength.

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

No branches or pull requests

1 participant