ssn-validator-js
v1.0.0
Published
A simple package to validate ssn numbers
Downloads
5
Maintainers
Readme
ssn-validator
🛠️ A simple, robust JavaScript library for validating US Social Security Numbers (SSN) according to the official SSA rules.
📦 Installation
npm install ssn-validatoror with Yarn:
yarn add ssn-validator🚀 Usage
// Import the main validator function
const validateSSN = require("ssn-validator");
// Validate a standard SSN
console.log(validateSSN("011-23-4567")); // true
// Check invalid examples
console.log(validateSSN("666-12-3456")); // false (Invalid Area Number)
console.log(validateSSN("901-23-4567")); // false (Invalid Area Number 900-999)
console.log(validateSSN("011-00-4567")); // false (Invalid Group Number)
console.log(validateSSN("011-23-0000")); // false (Invalid Serial Number)
console.log(validateSSN("123456789")); // false (Missing hyphens)#Validation Criteria:
✅ Must be a string with 9 digits, formatted as XXX-XX-XXXX.
✅ Area Number (First 3 digits): Cannot be 000, 666, or any number between 900 and 999.
✅ Group Number (Middle 2 digits): Cannot be 00. Must be between 01 and 99.
✅ Serial Number (Last 4 digits): Cannot be 0000. Must be between 0001 and 9999.
🌐 Links
- NPM: string-tools
- GitHub: Repository
📄 License
© [Yubraj Dhungana](https://github.com/yubiStona)
