Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@tk007/sa-id-validator

tkmateka137MIT1.0.1TypeScript support: included

A simple TypeScript library to validate South African ID numbers.

south-africa, id-number, validation, typescript, identity, validator

readme

SA ID Validator

npm version build status

🇿🇦 SA ID Validator

npm version CI License: MIT

Validate South African ID Numbers easily using TypeScript.


✨ Features

  • Validate if a South African ID number is correct
  • Extract Gender
  • Extract Date of Birth
  • Calculate Age
  • Fully typed with TypeScript
  • Zero dependencies

📦 Install

`bash npm install @tk007/sa-id-validator

OR with yarn

yarn add @tk007/sa-id-validator

🚀 Usage

import { validateSouthAfricanID } from '@tk007/sa-id-validator';

const result = validateSouthAfricanID('8001015009087');

console.log(result); // Output: // { // isValid: true, // gender: "Male", // dateOfBirth: "1980-01-01", // age: 45 // }

📋 API validateSouthAfricanID(idNumber: string): ValidationResult

Field Type Description
isValid boolean Whether the ID number is valid
gender string "Male" or "Female"
dateOfBirth string Date of birth in YYYY-MM-DD format
age number Current age based on today

🛠️ Development Clone the repo and install dependencies:

git clone https://github.com/tk007/sa-id-validator.git cd sa-id-validator npm install

Build:

npm run build

Run tests:

npm run test

📜 License MIT © tk007

🙌 Contributing Contributions, issues, and feature requests are welcome! Feel free to open an issue or submit a pull request.


🚀 If you add this, your package page will look so much more professional and polished!

Would you like me to also give you a matching package.json metadata improvement (description, homepage, repository fields, etc)? 📦
It'll make your npm page even better! 🚀
Want it?