forked from persian-tools/go-persian-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
phonenumbers
Amir Iranmanesh edited this page Aug 11, 2026
·
2 revisions
Validate Iranian mobile numbers, normalize their prefix, and resolve operator details.
import "github.com/amiranmanesh/go-persian-tools/phonenumbers"Accepted dialing prefixes: +98, 98, 0098, 0, or none at all.
phonenumbers.IsPhoneValid("09122221811") // true
phonenumbers.IsPhoneValid("+989122221811") // true
phonenumbers.IsPhoneValid("9122221811") // true
phonenumbers.IsPhoneValid("12903908") // falseStore numbers from different sources in one shape:
phonenumbers.PhoneNumberNormalizer("09122221811", "+98") // +989122221811
phonenumbers.PhoneNumberNormalizer("+989122221811", "0") // 09122221811details, err := phonenumbers.GetPhoneDetails("09123456789")
if err == nil {
details.GetOperator() // phonenumbers.MCI
details.GetBase() // تهران
details.GetProvinceList() // [البرز زنجان سمنان قزوین قم ...]
details.GetSimTypeList() // [Permanent]
details.GetModel() // "" unless the prefix is reserved for one
}| Error | When |
|---|---|
phonenumbers.ErrInvalidFormat |
not a valid Iranian mobile number |
phonenumbers.ErrInvalidPrefix |
valid number, unrecognized operator prefix |
| Operator | Prefixes |
|---|---|
| MCI (همراه اول) | 910–919, 990–996 |
| Irancell (ایرانسل) | 900–905, 930, 933, 935–939, 941 |
| RightTel (رایتل) | 920–924 |
| Taliya (تالیا) | 932 |
| Shatel Mobile (شاتل موبایل) | 998 |
| ApTel (آپتل) | 999 |
| Tele Kish (تلهکیش) | 934 |
| Espadan (اسپادان) | 931 |
The last three, plus RightTel's 924, were added in v1.1.0.
Prefix tables are exported (phonenumbers.MCIMap, IRANCELL, RIGHTTEL,
TALIYA, SHATELMOBILE, APTEL, TELEKISH, ESPADAN), and
Operator.Details() returns the table for an operator.
Only the MCI prefixes carry provinces; the virtual operators are nationwide
(کشوری) and expose an empty province list.
Packages
Project