Closed josephmancuso closed 5 years ago
I feel like this is a feature we could possibly take from another library. This problem has been solved many times before. Let's try to not reinvent the wheel. 😄
https://github.com/daviddrysdale/python-phonenumbers
This might be a tad overkill, but I like what is going on here.
hmm i thhink we can do it with simple regex. Not sure it's reinventing the wheel too much. That package looks awesome but I deff think it's overkill when we can just regex a string
Oh, I just wanted to avoid a bunch of if statements checking all these conditions. lol
I was thinking about regex, but with international numbers and different number formats, I am not sure if we could come up with all the necessary ones. We could have a few defaults and have a way to pass a regex string if the dev needs a more complex one.
thats actually a really good idea
validate.phone('field', format='123-456-7890') # 2 or 3 most common defaults
validate.phone('field', pattern=r'\w{0,3}..') # regex
actually wouldn't it just be better to add a regex
validator in that case?
hmm..good point.
We could just have a regex validator object, and pass that into the .phone
method. We obviously could just validate the regex operator ourselves, or we can let the .phone
method do it. You could pass in multiple regex validators (for different phone number representations), and the .phone
method would figure it out.
this is done for now. Can update it at a later point when new feature requests come in.
This is gonna be tricky because there are a lot of different formats for a phone number.
We're gonna have to do something like this maybe?
we can have predesignated formats that people can choose from and then we can do: