npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

verifications

v0.3.0

Published

universal verification library for developers

Downloads

49

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