Squish username before validation#10239
Merged
Gargron merged 2 commits intomastodon:masterfrom Mar 11, 2019
Merged
Conversation
Gargron
requested changes
Mar 11, 2019
| validates :note, note_length: { maximum: 160 }, if: -> { local? && will_save_change_to_note? } | ||
| validates :fields, length: { maximum: 4 }, if: -> { local? && will_save_change_to_fields? } | ||
|
|
||
| before_validation(on: :create) do |
Member
There was a problem hiding this comment.
Style-wise, it would be preferable to do it via a private method
before_validation :prepare_username, on: :create
I am also not sure what squish gives here over strip, would prefer to just use strip
Contributor
Author
There was a problem hiding this comment.
Indeed, I will move before_validation into a private method.
Regarding squish, actually it processes unicode whitespaces. strip does not.
pry(main)> "\u3000test\u00a0".strip
=> " test "
pry(main)> "\u3000test\u00a0".squish
=> "test"If you agree to use squish to process Unicode white-spaces, I will add a dedicated test for that, or at least I will add Unicode white-spaces into the test I already have added.
Also add Unicode wite-spaces to the spec to support the use of squish over strip.
Gargron
approved these changes
Mar 11, 2019
hiyuki2578
pushed a commit
to ProjectMyosotis/mastodon
that referenced
this pull request
Oct 2, 2019
* Squish username before validation (mastodon#10101) Fix mastodon#10101 * Move before_validation hook to a private method Also add Unicode wite-spaces to the spec to support the use of squish over strip.
messenjahofchrist
pushed a commit
to Origin-Creative/mastodon
that referenced
this pull request
Jul 30, 2021
* Squish username before validation (mastodon#10101) Fix mastodon#10101 * Move before_validation hook to a private method Also add Unicode wite-spaces to the spec to support the use of squish over strip.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #10101