why is a string with characters considered as valid ? #48

Closed
ddidier opened this Issue Jun 28, 2012 · 9 comments

Projects

None yet

3 participants

@ddidier

Hi,
There certainly must be a reason but why is a string with characters considered as valid ?
ex : +33123456789-blabla
Thanks

@floere
Owner

Because it contains enough information to be normalizable to a E164 number. Does that help?

@ddidier

yes, but from the wiki page I can tell that a E164 number contains only numbers, so I thought that would be invalid.
maybe adding an option to consider the non digit chars would be helpful ? or not ?
thanks

@floere
Owner

I am unsure – are you referring to the plausible? method when you say valid?

@ddidier

Yes

@floere
Owner

Here's a description of plausible?: https://github.com/floere/phony#plausibility – does that help? Let me put this another way: What is the goal you are trying to achieve?

@ddidier

At first that was to validate an active record field, but i found phony-rails, which normalize before validating. So that does not really matter anymore. Just for the discussion now :
I read your definition of 'plausible' : can't we say that a number with a character is wrong with a certainty of 100% ?

@floere
Owner

You make a good point. Perhaps the current plausible? should be renamed to normalizable? and I should write a more strict plausible? method.
The original plausible? method came out of wanting to know whether a number is normalizable, but also ok to save into a database. And yes, the current description rather points towards a plausible number not including characters, indeed. Good catch!

I will have to think about it – input welcome!

@floere
Owner

Leaving this on here as a reminder to think about this.

@floere floere referenced this issue Nov 1, 2012
Closed

length_validation #63

@g1smd

I thought this was going to be a question about numbers such as +1 555 88BINGO and +1 555 DIY TOOL. :)

@floere floere closed this Apr 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment