PHPackages                             mrone-inc/tz-phone-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. mrone-inc/tz-phone-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

mrone-inc/tz-phone-validator
============================

Tanzanian phone number validator — identify Vodacom, Tigo, Airtel, Halotel, TTCL, and Zantel numbers

00PHPCI failing

Since May 14Pushed 3w agoCompare

[ Source](https://github.com/MrOne-inc/tz-phone-validator)[ Packagist](https://packagist.org/packages/mrone-inc/tz-phone-validator)[ RSS](/packages/mrone-inc-tz-phone-validator/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

tz-phone-validator
==================

[](#tz-phone-validator)

Validate and identify Tanzanian mobile phone numbers across all networks. Zero dependencies.

Supported Networks
------------------

[](#supported-networks)

CarrierPrefixesExampleVodacom074, 075, 0760754 123 456Tigo065, 067, 0710652 123 456Airtel068, 069, 078, 0790684 123 456Halotel061, 062, 0630622 123 456TTCL0730732 123 456Zantel0770772 123 456Features
--------

[](#features)

- **Validate** — check if a number is a real Tanzanian mobile number
- **Identify carrier** — detect which network a number belongs to
- **Normalize** — clean any format to `255XXXXXXXXX`
- **All formats accepted** — `0754...`, `+255754...`, `255754...`, `754...`, with spaces/dashes

Installation
------------

[](#installation)

### PHP (Composer)

[](#php-composer)

```
composer require mrone-inc/tz-phone-validator
```

```
use TzPhoneValidator\TzPhone;

TzPhone::isValid('0754123456');      // true
TzPhone::getCarrier('0754123456');   // "Vodacom"
TzPhone::normalize('0754123456');    // "255754123456"
TzPhone::isVodacom('0754123456');    // true

// Check all carriers
TzPhone::isTigo('0654123456');       // true
TzPhone::isAirtel('0684123456');     // true
TzPhone::isHalotel('0624123456');    // true
TzPhone::isTTCL('0734123456');      // true
TzPhone::isZantel('0774123456');     // true
```

### Python (pip)

[](#python-pip)

```
pip install tz-phone-validator
```

```
from tz_phone_validator import is_valid, get_carrier, normalize, TzPhone

# Functional API
is_valid("0754123456")      # True
get_carrier("0754123456")   # "Vodacom"
normalize("0754123456")     # "255754123456"

# OOP API
phone = TzPhone("0754123456")
phone.is_valid      # True
phone.carrier        # "Vodacom"
phone.normalized     # "255754123456"
phone.is_vodacom     # True
```

### Node.js (npm)

[](#nodejs-npm)

```
npm install tz-phone-validator
```

```
const { isValid, getCarrier, normalize } = require('tz-phone-validator');

isValid('0754123456');      // true
getCarrier('0754123456');   // 'Vodacom'
normalize('0754123456');    // '255754123456'
isVodacom('0754123456');    // true
```

### Java

[](#java)

Copy `java/src/TzPhone.java` into your project. Requires Java 17+.

```
TzPhone.isValid("0754123456");      // true
TzPhone.getCarrier("0754123456");   // Optional.of("Vodacom")
TzPhone.normalize("0754123456");    // Optional.of("255754123456")
TzPhone.isVodacom("0754123456");    // true
```

Input Formats
-------------

[](#input-formats)

All functions accept any of these formats:

InputNormalized`0754123456``255754123456``+255754123456``255754123456``255754123456``255754123456``754123456``255754123456``0754 123 456``255754123456``0754-123-456``255754123456``(0754) 123456``255754123456`Running Tests
-------------

[](#running-tests)

```
# PHP
cd php && composer install && vendor/bin/phpunit

# Python
cd python && pip install -e ".[dev]" && pytest

# Node
cd node && npm test

# Java
cd java && javac src/TzPhone.java tests/TzPhoneTest.java -d out && java -cp out TzPhoneTest
```

License
-------

[](#license)

MIT

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance62

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2c844b0341d8c6f757c08a329436464bda338e52fef621836881c655aae5671f?d=identicon)[medrickmeshack](/maintainers/medrickmeshack)

---

Top Contributors

[![MrOne-inc](https://avatars.githubusercontent.com/u/57585301?v=4)](https://github.com/MrOne-inc "MrOne-inc (4 commits)")

### Embed Badge

![Health badge](/badges/mrone-inc-tz-phone-validator/health.svg)

```
[![Health](https://phpackages.com/badges/mrone-inc-tz-phone-validator/health.svg)](https://phpackages.com/packages/mrone-inc-tz-phone-validator)
```

###  Alternatives

[ziming/laravel-zxcvbn

Zxcvbn Password validation rule for Laravel

3064.3k](/packages/ziming-laravel-zxcvbn)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
