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
555
stars
111
forks
source link
Fix code example in README to match description #167
You can validate against the normalized input as opposed to the raw input:
but the code example is still validating the raw input. This example "works" as long as the user enters a US number since the validation defaults to "US", but breaks if a an "IT" number is entered, for example.
Also, since we're validating the already normalized phone number, I don't think providing the "normalized_country_code" option is useful.
EDIT:
I added commit e44e76e because I'm guessing in the most common use case people don't want their records to be valid if the user enters a random string like "whatever", but also don't want to force a phone number - if they do, they should validate that the "phone_number" is present.
Coverage remained the same at 99.809% when pulling ff0a58980da40676e700e660b4a5b295ca04614b on mattruzicka:master into 9e268a7d7167caeb68dc4d453c3f68e588603445 on joost:master.
Coverage remained the same at 99.809% when pulling e44e76ed93fde684566ce8d843f2e7d4bd4a67a4 on mattruzicka:master into 9e268a7d7167caeb68dc4d453c3f68e588603445 on joost:master.
Coverage remained the same at 99.809% when pulling e44e76ed93fde684566ce8d843f2e7d4bd4a67a4 on mattruzicka:master into 9e268a7d7167caeb68dc4d453c3f68e588603445 on joost:master.
The description for the code example says:
but the code example is still validating the raw input. This example "works" as long as the user enters a US number since the validation defaults to "US", but breaks if a an "IT" number is entered, for example.
Also, since we're validating the already normalized phone number, I don't think providing the "normalized_country_code" option is useful.
EDIT: I added commit e44e76e because I'm guessing in the most common use case people don't want their records to be valid if the user enters a random string like "whatever", but also don't want to force a phone number - if they do, they should validate that the "phone_number" is present.