silotech / validate-sl-number
A simple function to validate a Sierra Leone Number with the present NDC's
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/silotech/validate-sl-number
Requires (Dev)
- pestphp/pest: 4.x-dev
This package is auto-updated.
Last update: 2026-01-24 17:11:50 UTC
README
A PHP package to validate Sierra Leone phone numbers and return them in a fully qualified format with country code.
π¦ Installation
Install via Composer:
composer require silotech/validate-sl-number
If your package is in development and you want to allow unstable versions, you can specify:
composer require silotech/validate-sl-number:dev-main
βοΈ Usage
Include Composerβs autoload file and call the function:
<?php require __DIR__ . "/vendor/autoload.php"; $phone = "0023273111222"; $result = isPhoneNumberAValidSLNumber($phone); if ($result !== false) { echo "Valid SL Number: " . $result; } else { echo "Invalid SL Number"; }
π Function
isPhoneNumberAValidSLNumber(string $phone_number): bool|string
Validates a Sierra Leone phone number and returns it in fully qualified format with +232 if valid.
Parameters:
$phone_number (string)β The phone number to validate.
Acceptable formats:
+232xxxxxxxx00232xxxxxxxx- Local format:
0xxxxxxxx
Returns:
stringβ Fully qualified phone number if valid (e.g.,+23276111222)falseif invalid
π Examples
isPhoneNumberAValidSLNumber("+23273111222"); // "+23273111222" isPhoneNumberAValidSLNumber("0023232111222"); // "+23232111222" isPhoneNumberAValidSLNumber("033111222"); // "+23233111222" isPhoneNumberAValidSLNumber("070111222"); // false
π Requirements
- PHP >= 7.4
- Composer
π Development
If you are developing or updating this package:
git clone https://github.com/sepolly/validate-sl-number.git
cd validate-sl-number
composer install
π License
MIT License. See the LICENSE file for details.
π’ Author
Simeon Michael
GitHub Profile