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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@devsadikbd/bd-validator

v1.0.1

Published

A utility library for validating Bangladeshi phone numbers, NID, TIN, passport, postal codes and bank accounts.

Readme

bd-validator 🇧🇩

A lightweight, zero-dependency utility library for validating Bangladeshi data — phone numbers, NID, TIN, passport, postal codes, and bank accounts.


Features

  • Phone number validation + formatting + operator detection
  • NID (National ID) — supports 10, 13, and 17-digit formats
  • TIN (Tax Identification Number)
  • Passport number
  • Postal code
  • Bank account number
  • ✅ Full TypeScript support
  • ✅ Works in Node.js, React, Next.js, Vue, and browsers
  • ✅ Zero dependencies

Installation

npm install bd-validator
# or
yarn add bd-validator
# or
pnpm add bd-validator

Usage

import {
  isValidPhone,
  formatPhone,
  getOperator,
  isValidNID,
  validate,
} from "bd-validator";

// Phone validation
isValidPhone("01711234567"); // true
isValidPhone("+8801711234567"); // true
isValidPhone("01211234567"); // false (invalid prefix)

// Format phone
formatPhone("01711234567"); // '+8801711234567'

// Detect operator
getOperator("01711234567"); // 'Grameenphone'
getOperator("01911234567"); // 'Banglalink'
getOperator("01511234567"); // 'Teletalk'
getOperator("01611234567"); // 'Robi'

// NID validation
isValidNID("1234567890"); // true (10-digit)
isValidNID("1234567890123"); // true (13-digit old format)
isValidNID("12345678901234567"); // true (17-digit new format)

// TIN
isValidTIN("123456789012"); // true

// Postal code
isValidPostalCode("1216"); // true

// Passport
isValidPassport("AB1234567"); // true

// Bank account
isValidBankAccount("1234567890123"); // true

// Generic validate function
const result = validate("01711234567", "phone");
// {
//   valid: true,
//   type: 'phone',
//   formatted: '+8801711234567',
//   meta: { operator: 'Grameenphone' }
// }

API Reference

Phone

| Function | Description | Returns | | --------------------- | --------------------------- | ---------------- | | isValidPhone(phone) | Validates BD mobile number | boolean | | formatPhone(phone) | Formats to +880XXXXXXXXXX | string \| null | | getOperator(phone) | Returns operator name | string \| null |

Supported operators: Grameenphone, Banglalink, Robi, Airtel (Robi), Teletalk

Supported formats: 01XXXXXXXXX, 8801XXXXXXXXX, +8801XXXXXXXXX


NID

| Function | Description | Returns | | ----------------- | ------------------------------- | ------------------------ | | isValidNID(nid) | Validates NID (10/13/17 digits) | boolean | | getNIDType(nid) | Returns 'old' or 'new' | 'old' \| 'new' \| null |


Other Validators

| Function | Description | Returns | | ----------------------------- | -------------------------------------- | --------- | | isValidTIN(tin) | Validates 12-digit TIN | boolean | | isValidPostalCode(code) | Validates 4-digit postal code | boolean | | isValidPassport(passport) | Validates BD passport (e.g. AB1234567) | boolean | | isValidBankAccount(account) | Validates 13–17 digit bank account | boolean |


Generic validate()

validate(value: string, type: ValidationType): ValidationResult

ValidationType: 'phone' | 'nid' | 'tin' | 'postal' | 'passport' | 'bank'

interface ValidationResult {
  valid: boolean;
  type: ValidationType;
  formatted?: string | null;
  meta?: Record<string, unknown>;
}

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

git clone https://github.com/devsadikbd/bd-validator.git
cd bd-validator
npm install
npm test

License

MIT © Md Sadik Hasan