Skip to content
Checks the South Africa National ID input is valid and allows you to return specific error messages
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
.npmignore
.travis.yml
LICENSE
README.md
babel.config.js
index.js
index.test.js
jest.config.js
package.json
yarn.lock

README.md

🇿🇦 South Africa National ID Validation

npm npm Build Status Coverage Status GitHub

Checks the National ID input:

  • is valid (regex)
    • correct format
    • correct citizenship
    • correct number of digits
    • not blank
  • passes checksum
  • has a correct date
  • is above a minimum age (optional)

Usage

Grab from NPM / Yarn

npm i south-africa-national-id-validation
yarn add south-africa-national-id-validation
import verifyNationalIdNumber from 'south-africa-national-id-validation'

verifyNationalIdNumber({
    number //(string) the number to check
    minAge //(number) minimum allowed age
    errorMessages: {
        format //(string) error to display when format check fails
        date //(string) error to display when date check fails
        age //(string) error to display when age check fails
        checksum //(string) error to display when checksum check fails
    }
})

Check out the tests for specific use case examples


Based off the westercape docs

Inspired by valid-south-african-id

You can’t perform that action at this time.