A TypeScript Ready universal verification library (Server-Side and Client-Side) for developers.
[TOC]
npm i -s verifications
// Node.js :
const Verifications = require('verifications');
// ES6 :
import Verifications from 'verifications';
// Typescript :
import * as Verifications from 'verifications';
- NationalID
- verify(code: string, locale?: string): boolean
- CreditCard
- verify(code: string): boolean
- type(code: string): string | undefined
- issuer(code: string): { name: string, alias: string, website: string } | undefined
- identify(code: string): { type: Type, issuer: Issuer } | undefined
- Phone
- identify(number: string): identity: { [key: string]: any } | undefined
- country(number: string): { name: string, alias: string } | undefined
- fancy(number: string): string
- normalize(number: string): string
Verifications
.NationalID
.verify('xxx-xxxxxx-x');
// returns true if the code matches any supported format
you can also enforce the locale
Verifications
.NationalID
.verify('xxx-xx-xxxx', 'US');
Supported Locales:
- Iran (IR) - کد ملی
- United States (US) - Social Security Number (SSN)
- United Kingdom (UK) - National Insurance Number (NINO)
Verifications
.CreditCard
.verify('xxxx-xxxx-xxxx-xxxx');
// returns true if the code matches any supported format
Verifications
.CreditCard
.identify('xxxx-xxxx-xxxx-xxxx');
// returns identity of the card/issuer
Verifications
.CreditCard
.type('xxxx-xxxx-xxxx-xxxx');
// returns type of the card
Verifications
.CreditCard
.issuer('xxxx-xxxx-xxxx-xxxx');
// returns issuer of the card
Luhn verification algorithm (almost all credit cards around the globe)
- 9 card/issuer types
- 46 active issuers are supported
Verifications
.Phone
.identify('+xx (xxx) xxx xxxx');
// returns the identity of the number or undefined
Verifications
.Phone
.country('+xx (xxx) xxx xxxx');
// returns the country of the number or undefined
Verifications
.Phone
.fancy('00xx xx x xxx x x xx');
// returns the beautified format if supported or the given number
Verifications
.Phone
.normalize('+xx (xxx) xxx xxxx');
// returns numbers only -> xxxxxxxxxxxx