Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nusantara-valid

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nusantara-valid

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

  • 0.4.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
129
decreased by-11.03%
Maintainers
0
Weekly downloads
 
Created
Source

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

Nusantara Valid logo

Nusantara Valid

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

  • Download the latest release.

  • Clone the repo:

    git clone https://github.com/agraris/nusantara-valid.git

  • Install with npm:

    npm install nusantara-valid

  • CDN from jsDelivr

    https://cdn.jsdelivr.net/npm/nusantara-valid@0.4.2/dist/umd/nusantara-valid.min.js

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/nusantara-valid@0.4.2/dist/umd/nusantara-valid.min.js"></script>

API

ATM Number (Nomor Rekening)
isValidATMNumber(atm: string);

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

isValidATMNumberWithComparison('1230005123000', 'MDRK');
// true
Bank
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' },
//     ...
// ]
Cellular Number (Nomor HP)
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'
Cellular Provider
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' },
//     ...
// ]
Credit Card Number
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'
E-Mail
isValidEmail(email: string);

Result:

isValidEmail('myawesom-email@domain.tld');
// true
Nomor Induk Kependudukan (NIK)
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'
//     }
// }
Nomor Induk Pegawai Negeri Sipil (NIP)
isValidNIP(nip: string);

Result:

isValidNIP('198512262000051001');
// true
Nomor Induk Siswa Nasional (NISN)
isValidNISN(nisn: string);

Result:

isValidNISN('0061230001');
// true
Nomor Pokok Wajib Pajak (NPWP)
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'
Province
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' },
//     ...
// ]
Tanda Nomor Kendaraan Bermotor (TNKB)
isValidTNKB(tnkb: string);

getDataTNKB(tnkb: string);

Result:

isValidTNKB('AB1234XYZ');
// true

getDataTNKB('AB1234XYZ');
// {
//     areaCode: 'AB',
//     index: 1234,
//     detailedAreaCode: 'XYZ',
//     province: {
//         key: '34',
//         name: 'Yogyakarta'
//     }
// }
Telephone Number (Nomor Telefon)
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'
ZIP Code (Kode POS)
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)

Province
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.

Keywords

FAQs

Package last updated on 14 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc