Download the PHP package phprsa/id-validator without Composer

On this page you can find all versions of the php package phprsa/id-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package id-validator

PHP RSA ID Validator

PHP Version License Packagist

A lightweight PHP library for validating South African ID numbers. It performs full structural checks, validates birth dates (with correct century resolution), determines gender, identifies citizenship, and verifies the Luhn check digit. Ideal for forms, authentication systems, HR platforms, and any application requiring reliable South African ID verification.


Features


Requirements


Installation

Using Composer

Manual load

If you're not using Composer, require the three source files directly (in this order, since RsaIdValidator depends on the other two):


Usage

validate() returns an IdValidationResult object rather than a bare array, so your editor can autocomplete the available fields and typos fail at static-analysis time instead of silently returning null:

Property Type Notes
valid bool Always present
idNumber ?string Present only when valid is true
dateOfBirth ?DateTimeImmutable Present only when valid is true
gender ?Gender Backed enum: Gender::Male / Gender::Female
citizenship ?Citizenship Backed enum: Citizenship::Citizen / Citizenship::PermanentResident
checkDigit ?int Present only when valid is true
error ?string Present only when valid is false

Quick boolean check

If you just need a yes/no answer, skip the object entirely:

Migrating from v1.x (array-based results)

v1.x returned a plain associative array. If you're not ready to switch call sites over to the typed properties yet, toArray() reproduces the old shape:


A note on century ambiguity

An RSA ID number only stores a two-digit year, so a year like 35 is genuinely ambiguous between 1935 and 2035 — the ID number alone can't tell you which. This library resolves that the only sound way it can: a candidate century is rejected outright if it would place the birth date in the future, and otherwise accepted if it produces a plausible age (0–122 years). Where both centuries remain plausible, 2000s is preferred, since that's the more common case in practice. If your application needs different disambiguation rules (e.g. always assuming the older century for a particular use case), you'll want to layer that logic on top of dateOfBirth yourself.


Demo

demo/index.php is a small self-contained web page for manual testing. It's for demonstration only — remove it or put it behind auth before deploying anywhere near production, since it accepts raw ID numbers over POST.


Running the tests

All sample IDs in the test suite are real, independently-verified numbers (checked against the Luhn variant documented in RsaIdValidator::validateLuhn()) — not placeholders.


License

MIT


All versions of id-validator with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package phprsa/id-validator contains the following files

Loading the files please wait ...