This Gem adds useful methods to your Rails app to validate, display and save phone numbers. It uses the super awesome Phony gem (https://github.com/floere/phony).
MIT License
554
stars
111
forks
source link
phony_formatted not returning original String for non-digit only strings #163
In practice, when one uses phony_formatted for the value of an input field, this leads to user input wrongly replaced with nothing. The obvious workaround is something like
value.phony_formatted || value
But I wonder if the method itself shouldn't be changed in a way that matches the documented behaviour. Especially since there is an option to be strict about values.
The documentation for phony_formatted states that: "When an error occurs during conversion it will return the original String." but this is not true.
Given the following example:
it returns nil, too, since in all non-digit characters are removed from the string (https://github.com/joost/phony_rails/blob/master/lib/phony_rails/string_extensions.rb#L29).
In practice, when one uses phony_formatted for the value of an input field, this leads to user input wrongly replaced with nothing. The obvious workaround is something like
But I wonder if the method itself shouldn't be changed in a way that matches the documented behaviour. Especially since there is an option to be strict about values.