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

nusantara-valid

v0.4.2

Published

Nusantara Valid is a data validator to validate any Indonesian specific civil data such as nik, nip, and many more.

Downloads

473

Readme

npm version Coverage Status JS gzip size Extended JS gzip size Code license

Nusantara Valid is a data validator to validate any Indonesian specific civil data such as nik, nip, and many more.

Baca petunjuk berbahasa Indonesia

Table of contents

What it can do?

  • ATM Number (Nomor Rekening)
  • Cellular Number / Mobile Number
  • Credit Card Number
  • E-Mail
  • NIK (Nomor Induk Kependudukan)
  • NIP (Nomor Induk Pegawai Negeri Sipil)
  • NISN (Nomor Induk Siswa Nasional)
  • NPWP (Nomor Pokok Wajib Pajak)
  • TNKB (Tanda Nomor Kendaraan Bermotor)
  • Telephon Number
  • ZIP Code (Kode Pos)

Getting started

There are some ways to import the package

What's included

The package includes multiple formats to support different build process.

  • /cjs/nusantara-valid.js - CommonJS module.
  • /esm/nusantara-valid.js - ES module.
  • /umd/nusantara-valid.js - UMD module. Can be used in browser with script tag

We provide compiled JS (nusantara-valid.js), as well as compiled and minified JS (nusantara-valid.min.js) in each module. Extended JS files (nusantara-valid.extended.js and minified nusantara-valid.extended.min.js) include additional PROVINCE_DATA such as regencies and districts also some additional verification process.

Folder structure

nusantara-valid/
└── dist/
    ├── cjs/
    │   ├── nusantara-valid.extended.js
    │   ├── nusantara-valid.extended.js.map
    │   ├── nusantara-valid.extended.min.js
    │   ├── nusantara-valid.extended.min.js.map
    │   ├── nusantara-valid.js
    │   ├── nusantara-valid.js.map
    │   ├── nusantara-valid.min.js
    │   └── nusantara-valid.min.js.map
    ├── esm/
    │   ├── nusantara-valid.extended.js
    │   ├── nusantara-valid.extended.js.map
    │   ├── nusantara-valid.extended.min.js
    │   ├── nusantara-valid.extended.min.js.map
    │   ├── nusantara-valid.js
    │   ├── nusantara-valid.js.map
    │   ├── nusantara-valid.min.js
    │   └── nusantara-valid.min.js.map
    └── umd/
        ├── nusantara-valid.extended.js
        ├── nusantara-valid.extended.js.map
        ├── nusantara-valid.extended.min.js
        ├── nusantara-valid.extended.min.js.map
        ├── nusantara-valid.js
        ├── nusantara-valid.js.map
        ├── nusantara-valid.min.js
        └── nusantara-valid.min.js.map

Usage

CommonJS module way (require())

const NusantaraValid = require('nusantara-valid')

ES module way (import)

import NusantaraValid from './node_modules/nusantara-valid/dist/esm/nusantara-valid.js'

Good-old-browser-way (<script></script>)

Local

<script src="../dist/umd/nusantara-valid.min.js"></script>

CDN

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/nusantara-valid.min.js"></script>

API

isValidATMNumber(atm: string);

isValidATMNumberWithComparison(atm: string, bankKey: string);
isValidATMNumber('87.800.000.00');
// true

isValidATMNumberWithComparison('1230005123000', 'MDRK');
// true
getDataBank(bankKey: string);

getDataBanks();

Result:

getDataBank('BCAK');
// { key: 'BCAK', name: 'Bank Central Asia' }

getDataBanks();
// [
//     { key: 'BCAK', name: 'Bank Central Asia' },
//     { key: 'BCAS', name: 'Bank Central Asia Syariah' },
//     { key: 'BNIK', name: 'Bank Negara Indonesia' },
//     ...
// ]
isValidCellularNumber(cel: string);

isValidCellularNumberWithComparison(cel: string, providerKey: string);

getDataCellularNumber(cel: string);

formatCellularNumber(cel: string, int:boolean = false)

Result:

isValidCellularNumber('081212341234');
// true

isValidCellularNumberWithComparison('081212341234', 'TELKOMSEL');
// true

getDataCellularNumber('085612341234');
// {
//     "number": "0856-1234-1234",
//     "provider": {
//         "key": "INDOSAT",
//         "name": "Indosat Ooredoo"
//     }
// }

formatCellularNumber('+6281812341234');
// '0818-1234-1234'
formatCellularNumber('085612341234', true);
// '+62856-1234-1234'
getDataCellularProvider(key: string);

