3.1.1 β€’ Published 5 years ago

south-africa-national-id-validation v3.1.1

Weekly downloads
252
License
MIT
Repository
github
Last release
5 years ago

πŸ‡ΏπŸ‡¦ 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

TODO

  • Consider using date-fns/toDate helper for date validation once 2.0 is released
3.1.1

5 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

1.0.0

6 years ago