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).
I had the use case for an alarm that has a recipient, which can be an email or a phone number (sms), so I wanted to be able to conditionally normalize the recipient field - otherwise it would butcher an email address with numbers in it (see tests).
The code is maybe a little more complex than I would like, but the alternative was to be very verbose because there is some nested conditional stuff (if with proc, unless with proc, if with symbol, unless with symbol).
Coverage increased (+0.006%) to 99.809% when pulling 2d75f888c4fbfa117c46d0b5a59e418a8ff2766f on Ross-Hunter:feature/conditional-normalization into 4e0a3df4f46482bb5eef1f991256716ab373a512 on joost:master.
Coverage increased (+0.006%) to 99.809% when pulling fad9f6e6f01862705cf9d5f32c1549b71b9aa2d3 on Ross-Hunter:feature/conditional-normalization into 4e0a3df4f46482bb5eef1f991256716ab373a512 on joost:master.
Coverage increased (+0.006%) to 99.809% when pulling fad9f6e6f01862705cf9d5f32c1549b71b9aa2d3 on Ross-Hunter:feature/conditional-normalization into 4e0a3df4f46482bb5eef1f991256716ab373a512 on joost:master.
Coverage increased (+0.006%) to 99.809% when pulling 7422a3c6f468ea88847a1734ec6a657b9cdcc6f2 on Ross-Hunter:feature/conditional-normalization into 4e0a3df4f46482bb5eef1f991256716ab373a512 on joost:master.
Coverage increased (+0.006%) to 99.809% when pulling 7422a3c6f468ea88847a1734ec6a657b9cdcc6f2 on Ross-Hunter:feature/conditional-normalization into 4e0a3df4f46482bb5eef1f991256716ab373a512 on joost:master.
Allows an
:if
or:unless
option to be passed tophony_normalize
. Works with symbols that reference methods or lambdas, just like validations do.More comprehensively fixes https://github.com/joost/phony_rails/issues/149
I had the use case for an alarm that has a recipient, which can be an email or a phone number (sms), so I wanted to be able to conditionally normalize the recipient field - otherwise it would butcher an email address with numbers in it (see tests).
The code is maybe a little more complex than I would like, but the alternative was to be very verbose because there is some nested conditional stuff (if with proc, unless with proc, if with symbol, unless with symbol).
Thanks!