Skip to content

Laravel package that provides a set of utility functions and custom validation rules for working with phone numbers in the Zimbabwean context

License

Notifications You must be signed in to change notification settings

joemunapo/zim-phone-utils

 
 

Repository files navigation

A Laravel package for working with phone numbers in the Zimbabwean context

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Zim Phone Utils is a Laravel package that provides a set of utility functions and custom validation rules for working with phone numbers in the Zimbabwean context. It simplifies tasks such as formatting phone numbers, extracting country codes, determining mobile carriers, and validating phone numbers against specific criteria.

Features

  • Format phone numbers in national or international format
  • Extract country ISO codes and country codes from phone numbers
  • Determine the mobile carrier for a given phone number
  • Custom validation rules for phone numbers and mobile carriers
  • Seamless integration with Laravel's validation system

Installation

You can install the package via composer:

composer require joemags-apps/zim-phone-utils

Usage

use JoemagsApps\ZimPhoneUtils\Utils;

// Format a phone number
$formattedNumber = Utils::formatPhoneNumber('+263771234567');

// Get the country ISO code
$countryIso = Utils::getCountryIso('+263771234567');

// Get the mobile carrier
$carrier = Utils::getPhoneCarrier('+263771234567');

// Validate a phone number
$request->validate([
    'phone' => 'required|phone:ZW',
]);

// Validate a mobile carrier
$request->validate([
    'carrier' => 'required|carrier:Econet,NetOne,Telecel',
]);

Testing

composer test # Run tests

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Laravel package that provides a set of utility functions and custom validation rules for working with phone numbers in the Zimbabwean context

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%