Phone Numbers
Top-level utilities handle Tanzania phone validation and normalization.
| Function | Description |
|---|---|
NormalizeTZPhone(string) | Converts 0712345678, 255..., +255... to E.164 +255...; errors on invalid numbers. |
IsValidTZPhone(string) | Returns bool — validation without an error. |
phone, err := sendafrica.NormalizeTZPhone("0712345678")
// phone == "+255712345678"
if sendafrica.IsValidTZPhone("0712345678") {
fmt.Println("valid Tanzania mobile")
}Accepted formats
| Format | Example | Result |
|---|---|---|
| Tanzania local | 0712345678 | Normalized to +255712345678 |
International with + | +255712345678 | Passed through |
International without + | 255712345678 | Normalized with country code |
Tanzania mobile prefixes are 071–078, 068, and 069. The same logic runs inside SMS.Send — invalid numbers fail local validation (ErrInvalidPhone) before any network call. International destinations must be present in GET /v1/rates to be billable.
Last updated on