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

[WIP]Have Required validator trim strings to fix #2361 #2365

Merged
merged 1 commit into from
May 18, 2017
Merged

[WIP]Have Required validator trim strings to fix #2361 #2365

merged 1 commit into from
May 18, 2017

Conversation

chesedo
Copy link
Contributor

@chesedo chesedo commented Jan 6, 2017

This will cause the Required validator not to consider fields that has
only spaces or new lines to be regarded as valid. This is done by
checking if the trimmed version of the string is valid.

This will cause the Required validator not to consider fields that has
only spaces or new lines to be regarded as valid. This is done by
checking if the trimmed version of the string is valid.
@chesedo chesedo changed the title Have Required validator trim strings to fix #2361 [WIP]Have Required validator trim strings to fix #2361 Jan 6, 2017
@chesedo
Copy link
Contributor Author

chesedo commented Jan 6, 2017

Check my next PR where I highlighted that this is also possible in MaxSize, MinSize and Length. That solution will fix it for all validators where this is possible, but it only works for structs called by reference on the validator.Valid() method.

This one will work for all validators called directly (eg. validator.Required()), but will still leave the field 'dirty' and it would probably go into the DB with the padding spaces.

So I would like advise on which solution you would prefer (or both maybe)? If this one will be used, then I would like to also add it for the validators mentioned above before it is merged.

@astaxie astaxie merged commit 388a561 into beego:develop May 18, 2017
@astaxie astaxie mentioned this pull request May 18, 2017
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.

None yet

2 participants