@tk007/sa-id-validator
v1.0.1
Published
A simple TypeScript library to validate South African ID numbers.
Maintainers
Readme
🇿🇦 SA ID Validator
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
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?