whisperfish / rust-phonenumber

Library for parsing, formatting and validating international phone numbers.
Apache License 2.0
163 stars 56 forks source link

Add `PhoneNumber::number_type` method #57

Closed tom25519 closed 1 year ago

tom25519 commented 1 year ago

This PR adds a new method, PhoneNumber::number_type, which attempts to determine the Type of a phone number. I would imagine this is quite a common use-case for the library (for example, a website which accepts phone numbers for account recovery may want to check a provided number is actually a mobile number, and not a premium rate line). The actual implementation just uses the existing validator::number_type function, which is not currently exposed publicly. Thank you!