Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Should the initializer work with nil as a phone_number? #18

Open
meceo opened this issue Dec 9, 2020 · 0 comments
Open

Should the initializer work with nil as a phone_number? #18

meceo opened this issue Dec 9, 2020 · 0 comments

Comments

@meceo
Copy link

meceo commented Dec 9, 2020

Perhaps we should allow the initializer to work with nil value as a phone number. Current behavior raises an exception "NoMethodError: undefined method `sub' for nil:NilClass". That requires a user of the model to always check if the phone number isn't nil. However, when an empty string is provided a user can call msisdn.valid? to check whether a model is valid without wondering about the reasons (invalid due to phone number being nil or because of something else)

phone_number = phone_number

change proposition:
phone_number = phone_number.to_s.sub...(etc)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant