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

Package detail

verifications

ardalanamini21MIT0.3.0TypeScript support: included

universal verification library for developers

verification, identification, IR, US, credit card, types, Airlines, Travel, Banking and Financial, Merchandising and Banking/Financial, Petroleum, Healthcare, Telecommunications, National Assignment, issuer, bank, Mellat Bank, Saman Bank, Parsian Bank, Tejarat Bank, Ansar Bank, Eghtesad Novin Bank, Karafarin Bank, Export Development Bank of Iran, Post Bank of Iran, Bank of Industry and Mine, Bank Maskan, Ayandeh Bank, Sina Bank, Mehr Eqtesad Bank, Sarmayeh Bank, Bank Sepah, Refah Bank, American Express, Bank Pasargad, Shahr Bank, Tose'e Ta'avon Bank, Bank Day, Bank Saderat Iran, Keshavarzi Bank, Bank Melli Iran, China UnionPay, Diners Club International, Discover Card, Decoupled debit card, Japan Credit Bureau, Maestro, Dankort, Mir (payment system), MasterCard, Visa Inc, Universal Air Travel Plan, Interswitch, TROY, CARDGUARD EAD BG ILS, Royal Bank of Canada, TD Canada Trust, The Bank of Nova Scotia, Bank of Montreal, Hongkong Bank of Canada, national code, ssn, social security number

readme

Verifications

A TypeScript Ready universal verification library (Server-Side and Client-Side) for developers.

npm npm GitHub stars license

[TOC]

Installation

npm i -s verifications

Usage

require / import

// Node.js :
const Verifications = require('verifications');
// ES6 :
import Verifications from 'verifications';
// Typescript :
import * as Verifications from 'verifications';

Available Methods

  • 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

NationalID

Verify
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)

CreditCard

Verify
Verifications
    .CreditCard
    .verify('xxxx-xxxx-xxxx-xxxx');
// returns true if the code matches any supported format
Identify
Verifications
    .CreditCard
    .identify('xxxx-xxxx-xxxx-xxxx');
// returns identity of the card/issuer
Type
Verifications
    .CreditCard
    .type('xxxx-xxxx-xxxx-xxxx');
// returns type of the card
Issuer
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

Phone

Identify
Verifications
    .Phone
    .identify('+xx (xxx) xxx xxxx');
// returns the identity of the number or undefined
Country
Verifications
    .Phone
    .country('+xx (xxx) xxx xxxx');
// returns the country of the number or undefined
Fancy
Verifications
    .Phone
    .fancy('00xx xx x xxx x x xx');
// returns the beautified format if supported or the given number
Normalize
Verifications
    .Phone
    .normalize('+xx (xxx) xxx xxxx');
// returns numbers only -> xxxxxxxxxxxx

changelog

Change Log

v0.3.0

  1. added Phone to verifications (IR only for now)
  2. added UK to NationalID locales support
  3. transformed json files info js variables (no more json-loader, yay!)