https://github.com/ardalanamini/verifications
universal verification library for developers
https://github.com/ardalanamini/verifications
credit-card identification national-code social-security-number ssn verification
Last synced: 16 days ago
JSON representation
universal verification library for developers
- Host: GitHub
- URL: https://github.com/ardalanamini/verifications
- Owner: ardalanamini
- License: mit
- Created: 2017-12-06T15:54:41.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-11T14:45:45.000Z (over 7 years ago)
- Last Synced: 2025-05-07T23:44:31.940Z (16 days ago)
- Topics: credit-card, identification, national-code, social-security-number, ssn, verification
- Language: TypeScript
- Homepage:
- Size: 2.35 MB
- Stars: 8
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Verifications
A **TypeScript Ready** universal verification library (Server-Side and Client-Side) for developers.
[](https://www.npmjs.com/package/verifications)
[](https://www.npmjs.com/package/verifications)
[](https://github.com/ardalanamini/verifications/stargazers)
[](https://github.com/ardalanamini/verifications/blob/master/LICENSE)[TOC]
## Installation
`npm i -s verifications`
## Usage
### require / import
```javascript
// 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
```javascript
Verifications
.NationalID
.verify('xxx-xxxxxx-x');
// returns true if the code matches any supported format
```you can also enforce the locale
```javascript
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
```javascript
Verifications
.CreditCard
.verify('xxxx-xxxx-xxxx-xxxx');
// returns true if the code matches any supported format
```##### Identify
```javascript
Verifications
.CreditCard
.identify('xxxx-xxxx-xxxx-xxxx');
// returns identity of the card/issuer
```##### Type
```javascript
Verifications
.CreditCard
.type('xxxx-xxxx-xxxx-xxxx');
// returns type of the card
```##### Issuer
```javascript
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
```javascript
Verifications
.Phone
.identify('+xx (xxx) xxx xxxx');
// returns the identity of the number or undefined
```##### Country
```javascript
Verifications
.Phone
.country('+xx (xxx) xxx xxxx');
// returns the country of the number or undefined
```##### Fancy
```javascript
Verifications
.Phone
.fancy('00xx xx x xxx x x xx');
// returns the beautified format if supported or the given number
```##### Normalize
```javascript
Verifications
.Phone
.normalize('+xx (xxx) xxx xxxx');
// returns numbers only -> xxxxxxxxxxxx
```