PHPackages                             trishanapp/lk-business-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. trishanapp/lk-business-validator

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

trishanapp/lk-business-validator
================================

Validate Sri Lanka business data: NIC, BR numbers, phone numbers, postal codes, VAT/TIN, and more.

v1.0.0(2mo ago)001MITPHPPHP ^8.0

Since May 14Pushed 2mo agoCompare

[ Source](https://github.com/gosdrkht/lk-business-validator)[ Packagist](https://packagist.org/packages/trishanapp/lk-business-validator)[ Docs](https://github.com/trishanapp/lk-business-validator)[ RSS](/packages/trishanapp-lk-business-validator/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

🇱🇰 lk-business-validator
========================

[](#-lk-business-validator)

[![Packagist](https://camo.githubusercontent.com/31e5ae50a9a656f71a5b53a2ff87369e90d86377dd689d40d56e517893b662e5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7472697368616e6170702f6c6b2d627573696e6573732d76616c696461746f72)](https://packagist.org/packages/trishanapp/lk-business-validator)[![PHP](https://camo.githubusercontent.com/2f6f9af2e917cbf5786673e8e4ed8d0d9b29be6131327a992063e69136a93411/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e302532422d626c7565)](https://php.net)[![License: MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![Tests](https://camo.githubusercontent.com/d940ad7f0752e2cbe0d63c50dcebf329078807390051c41fe63258f1b5c4e182/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d70617373696e672d627269676874677265656e)](#)

**The only PHP validation library built specifically for Sri Lanka.**

Validate NIC numbers, Business Registration numbers, phone numbers, postal codes, and VAT/TIN numbers — with parsing, normalization, and Laravel rule integration out of the box.

---

📦 Installation
--------------

[](#-installation)

```
composer require trishanapp/lk-business-validator
```

Laravel users: the service provider auto-discovers — no config needed.

---

🚀 Quick Start
-------------

[](#-quick-start)

```
use Trishanapp\LkBusinessValidator\LkValidator;

// NIC
LkValidator::nic('851234567V');       // true
LkValidator::nic('198512345678');     // true (new format)

// Phone
LkValidator::phone('0771234567');     // true
LkValidator::phone('+94771234567');   // true

// Business Registration
LkValidator::br('PV00123456');        // true
LkValidator::br('PV/00123456');       // true (slash accepted)

// Postal Code
LkValidator::postalCode('00100');     // true (Colombo)
LkValidator::postalCode('80000');     // true (Galle)

// VAT / TIN
LkValidator::vat('123456789-7000');   // true
LkValidator::tin('123456789');        // true
```

---

📖 Full API Reference
--------------------

[](#-full-api-reference)

### NIC Validator

[](#nic-validator)

```
use Trishanapp\LkBusinessValidator\LkValidator;

// Validate (old format: 9 digits + V/X, new format: 12 digits)
LkValidator::nic('851234567V');       // true
LkValidator::nic('198512345678');     // true

// Parse — returns full details
LkValidator::nicParse('851234567V');
// [
//   'valid'      => true,
//   'format'     => 'old',
//   'birth_year' => 1985,
//   'gender'     => 'Male',
// ]

// Direct helpers
NicValidator::getBirthYear('851234567V');       // 1985
NicValidator::getGender('856234567V');          // 'Female' (day > 500)
NicValidator::convertToNew('851234567V');       // '198512304567'
```

---

### Phone Validator

[](#phone-validator)

```
// Validate — supports local, +94, and 94 prefixes
LkValidator::phone('0771234567');      // true
LkValidator::phone('+94771234567');    // true
LkValidator::phone('077 123 4567');    // true (spaces OK)

// Parse
LkValidator::phoneParse('0771234567');
// [
//   'valid'         => true,
//   'normalized'    => '0771234567',
//   'international' => '+94771234567',
//   'network'       => 'Dialog',
//   'type'          => 'mobile',
// ]

// Helpers
LkValidator::phoneNormalize('+94771234567');     // '0771234567'
LkValidator::phoneToInternational('0771234567'); // '+94771234567'
```

Networks detected: **Dialog**, **Dialog/Mobitel**, **Airtel**, **Hutch**, **SLT**

---

### Business Registration Validator

[](#business-registration-validator)

```
// Supported prefixes: PV, PB, HP, SP, PR, GN, SC
LkValidator::br('PV00123456');    // true — Private Limited
LkValidator::br('PR00123456');    // true — Partnership
LkValidator::br('PV/00123456');   // true — slash format OK

// Parse
LkValidator::brParse('PV00123456');
// [
//   'valid'        => true,
//   'normalized'   => 'PV00123456',
//   'prefix'       => 'PV',
//   'company_type' => 'Private Limited Company',
// ]
```

PrefixTypePVPrivate Limited CompanyPBPublic CompanyHPForeign Company (Branch)SPSole ProprietorshipPRPartnershipGNGuarantee CompanySCUnlimited Company---

### Postal Code Validator

[](#postal-code-validator)

```
LkValidator::postalCode('00100');  // true — Colombo 1
LkValidator::postalCode('80000');  // true — Galle
LkValidator::postalCode('999');    // false — too short

// Parse with province detection
LkValidator::postalCodeParse('80000');
// [
//   'valid'    => true,
//   'code'     => '80000',
//   'province' => 'Southern',
// ]
```

---

### VAT / TIN Validator

[](#vat--tin-validator)

```
LkValidator::vat('123456789-7000');  // true
LkValidator::vat('123456789');       // true (without suffix)
LkValidator::tin('123456789');       // true (9 digits)
LkValidator::tin('1234567890');      // true (10 digits)

// Parse
LkValidator::vatParse('123456789');
// [
//   'valid'      => true,
//   'type'       => 'TIN',
//   'normalized' => '123456789-7000',
// ]
```

---

### Batch Validation

[](#batch-validation)

```
$result = LkValidator::validateBatch([
    'nic'          => '851234567V',
    'phone'        => '0771234567',
    'br'           => 'PV00123456',
    'postal_code'  => '00100',
    'vat'          => '123456789-7000',
]);

// ['valid' => true, 'errors' => []]
```

---

🔧 Laravel Integration
---------------------

[](#-laravel-integration)

After installing, these validation rules are automatically available:

```
$request->validate([
    'nic'          => ['required', 'lk_nic'],
    'phone'        => ['required', 'lk_phone'],
    'br_number'    => ['required', 'lk_br'],
    'postal_code'  => ['required', 'lk_postal_code'],
    'vat_number'   => ['nullable', 'lk_vat'],
    'tin_number'   => ['nullable', 'lk_tin'],
]);
```

Custom error messages:

```
// lang/en/validation.php
'lk_nic'         => 'Please enter a valid Sri Lanka NIC number.',
'lk_phone'       => 'Please enter a valid Sri Lanka phone number.',
'lk_br'          => 'Please enter a valid Business Registration number.',
'lk_postal_code' => 'Please enter a valid Sri Lanka postal code.',
'lk_vat'         => 'Please enter a valid VAT registration number.',
```

---

🧪 Running Tests
---------------

[](#-running-tests)

```
composer install
./vendor/bin/phpunit
```

---

🏗️ Built for Sri Lankan Developers
----------------------------------

[](#️-built-for-sri-lankan-developers)

This package is maintained by [Trishan](https://leadingedgesolutions.lk) — founder of [Leading Edge Solutions](https://leadingedgesolutions.lk) and builder of Sri Lankan SaaS products including [Ceylon Ledger](https://ceylonledger.lk).

If this package saved you time, consider [sponsoring on GitHub](https://github.com/sponsors/trishanapp) ☕

---

📄 License
---------

[](#-license)

MIT © [Trishan / Leading Edge Solutions](https://leadingedgesolutions.lk)

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance86

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

72d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f740b2c6ef91d6ccb653d5e67e44d130dd8b4dd921b57b0e410bf774f6bfb264?d=identicon)[vidurangamts](/maintainers/vidurangamts)

---

Top Contributors

[![gosdrkht](https://avatars.githubusercontent.com/u/34083763?v=4)](https://github.com/gosdrkht "gosdrkht (2 commits)")

---

Tags

phplaravelvalidatorsri-lankanicbusiness registration

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/trishanapp-lk-business-validator/health.svg)

```
[![Health](https://phpackages.com/badges/trishanapp-lk-business-validator/health.svg)](https://phpackages.com/packages/trishanapp-lk-business-validator)
```

###  Alternatives

[laravel-validation-rules/us-state

Validate US States and Canada Provinces

16181.0k](/packages/laravel-validation-rules-us-state)[stuyam/laravel-phone-validator

A phone validator for Laravel using the free Twilio phone lookup service.

2861.9k](/packages/stuyam-laravel-phone-validator)[yorcreative/laravel-argonaut-dto

Argonaut is a lightweight Data Transfer Object (DTO) package for Laravel that supports nested casting, recursive serialization, and validation out of the box. Ideal for service layers, APIs, and clean architecture workflows.

1053.4k2](/packages/yorcreative-laravel-argonaut-dto)[laravel-validation-rules/timezone

Validate that a given timezone is valid.

2119.0k](/packages/laravel-validation-rules-timezone)

PHPackages © 2026

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