DrHyde / perl-modules-Number-Phone

Number::Phone and friends
24 stars 32 forks source link

Test for invalid characters in string #143

Closed keckeroo closed 6 months ago

keckeroo commented 6 months ago

It would be nice to add tests to 'is_valid' to reject any input that has non-numeric content (except for standard ones like +-(). For example the following number passes (along with many other variations of same). We only picked this up in our integration tests and unfortunately assumed that this module would flag such errors.

The stripping is done in Phone.pm at line 291/292

new("US", "2a1b5c5d5e5f1g2h1i2j")

Thanks!

DrHyde commented 6 months ago

It is unfortunately quite common for people to put all kinds of punctuation into phone number fields in forms and databases, so the code has to accept that.

I could change it to more aggressively reject non-punctuation characters, but I have a policy of not making significant changes like that without a 2 year deprecation cycle. So yes, I'll do this, but it will only start emitting warnings at first, then will become a fatal error after two years.

DrHyde commented 6 months ago

Warnings are in this commit 9d7335a2f8544b302158797a38cb08fb6b05b592 and will be in the next quarterly release.