rmm5t / strip_attributes

:hocho: An ActiveModel extension that automatically strips all attributes of leading and trailing whitespace before validation. If the attribute is blank, it strips the value to nil.
https://github.com/rmm5t/strip_attributes
MIT License
558 stars 51 forks source link

Zero-width space doesn't result in nil after stripping #46

Closed aried3r closed 4 years ago

aried3r commented 4 years ago

This is more a question instead of a PR. While using this gem in our codebase we discovered that while strings like "\n\t\ " result in nil, "\u200B" results in the empty string. Is this intended behavior?

You can see the failing test in this PR.

rmm5t commented 4 years ago

Good catch. I'd agree that the existing behavior is a problem and your desired test is the correct behavior. I'll try to fix this shortly.

rmm5t commented 4 years ago

@aried3r Thank you for this. v1.9.1 is now released with this fix. https://rubygems.org/gems/strip_attributes