The validate-functions
package provides a set of utility functions for validating common identification numbers and formats.
To install the package, use npm:
npm install validate-functions
More usage details are available here.
This package includes various categorised validators which can be helppful for various developments.
- Credit Card Number: Validate using the Luhn algorithm.
- Passport Number: Support formats for multiple countries.
- Aadhaar: Validites Indian Identity numbers using specific patterns.
- TIN/EIN: Validate Taxpayer Identification Number (TIN) or Employer Identification Number (EIN).
- Postal/ZIP Code: Validate based on country-specific formats. It supports top 25 countries based on ISO 3166-1 alpha-2 codes namely: US, CN, IN, ID, PK, BR, NG, BD, RU, MX, JP, ET, PH, EG, VN, CD, TR, IR, DE, TH, GB, FR, IT, TZ, ZA.
- Email: Validate email addresses which conform to standard formats.
- IP Address: Validate IPv4 and IPv6 formats.
- URL: Validate structure and it supports URLs with and without protocols, and it handles query parameters and fragments.
- MAC Address: Validate for networking hardware.
- PAN (Permanent Account Number): For Indian tax records.
- Social Security Number (SSN): Validates U.S. Social Security Numbers based on predefined rules.
- Social Insurance Number (SIN): For Canada or equivalent in other countries.
- File Extensions: Validate file names/extensions (e.g.,
.jpg
,.pdf
).
- Hex Color Codes: Validate
#RRGGBB
or#RGB
color formats. - EAN/UPC: Validate international product codes.
- Base64: Validate for Base64 encoded string.