Data Validation for Random varying Phone Numbers
- by baron
I am storing phone numbers of varying lengths in my WPF (C#, VS 08) App.
I store them as strings. My question is about my method AddNewPhoneNo(string phoneNo).
In this method, I use Int.TryParse to validate the incoming number (i.e. not null, is numeric...). I've since realized this is probably not the best way to do this, because then I am limited to a number which is ± 2147483647. Definetly this is not always the case with phone numbers.
What is a good, easy way to validate phone numbers? I guess the basic rules would be as follows:
All numeric
All positive
Upto 25 chars (could be more, but this will to do for time being)
Can't thing if theres any more rules at the moment, that's probably it.