PHPackages                             akukoder/mykad-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. akukoder/mykad-validator

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

akukoder/mykad-validator
========================

A library for validating MyKad or MyKid format

1.0.8(5y ago)11.9k1MITPHPPHP ^7.3CI failing

Since May 7Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/akukoder/mykad-validator)[ Packagist](https://packagist.org/packages/akukoder/mykad-validator)[ Docs](https://akukoder.com)[ RSS](/packages/akukoder-mykad-validator/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (2)Versions (8)Used By (0)

MyKad Validator
===============

[](#mykad-validator)

[![Build Status](https://camo.githubusercontent.com/7b8e92572d782cb00ab44a3a2be37721b4dec06688df79e2696e9ae19762f5cb/68747470733a2f2f7472617669732d63692e6f72672f616b756b6f6465722f6d796b61642d76616c696461746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/akukoder/mykad-validator)[![GitHub tag (latest by date)](https://camo.githubusercontent.com/0feff5b62caae6af974d32a723acfb2ce796d7bad8c512a1e22de6f3ff85b5e9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f616b756b6f6465722f6d796b61642d76616c696461746f72)](https://camo.githubusercontent.com/0feff5b62caae6af974d32a723acfb2ce796d7bad8c512a1e22de6f3ff85b5e9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f616b756b6f6465722f6d796b61642d76616c696461746f72)[![Packagist PHP Version Support (custom server)](https://camo.githubusercontent.com/b0522c436ae89e0d94197ef811f0cc1d86828862b5bce0c5110199e86c19f139/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f616b756b6f6465722f6d796b61642d76616c696461746f72)](https://camo.githubusercontent.com/b0522c436ae89e0d94197ef811f0cc1d86828862b5bce0c5110199e86c19f139/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f616b756b6f6465722f6d796b61642d76616c696461746f72)[![Packagist License](https://camo.githubusercontent.com/c1707877b1f605afbcda9628695e0d42ef542f154728cb44396fa00ac2850c96/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616b756b6f6465722f6d796b61642d76616c696461746f72)](https://camo.githubusercontent.com/c1707877b1f605afbcda9628695e0d42ef542f154728cb44396fa00ac2850c96/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616b756b6f6465722f6d796b61642d76616c696461746f72)

About MyKad
-----------

[](#about-mykad)

> The Government Multi-Purpose Smart Card Project (MPSC) or MyKad is part of the Multimedia Super Corridor (MSC Malaysia) initiative.

Introduction
------------

[](#introduction)

One of the most annoying thing when dealing with user records is when they entered wrong MyKad/MyKid number. This package helps reduce the burden to deal with invalid input by users.

This package will validate MyKad/MyKid number to make sure:

- Contains numbers only
- Valid length
- Valid date of birth
- Valid state/country code

***Note:***

Any other unnecessary characters from the input will be removed, including dashes.

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

[](#installation)

You can install the package via composer:

```
composer require akukoder/mykad-validator

```

Usage
-----

[](#usage)

```
use AkuKoder\MyKadValidator\Validator;

$validator = new Validator;

// This will return false
if ($validator->validate('982404-06-5883')) {

}

// This will return false
if ($validator->validate('982404-06-83')) {

}

// This will return false
if ($validator->validate('980404-00-5335')) {

}

// This will return false
if ($validator->validate('9804AA-00-5335')) {

}

// This will return true
if ($validator->validate('980404-06-5335')) {

}
```

### Get exception on errors

[](#get-exception-on-errors)

```
use AkuKoder\MyKadValidator\Validator;

$validator = new Validator;

// This will throw \AkuKoder\MyKadValidator\Exceptions\InvalidDateException
if ($validator->validate('982404-06-5883', true)) {

}

// This will throw \AkuKoder\MyKadValidator\Exceptions\InvalidLengthException
if ($validator->validate('982404-06-83', true)) {

}

// This will throw \AkuKoder\MyKadValidator\Exceptions\InvalidCodeException
if ($validator->validate('980404-00-5335', true)) {

}

// This will throw \AkuKoder\MyKadValidator\Exceptions\InvalidCharacterException
if ($validator->validate('9804AA-00-5335', true)) {

}
```

Testing
-------

[](#testing)

```
composer test

```

Reference
---------

[](#reference)

1.

License
-------

[](#license)

The MIT License (MIT).

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance47

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.5% 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

Every ~21 days

Recently: every ~27 days

Total

6

Last Release

2095d ago

PHP version history (2 changes)1.0.3PHP ^7.4

1.0.5PHP ^7.3

### Community

Maintainers

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

---

Top Contributors

[![syahzul](https://avatars.githubusercontent.com/u/707301?v=4)](https://github.com/syahzul "syahzul (21 commits)")[![huiyang](https://avatars.githubusercontent.com/u/517651?v=4)](https://github.com/huiyang "huiyang (1 commits)")

---

Tags

validatorMyKadmykid

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/akukoder-mykad-validator/health.svg)

```
[![Health](https://phpackages.com/badges/akukoder-mykad-validator/health.svg)](https://phpackages.com/packages/akukoder-mykad-validator)
```

###  Alternatives

[respect/validation

The most awesome validation engine ever created for PHP

5.9k37.4M383](/packages/respect-validation)[seld/jsonlint

JSON Linter

1.3k217.8M205](/packages/seld-jsonlint)[composer/spdx-licenses

SPDX licenses list and validation library.

1.4k184.2M25](/packages/composer-spdx-licenses)[opis/json-schema

Json Schema Validator for PHP

64236.9M186](/packages/opis-json-schema)[intervention/validation

Additional validation rules for the Laravel framework

6826.7M8](/packages/intervention-validation)[laminas/laminas-validator

Validation classes for a wide range of domains, and the ability to chain validators to create complex validation criteria

15544.9M188](/packages/laminas-laminas-validator)

PHPackages © 2026

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