getDataCellularProviders();

Result:

getDataCellularProvider('TELKOMSEL');
// { "key": "TELKOMSEL", "name": "Telkomsel" }

getDataCellularProviders();
// [
//     { key: 'TELKOMSEL', name: 'Telkomsel' },
//     { key: 'INDOSAT', name: 'Indosat Ooredoo' },
//     { key: 'XL', name: 'XL Axiata' },
//     ...
// ]
isValidCCNumber(cc: string);

formatCCNumber(cc: string);

Result:

isValidCCNumber('4000123456789010');
// true
isValidCCNumber('5000 1234 5678 9010');
// true

formatCCNumber('4000123456789010');
// '4000 1234 5678 9010'
formatCCNumber('5000 1234 5678 9010');
// '5000 1234 5678 9010'
isValidEmail(email: string);

Result:

isValidEmail('[email protected]');
// true
isValidNIK(nik: string);

isValidNIKWithComparison(nik: string, comparison: { provinceKy?: string, birthday?: string });

getDataNIK(nik: string);

Result:

isValidNIK('3101011212930001');
// true

isValidNIKWithComparison('3101011212930001', { provinceKey: '31', birthday: '1993-12-12' });
// true

getDataNIK('3101011212930001');
// {
//     nik: '3101011212930001',
//     birthday: 2006-12-20T00:00:00.000Z,
//     sex: 'Male',
//     province: {
//         key: '31',
//         name: 'Jakarta'
//     }
// }
isValidNIP(nip: string);

Result:

isValidNIP('198512262000051001');
// true
isValidNISN(nisn: string);

Result:

isValidNISN('0061230001');
// true
isValidNPWP(npwp: string);

formatNPWP(npwp: string);

Result:

isValidNPWP('09.123.123.1-123.123');
// true
isValidNPWP('091231231123123');
// true

formatNPWP('091231231123123');
// '09.123.123.1-123.123'
getDataProvince(key: string);

getDataProvinces();

Result:

getDataProvince('34');
// { key: '34', name: 'Yogyakarta' }

getDataProvinces();
// [
//     { bpsCode: '11', name: 'Aceh' },
//     { bpsCode: '12', name: 'Sumatra Utara' },
//     { bpsCode: '13', name: 'Sumatra Barat' },
//     ...
// ]
isValidTNKB(tnkb: string);

getDataTNKB(tnkb: string);

Result:

isValidTNKB('AB1234XYZ');
// true

getDataTNKB('AB1234XYZ');
// {
//     areaCode: 'AB',
//     index: 1234,
//     detailedAreaCode: 'XYZ',
//     province: {
//         key: '34',
//         name: 'Yogyakarta'
//     }
// }
isValidTelephoneNumber(tel: string);

getDataTelephoneNumber(cel: string);

formatTelephoneNumber(tel: string, int:boolean = false)

Result:

isValidTelephoneNumber('0274123123');
// true

getDataTelephoneNumber('0274123123');
// {
//     "number": "0274-123123",
//     "origin": {
//         "key": "34",
//         "name": "Yogyakarta"
//     }
// }

formatTelephoneNumber('0274123123');
// '0274-123123'
formatTelephoneNumber('0274123123', true);
// '+62274-123123'
isValidZIP(zip: string | number);

isValidZIPWithComparison(zip: string | number, comparison: { provinceKy?: string });

Result:

isValidZIP('55264');
// true
isValidZIP(55264);
// true

isValidZIPWithComparison('55264', { provinceKey: '34' });
// true
isValidZIPWithComparison(55264, { provinceKey: '34' });
// true

API (Extended Only)

getDataRegenciesInProvince(provinceBPSCode: string);

getDataDistrictsInRegency(regencyBPSCode: string);

Result:

getDataRegenciesInProvince('31'); // Regencies and City (Kabupaten dan Kota) in Jakarta
// [
//   { bpsCode: '31.01', name: 'Kepulauan Seribu' },
//   { bpsCode: '31.71', name: 'Jakarta Pusat' },
//   { bpsCode: '31.72', name: 'Jakarta Utara' },
//   ...
// ]

getDataDistrictsInRegency('31.71'); // Districts (Kecamatan) in Jakarta Pusat
// [
//   { name: 'Gambir', bpsCode: '31.71.01' },
//   { name: 'Sawah Besar', bpsCode: '31.71.02' },
//   { name: 'Kemayoran', bpsCode: '31.71.03' },
//   ...
// ]

License

Copyright (c) 2020 - Fajar Setya Budi.

Nusantara Valid released under the MIT License.