nusantara-valid
Advanced tools
Comparing version 0.2.0 to 0.3.0
/*! | ||
* Nusantara Valid v0.2.0 | ||
* Nusantara Valid v0.3.0 | ||
* Copyright 2020 - Fajar Setya Budi (https://magicjar.github.io) | ||
* Contributors (https://github.com/magicjar/nusantara-valid/graphs/contributors) | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Contributors (https://github.com/agraris/nusantara-valid/graphs/contributors) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
*/ | ||
@@ -97,3 +97,3 @@ 'use strict'; | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -103,4 +103,3 @@ /** | ||
* | ||
* List of bank in Indonesia including BPS code, vehicle plate, | ||
* telephone numbers, and zip code. | ||
* List of bank in Indonesia. | ||
**/ | ||
@@ -111,3 +110,3 @@ var BANK_DATA = { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -117,3 +116,3 @@ BCAS: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -123,3 +122,3 @@ BNIK: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -129,3 +128,3 @@ BNIS: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -135,3 +134,3 @@ BRIK: { | ||
digits: 15, | ||
dotIndex: [] | ||
dotIndex: [2, 5, 8, 11] | ||
}, | ||
@@ -141,3 +140,3 @@ BRIS: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -197,3 +196,3 @@ BTNK: { | ||
digits: 13, | ||
dotIndex: [] | ||
dotIndex: [2, 5, 8] | ||
}, | ||
@@ -203,3 +202,3 @@ MDRS: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -242,3 +241,14 @@ MGAK: { | ||
}; | ||
/** | ||
* BANK_KEYS | ||
* | ||
* List of bank object keys. | ||
**/ | ||
var BANK_KEYS = Object.keys(BANK_DATA); | ||
/** | ||
* BANK_NUMBER_LENGTHS | ||
* | ||
* List of bank's number (ATM number) length. | ||
**/ | ||
var BANK_NUMBER_LENGTHS = BANK_KEYS.reduce(function (pref, curr) { return includes(pref, BANK_DATA[curr].digits) ? pref : pref.concat(BANK_DATA[curr].digits); }, []); | ||
@@ -248,3 +258,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -255,3 +265,2 @@ * @class The ATMNumber class | ||
function ATMNumber() { | ||
this.VALID_ATMNUMBER_LENGTH = BANK_KEYS.reduce(function (pref, curr) { return includes(pref, BANK_DATA[curr].digits) ? pref : pref.concat(BANK_DATA[curr].digits); }, []); | ||
} | ||
@@ -263,6 +272,3 @@ ATMNumber.prototype.isValid = function (atm, bank) { | ||
var numOnly = numbersOnly(atm); | ||
var matchLength = correctLength(2, numOnly.length, { collection: this.VALID_ATMNUMBER_LENGTH }); | ||
if (bank) | ||
matchLength = correctLength(0, numOnly.length, { minLength: BANK_DATA[bank].digits }); | ||
return matchLength; | ||
return bank ? correctLength(0, numOnly.length, { minLength: BANK_DATA[bank].digits }) : correctLength(2, numOnly.length, { collection: BANK_NUMBER_LENGTHS }); | ||
}; | ||
@@ -300,3 +306,3 @@ return ATMNumber; | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -353,3 +359,3 @@ * @class The Bank class | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -406,3 +412,14 @@ /** | ||
var CELLULAR_HYPEN_INDEXES = [2, 6]; | ||
/** | ||
* CELLULAR_PROVIDER_KEYS | ||
* | ||
* List of cellular provider object keys. | ||
**/ | ||
var CELLULAR_PROVIDER_KEYS = Object.keys(CELLULAR_PROVIDER_DATA); | ||
/** | ||
* CELLULAR_PROVIDER_PREFIXES | ||
* | ||
* List of cellular provider prefixes. | ||
**/ | ||
var CELLULAR_PROVIDER_PREFIXES = CELLULAR_PROVIDER_KEYS.reduce(function (a, b) { return a.concat(CELLULAR_PROVIDER_DATA[b].prefix); }, []); | ||
@@ -412,3 +429,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -422,5 +439,5 @@ /** | ||
var PROVINCE_DATA = { | ||
AC: { | ||
'11': { | ||
name: 'Aceh', | ||
bpsCode: 11, | ||
bpsCode: '11', | ||
vehiclePlate: ['BL'], | ||
@@ -435,68 +452,41 @@ tel: range(641, 659).concat([627, 629]), | ||
}, | ||
BA: { | ||
name: 'Bali', | ||
bpsCode: 51, | ||
vehiclePlate: ['DK'], | ||
tel: range(361, 368), | ||
'12': { | ||
name: 'Sumatra Utara', | ||
bpsCode: '12', | ||
vehiclePlate: ['BB', 'BK'], | ||
tel: range(620, 639).concat([601]), | ||
zipCode: [ | ||
{ | ||
from: 80111, | ||
to: 82262 | ||
from: 20111, | ||
to: 22999 | ||
} | ||
] | ||
}, | ||
BB: { | ||
name: 'Kepulauan Bangka Belitung', | ||
bpsCode: 19, | ||
vehiclePlate: ['BN'], | ||
tel: range(715, 719), | ||
'13': { | ||
name: 'Sumatra Barat', | ||
bpsCode: '13', | ||
vehiclePlate: ['BA'], | ||
tel: range(751, 759), | ||
zipCode: [ | ||
{ | ||
from: 33111, | ||
to: 33792 | ||
from: 25111, | ||
to: 27779 | ||
} | ||
] | ||
}, | ||
BE: { | ||
name: 'Bengkulu', | ||
bpsCode: 17, | ||
vehiclePlate: ['BD'], | ||
tel: range(736, 739).concat([732]), | ||
'14': { | ||
name: 'Riau', | ||
bpsCode: '14', | ||
vehiclePlate: ['BM'], | ||
tel: range(760, 769).concat([624]), | ||
zipCode: [ | ||
{ | ||
from: 38113, | ||
to: 39377 | ||
from: 28111, | ||
to: 29569 | ||
} | ||
] | ||
}, | ||
BT: { | ||
name: 'Banten', | ||
bpsCode: 36, | ||
vehiclePlate: ['A'], | ||
tel: range(252, 257), | ||
zipCode: [ | ||
{ | ||
from: 15111, | ||
to: 15820 | ||
}, { | ||
from: 42111, | ||
to: 42455 | ||
} | ||
] | ||
}, | ||
GO: { | ||
name: 'Gorontalo', | ||
bpsCode: 75, | ||
vehiclePlate: ['DM'], | ||
tel: [435, 443], | ||
zipCode: [ | ||
{ | ||
from: 96111, | ||
to: 96574 | ||
} | ||
] | ||
}, | ||
JA: { | ||
'15': { | ||
name: 'Jambi', | ||
bpsCode: 15, | ||
bpsCode: '15', | ||
vehiclePlate: ['BH'], | ||
@@ -511,167 +501,158 @@ tel: range(740, 748), | ||
}, | ||
JB: { | ||
name: 'Jawa Barat', | ||
bpsCode: 32, | ||
vehiclePlate: ['D', 'E', 'F', 'T', 'Z'], | ||
tel: range(231, 234).concat(range(260, 267)).concat([22, 251]), | ||
'16': { | ||
name: 'Sumatra Selatan', | ||
bpsCode: '16', | ||
vehiclePlate: ['BG'], | ||
tel: range(711, 714).concat(range(730, 735)).concat([702]), | ||
zipCode: [ | ||
{ | ||
from: 16110, | ||
to: 17730 | ||
}, { | ||
from: 40111, | ||
to: 46476 | ||
from: 30111, | ||
to: 32388 | ||
} | ||
] | ||
}, | ||
JI: { | ||
name: 'Jawa Timur', | ||
bpsCode: 35, | ||
vehiclePlate: ['L', 'M', 'N', 'P', 'S', 'W', 'AE', 'AG'], | ||
tel: range(321, 358).concat([31]), | ||
'17': { | ||
name: 'Bengkulu', | ||
bpsCode: '17', | ||
vehiclePlate: ['BD'], | ||
tel: range(736, 739).concat([732]), | ||
zipCode: [ | ||
{ | ||
from: 60111, | ||
to: 69493 | ||
from: 38113, | ||
to: 39377 | ||
} | ||
] | ||
}, | ||
JK: { | ||
name: 'Jakarta', | ||
bpsCode: 31, | ||
vehiclePlate: ['B'], | ||
tel: [21], | ||
'18': { | ||
name: 'Lampung', | ||
bpsCode: '18', | ||
vehiclePlate: ['BE'], | ||
tel: range(721, 729), | ||
zipCode: [ | ||
{ | ||
from: 10110, | ||
to: 14540 | ||
from: 34111, | ||
to: 35686 | ||
} | ||
] | ||
}, | ||
JT: { | ||
name: 'Jawa Tengah', | ||
bpsCode: 33, | ||
vehiclePlate: ['G', 'H', 'K', 'R', 'AA', 'AD'], | ||
tel: range(275, 299).concat(range(271, 273)).concat([24, 356]), | ||
'19': { | ||
name: 'Kepulauan Bangka Belitung', | ||
bpsCode: '19', | ||
vehiclePlate: ['BN'], | ||
tel: range(715, 719), | ||
zipCode: [ | ||
{ | ||
from: 50111, | ||
to: 54474 | ||
}, { | ||
from: 56111, | ||
to: 59584 | ||
from: 33111, | ||
to: 33792 | ||
} | ||
] | ||
}, | ||
KB: { | ||
name: 'Kalimantan Barat', | ||
bpsCode: 61, | ||
vehiclePlate: ['KB'], | ||
tel: range(564, 568).concat([534]), | ||
'21': { | ||
name: 'Kepulauan Riau', | ||
bpsCode: '21', | ||
vehiclePlate: ['BP'], | ||
tel: range(771, 779), | ||
zipCode: [ | ||
{ | ||
from: 78111, | ||
to: 79682 | ||
from: 29111, | ||
to: 29878 | ||
} | ||
] | ||
}, | ||
KI: { | ||
name: 'Kalimantan Timur', | ||
bpsCode: 64, | ||
vehiclePlate: ['KT'], | ||
tel: range(541, 556), | ||
'31': { | ||
name: 'Jakarta', | ||
bpsCode: '31', | ||
vehiclePlate: ['B'], | ||
tel: [21], | ||
zipCode: [ | ||
{ | ||
from: 75111, | ||
to: 77381 | ||
from: 10110, | ||
to: 14540 | ||
} | ||
] | ||
}, | ||
KR: { | ||
name: 'Kepulauan Riau', | ||
bpsCode: 21, | ||
vehiclePlate: ['BP'], | ||
tel: range(771, 779), | ||
'32': { | ||
name: 'Jawa Barat', | ||
bpsCode: '32', | ||
vehiclePlate: ['D', 'E', 'F', 'T', 'Z'], | ||
tel: range(231, 234).concat(range(260, 267)).concat([22, 251]), | ||
zipCode: [ | ||
{ | ||
from: 29111, | ||
to: 29878 | ||
from: 16110, | ||
to: 17730 | ||
}, { | ||
from: 40111, | ||
to: 46476 | ||
} | ||
] | ||
}, | ||
KS: { | ||
name: 'Kalimantan Selatan', | ||
bpsCode: 63, | ||
vehiclePlate: ['DA'], | ||
tel: range(511, 527), | ||
'33': { | ||
name: 'Jawa Tengah', | ||
bpsCode: '33', | ||
vehiclePlate: ['G', 'H', 'K', 'R', 'AA', 'AD'], | ||
tel: range(275, 299).concat(range(271, 273)).concat([24, 356]), | ||
zipCode: [ | ||
{ | ||
from: 70111, | ||
to: 72276 | ||
from: 50111, | ||
to: 54474 | ||
}, { | ||
from: 56111, | ||
to: 59584 | ||
} | ||
] | ||
}, | ||
KT: { | ||
name: 'Kalimantan Tengah', | ||
bpsCode: 62, | ||
vehiclePlate: ['KH'], | ||
tel: range(513, 539), | ||
'34': { | ||
name: 'Yogyakarta', | ||
bpsCode: '34', | ||
vehiclePlate: ['AB'], | ||
tel: [274], | ||
zipCode: [ | ||
{ | ||
from: 73111, | ||
to: 74874 | ||
from: 55111, | ||
to: 55893 | ||
} | ||
] | ||
}, | ||
KU: { | ||
name: 'Kalimantan Utara', | ||
bpsCode: 65, | ||
vehiclePlate: ['KU'], | ||
tel: range(551, 556), | ||
'35': { | ||
name: 'Jawa Timur', | ||
bpsCode: '35', | ||
vehiclePlate: ['L', 'M', 'N', 'P', 'S', 'W', 'AE', 'AG'], | ||
tel: range(321, 358).concat([31]), | ||
zipCode: [ | ||
{ | ||
from: 77111, | ||
to: 77574 | ||
from: 60111, | ||
to: 69493 | ||
} | ||
] | ||
}, | ||
LA: { | ||
name: 'Lampung', | ||
bpsCode: 18, | ||
vehiclePlate: ['BE'], | ||
tel: range(721, 729), | ||
'36': { | ||
name: 'Banten', | ||
bpsCode: '36', | ||
vehiclePlate: ['A'], | ||
tel: range(252, 257), | ||
zipCode: [ | ||
{ | ||
from: 34111, | ||
to: 35686 | ||
from: 15111, | ||
to: 15820 | ||
}, { | ||
from: 42111, | ||
to: 42455 | ||
} | ||
] | ||
}, | ||
MA: { | ||
name: 'Maluku', | ||
bpsCode: 81, | ||
vehiclePlate: ['DE'], | ||
tel: range(910, 931), | ||
'51': { | ||
name: 'Bali', | ||
bpsCode: '51', | ||
vehiclePlate: ['DK'], | ||
tel: range(361, 368), | ||
zipCode: [ | ||
{ | ||
from: 97114, | ||
to: 97669 | ||
from: 80111, | ||
to: 82262 | ||
} | ||
] | ||
}, | ||
MU: { | ||
name: 'Maluku Utara', | ||
bpsCode: 82, | ||
vehiclePlate: ['DG'], | ||
tel: range(910, 931), | ||
zipCode: [ | ||
{ | ||
from: 97711, | ||
to: 97869 | ||
} | ||
] | ||
}, | ||
NB: { | ||
'52': { | ||
name: 'Nusa Tenggara Barat', | ||
bpsCode: 52, | ||
bpsCode: '52', | ||
vehiclePlate: ['DR', 'EA'], | ||
@@ -686,5 +667,5 @@ tel: range(370, 376).concat([364]), | ||
}, | ||
NT: { | ||
'53': { | ||
name: 'Nusa Tenggara Timur', | ||
bpsCode: 53, | ||
bpsCode: '53', | ||
vehiclePlate: ['DH', 'EB', 'ED'], | ||
@@ -699,41 +680,65 @@ tel: range(380, 389), | ||
}, | ||
PA: { | ||
name: 'Papua', | ||
bpsCode: 94, | ||
vehiclePlate: ['PA'], | ||
tel: range(951, 986).concat([901, 902]), | ||
'61': { | ||
name: 'Kalimantan Barat', | ||
bpsCode: '61', | ||
vehiclePlate: ['KB'], | ||
tel: range(564, 568).concat([534]), | ||
zipCode: [ | ||
{ | ||
from: 98511, | ||
to: 99976 | ||
from: 78111, | ||
to: 79682 | ||
} | ||
] | ||
}, | ||
PB: { | ||
name: 'Papua Barat', | ||
bpsCode: 91, | ||
vehiclePlate: ['PB'], | ||
tel: range(951, 986).concat([901, 902]), | ||
'62': { | ||
name: 'Kalimantan Tengah', | ||
bpsCode: '62', | ||
vehiclePlate: ['KH'], | ||
tel: range(513, 539), | ||
zipCode: [ | ||
{ | ||
from: 98011, | ||
to: 98495 | ||
from: 73111, | ||
to: 74874 | ||
} | ||
] | ||
}, | ||
RI: { | ||
name: 'Riau', | ||
bpsCode: 14, | ||
vehiclePlate: ['BM'], | ||
tel: range(760, 769).concat([624]), | ||
'63': { | ||
name: 'Kalimantan Selatan', | ||
bpsCode: '63', | ||
vehiclePlate: ['DA'], | ||
tel: range(511, 527), | ||
zipCode: [ | ||
{ | ||
from: 28111, | ||
to: 29569 | ||
from: 70111, | ||
to: 72276 | ||
} | ||
] | ||
}, | ||
SA: { | ||
'64': { | ||
name: 'Kalimantan Timur', | ||
bpsCode: '64', | ||
vehiclePlate: ['KT'], | ||
tel: range(541, 556), | ||
zipCode: [ | ||
{ | ||
from: 75111, | ||
to: 77381 | ||
} | ||
] | ||
}, | ||
'65': { | ||
name: 'Kalimantan Utara', | ||
bpsCode: '65', | ||
vehiclePlate: ['KU'], | ||
tel: range(551, 556), | ||
zipCode: [ | ||
{ | ||
from: 77111, | ||
to: 77574 | ||
} | ||
] | ||
}, | ||
'71': { | ||
name: 'Sulawesi Utara', | ||
bpsCode: 71, | ||
bpsCode: '71', | ||
vehiclePlate: ['DB', 'DL'], | ||
@@ -748,17 +753,32 @@ tel: range(430, 438), | ||
}, | ||
SB: { | ||
name: 'Sumatra Barat', | ||
bpsCode: 13, | ||
vehiclePlate: ['BA'], | ||
tel: range(751, 759), | ||
'72': { | ||
name: 'Sulawesi Tengah', | ||
bpsCode: '72', | ||
vehiclePlate: ['DN'], | ||
tel: range(445, 465), | ||
zipCode: [ | ||
{ | ||
from: 25111, | ||
to: 27779 | ||
from: 94111, | ||
to: 94981 | ||
} | ||
] | ||
}, | ||
SG: { | ||
'73': { | ||
name: 'Sulawesi Selatan', | ||
bpsCode: '73', | ||
vehiclePlate: ['DD', 'DP', 'DW'], | ||
tel: range(410, 421).concat(range(471, 485)).concat([423, 427]), | ||
zipCode: [ | ||
{ | ||
from: 90111, | ||
to: 91273 | ||
}, { | ||
from: 91611, | ||
to: 92985 | ||
} | ||
] | ||
}, | ||
'74': { | ||
name: 'Sulawesi Tenggara', | ||
bpsCode: 74, | ||
bpsCode: '74', | ||
vehiclePlate: ['DT'], | ||
@@ -773,20 +793,17 @@ tel: range(401, 408), | ||
}, | ||
SN: { | ||
name: 'Sulawesi Selatan', | ||
bpsCode: 73, | ||
vehiclePlate: ['DD', 'DP', 'DW'], | ||
tel: range(410, 421).concat(range(471, 485)).concat([423, 427]), | ||
'75': { | ||
name: 'Gorontalo', | ||
bpsCode: '75', | ||
vehiclePlate: ['DM'], | ||
tel: [435, 443], | ||
zipCode: [ | ||
{ | ||
from: 90111, | ||
to: 91273 | ||
}, { | ||
from: 91611, | ||
to: 92985 | ||
from: 96111, | ||
to: 96574 | ||
} | ||
] | ||
}, | ||
SR: { | ||
'76': { | ||
name: 'Sulawesi Barat', | ||
bpsCode: 76, | ||
bpsCode: '76', | ||
vehiclePlate: ['DC'], | ||
@@ -801,47 +818,47 @@ tel: [422, 426, 428], | ||
}, | ||
SS: { | ||
name: 'Sumatra Selatan', | ||
bpsCode: 16, | ||
vehiclePlate: ['BG'], | ||
tel: range(711, 714).concat(range(730, 735)).concat([702]), | ||
'81': { | ||
name: 'Maluku', | ||
bpsCode: '81', | ||
vehiclePlate: ['DE'], | ||
tel: range(910, 931), | ||
zipCode: [ | ||
{ | ||
from: 30111, | ||
to: 32388 | ||
from: 97114, | ||
to: 97669 | ||
} | ||
] | ||
}, | ||
ST: { | ||
name: 'Sulawesi Tengah', | ||
bpsCode: 72, | ||
vehiclePlate: ['DN'], | ||
tel: range(445, 465), | ||
'82': { | ||
name: 'Maluku Utara', | ||
bpsCode: '82', | ||
vehiclePlate: ['DG'], | ||
tel: range(910, 931), | ||
zipCode: [ | ||
{ | ||
from: 94111, | ||
to: 94981 | ||
from: 97711, | ||
to: 97869 | ||
} | ||
] | ||
}, | ||
SU: { | ||
name: 'Sumatra Utara', | ||
bpsCode: 12, | ||
vehiclePlate: ['BB', 'BK'], | ||
tel: range(620, 639).concat([601]), | ||
'91': { | ||
name: 'Papua Barat', | ||
bpsCode: '91', | ||
vehiclePlate: ['PB'], | ||
tel: range(951, 986).concat([901, 902]), | ||
zipCode: [ | ||
{ | ||
from: 20111, | ||
to: 22999 | ||
from: 98011, | ||
to: 98495 | ||
} | ||
] | ||
}, | ||
YO: { | ||
name: 'Yogyakarta', | ||
bpsCode: 34, | ||
vehiclePlate: ['AB'], | ||
tel: [274], | ||
'92': { | ||
name: 'Papua', | ||
bpsCode: '92', | ||
vehiclePlate: ['PA'], | ||
tel: range(951, 986).concat([901, 902]), | ||
zipCode: [ | ||
{ | ||
from: 55111, | ||
to: 55893 | ||
from: 98511, | ||
to: 99976 | ||
} | ||
@@ -862,3 +879,3 @@ ] | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -869,3 +886,2 @@ * @class The CellularNumber class | ||
function CellularNumber() { | ||
this.CELLULAR_PROVIDER_PREFIXES = CELLULAR_PROVIDER_KEYS.reduce(function (a, b) { return a.concat(CELLULAR_PROVIDER_DATA[b].prefix); }, []); | ||
} | ||
@@ -876,15 +892,8 @@ CellularNumber.prototype.isValid = function (mobile, providerKey) { | ||
return false; | ||
var cleanCellularNumber = cleanPhoneNumbers(mobile, { cellular: true, countryCode: COUNTRY_CODE }); | ||
var prefixCollection; | ||
var cleanCellularNumber = cleanPhoneNumbers(mobile, { cellular: true, countryCode: COUNTRY_CODE }); | ||
var validLength = correctLength(1, cleanCellularNumber.length, { minLength: CELLULAR_MIN_LENGTH, maxLength: CELLULAR_MAX_LENGTH }); | ||
if (providerKey) | ||
prefixCollection = CELLULAR_PROVIDER_DATA[providerKey].prefix; | ||
else | ||
prefixCollection = this.CELLULAR_PROVIDER_PREFIXES; | ||
return validLength | ||
&& this.isValidCellularProviderPrefix(Number(cleanCellularNumber.substr(0, 3)), prefixCollection); | ||
providerKey ? prefixCollection = CELLULAR_PROVIDER_DATA[providerKey].prefix : prefixCollection = CELLULAR_PROVIDER_PREFIXES; | ||
return correctLength(1, cleanCellularNumber.length, { minLength: CELLULAR_MIN_LENGTH, maxLength: CELLULAR_MAX_LENGTH }) | ||
&& includes(prefixCollection, Number(cleanCellularNumber.substr(0, 3))); | ||
}; | ||
CellularNumber.prototype.isValidCellularProviderPrefix = function (prefix, prefixCollection) { | ||
return includes(prefixCollection, prefix); | ||
}; | ||
CellularNumber.prototype.getData = function (mobile) { | ||
@@ -977,3 +986,3 @@ var data = {}; | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1030,3 +1039,3 @@ * @class The CellularProvider class | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1058,3 +1067,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1119,3 +1128,3 @@ * @class The CreditCard class | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1146,3 +1155,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1180,3 +1189,3 @@ * @class The Email class | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1188,4 +1197,4 @@ /** | ||
* NIK_REGEX[1] = 2 digits of Province Code (BPS Code) | ||
* NIK_REGEX[2] = 2 digits of City or Distric Code | ||
* NIK_REGEX[3] = 2 digits of Sub Distric Code | ||
* NIK_REGEX[2] = 2 digits of Regency Code | ||
* NIK_REGEX[3] = 2 digits of Distric Code | ||
* NIK_REGEX[4] = 6 digits of Birthday with DDMMYY format, for woman DD + 40 | ||
@@ -1203,5 +1212,57 @@ * NIK_REGEX[5] = 4 digits of Index | ||
/** | ||
* Nusantara Valid: _province.ts | ||
* | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
* @class The Province class | ||
**/ | ||
var Province = /** @class */ (function () { | ||
function Province() { | ||
} | ||
Province.prototype.getData = function (index) { | ||
if (index === void 0) { index = ''; } | ||
var province; | ||
if (index) { | ||
province = { | ||
bpsCode: index, | ||
name: PROVINCE_DATA[index].name | ||
}; | ||
} | ||
else { | ||
province = PROVINCE_KEYS.map(function (key) { return ({ | ||
bpsCode: key, | ||
name: PROVINCE_DATA[key].name, | ||
}); }); | ||
} | ||
return province; | ||
}; | ||
return Province; | ||
}()); | ||
var prov = new Province(); | ||
/** | ||
* Get specific province data with IDataProvince object structure | ||
* | ||
* Return object data based on provided province key | ||
* | ||
* @param {string} provinceKey - Array key of the province | ||
* @return {IDataProvince} IDataProvince object | ||
**/ | ||
function getDataProvince(provinceKey) { | ||
return prov.getData(provinceKey); | ||
} | ||
/** | ||
* Get all province data with IDataProvince object structure | ||
* | ||
* Return all IDataProvince object in Array<IDataProvince> | ||
* | ||
* @return {IDataProvince[]} Array of IDataProvince object | ||
**/ | ||
function getDataProvinces() { | ||
return prov.getData(); | ||
} | ||
/** | ||
* Nusantara Valid: _nomorIndukKependudukan.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1212,3 +1273,2 @@ * @class The NomorIndukKepemdudukan class | ||
function NomorIndukKependudukan() { | ||
this.VALID_BPSCODE = PROVINCE_KEYS.reduce(function (a, b) { return a.concat(PROVINCE_DATA[b].bpsCode); }, []); | ||
} | ||
@@ -1225,7 +1285,6 @@ NomorIndukKependudukan.prototype.isValid = function (nik, provinceKey, birthday) { | ||
var cBirthday = this.reformatBirthday(validNIK[4]); | ||
var validProvince = includes(this.VALID_BPSCODE, parseInt(validNIK[1])); | ||
var validProvince = includes(PROVINCE_KEYS, validNIK[1]); | ||
var validBirthday = !isNaN(formatDate('19' + cBirthday).getTime()); | ||
// Comparison | ||
if (provinceKey) { | ||
if (PROVINCE_DATA[provinceKey].bpsCode != validNIK[1]) { | ||
if (provinceKey != validNIK[1]) { | ||
validProvince = false; | ||
@@ -1265,16 +1324,6 @@ } | ||
var reformatedBirthday = this.reformatBirthday(validNIK[4]); | ||
var validProvince = includes(this.VALID_BPSCODE, parseInt(validNIK[1])); | ||
var validProvince = includes(PROVINCE_KEYS, validNIK[1]); | ||
var validBirthday = !isNaN(formatDate('19' + reformatedBirthday).getTime()); | ||
if (validProvince) { | ||
var province = {}; | ||
for (var _i = 0, PROVINCE_KEYS_1 = PROVINCE_KEYS; _i < PROVINCE_KEYS_1.length; _i++) { | ||
var key = PROVINCE_KEYS_1[_i]; | ||
var element = PROVINCE_DATA[key]; | ||
if (element.bpsCode == validNIK[1]) { | ||
province.key = key, | ||
province.name = element.name; | ||
break; | ||
} | ||
} | ||
data.province = province; | ||
data.province = getDataProvince(validNIK[1]); | ||
} | ||
@@ -1336,3 +1385,3 @@ if (validBirthday) { | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1359,3 +1408,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1416,3 +1465,3 @@ * @class The NomorIndukPegawaiNegeriSipil class | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1446,3 +1495,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1488,3 +1537,3 @@ * @class The NomorIndukSiswaNasional class | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1537,3 +1586,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1600,57 +1649,5 @@ * @class The NomorPokokWajibPajak class | ||
/** | ||
* Nusantara Valid: _province.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* | ||
* @class The Province class | ||
**/ | ||
var Province = /** @class */ (function () { | ||
function Province() { | ||
} | ||
Province.prototype.getData = function (index) { | ||
if (index === void 0) { index = ''; } | ||
var province; | ||
if (index) { | ||
province = { | ||
key: index, | ||
name: PROVINCE_DATA[index].name | ||
}; | ||
} | ||
else { | ||
province = PROVINCE_KEYS.map(function (key) { return ({ | ||
key: key, | ||
name: PROVINCE_DATA[key].name, | ||
}); }); | ||
} | ||
return province; | ||
}; | ||
return Province; | ||
}()); | ||
var prov = new Province(); | ||
/** | ||
* Get specific province data with IDataProvince object structure | ||
* | ||
* Return object data based on provided province key | ||
* | ||
* @param {string} provinceKey - Array key of the province | ||
* @return {IDataProvince} IDataProvince object | ||
**/ | ||
function getDataProvince(provinceKey) { | ||
return prov.getData(provinceKey); | ||
} | ||
/** | ||
* Get all province data with IDataProvince object structure | ||
* | ||
* Return all IDataProvince object in Array<IDataProvince> | ||
* | ||
* @return {IDataProvince[]} Array of IDataProvince object | ||
**/ | ||
function getDataProvinces() { | ||
return prov.getData(); | ||
} | ||
/** | ||
* Nusantara Valid: _telephoneNumber.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1688,3 +1685,3 @@ * @class The TelephoneNumber class | ||
data.origin = { | ||
key: key, | ||
bpsCode: key, | ||
name: element.name | ||
@@ -1761,3 +1758,3 @@ }; | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1777,3 +1774,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1812,3 +1809,3 @@ * @class The TandaNomorKendaraanBermotor class | ||
province: { | ||
key: key, | ||
bpsCode: key, | ||
name: element.name | ||
@@ -1851,3 +1848,3 @@ } | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1858,3 +1855,3 @@ * @class The ZIPCode class | ||
function ZIPCode() { | ||
this.ZIP_RANGE = PROVINCE_KEYS.reduce(function (a, b) { return a.concat(PROVINCE_DATA[b].zipCode); }, []); | ||
this.ZIP_RANGES = PROVINCE_KEYS.reduce(function (a, b) { return a.concat(PROVINCE_DATA[b].zipCode); }, []); | ||
} | ||
@@ -1865,8 +1862,7 @@ ZIPCode.prototype.isValid = function (zip, provinceKey) { | ||
return false; | ||
var zipArray = this.ZIP_RANGE; | ||
var zipArray; | ||
zip = zip.toString(); | ||
var validLength = correctLength(0, zip.length, { minLength: 5 }); | ||
if (provinceKey) | ||
zipArray = PROVINCE_DATA[provinceKey].zipCode; | ||
return validLength | ||
provinceKey ? zipArray = PROVINCE_DATA[provinceKey].zipCode : zipArray = this.ZIP_RANGES; | ||
return parseInt(zip).toString() === zip | ||
&& correctLength(0, zip.length, { minLength: 5 }) | ||
&& this.isValidZIPCode(zip, zipArray); | ||
@@ -1873,0 +1869,0 @@ }; |
/*! | ||
* Nusantara Valid v0.2.0 | ||
* Nusantara Valid v0.3.0 | ||
* Copyright 2020 - Fajar Setya Budi (https://magicjar.github.io) | ||
* Contributors (https://github.com/magicjar/nusantara-valid/graphs/contributors) | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Contributors (https://github.com/agraris/nusantara-valid/graphs/contributors) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
*/ | ||
"use strict";function numbersOnly(e){return String(e).replace(/[^\d]/g,"")}function cleanPhoneNumbers(e,t){void 0===t&&(t={});var n=t.cellular,a=void 0!==n&&n,r=t.countryCode,i=void 0===r?0:r,o=String(e).replace(/[^\d]/g,"").replace(/^0+/,"");return a&&Number(o.substr(0,2))===i&&(o=o.substring(2)),o}function correctLength(e,t,n){var a=n.collection,r=void 0===a?[]:a,i=n.minLength,o=void 0===i?0:i,l=n.maxLength,u=void 0===l?0:l;switch(e){case 0:return t==o;case 1:return t>=o&&t<=u;case 2:return r.includes(t);default:return!1}}function formatDate(e){return new Date(numbersOnly(e).replace(/(\d{4})(?:(\d{2})?)(?:(\d{2})?)/,"$1-$2-$3"))}function includes(e,t){return e.indexOf(t)>-1}Object.defineProperty(exports,"__esModule",{value:!0});var range=function(e,t){for(var n=[],a=e;a<=t;a++)n=n.concat(a);return n},BANK_DATA={BCAK:{name:"Bank Central Asia",digits:10,dotIndex:[]},BCAS:{name:"Bank Central Asia Syariah",digits:10,dotIndex:[]},BNIK:{name:"Bank Negara Indonesia",digits:10,dotIndex:[]},BNIS:{name:"Bank Negara Indonesia Syariah",digits:10,dotIndex:[]},BRIK:{name:"Bank Rakyat Indonesia",digits:15,dotIndex:[]},BRIS:{name:"Bank Rakyat Indonesia Syariah",digits:10,dotIndex:[]},BTNK:{name:"Bank Tabungan Negara",digits:16,dotIndex:[]},BTNS:{name:"Bank Tabungan Negara Syariah",digits:10,dotIndex:[]},BTPK:{name:"Bank Tabungan Pensiunan Nasional",digits:11,dotIndex:[]},BTPS:{name:"Bank Tabungan Pensiunan Nasional Syariah",digits:10,dotIndex:[]},BUKK:{name:"Bank Bukopin",digits:10,dotIndex:[]},BUKS:{name:"Bank Bukopin Syariah",digits:10,dotIndex:[]},CMBK:{name:"Bank CIMB Niaga",digits:13,dotIndex:[]},CMBS:{name:"Bank CIMB Niaga Syariah",digits:13,dotIndex:[]},DNMK:{name:"Bank Danamon",digits:10,dotIndex:[]},DNMS:{name:"Bank Danamon Syariah",digits:10,dotIndex:[]},MDRK:{name:"Bank Mandiri",digits:13,dotIndex:[]},MDRS:{name:"Bank Mandiri Syariah",digits:10,dotIndex:[]},MGAK:{name:"Bank Mega",digits:15,dotIndex:[]},MGAS:{name:"Bank Mega Syariah",digits:10,dotIndex:[]},MUAM:{name:"Bank Muamalat",digits:10,dotIndex:[]},PMTK:{name:"Bank Permata",digits:10,dotIndex:[]},PMTS:{name:"Bank Permata Syariah",digits:10,dotIndex:[]},PNBK:{name:"Panin Bank",digits:10,dotIndex:[]},PNBS:{name:"Panin Bank Syariah",digits:10,dotIndex:[]}},BANK_KEYS=Object.keys(BANK_DATA),ATMNumber=function(){function e(){this.VALID_ATMNUMBER_LENGTH=BANK_KEYS.reduce((function(e,t){return includes(e,BANK_DATA[t].digits)?e:e.concat(BANK_DATA[t].digits)}),[])}return e.prototype.isValid=function(e,t){if(void 0===t&&(t=""),!e||"string"!=typeof e)return!1;var n=numbersOnly(e),a=correctLength(2,n.length,{collection:this.VALID_ATMNUMBER_LENGTH});return t&&(a=correctLength(0,n.length,{minLength:BANK_DATA[t].digits})),a},e}(),theATM=new ATMNumber;function isValidATMNumber(e){return theATM.isValid(e)}function isValidATMNumberWithComparison(e,t){return void 0===t&&(t=""),theATM.isValid(e,t)}var Bank=function(){function e(){}return e.prototype.getData=function(e){return void 0===e&&(e=""),e?{key:e,name:BANK_DATA[e].name}:BANK_KEYS.map((function(e){return{key:e,name:BANK_DATA[e].name}}))},e}(),bank=new Bank;function getDataBank(e){return bank.getData(e)}function getDataBanks(){return bank.getData()}var CELLULAR_PROVIDER_DATA={TELKOMSEL:{name:"Telkomsel",prefix:range(811,813).concat(range(821,823)).concat(range(851,853))},INDOSAT:{name:"Indosat Ooredoo",prefix:range(814,816).concat(range(855,858))},XL:{name:"XL Axiata",prefix:range(817,819).concat([859,877,878])},TRI:{name:"Hutchinson Tri",prefix:range(895,899)},SMARTFREN:{name:"Smartfren",prefix:range(881,889)},AXIS:{name:"AXIS",prefix:range(831,833).concat([838])}},CELLULAR_MIN_LENGTH=10,CELLULAR_MAX_LENGTH=12,CELLULAR_HYPEN_INDEXES=[2,6],CELLULAR_PROVIDER_KEYS=Object.keys(CELLULAR_PROVIDER_DATA),PROVINCE_DATA={AC:{name:"Aceh",bpsCode:11,vehiclePlate:["BL"],tel:range(641,659).concat([627,629]),zipCode:[{from:23111,to:24794}]},BA:{name:"Bali",bpsCode:51,vehiclePlate:["DK"],tel:range(361,368),zipCode:[{from:80111,to:82262}]},BB:{name:"Kepulauan Bangka Belitung",bpsCode:19,vehiclePlate:["BN"],tel:range(715,719),zipCode:[{from:33111,to:33792}]},BE:{name:"Bengkulu",bpsCode:17,vehiclePlate:["BD"],tel:range(736,739).concat([732]),zipCode:[{from:38113,to:39377}]},BT:{name:"Banten",bpsCode:36,vehiclePlate:["A"],tel:range(252,257),zipCode:[{from:15111,to:15820},{from:42111,to:42455}]},GO:{name:"Gorontalo",bpsCode:75,vehiclePlate:["DM"],tel:[435,443],zipCode:[{from:96111,to:96574}]},JA:{name:"Jambi",bpsCode:15,vehiclePlate:["BH"],tel:range(740,748),zipCode:[{from:36111,to:37574}]},JB:{name:"Jawa Barat",bpsCode:32,vehiclePlate:["D","E","F","T","Z"],tel:range(231,234).concat(range(260,267)).concat([22,251]),zipCode:[{from:16110,to:17730},{from:40111,to:46476}]},JI:{name:"Jawa Timur",bpsCode:35,vehiclePlate:["L","M","N","P","S","W","AE","AG"],tel:range(321,358).concat([31]),zipCode:[{from:60111,to:69493}]},JK:{name:"Jakarta",bpsCode:31,vehiclePlate:["B"],tel:[21],zipCode:[{from:10110,to:14540}]},JT:{name:"Jawa Tengah",bpsCode:33,vehiclePlate:["G","H","K","R","AA","AD"],tel:range(275,299).concat(range(271,273)).concat([24,356]),zipCode:[{from:50111,to:54474},{from:56111,to:59584}]},KB:{name:"Kalimantan Barat",bpsCode:61,vehiclePlate:["KB"],tel:range(564,568).concat([534]),zipCode:[{from:78111,to:79682}]},KI:{name:"Kalimantan Timur",bpsCode:64,vehiclePlate:["KT"],tel:range(541,556),zipCode:[{from:75111,to:77381}]},KR:{name:"Kepulauan Riau",bpsCode:21,vehiclePlate:["BP"],tel:range(771,779),zipCode:[{from:29111,to:29878}]},KS:{name:"Kalimantan Selatan",bpsCode:63,vehiclePlate:["DA"],tel:range(511,527),zipCode:[{from:70111,to:72276}]},KT:{name:"Kalimantan Tengah",bpsCode:62,vehiclePlate:["KH"],tel:range(513,539),zipCode:[{from:73111,to:74874}]},KU:{name:"Kalimantan Utara",bpsCode:65,vehiclePlate:["KU"],tel:range(551,556),zipCode:[{from:77111,to:77574}]},LA:{name:"Lampung",bpsCode:18,vehiclePlate:["BE"],tel:range(721,729),zipCode:[{from:34111,to:35686}]},MA:{name:"Maluku",bpsCode:81,vehiclePlate:["DE"],tel:range(910,931),zipCode:[{from:97114,to:97669}]},MU:{name:"Maluku Utara",bpsCode:82,vehiclePlate:["DG"],tel:range(910,931),zipCode:[{from:97711,to:97869}]},NB:{name:"Nusa Tenggara Barat",bpsCode:52,vehiclePlate:["DR","EA"],tel:range(370,376).concat([364]),zipCode:[{from:83115,to:84459}]},NT:{name:"Nusa Tenggara Timur",bpsCode:53,vehiclePlate:["DH","EB","ED"],tel:range(380,389),zipCode:[{from:85111,to:87284}]},PA:{name:"Papua",bpsCode:94,vehiclePlate:["PA"],tel:range(951,986).concat([901,902]),zipCode:[{from:98511,to:99976}]},PB:{name:"Papua Barat",bpsCode:91,vehiclePlate:["PB"],tel:range(951,986).concat([901,902]),zipCode:[{from:98011,to:98495}]},RI:{name:"Riau",bpsCode:14,vehiclePlate:["BM"],tel:range(760,769).concat([624]),zipCode:[{from:28111,to:29569}]},SA:{name:"Sulawesi Utara",bpsCode:71,vehiclePlate:["DB","DL"],tel:range(430,438),zipCode:[{from:95111,to:95999}]},SB:{name:"Sumatra Barat",bpsCode:13,vehiclePlate:["BA"],tel:range(751,759),zipCode:[{from:25111,to:27779}]},SG:{name:"Sulawesi Tenggara",bpsCode:74,vehiclePlate:["DT"],tel:range(401,408),zipCode:[{from:93111,to:93963}]},SN:{name:"Sulawesi Selatan",bpsCode:73,vehiclePlate:["DD","DP","DW"],tel:range(410,421).concat(range(471,485)).concat([423,427]),zipCode:[{from:90111,to:91273},{from:91611,to:92985}]},SR:{name:"Sulawesi Barat",bpsCode:76,vehiclePlate:["DC"],tel:[422,426,428],zipCode:[{from:91311,to:91591}]},SS:{name:"Sumatra Selatan",bpsCode:16,vehiclePlate:["BG"],tel:range(711,714).concat(range(730,735)).concat([702]),zipCode:[{from:30111,to:32388}]},ST:{name:"Sulawesi Tengah",bpsCode:72,vehiclePlate:["DN"],tel:range(445,465),zipCode:[{from:94111,to:94981}]},SU:{name:"Sumatra Utara",bpsCode:12,vehiclePlate:["BB","BK"],tel:range(620,639).concat([601]),zipCode:[{from:20111,to:22999}]},YO:{name:"Yogyakarta",bpsCode:34,vehiclePlate:["AB"],tel:[274],zipCode:[{from:55111,to:55893}]}},COUNTRY_CODE=62,PROVINCE_KEYS=Object.keys(PROVINCE_DATA),CellularNumber=function(){function e(){this.CELLULAR_PROVIDER_PREFIXES=CELLULAR_PROVIDER_KEYS.reduce((function(e,t){return e.concat(CELLULAR_PROVIDER_DATA[t].prefix)}),[])}return e.prototype.isValid=function(e,t){if(void 0===t&&(t=""),!e||"string"!=typeof e)return!1;var n,a=cleanPhoneNumbers(e,{cellular:!0,countryCode:COUNTRY_CODE}),r=correctLength(1,a.length,{minLength:CELLULAR_MIN_LENGTH,maxLength:CELLULAR_MAX_LENGTH});return n=t?CELLULAR_PROVIDER_DATA[t].prefix:this.CELLULAR_PROVIDER_PREFIXES,r&&this.isValidCellularProviderPrefix(Number(a.substr(0,3)),n)},e.prototype.isValidCellularProviderPrefix=function(e,t){return includes(t,e)},e.prototype.getData=function(e){var t={};t.number=this.format(e);for(var n=Number(cleanPhoneNumbers(e,{cellular:!0,countryCode:COUNTRY_CODE}).substr(0,3)),a=0,r=CELLULAR_PROVIDER_KEYS;a<r.length;a++){var i=r[a],o=CELLULAR_PROVIDER_DATA[i];if(includes(o.prefix,n)){t.provider={key:i,name:o.name};break}}return t},e.prototype.format=function(e,t){void 0===t&&(t=!1);var n=cleanPhoneNumbers(e,{cellular:!0,countryCode:COUNTRY_CODE}),a=n.slice(0,n.length).split("").reduce((function(e,t,a){var r=""+e+t;return a!==n.length-1&&includes(CELLULAR_HYPEN_INDEXES,a)?r+"-":r}),"");return t?"+"+COUNTRY_CODE.toString()+a:"0"+a},e}(),cellularNumber=new CellularNumber;function isValidCellularNumber(e){return cellularNumber.isValid(e)}function isValidCellularNumberWithComparison(e,t){return cellularNumber.isValid(e,t)}function getDataCellularNumber(e){return cellularNumber.getData(e)}function formatCellularNumber(e,t){return void 0===t&&(t=!1),cellularNumber.format(e,t)}var CellularProvider=function(){function e(){}return e.prototype.getData=function(e){return void 0===e&&(e=""),e?{key:e,name:CELLULAR_PROVIDER_DATA[e].name}:CELLULAR_PROVIDER_KEYS.map((function(e){return{key:e,name:CELLULAR_PROVIDER_DATA[e].name}}))},e}(),isp=new CellularProvider;function getDataCellularProvider(e){return isp.getData(e)}function getDataCellularProviders(){return isp.getData()}var CC_LENGTH=16,CC_VALID_MII=["4","5"],CC_SPACE_INDEXES=[3,7,11,11],CreditCard=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=numbersOnly(e);return this.isValidMII(e.charAt(0))&&correctLength(0,t.length,{minLength:CC_LENGTH})},e.prototype.isValidMII=function(e){return includes(CC_VALID_MII,e)},e.prototype.format=function(e){var t=numbersOnly(e);return t.slice(0,CC_LENGTH).split("").reduce((function(e,n,a){var r=""+e+n;return a!==t.length-1&&includes(CC_SPACE_INDEXES,a)?r+" ":r}),"")},e}(),cc=new CreditCard;function isValidCCNumber(e){return cc.isValid(e)}function formatCCNumber(e){return cc.format(e)}var EMAIL_REGEX=/^([a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*)@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+(?:[a-zA-Z]+)$/,MAX_LOCALPART_LENGTH=64,MAX_EMAIL_LENGTH=254,Email=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=EMAIL_REGEX.exec(e);return null!==t&&correctLength(1,t[0].length,{minLength:1,maxLength:MAX_EMAIL_LENGTH})&&correctLength(1,t[1].length,{minLength:1,maxLength:MAX_LOCALPART_LENGTH})},e}(),theEmail=new Email;function isValidEmail(e){return theEmail.isValid(e)}var NIK_REGEX=/^(\d{2})(\d{2})(\d{2})(\d{6})(\d{4})$/,NIK_LENGTH=16,NomorIndukKependudukan=function(){function e(){this.VALID_BPSCODE=PROVINCE_KEYS.reduce((function(e,t){return e.concat(PROVINCE_DATA[t].bpsCode)}),[])}return e.prototype.isValid=function(e,t,n){if(void 0===t&&(t=""),void 0===n&&(n=""),!e||"string"!=typeof e)return!1;var a=NIK_REGEX.exec(numbersOnly(e));if(!a)return!1;var r=correctLength(0,a[0].length,{minLength:NIK_LENGTH}),i=this.reformatBirthday(a[4]),o=includes(this.VALID_BPSCODE,parseInt(a[1])),l=!isNaN(formatDate("19"+i).getTime());(t&&PROVINCE_DATA[t].bpsCode!=a[1]&&(o=!1),n)&&(i!=numbersOnly(n).substring(2,8)&&(l=!1));return r&&o&&l},e.prototype.reformatBirthday=function(e){var t=/(\d{2})(\d{2})(\d{2})/.exec(e);if(t){var n=t[1],a=t[2],r=t[3];return Number(n)>40&&(n=(Number(n)-40).toString()),r+""+a+n}return""},e.prototype.getData=function(e){var t=NIK_REGEX.exec(numbersOnly(e)),n={};if(!t)return n;n.nik=t[0],n.sex=Number(t[4].substr(0,2))>40?"Female":"Male";var a=this.reformatBirthday(t[4]),r=includes(this.VALID_BPSCODE,parseInt(t[1])),i=!isNaN(formatDate("19"+a).getTime());if(r){for(var o={},l=0,u=PROVINCE_KEYS;l<u.length;l++){var d=u[l],s=PROVINCE_DATA[d];if(s.bpsCode==t[1]){o.key=d,o.name=s.name;break}}n.province=o}if(i){var c=(new Date).getFullYear(),m=Number(a.substr(0,2))+2e3,N=a.substring(2,6);m>c&&(m-=100),n.birthday=new Date(formatDate(m+""+N))}return n},e}(),theNIK=new NomorIndukKependudukan;function isValidNIK(e){return theNIK.isValid(e)}function isValidNIKWithComparison(e,t){var n=t.provinceKey,a=void 0===n?"":n,r=t.birthday,i=void 0===r?"":r;return theNIK.isValid(e,a,i)}function getDataNIK(e){return theNIK.getData(e)}var NIP_REGEX=/^(\d{8})(\d{6})([1,2]{1})(\d{3})$/,NIP_LENGTH=18,NomorIndukPegawaiNegeriSipil=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=NIP_REGEX.exec(numbersOnly(e));return null!==t&&!isNaN(formatDate(t[1]).getTime())&&!isNaN(formatDate(t[2]).getTime())&&correctLength(0,t[0].length,{minLength:NIP_LENGTH})},e.prototype.getData=function(e){var t={},n=NIP_REGEX.exec(numbersOnly(e));return n?(t.nip=n[0],t.birthday=formatDate(n[1]),t.recruit_date=n[2].substr(0,4)+"-"+n[2].substr(4,2),t.sex=1==Number(n[3])?"Male":"Female",t):t},e}(),theNIP=new NomorIndukPegawaiNegeriSipil;function isValidNIP(e){return theNIP.isValid(e)}function getDataNIP(e){return theNIP.getData(e)}var NISN_REGEX=/^(\d{3})(\d{3})(\d{4})$/,NISN_LENGTH=10,NISN_AGE_VALIDITY=22,NomorIndukSiswaNasional=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=NISN_REGEX.exec(numbersOnly(e));return null!==t&&this.isValidPeriod(t[1])&&correctLength(0,t[0].length,{minLength:NISN_LENGTH})},e.prototype.isValidPeriod=function(e){var t=(new Date).getFullYear(),n=t-NISN_AGE_VALIDITY,a=parseInt(e)+2e3;return a>t&&(a-=1e3),!(a<n)},e}(),theNISN=new NomorIndukSiswaNasional;function isValidNISN(e){return theNISN.isValid(e)}var NPWP_REGEX=/^(\d{2})(\d{3})(\d{3})(\d{1})(\d{3})(\d{3})$/,NPWP_LENGTH=15,NPWP_TAX_IDENTITIES=["01","02","21","31","00","20","04","05","06","07","08","09","24","25","26","31","34","35","36","47","48","49","57","58","67","77","78","79","87","88","89","97"],NPWP_DOT_INDEXES=[1,4,7,11],NPWP_HYPHEN_INDEXES=[8],NomorPokokWajibPajak=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=numbersOnly(e),n=NPWP_REGEX.exec(t);return null!==n&&this.isValidTaxIdentity(n[1])&&correctLength(0,n[0].length,{minLength:NPWP_LENGTH})},e.prototype.isValidTaxIdentity=function(e){return includes(NPWP_TAX_IDENTITIES,e)},e.prototype.format=function(e){var t=numbersOnly(e);return t.slice(0,NPWP_LENGTH).split("").reduce((function(e,n,a){var r=""+e+n;if(a!==t.length-1){if(includes(NPWP_DOT_INDEXES,a))return r+".";if(includes(NPWP_HYPHEN_INDEXES,a))return r+"-"}return r}),"")},e}(),theNPWP=new NomorPokokWajibPajak;function isValidNPWP(e){return theNPWP.isValid(e)}function formatNPWP(e){return theNPWP.format(e)}var Province=function(){function e(){}return e.prototype.getData=function(e){return void 0===e&&(e=""),e?{key:e,name:PROVINCE_DATA[e].name}:PROVINCE_KEYS.map((function(e){return{key:e,name:PROVINCE_DATA[e].name}}))},e}(),prov=new Province;function getDataProvince(e){return prov.getData(e)}function getDataProvinces(){return prov.getData()}var TelephoneNumber=function(){function e(){this.VALID_TELEPHONE_AREACODE=PROVINCE_KEYS.reduce((function(e,t){return e.concat(PROVINCE_DATA[t].tel)}),[])}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=cleanPhoneNumbers(e);return!isNaN(this.isValidCellularPrefix(t))},e.prototype.isValidCellularPrefix=function(e){var t=Number(e.substr(0,2));return includes(this.VALID_TELEPHONE_AREACODE,t)?t:(t=Number(e.substr(0,3)),includes(this.VALID_TELEPHONE_AREACODE,t)?t:NaN)},e.prototype.getData=function(e){var t={},n=cleanPhoneNumbers(e);t.number=this.format(n);for(var a=this.isValidCellularPrefix(n),r=0,i=PROVINCE_KEYS;r<i.length;r++){var o=i[r],l=PROVINCE_DATA[o];if(includes(l.tel,a)){t.origin={key:o,name:l.name};break}}return t},e.prototype.format=function(e,t){void 0===t&&(t=!1);var n=cleanPhoneNumbers(e),a=this.isValidCellularPrefix(n).toString(),r=[];r=2===a.length?[1]:[2];var i=n.slice(0,n.length).split("").reduce((function(e,t,a){var i=""+e+t;return a!==n.length-1&&includes(r,a)?i+"-":i}),"");return t?"+"+COUNTRY_CODE+i:"0"+i},e}(),telNumber=new TelephoneNumber;function isValidTelephoneNumber(e){return telNumber.isValid(e)}function getDataTelephoneNumber(e){return telNumber.getData(e)}function formatTelephoneNumber(e,t){return void 0===t&&(t=!1),telNumber.format(e,t)}var TNKB_REGEX=/^([A-Z]{1,2})(\d{1,4})([A-Z]{1,3})$/,TandaNomorKendaraanBermotor=function(){function e(){this.VALID_TNKB_AREACODE=PROVINCE_KEYS.reduce((function(e,t){return e.concat(PROVINCE_DATA[t].vehiclePlate)}),[])}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=e.toUpperCase(),n=TNKB_REGEX.exec(t);return null!==n&&this.isValidTNKBArea(n[1])},e.prototype.isValidTNKBArea=function(e){return includes(this.VALID_TNKB_AREACODE,e)},e.prototype.getData=function(e){var t={},n=e.toUpperCase(),a=TNKB_REGEX.exec(n);if(!a)return t;for(var r=0,i=PROVINCE_KEYS;r<i.length;r++){var o=i[r],l=PROVINCE_DATA[o];if(includes(l.vehiclePlate,a[1])){t={areaCode:a[1],index:Number(a[2]),detailedAreaCode:a[3],province:{key:o,name:l.name}};break}}return t},e}(),theTNKB=new TandaNomorKendaraanBermotor;function isValidTNKB(e){return theTNKB.isValid(e)}function getDataTNKB(e){return theTNKB.getData(e)}var ZIPCode=function(){function e(){this.ZIP_RANGE=PROVINCE_KEYS.reduce((function(e,t){return e.concat(PROVINCE_DATA[t].zipCode)}),[])}return e.prototype.isValid=function(e,t){if(void 0===t&&(t=""),!e)return!1;var n=this.ZIP_RANGE,a=correctLength(0,(e=e.toString()).length,{minLength:5});return t&&(n=PROVINCE_DATA[t].zipCode),a&&this.isValidZIPCode(e,n)},e.prototype.isValidZIPCode=function(e,t){for(var n=0,a=t;n<a.length;n++){var r=a[n];if(r.from<=e&&r.to>=e)return!0}return!1},e}(),theZIP=new ZIPCode;function isValidZIP(e){return theZIP.isValid(e)}function isValidZIPWithComparison(e,t){var n=t.provinceKey,a=void 0===n?"":n;return theZIP.isValid(e,a)}exports.cleanPhoneNumbers=cleanPhoneNumbers,exports.correctLength=correctLength,exports.formatCCNumber=formatCCNumber,exports.formatCellularNumber=formatCellularNumber,exports.formatDate=formatDate,exports.formatNPWP=formatNPWP,exports.formatTelephoneNumber=formatTelephoneNumber,exports.getDataBank=getDataBank,exports.getDataBanks=getDataBanks,exports.getDataCellularNumber=getDataCellularNumber,exports.getDataCellularProvider=getDataCellularProvider,exports.getDataCellularProviders=getDataCellularProviders,exports.getDataNIK=getDataNIK,exports.getDataNIP=getDataNIP,exports.getDataProvince=getDataProvince,exports.getDataProvinces=getDataProvinces,exports.getDataTNKB=getDataTNKB,exports.getDataTelephoneNumber=getDataTelephoneNumber,exports.includes=includes,exports.isValidATMNumber=isValidATMNumber,exports.isValidATMNumberWithComparison=isValidATMNumberWithComparison,exports.isValidCCNumber=isValidCCNumber,exports.isValidCellularNumber=isValidCellularNumber,exports.isValidCellularNumberWithComparison=isValidCellularNumberWithComparison,exports.isValidEmail=isValidEmail,exports.isValidNIK=isValidNIK,exports.isValidNIKWithComparison=isValidNIKWithComparison,exports.isValidNIP=isValidNIP,exports.isValidNISN=isValidNISN,exports.isValidNPWP=isValidNPWP,exports.isValidTNKB=isValidTNKB,exports.isValidTelephoneNumber=isValidTelephoneNumber,exports.isValidZIP=isValidZIP,exports.isValidZIPWithComparison=isValidZIPWithComparison,exports.numbersOnly=numbersOnly,exports.range=range; | ||
"use strict";function numbersOnly(e){return String(e).replace(/[^\d]/g,"")}function cleanPhoneNumbers(e,t){void 0===t&&(t={});var n=t.cellular,a=void 0!==n&&n,r=t.countryCode,i=void 0===r?0:r,o=String(e).replace(/[^\d]/g,"").replace(/^0+/,"");return a&&Number(o.substr(0,2))===i&&(o=o.substring(2)),o}function correctLength(e,t,n){var a=n.collection,r=void 0===a?[]:a,i=n.minLength,o=void 0===i?0:i,l=n.maxLength,u=void 0===l?0:l;switch(e){case 0:return t==o;case 1:return t>=o&&t<=u;case 2:return r.includes(t);default:return!1}}function formatDate(e){return new Date(numbersOnly(e).replace(/(\d{4})(?:(\d{2})?)(?:(\d{2})?)/,"$1-$2-$3"))}function includes(e,t){return e.indexOf(t)>-1}Object.defineProperty(exports,"__esModule",{value:!0});var range=function(e,t){for(var n=[],a=e;a<=t;a++)n=n.concat(a);return n},BANK_DATA={BCAK:{name:"Bank Central Asia",digits:10,dotIndex:[2,5]},BCAS:{name:"Bank Central Asia Syariah",digits:10,dotIndex:[2,5]},BNIK:{name:"Bank Negara Indonesia",digits:10,dotIndex:[2,5]},BNIS:{name:"Bank Negara Indonesia Syariah",digits:10,dotIndex:[2,5]},BRIK:{name:"Bank Rakyat Indonesia",digits:15,dotIndex:[2,5,8,11]},BRIS:{name:"Bank Rakyat Indonesia Syariah",digits:10,dotIndex:[2,5]},BTNK:{name:"Bank Tabungan Negara",digits:16,dotIndex:[]},BTNS:{name:"Bank Tabungan Negara Syariah",digits:10,dotIndex:[]},BTPK:{name:"Bank Tabungan Pensiunan Nasional",digits:11,dotIndex:[]},BTPS:{name:"Bank Tabungan Pensiunan Nasional Syariah",digits:10,dotIndex:[]},BUKK:{name:"Bank Bukopin",digits:10,dotIndex:[]},BUKS:{name:"Bank Bukopin Syariah",digits:10,dotIndex:[]},CMBK:{name:"Bank CIMB Niaga",digits:13,dotIndex:[]},CMBS:{name:"Bank CIMB Niaga Syariah",digits:13,dotIndex:[]},DNMK:{name:"Bank Danamon",digits:10,dotIndex:[]},DNMS:{name:"Bank Danamon Syariah",digits:10,dotIndex:[]},MDRK:{name:"Bank Mandiri",digits:13,dotIndex:[2,5,8]},MDRS:{name:"Bank Mandiri Syariah",digits:10,dotIndex:[2,5]},MGAK:{name:"Bank Mega",digits:15,dotIndex:[]},MGAS:{name:"Bank Mega Syariah",digits:10,dotIndex:[]},MUAM:{name:"Bank Muamalat",digits:10,dotIndex:[]},PMTK:{name:"Bank Permata",digits:10,dotIndex:[]},PMTS:{name:"Bank Permata Syariah",digits:10,dotIndex:[]},PNBK:{name:"Panin Bank",digits:10,dotIndex:[]},PNBS:{name:"Panin Bank Syariah",digits:10,dotIndex:[]}},BANK_KEYS=Object.keys(BANK_DATA),BANK_NUMBER_LENGTHS=BANK_KEYS.reduce((function(e,t){return includes(e,BANK_DATA[t].digits)?e:e.concat(BANK_DATA[t].digits)}),[]),ATMNumber=function(){function e(){}return e.prototype.isValid=function(e,t){if(void 0===t&&(t=""),!e||"string"!=typeof e)return!1;var n=numbersOnly(e);return t?correctLength(0,n.length,{minLength:BANK_DATA[t].digits}):correctLength(2,n.length,{collection:BANK_NUMBER_LENGTHS})},e}(),theATM=new ATMNumber;function isValidATMNumber(e){return theATM.isValid(e)}function isValidATMNumberWithComparison(e,t){return void 0===t&&(t=""),theATM.isValid(e,t)}var Bank=function(){function e(){}return e.prototype.getData=function(e){return void 0===e&&(e=""),e?{key:e,name:BANK_DATA[e].name}:BANK_KEYS.map((function(e){return{key:e,name:BANK_DATA[e].name}}))},e}(),bank=new Bank;function getDataBank(e){return bank.getData(e)}function getDataBanks(){return bank.getData()}var CELLULAR_PROVIDER_DATA={TELKOMSEL:{name:"Telkomsel",prefix:range(811,813).concat(range(821,823)).concat(range(851,853))},INDOSAT:{name:"Indosat Ooredoo",prefix:range(814,816).concat(range(855,858))},XL:{name:"XL Axiata",prefix:range(817,819).concat([859,877,878])},TRI:{name:"Hutchinson Tri",prefix:range(895,899)},SMARTFREN:{name:"Smartfren",prefix:range(881,889)},AXIS:{name:"AXIS",prefix:range(831,833).concat([838])}},CELLULAR_MIN_LENGTH=10,CELLULAR_MAX_LENGTH=12,CELLULAR_HYPEN_INDEXES=[2,6],CELLULAR_PROVIDER_KEYS=Object.keys(CELLULAR_PROVIDER_DATA),CELLULAR_PROVIDER_PREFIXES=CELLULAR_PROVIDER_KEYS.reduce((function(e,t){return e.concat(CELLULAR_PROVIDER_DATA[t].prefix)}),[]),PROVINCE_DATA={11:{name:"Aceh",bpsCode:"11",vehiclePlate:["BL"],tel:range(641,659).concat([627,629]),zipCode:[{from:23111,to:24794}]},12:{name:"Sumatra Utara",bpsCode:"12",vehiclePlate:["BB","BK"],tel:range(620,639).concat([601]),zipCode:[{from:20111,to:22999}]},13:{name:"Sumatra Barat",bpsCode:"13",vehiclePlate:["BA"],tel:range(751,759),zipCode:[{from:25111,to:27779}]},14:{name:"Riau",bpsCode:"14",vehiclePlate:["BM"],tel:range(760,769).concat([624]),zipCode:[{from:28111,to:29569}]},15:{name:"Jambi",bpsCode:"15",vehiclePlate:["BH"],tel:range(740,748),zipCode:[{from:36111,to:37574}]},16:{name:"Sumatra Selatan",bpsCode:"16",vehiclePlate:["BG"],tel:range(711,714).concat(range(730,735)).concat([702]),zipCode:[{from:30111,to:32388}]},17:{name:"Bengkulu",bpsCode:"17",vehiclePlate:["BD"],tel:range(736,739).concat([732]),zipCode:[{from:38113,to:39377}]},18:{name:"Lampung",bpsCode:"18",vehiclePlate:["BE"],tel:range(721,729),zipCode:[{from:34111,to:35686}]},19:{name:"Kepulauan Bangka Belitung",bpsCode:"19",vehiclePlate:["BN"],tel:range(715,719),zipCode:[{from:33111,to:33792}]},21:{name:"Kepulauan Riau",bpsCode:"21",vehiclePlate:["BP"],tel:range(771,779),zipCode:[{from:29111,to:29878}]},31:{name:"Jakarta",bpsCode:"31",vehiclePlate:["B"],tel:[21],zipCode:[{from:10110,to:14540}]},32:{name:"Jawa Barat",bpsCode:"32",vehiclePlate:["D","E","F","T","Z"],tel:range(231,234).concat(range(260,267)).concat([22,251]),zipCode:[{from:16110,to:17730},{from:40111,to:46476}]},33:{name:"Jawa Tengah",bpsCode:"33",vehiclePlate:["G","H","K","R","AA","AD"],tel:range(275,299).concat(range(271,273)).concat([24,356]),zipCode:[{from:50111,to:54474},{from:56111,to:59584}]},34:{name:"Yogyakarta",bpsCode:"34",vehiclePlate:["AB"],tel:[274],zipCode:[{from:55111,to:55893}]},35:{name:"Jawa Timur",bpsCode:"35",vehiclePlate:["L","M","N","P","S","W","AE","AG"],tel:range(321,358).concat([31]),zipCode:[{from:60111,to:69493}]},36:{name:"Banten",bpsCode:"36",vehiclePlate:["A"],tel:range(252,257),zipCode:[{from:15111,to:15820},{from:42111,to:42455}]},51:{name:"Bali",bpsCode:"51",vehiclePlate:["DK"],tel:range(361,368),zipCode:[{from:80111,to:82262}]},52:{name:"Nusa Tenggara Barat",bpsCode:"52",vehiclePlate:["DR","EA"],tel:range(370,376).concat([364]),zipCode:[{from:83115,to:84459}]},53:{name:"Nusa Tenggara Timur",bpsCode:"53",vehiclePlate:["DH","EB","ED"],tel:range(380,389),zipCode:[{from:85111,to:87284}]},61:{name:"Kalimantan Barat",bpsCode:"61",vehiclePlate:["KB"],tel:range(564,568).concat([534]),zipCode:[{from:78111,to:79682}]},62:{name:"Kalimantan Tengah",bpsCode:"62",vehiclePlate:["KH"],tel:range(513,539),zipCode:[{from:73111,to:74874}]},63:{name:"Kalimantan Selatan",bpsCode:"63",vehiclePlate:["DA"],tel:range(511,527),zipCode:[{from:70111,to:72276}]},64:{name:"Kalimantan Timur",bpsCode:"64",vehiclePlate:["KT"],tel:range(541,556),zipCode:[{from:75111,to:77381}]},65:{name:"Kalimantan Utara",bpsCode:"65",vehiclePlate:["KU"],tel:range(551,556),zipCode:[{from:77111,to:77574}]},71:{name:"Sulawesi Utara",bpsCode:"71",vehiclePlate:["DB","DL"],tel:range(430,438),zipCode:[{from:95111,to:95999}]},72:{name:"Sulawesi Tengah",bpsCode:"72",vehiclePlate:["DN"],tel:range(445,465),zipCode:[{from:94111,to:94981}]},73:{name:"Sulawesi Selatan",bpsCode:"73",vehiclePlate:["DD","DP","DW"],tel:range(410,421).concat(range(471,485)).concat([423,427]),zipCode:[{from:90111,to:91273},{from:91611,to:92985}]},74:{name:"Sulawesi Tenggara",bpsCode:"74",vehiclePlate:["DT"],tel:range(401,408),zipCode:[{from:93111,to:93963}]},75:{name:"Gorontalo",bpsCode:"75",vehiclePlate:["DM"],tel:[435,443],zipCode:[{from:96111,to:96574}]},76:{name:"Sulawesi Barat",bpsCode:"76",vehiclePlate:["DC"],tel:[422,426,428],zipCode:[{from:91311,to:91591}]},81:{name:"Maluku",bpsCode:"81",vehiclePlate:["DE"],tel:range(910,931),zipCode:[{from:97114,to:97669}]},82:{name:"Maluku Utara",bpsCode:"82",vehiclePlate:["DG"],tel:range(910,931),zipCode:[{from:97711,to:97869}]},91:{name:"Papua Barat",bpsCode:"91",vehiclePlate:["PB"],tel:range(951,986).concat([901,902]),zipCode:[{from:98011,to:98495}]},92:{name:"Papua",bpsCode:"92",vehiclePlate:["PA"],tel:range(951,986).concat([901,902]),zipCode:[{from:98511,to:99976}]}},COUNTRY_CODE=62,PROVINCE_KEYS=Object.keys(PROVINCE_DATA),CellularNumber=function(){function e(){}return e.prototype.isValid=function(e,t){if(void 0===t&&(t=""),!e||"string"!=typeof e)return!1;var n,a=cleanPhoneNumbers(e,{cellular:!0,countryCode:COUNTRY_CODE});return n=t?CELLULAR_PROVIDER_DATA[t].prefix:CELLULAR_PROVIDER_PREFIXES,correctLength(1,a.length,{minLength:CELLULAR_MIN_LENGTH,maxLength:CELLULAR_MAX_LENGTH})&&includes(n,Number(a.substr(0,3)))},e.prototype.getData=function(e){var t={};t.number=this.format(e);for(var n=Number(cleanPhoneNumbers(e,{cellular:!0,countryCode:COUNTRY_CODE}).substr(0,3)),a=0,r=CELLULAR_PROVIDER_KEYS;a<r.length;a++){var i=r[a],o=CELLULAR_PROVIDER_DATA[i];if(includes(o.prefix,n)){t.provider={key:i,name:o.name};break}}return t},e.prototype.format=function(e,t){void 0===t&&(t=!1);var n=cleanPhoneNumbers(e,{cellular:!0,countryCode:COUNTRY_CODE}),a=n.slice(0,n.length).split("").reduce((function(e,t,a){var r=""+e+t;return a!==n.length-1&&includes(CELLULAR_HYPEN_INDEXES,a)?r+"-":r}),"");return t?"+"+COUNTRY_CODE.toString()+a:"0"+a},e}(),cellularNumber=new CellularNumber;function isValidCellularNumber(e){return cellularNumber.isValid(e)}function isValidCellularNumberWithComparison(e,t){return cellularNumber.isValid(e,t)}function getDataCellularNumber(e){return cellularNumber.getData(e)}function formatCellularNumber(e,t){return void 0===t&&(t=!1),cellularNumber.format(e,t)}var CellularProvider=function(){function e(){}return e.prototype.getData=function(e){return void 0===e&&(e=""),e?{key:e,name:CELLULAR_PROVIDER_DATA[e].name}:CELLULAR_PROVIDER_KEYS.map((function(e){return{key:e,name:CELLULAR_PROVIDER_DATA[e].name}}))},e}(),isp=new CellularProvider;function getDataCellularProvider(e){return isp.getData(e)}function getDataCellularProviders(){return isp.getData()}var CC_LENGTH=16,CC_VALID_MII=["4","5"],CC_SPACE_INDEXES=[3,7,11,11],CreditCard=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=numbersOnly(e);return this.isValidMII(e.charAt(0))&&correctLength(0,t.length,{minLength:CC_LENGTH})},e.prototype.isValidMII=function(e){return includes(CC_VALID_MII,e)},e.prototype.format=function(e){var t=numbersOnly(e);return t.slice(0,CC_LENGTH).split("").reduce((function(e,n,a){var r=""+e+n;return a!==t.length-1&&includes(CC_SPACE_INDEXES,a)?r+" ":r}),"")},e}(),cc=new CreditCard;function isValidCCNumber(e){return cc.isValid(e)}function formatCCNumber(e){return cc.format(e)}var EMAIL_REGEX=/^([a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*)@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+(?:[a-zA-Z]+)$/,MAX_LOCALPART_LENGTH=64,MAX_EMAIL_LENGTH=254,Email=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=EMAIL_REGEX.exec(e);return null!==t&&correctLength(1,t[0].length,{minLength:1,maxLength:MAX_EMAIL_LENGTH})&&correctLength(1,t[1].length,{minLength:1,maxLength:MAX_LOCALPART_LENGTH})},e}(),theEmail=new Email;function isValidEmail(e){return theEmail.isValid(e)}var NIK_REGEX=/^(\d{2})(\d{2})(\d{2})(\d{6})(\d{4})$/,NIK_LENGTH=16,Province=function(){function e(){}return e.prototype.getData=function(e){return void 0===e&&(e=""),e?{bpsCode:e,name:PROVINCE_DATA[e].name}:PROVINCE_KEYS.map((function(e){return{bpsCode:e,name:PROVINCE_DATA[e].name}}))},e}(),prov=new Province;function getDataProvince(e){return prov.getData(e)}function getDataProvinces(){return prov.getData()}var NomorIndukKependudukan=function(){function e(){}return e.prototype.isValid=function(e,t,n){if(void 0===t&&(t=""),void 0===n&&(n=""),!e||"string"!=typeof e)return!1;var a=NIK_REGEX.exec(numbersOnly(e));if(!a)return!1;var r=correctLength(0,a[0].length,{minLength:NIK_LENGTH}),i=this.reformatBirthday(a[4]),o=includes(PROVINCE_KEYS,a[1]),l=!isNaN(formatDate("19"+i).getTime());(t&&t!=a[1]&&(o=!1),n)&&(i!=numbersOnly(n).substring(2,8)&&(l=!1));return r&&o&&l},e.prototype.reformatBirthday=function(e){var t=/(\d{2})(\d{2})(\d{2})/.exec(e);if(t){var n=t[1],a=t[2],r=t[3];return Number(n)>40&&(n=(Number(n)-40).toString()),r+""+a+n}return""},e.prototype.getData=function(e){var t=NIK_REGEX.exec(numbersOnly(e)),n={};if(!t)return n;n.nik=t[0],n.sex=Number(t[4].substr(0,2))>40?"Female":"Male";var a=this.reformatBirthday(t[4]),r=includes(PROVINCE_KEYS,t[1]),i=!isNaN(formatDate("19"+a).getTime());if(r&&(n.province=getDataProvince(t[1])),i){var o=(new Date).getFullYear(),l=Number(a.substr(0,2))+2e3,u=a.substring(2,6);l>o&&(l-=100),n.birthday=new Date(formatDate(l+""+u))}return n},e}(),theNIK=new NomorIndukKependudukan;function isValidNIK(e){return theNIK.isValid(e)}function isValidNIKWithComparison(e,t){var n=t.provinceKey,a=void 0===n?"":n,r=t.birthday,i=void 0===r?"":r;return theNIK.isValid(e,a,i)}function getDataNIK(e){return theNIK.getData(e)}var NIP_REGEX=/^(\d{8})(\d{6})([1,2]{1})(\d{3})$/,NIP_LENGTH=18,NomorIndukPegawaiNegeriSipil=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=NIP_REGEX.exec(numbersOnly(e));return null!==t&&!isNaN(formatDate(t[1]).getTime())&&!isNaN(formatDate(t[2]).getTime())&&correctLength(0,t[0].length,{minLength:NIP_LENGTH})},e.prototype.getData=function(e){var t={},n=NIP_REGEX.exec(numbersOnly(e));return n?(t.nip=n[0],t.birthday=formatDate(n[1]),t.recruit_date=n[2].substr(0,4)+"-"+n[2].substr(4,2),t.sex=1==Number(n[3])?"Male":"Female",t):t},e}(),theNIP=new NomorIndukPegawaiNegeriSipil;function isValidNIP(e){return theNIP.isValid(e)}function getDataNIP(e){return theNIP.getData(e)}var NISN_REGEX=/^(\d{3})(\d{3})(\d{4})$/,NISN_LENGTH=10,NISN_AGE_VALIDITY=22,NomorIndukSiswaNasional=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=NISN_REGEX.exec(numbersOnly(e));return null!==t&&this.isValidPeriod(t[1])&&correctLength(0,t[0].length,{minLength:NISN_LENGTH})},e.prototype.isValidPeriod=function(e){var t=(new Date).getFullYear(),n=t-NISN_AGE_VALIDITY,a=parseInt(e)+2e3;return a>t&&(a-=1e3),!(a<n)},e}(),theNISN=new NomorIndukSiswaNasional;function isValidNISN(e){return theNISN.isValid(e)}var NPWP_REGEX=/^(\d{2})(\d{3})(\d{3})(\d{1})(\d{3})(\d{3})$/,NPWP_LENGTH=15,NPWP_TAX_IDENTITIES=["01","02","21","31","00","20","04","05","06","07","08","09","24","25","26","31","34","35","36","47","48","49","57","58","67","77","78","79","87","88","89","97"],NPWP_DOT_INDEXES=[1,4,7,11],NPWP_HYPHEN_INDEXES=[8],NomorPokokWajibPajak=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=numbersOnly(e),n=NPWP_REGEX.exec(t);return null!==n&&this.isValidTaxIdentity(n[1])&&correctLength(0,n[0].length,{minLength:NPWP_LENGTH})},e.prototype.isValidTaxIdentity=function(e){return includes(NPWP_TAX_IDENTITIES,e)},e.prototype.format=function(e){var t=numbersOnly(e);return t.slice(0,NPWP_LENGTH).split("").reduce((function(e,n,a){var r=""+e+n;if(a!==t.length-1){if(includes(NPWP_DOT_INDEXES,a))return r+".";if(includes(NPWP_HYPHEN_INDEXES,a))return r+"-"}return r}),"")},e}(),theNPWP=new NomorPokokWajibPajak;function isValidNPWP(e){return theNPWP.isValid(e)}function formatNPWP(e){return theNPWP.format(e)}var TelephoneNumber=function(){function e(){this.VALID_TELEPHONE_AREACODE=PROVINCE_KEYS.reduce((function(e,t){return e.concat(PROVINCE_DATA[t].tel)}),[])}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=cleanPhoneNumbers(e);return!isNaN(this.isValidCellularPrefix(t))},e.prototype.isValidCellularPrefix=function(e){var t=Number(e.substr(0,2));return includes(this.VALID_TELEPHONE_AREACODE,t)?t:(t=Number(e.substr(0,3)),includes(this.VALID_TELEPHONE_AREACODE,t)?t:NaN)},e.prototype.getData=function(e){var t={},n=cleanPhoneNumbers(e);t.number=this.format(n);for(var a=this.isValidCellularPrefix(n),r=0,i=PROVINCE_KEYS;r<i.length;r++){var o=i[r],l=PROVINCE_DATA[o];if(includes(l.tel,a)){t.origin={bpsCode:o,name:l.name};break}}return t},e.prototype.format=function(e,t){void 0===t&&(t=!1);var n=cleanPhoneNumbers(e),a=this.isValidCellularPrefix(n).toString(),r=[];r=2===a.length?[1]:[2];var i=n.slice(0,n.length).split("").reduce((function(e,t,a){var i=""+e+t;return a!==n.length-1&&includes(r,a)?i+"-":i}),"");return t?"+"+COUNTRY_CODE+i:"0"+i},e}(),telNumber=new TelephoneNumber;function isValidTelephoneNumber(e){return telNumber.isValid(e)}function getDataTelephoneNumber(e){return telNumber.getData(e)}function formatTelephoneNumber(e,t){return void 0===t&&(t=!1),telNumber.format(e,t)}var TNKB_REGEX=/^([A-Z]{1,2})(\d{1,4})([A-Z]{1,3})$/,TandaNomorKendaraanBermotor=function(){function e(){this.VALID_TNKB_AREACODE=PROVINCE_KEYS.reduce((function(e,t){return e.concat(PROVINCE_DATA[t].vehiclePlate)}),[])}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=e.toUpperCase(),n=TNKB_REGEX.exec(t);return null!==n&&this.isValidTNKBArea(n[1])},e.prototype.isValidTNKBArea=function(e){return includes(this.VALID_TNKB_AREACODE,e)},e.prototype.getData=function(e){var t={},n=e.toUpperCase(),a=TNKB_REGEX.exec(n);if(!a)return t;for(var r=0,i=PROVINCE_KEYS;r<i.length;r++){var o=i[r],l=PROVINCE_DATA[o];if(includes(l.vehiclePlate,a[1])){t={areaCode:a[1],index:Number(a[2]),detailedAreaCode:a[3],province:{bpsCode:o,name:l.name}};break}}return t},e}(),theTNKB=new TandaNomorKendaraanBermotor;function isValidTNKB(e){return theTNKB.isValid(e)}function getDataTNKB(e){return theTNKB.getData(e)}var ZIPCode=function(){function e(){this.ZIP_RANGES=PROVINCE_KEYS.reduce((function(e,t){return e.concat(PROVINCE_DATA[t].zipCode)}),[])}return e.prototype.isValid=function(e,t){return void 0===t&&(t=""),!!e&&(e=e.toString(),n=t?PROVINCE_DATA[t].zipCode:this.ZIP_RANGES,parseInt(e).toString()===e&&correctLength(0,e.length,{minLength:5})&&this.isValidZIPCode(e,n));var n},e.prototype.isValidZIPCode=function(e,t){for(var n=0,a=t;n<a.length;n++){var r=a[n];if(r.from<=e&&r.to>=e)return!0}return!1},e}(),theZIP=new ZIPCode;function isValidZIP(e){return theZIP.isValid(e)}function isValidZIPWithComparison(e,t){var n=t.provinceKey,a=void 0===n?"":n;return theZIP.isValid(e,a)}exports.cleanPhoneNumbers=cleanPhoneNumbers,exports.correctLength=correctLength,exports.formatCCNumber=formatCCNumber,exports.formatCellularNumber=formatCellularNumber,exports.formatDate=formatDate,exports.formatNPWP=formatNPWP,exports.formatTelephoneNumber=formatTelephoneNumber,exports.getDataBank=getDataBank,exports.getDataBanks=getDataBanks,exports.getDataCellularNumber=getDataCellularNumber,exports.getDataCellularProvider=getDataCellularProvider,exports.getDataCellularProviders=getDataCellularProviders,exports.getDataNIK=getDataNIK,exports.getDataNIP=getDataNIP,exports.getDataProvince=getDataProvince,exports.getDataProvinces=getDataProvinces,exports.getDataTNKB=getDataTNKB,exports.getDataTelephoneNumber=getDataTelephoneNumber,exports.includes=includes,exports.isValidATMNumber=isValidATMNumber,exports.isValidATMNumberWithComparison=isValidATMNumberWithComparison,exports.isValidCCNumber=isValidCCNumber,exports.isValidCellularNumber=isValidCellularNumber,exports.isValidCellularNumberWithComparison=isValidCellularNumberWithComparison,exports.isValidEmail=isValidEmail,exports.isValidNIK=isValidNIK,exports.isValidNIKWithComparison=isValidNIKWithComparison,exports.isValidNIP=isValidNIP,exports.isValidNISN=isValidNISN,exports.isValidNPWP=isValidNPWP,exports.isValidTNKB=isValidTNKB,exports.isValidTelephoneNumber=isValidTelephoneNumber,exports.isValidZIP=isValidZIP,exports.isValidZIPWithComparison=isValidZIPWithComparison,exports.numbersOnly=numbersOnly,exports.range=range; | ||
//# sourceMappingURL=nusantara-valid.min.js.map |
/*! | ||
* Nusantara Valid v0.2.0 | ||
* Nusantara Valid v0.3.0 | ||
* Copyright 2020 - Fajar Setya Budi (https://magicjar.github.io) | ||
* Contributors (https://github.com/magicjar/nusantara-valid/graphs/contributors) | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Contributors (https://github.com/agraris/nusantara-valid/graphs/contributors) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
*/ | ||
@@ -93,3 +93,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -99,4 +99,3 @@ /** | ||
* | ||
* List of bank in Indonesia including BPS code, vehicle plate, | ||
* telephone numbers, and zip code. | ||
* List of bank in Indonesia. | ||
**/ | ||
@@ -107,3 +106,3 @@ var BANK_DATA = { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -113,3 +112,3 @@ BCAS: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -119,3 +118,3 @@ BNIK: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -125,3 +124,3 @@ BNIS: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -131,3 +130,3 @@ BRIK: { | ||
digits: 15, | ||
dotIndex: [] | ||
dotIndex: [2, 5, 8, 11] | ||
}, | ||
@@ -137,3 +136,3 @@ BRIS: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -193,3 +192,3 @@ BTNK: { | ||
digits: 13, | ||
dotIndex: [] | ||
dotIndex: [2, 5, 8] | ||
}, | ||
@@ -199,3 +198,3 @@ MDRS: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -238,3 +237,14 @@ MGAK: { | ||
}; | ||
/** | ||
* BANK_KEYS | ||
* | ||
* List of bank object keys. | ||
**/ | ||
var BANK_KEYS = Object.keys(BANK_DATA); | ||
/** | ||
* BANK_NUMBER_LENGTHS | ||
* | ||
* List of bank's number (ATM number) length. | ||
**/ | ||
var BANK_NUMBER_LENGTHS = BANK_KEYS.reduce(function (pref, curr) { return includes(pref, BANK_DATA[curr].digits) ? pref : pref.concat(BANK_DATA[curr].digits); }, []); | ||
@@ -244,3 +254,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -251,3 +261,2 @@ * @class The ATMNumber class | ||
function ATMNumber() { | ||
this.VALID_ATMNUMBER_LENGTH = BANK_KEYS.reduce(function (pref, curr) { return includes(pref, BANK_DATA[curr].digits) ? pref : pref.concat(BANK_DATA[curr].digits); }, []); | ||
} | ||
@@ -259,6 +268,3 @@ ATMNumber.prototype.isValid = function (atm, bank) { | ||
var numOnly = numbersOnly(atm); | ||
var matchLength = correctLength(2, numOnly.length, { collection: this.VALID_ATMNUMBER_LENGTH }); | ||
if (bank) | ||
matchLength = correctLength(0, numOnly.length, { minLength: BANK_DATA[bank].digits }); | ||
return matchLength; | ||
return bank ? correctLength(0, numOnly.length, { minLength: BANK_DATA[bank].digits }) : correctLength(2, numOnly.length, { collection: BANK_NUMBER_LENGTHS }); | ||
}; | ||
@@ -296,3 +302,3 @@ return ATMNumber; | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -349,3 +355,3 @@ * @class The Bank class | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -402,3 +408,14 @@ /** | ||
var CELLULAR_HYPEN_INDEXES = [2, 6]; | ||
/** | ||
* CELLULAR_PROVIDER_KEYS | ||
* | ||
* List of cellular provider object keys. | ||
**/ | ||
var CELLULAR_PROVIDER_KEYS = Object.keys(CELLULAR_PROVIDER_DATA); | ||
/** | ||
* CELLULAR_PROVIDER_PREFIXES | ||
* | ||
* List of cellular provider prefixes. | ||
**/ | ||
var CELLULAR_PROVIDER_PREFIXES = CELLULAR_PROVIDER_KEYS.reduce(function (a, b) { return a.concat(CELLULAR_PROVIDER_DATA[b].prefix); }, []); | ||
@@ -408,3 +425,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -418,5 +435,5 @@ /** | ||
var PROVINCE_DATA = { | ||
AC: { | ||
'11': { | ||
name: 'Aceh', | ||
bpsCode: 11, | ||
bpsCode: '11', | ||
vehiclePlate: ['BL'], | ||
@@ -431,68 +448,41 @@ tel: range(641, 659).concat([627, 629]), | ||
}, | ||
BA: { | ||
name: 'Bali', | ||
bpsCode: 51, | ||
vehiclePlate: ['DK'], | ||
tel: range(361, 368), | ||
'12': { | ||
name: 'Sumatra Utara', | ||
bpsCode: '12', | ||
vehiclePlate: ['BB', 'BK'], | ||
tel: range(620, 639).concat([601]), | ||
zipCode: [ | ||
{ | ||
from: 80111, | ||
to: 82262 | ||
from: 20111, | ||
to: 22999 | ||
} | ||
] | ||
}, | ||
BB: { | ||
name: 'Kepulauan Bangka Belitung', | ||
bpsCode: 19, | ||
vehiclePlate: ['BN'], | ||
tel: range(715, 719), | ||
'13': { | ||
name: 'Sumatra Barat', | ||
bpsCode: '13', | ||
vehiclePlate: ['BA'], | ||
tel: range(751, 759), | ||
zipCode: [ | ||
{ | ||
from: 33111, | ||
to: 33792 | ||
from: 25111, | ||
to: 27779 | ||
} | ||
] | ||
}, | ||
BE: { | ||
name: 'Bengkulu', | ||
bpsCode: 17, | ||
vehiclePlate: ['BD'], | ||
tel: range(736, 739).concat([732]), | ||
'14': { | ||
name: 'Riau', | ||
bpsCode: '14', | ||
vehiclePlate: ['BM'], | ||
tel: range(760, 769).concat([624]), | ||
zipCode: [ | ||
{ | ||
from: 38113, | ||
to: 39377 | ||
from: 28111, | ||
to: 29569 | ||
} | ||
] | ||
}, | ||
BT: { | ||
name: 'Banten', | ||
bpsCode: 36, | ||
vehiclePlate: ['A'], | ||
tel: range(252, 257), | ||
zipCode: [ | ||
{ | ||
from: 15111, | ||
to: 15820 | ||
}, { | ||
from: 42111, | ||
to: 42455 | ||
} | ||
] | ||
}, | ||
GO: { | ||
name: 'Gorontalo', | ||
bpsCode: 75, | ||
vehiclePlate: ['DM'], | ||
tel: [435, 443], | ||
zipCode: [ | ||
{ | ||
from: 96111, | ||
to: 96574 | ||
} | ||
] | ||
}, | ||
JA: { | ||
'15': { | ||
name: 'Jambi', | ||
bpsCode: 15, | ||
bpsCode: '15', | ||
vehiclePlate: ['BH'], | ||
@@ -507,167 +497,158 @@ tel: range(740, 748), | ||
}, | ||
JB: { | ||
name: 'Jawa Barat', | ||
bpsCode: 32, | ||
vehiclePlate: ['D', 'E', 'F', 'T', 'Z'], | ||
tel: range(231, 234).concat(range(260, 267)).concat([22, 251]), | ||
'16': { | ||
name: 'Sumatra Selatan', | ||
bpsCode: '16', | ||
vehiclePlate: ['BG'], | ||
tel: range(711, 714).concat(range(730, 735)).concat([702]), | ||
zipCode: [ | ||
{ | ||
from: 16110, | ||
to: 17730 | ||
}, { | ||
from: 40111, | ||
to: 46476 | ||
from: 30111, | ||
to: 32388 | ||
} | ||
] | ||
}, | ||
JI: { | ||
name: 'Jawa Timur', | ||
bpsCode: 35, | ||
vehiclePlate: ['L', 'M', 'N', 'P', 'S', 'W', 'AE', 'AG'], | ||
tel: range(321, 358).concat([31]), | ||
'17': { | ||
name: 'Bengkulu', | ||
bpsCode: '17', | ||
vehiclePlate: ['BD'], | ||
tel: range(736, 739).concat([732]), | ||
zipCode: [ | ||
{ | ||
from: 60111, | ||
to: 69493 | ||
from: 38113, | ||
to: 39377 | ||
} | ||
] | ||
}, | ||
JK: { | ||
name: 'Jakarta', | ||
bpsCode: 31, | ||
vehiclePlate: ['B'], | ||
tel: [21], | ||
'18': { | ||
name: 'Lampung', | ||
bpsCode: '18', | ||
vehiclePlate: ['BE'], | ||
tel: range(721, 729), | ||
zipCode: [ | ||
{ | ||
from: 10110, | ||
to: 14540 | ||
from: 34111, | ||
to: 35686 | ||
} | ||
] | ||
}, | ||
JT: { | ||
name: 'Jawa Tengah', | ||
bpsCode: 33, | ||
vehiclePlate: ['G', 'H', 'K', 'R', 'AA', 'AD'], | ||
tel: range(275, 299).concat(range(271, 273)).concat([24, 356]), | ||
'19': { | ||
name: 'Kepulauan Bangka Belitung', | ||
bpsCode: '19', | ||
vehiclePlate: ['BN'], | ||
tel: range(715, 719), | ||
zipCode: [ | ||
{ | ||
from: 50111, | ||
to: 54474 | ||
}, { | ||
from: 56111, | ||
to: 59584 | ||
from: 33111, | ||
to: 33792 | ||
} | ||
] | ||
}, | ||
KB: { | ||
name: 'Kalimantan Barat', | ||
bpsCode: 61, | ||
vehiclePlate: ['KB'], | ||
tel: range(564, 568).concat([534]), | ||
'21': { | ||
name: 'Kepulauan Riau', | ||
bpsCode: '21', | ||
vehiclePlate: ['BP'], | ||
tel: range(771, 779), | ||
zipCode: [ | ||
{ | ||
from: 78111, | ||
to: 79682 | ||
from: 29111, | ||
to: 29878 | ||
} | ||
] | ||
}, | ||
KI: { | ||
name: 'Kalimantan Timur', | ||
bpsCode: 64, | ||
vehiclePlate: ['KT'], | ||
tel: range(541, 556), | ||
'31': { | ||
name: 'Jakarta', | ||
bpsCode: '31', | ||
vehiclePlate: ['B'], | ||
tel: [21], | ||
zipCode: [ | ||
{ | ||
from: 75111, | ||
to: 77381 | ||
from: 10110, | ||
to: 14540 | ||
} | ||
] | ||
}, | ||
KR: { | ||
name: 'Kepulauan Riau', | ||
bpsCode: 21, | ||
vehiclePlate: ['BP'], | ||
tel: range(771, 779), | ||
'32': { | ||
name: 'Jawa Barat', | ||
bpsCode: '32', | ||
vehiclePlate: ['D', 'E', 'F', 'T', 'Z'], | ||
tel: range(231, 234).concat(range(260, 267)).concat([22, 251]), | ||
zipCode: [ | ||
{ | ||
from: 29111, | ||
to: 29878 | ||
from: 16110, | ||
to: 17730 | ||
}, { | ||
from: 40111, | ||
to: 46476 | ||
} | ||
] | ||
}, | ||
KS: { | ||
name: 'Kalimantan Selatan', | ||
bpsCode: 63, | ||
vehiclePlate: ['DA'], | ||
tel: range(511, 527), | ||
'33': { | ||
name: 'Jawa Tengah', | ||
bpsCode: '33', | ||
vehiclePlate: ['G', 'H', 'K', 'R', 'AA', 'AD'], | ||
tel: range(275, 299).concat(range(271, 273)).concat([24, 356]), | ||
zipCode: [ | ||
{ | ||
from: 70111, | ||
to: 72276 | ||
from: 50111, | ||
to: 54474 | ||
}, { | ||
from: 56111, | ||
to: 59584 | ||
} | ||
] | ||
}, | ||
KT: { | ||
name: 'Kalimantan Tengah', | ||
bpsCode: 62, | ||
vehiclePlate: ['KH'], | ||
tel: range(513, 539), | ||
'34': { | ||
name: 'Yogyakarta', | ||
bpsCode: '34', | ||
vehiclePlate: ['AB'], | ||
tel: [274], | ||
zipCode: [ | ||
{ | ||
from: 73111, | ||
to: 74874 | ||
from: 55111, | ||
to: 55893 | ||
} | ||
] | ||
}, | ||
KU: { | ||
name: 'Kalimantan Utara', | ||
bpsCode: 65, | ||
vehiclePlate: ['KU'], | ||
tel: range(551, 556), | ||
'35': { | ||
name: 'Jawa Timur', | ||
bpsCode: '35', | ||
vehiclePlate: ['L', 'M', 'N', 'P', 'S', 'W', 'AE', 'AG'], | ||
tel: range(321, 358).concat([31]), | ||
zipCode: [ | ||
{ | ||
from: 77111, | ||
to: 77574 | ||
from: 60111, | ||
to: 69493 | ||
} | ||
] | ||
}, | ||
LA: { | ||
name: 'Lampung', | ||
bpsCode: 18, | ||
vehiclePlate: ['BE'], | ||
tel: range(721, 729), | ||
'36': { | ||
name: 'Banten', | ||
bpsCode: '36', | ||
vehiclePlate: ['A'], | ||
tel: range(252, 257), | ||
zipCode: [ | ||
{ | ||
from: 34111, | ||
to: 35686 | ||
from: 15111, | ||
to: 15820 | ||
}, { | ||
from: 42111, | ||
to: 42455 | ||
} | ||
] | ||
}, | ||
MA: { | ||
name: 'Maluku', | ||
bpsCode: 81, | ||
vehiclePlate: ['DE'], | ||
tel: range(910, 931), | ||
'51': { | ||
name: 'Bali', | ||
bpsCode: '51', | ||
vehiclePlate: ['DK'], | ||
tel: range(361, 368), | ||
zipCode: [ | ||
{ | ||
from: 97114, | ||
to: 97669 | ||
from: 80111, | ||
to: 82262 | ||
} | ||
] | ||
}, | ||
MU: { | ||
name: 'Maluku Utara', | ||
bpsCode: 82, | ||
vehiclePlate: ['DG'], | ||
tel: range(910, 931), | ||
zipCode: [ | ||
{ | ||
from: 97711, | ||
to: 97869 | ||
} | ||
] | ||
}, | ||
NB: { | ||
'52': { | ||
name: 'Nusa Tenggara Barat', | ||
bpsCode: 52, | ||
bpsCode: '52', | ||
vehiclePlate: ['DR', 'EA'], | ||
@@ -682,5 +663,5 @@ tel: range(370, 376).concat([364]), | ||
}, | ||
NT: { | ||
'53': { | ||
name: 'Nusa Tenggara Timur', | ||
bpsCode: 53, | ||
bpsCode: '53', | ||
vehiclePlate: ['DH', 'EB', 'ED'], | ||
@@ -695,41 +676,65 @@ tel: range(380, 389), | ||
}, | ||
PA: { | ||
name: 'Papua', | ||
bpsCode: 94, | ||
vehiclePlate: ['PA'], | ||
tel: range(951, 986).concat([901, 902]), | ||
'61': { | ||
name: 'Kalimantan Barat', | ||
bpsCode: '61', | ||
vehiclePlate: ['KB'], | ||
tel: range(564, 568).concat([534]), | ||
zipCode: [ | ||
{ | ||
from: 98511, | ||
to: 99976 | ||
from: 78111, | ||
to: 79682 | ||
} | ||
] | ||
}, | ||
PB: { | ||
name: 'Papua Barat', | ||
bpsCode: 91, | ||
vehiclePlate: ['PB'], | ||
tel: range(951, 986).concat([901, 902]), | ||
'62': { | ||
name: 'Kalimantan Tengah', | ||
bpsCode: '62', | ||
vehiclePlate: ['KH'], | ||
tel: range(513, 539), | ||
zipCode: [ | ||
{ | ||
from: 98011, | ||
to: 98495 | ||
from: 73111, | ||
to: 74874 | ||
} | ||
] | ||
}, | ||
RI: { | ||
name: 'Riau', | ||
bpsCode: 14, | ||
vehiclePlate: ['BM'], | ||
tel: range(760, 769).concat([624]), | ||
'63': { | ||
name: 'Kalimantan Selatan', | ||
bpsCode: '63', | ||
vehiclePlate: ['DA'], | ||
tel: range(511, 527), | ||
zipCode: [ | ||
{ | ||
from: 28111, | ||
to: 29569 | ||
from: 70111, | ||
to: 72276 | ||
} | ||
] | ||
}, | ||
SA: { | ||
'64': { | ||
name: 'Kalimantan Timur', | ||
bpsCode: '64', | ||
vehiclePlate: ['KT'], | ||
tel: range(541, 556), | ||
zipCode: [ | ||
{ | ||
from: 75111, | ||
to: 77381 | ||
} | ||
] | ||
}, | ||
'65': { | ||
name: 'Kalimantan Utara', | ||
bpsCode: '65', | ||
vehiclePlate: ['KU'], | ||
tel: range(551, 556), | ||
zipCode: [ | ||
{ | ||
from: 77111, | ||
to: 77574 | ||
} | ||
] | ||
}, | ||
'71': { | ||
name: 'Sulawesi Utara', | ||
bpsCode: 71, | ||
bpsCode: '71', | ||
vehiclePlate: ['DB', 'DL'], | ||
@@ -744,17 +749,32 @@ tel: range(430, 438), | ||
}, | ||
SB: { | ||
name: 'Sumatra Barat', | ||
bpsCode: 13, | ||
vehiclePlate: ['BA'], | ||
tel: range(751, 759), | ||
'72': { | ||
name: 'Sulawesi Tengah', | ||
bpsCode: '72', | ||
vehiclePlate: ['DN'], | ||
tel: range(445, 465), | ||
zipCode: [ | ||
{ | ||
from: 25111, | ||
to: 27779 | ||
from: 94111, | ||
to: 94981 | ||
} | ||
] | ||
}, | ||
SG: { | ||
'73': { | ||
name: 'Sulawesi Selatan', | ||
bpsCode: '73', | ||
vehiclePlate: ['DD', 'DP', 'DW'], | ||
tel: range(410, 421).concat(range(471, 485)).concat([423, 427]), | ||
zipCode: [ | ||
{ | ||
from: 90111, | ||
to: 91273 | ||
}, { | ||
from: 91611, | ||
to: 92985 | ||
} | ||
] | ||
}, | ||
'74': { | ||
name: 'Sulawesi Tenggara', | ||
bpsCode: 74, | ||
bpsCode: '74', | ||
vehiclePlate: ['DT'], | ||
@@ -769,20 +789,17 @@ tel: range(401, 408), | ||
}, | ||
SN: { | ||
name: 'Sulawesi Selatan', | ||
bpsCode: 73, | ||
vehiclePlate: ['DD', 'DP', 'DW'], | ||
tel: range(410, 421).concat(range(471, 485)).concat([423, 427]), | ||
'75': { | ||
name: 'Gorontalo', | ||
bpsCode: '75', | ||
vehiclePlate: ['DM'], | ||
tel: [435, 443], | ||
zipCode: [ | ||
{ | ||
from: 90111, | ||
to: 91273 | ||
}, { | ||
from: 91611, | ||
to: 92985 | ||
from: 96111, | ||
to: 96574 | ||
} | ||
] | ||
}, | ||
SR: { | ||
'76': { | ||
name: 'Sulawesi Barat', | ||
bpsCode: 76, | ||
bpsCode: '76', | ||
vehiclePlate: ['DC'], | ||
@@ -797,47 +814,47 @@ tel: [422, 426, 428], | ||
}, | ||
SS: { | ||
name: 'Sumatra Selatan', | ||
bpsCode: 16, | ||
vehiclePlate: ['BG'], | ||
tel: range(711, 714).concat(range(730, 735)).concat([702]), | ||
'81': { | ||
name: 'Maluku', | ||
bpsCode: '81', | ||
vehiclePlate: ['DE'], | ||
tel: range(910, 931), | ||
zipCode: [ | ||
{ | ||
from: 30111, | ||
to: 32388 | ||
from: 97114, | ||
to: 97669 | ||
} | ||
] | ||
}, | ||
ST: { | ||
name: 'Sulawesi Tengah', | ||
bpsCode: 72, | ||
vehiclePlate: ['DN'], | ||
tel: range(445, 465), | ||
'82': { | ||
name: 'Maluku Utara', | ||
bpsCode: '82', | ||
vehiclePlate: ['DG'], | ||
tel: range(910, 931), | ||
zipCode: [ | ||
{ | ||
from: 94111, | ||
to: 94981 | ||
from: 97711, | ||
to: 97869 | ||
} | ||
] | ||
}, | ||
SU: { | ||
name: 'Sumatra Utara', | ||
bpsCode: 12, | ||
vehiclePlate: ['BB', 'BK'], | ||
tel: range(620, 639).concat([601]), | ||
'91': { | ||
name: 'Papua Barat', | ||
bpsCode: '91', | ||
vehiclePlate: ['PB'], | ||
tel: range(951, 986).concat([901, 902]), | ||
zipCode: [ | ||
{ | ||
from: 20111, | ||
to: 22999 | ||
from: 98011, | ||
to: 98495 | ||
} | ||
] | ||
}, | ||
YO: { | ||
name: 'Yogyakarta', | ||
bpsCode: 34, | ||
vehiclePlate: ['AB'], | ||
tel: [274], | ||
'92': { | ||
name: 'Papua', | ||
bpsCode: '92', | ||
vehiclePlate: ['PA'], | ||
tel: range(951, 986).concat([901, 902]), | ||
zipCode: [ | ||
{ | ||
from: 55111, | ||
to: 55893 | ||
from: 98511, | ||
to: 99976 | ||
} | ||
@@ -858,3 +875,3 @@ ] | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -865,3 +882,2 @@ * @class The CellularNumber class | ||
function CellularNumber() { | ||
this.CELLULAR_PROVIDER_PREFIXES = CELLULAR_PROVIDER_KEYS.reduce(function (a, b) { return a.concat(CELLULAR_PROVIDER_DATA[b].prefix); }, []); | ||
} | ||
@@ -872,15 +888,8 @@ CellularNumber.prototype.isValid = function (mobile, providerKey) { | ||
return false; | ||
var cleanCellularNumber = cleanPhoneNumbers(mobile, { cellular: true, countryCode: COUNTRY_CODE }); | ||
var prefixCollection; | ||
var cleanCellularNumber = cleanPhoneNumbers(mobile, { cellular: true, countryCode: COUNTRY_CODE }); | ||
var validLength = correctLength(1, cleanCellularNumber.length, { minLength: CELLULAR_MIN_LENGTH, maxLength: CELLULAR_MAX_LENGTH }); | ||
if (providerKey) | ||
prefixCollection = CELLULAR_PROVIDER_DATA[providerKey].prefix; | ||
else | ||
prefixCollection = this.CELLULAR_PROVIDER_PREFIXES; | ||
return validLength | ||
&& this.isValidCellularProviderPrefix(Number(cleanCellularNumber.substr(0, 3)), prefixCollection); | ||
providerKey ? prefixCollection = CELLULAR_PROVIDER_DATA[providerKey].prefix : prefixCollection = CELLULAR_PROVIDER_PREFIXES; | ||
return correctLength(1, cleanCellularNumber.length, { minLength: CELLULAR_MIN_LENGTH, maxLength: CELLULAR_MAX_LENGTH }) | ||
&& includes(prefixCollection, Number(cleanCellularNumber.substr(0, 3))); | ||
}; | ||
CellularNumber.prototype.isValidCellularProviderPrefix = function (prefix, prefixCollection) { | ||
return includes(prefixCollection, prefix); | ||
}; | ||
CellularNumber.prototype.getData = function (mobile) { | ||
@@ -973,3 +982,3 @@ var data = {}; | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1026,3 +1035,3 @@ * @class The CellularProvider class | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1054,3 +1063,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1115,3 +1124,3 @@ * @class The CreditCard class | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1142,3 +1151,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1176,3 +1185,3 @@ * @class The Email class | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1184,4 +1193,4 @@ /** | ||
* NIK_REGEX[1] = 2 digits of Province Code (BPS Code) | ||
* NIK_REGEX[2] = 2 digits of City or Distric Code | ||
* NIK_REGEX[3] = 2 digits of Sub Distric Code | ||
* NIK_REGEX[2] = 2 digits of Regency Code | ||
* NIK_REGEX[3] = 2 digits of Distric Code | ||
* NIK_REGEX[4] = 6 digits of Birthday with DDMMYY format, for woman DD + 40 | ||
@@ -1199,5 +1208,57 @@ * NIK_REGEX[5] = 4 digits of Index | ||
/** | ||
* Nusantara Valid: _province.ts | ||
* | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
* @class The Province class | ||
**/ | ||
var Province = /** @class */ (function () { | ||
function Province() { | ||
} | ||
Province.prototype.getData = function (index) { | ||
if (index === void 0) { index = ''; } | ||
var province; | ||
if (index) { | ||
province = { | ||
bpsCode: index, | ||
name: PROVINCE_DATA[index].name | ||
}; | ||
} | ||
else { | ||
province = PROVINCE_KEYS.map(function (key) { return ({ | ||
bpsCode: key, | ||
name: PROVINCE_DATA[key].name, | ||
}); }); | ||
} | ||
return province; | ||
}; | ||
return Province; | ||
}()); | ||
var prov = new Province(); | ||
/** | ||
* Get specific province data with IDataProvince object structure | ||
* | ||
* Return object data based on provided province key | ||
* | ||
* @param {string} provinceKey - Array key of the province | ||
* @return {IDataProvince} IDataProvince object | ||
**/ | ||
function getDataProvince(provinceKey) { | ||
return prov.getData(provinceKey); | ||
} | ||
/** | ||
* Get all province data with IDataProvince object structure | ||
* | ||
* Return all IDataProvince object in Array<IDataProvince> | ||
* | ||
* @return {IDataProvince[]} Array of IDataProvince object | ||
**/ | ||
function getDataProvinces() { | ||
return prov.getData(); | ||
} | ||
/** | ||
* Nusantara Valid: _nomorIndukKependudukan.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1208,3 +1269,2 @@ * @class The NomorIndukKepemdudukan class | ||
function NomorIndukKependudukan() { | ||
this.VALID_BPSCODE = PROVINCE_KEYS.reduce(function (a, b) { return a.concat(PROVINCE_DATA[b].bpsCode); }, []); | ||
} | ||
@@ -1221,7 +1281,6 @@ NomorIndukKependudukan.prototype.isValid = function (nik, provinceKey, birthday) { | ||
var cBirthday = this.reformatBirthday(validNIK[4]); | ||
var validProvince = includes(this.VALID_BPSCODE, parseInt(validNIK[1])); | ||
var validProvince = includes(PROVINCE_KEYS, validNIK[1]); | ||
var validBirthday = !isNaN(formatDate('19' + cBirthday).getTime()); | ||
// Comparison | ||
if (provinceKey) { | ||
if (PROVINCE_DATA[provinceKey].bpsCode != validNIK[1]) { | ||
if (provinceKey != validNIK[1]) { | ||
validProvince = false; | ||
@@ -1261,16 +1320,6 @@ } | ||
var reformatedBirthday = this.reformatBirthday(validNIK[4]); | ||
var validProvince = includes(this.VALID_BPSCODE, parseInt(validNIK[1])); | ||
var validProvince = includes(PROVINCE_KEYS, validNIK[1]); | ||
var validBirthday = !isNaN(formatDate('19' + reformatedBirthday).getTime()); | ||
if (validProvince) { | ||
var province = {}; | ||
for (var _i = 0, PROVINCE_KEYS_1 = PROVINCE_KEYS; _i < PROVINCE_KEYS_1.length; _i++) { | ||
var key = PROVINCE_KEYS_1[_i]; | ||
var element = PROVINCE_DATA[key]; | ||
if (element.bpsCode == validNIK[1]) { | ||
province.key = key, | ||
province.name = element.name; | ||
break; | ||
} | ||
} | ||
data.province = province; | ||
data.province = getDataProvince(validNIK[1]); | ||
} | ||
@@ -1332,3 +1381,3 @@ if (validBirthday) { | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1355,3 +1404,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1412,3 +1461,3 @@ * @class The NomorIndukPegawaiNegeriSipil class | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1442,3 +1491,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1484,3 +1533,3 @@ * @class The NomorIndukSiswaNasional class | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1533,3 +1582,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1596,57 +1645,5 @@ * @class The NomorPokokWajibPajak class | ||
/** | ||
* Nusantara Valid: _province.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* | ||
* @class The Province class | ||
**/ | ||
var Province = /** @class */ (function () { | ||
function Province() { | ||
} | ||
Province.prototype.getData = function (index) { | ||
if (index === void 0) { index = ''; } | ||
var province; | ||
if (index) { | ||
province = { | ||
key: index, | ||
name: PROVINCE_DATA[index].name | ||
}; | ||
} | ||
else { | ||
province = PROVINCE_KEYS.map(function (key) { return ({ | ||
key: key, | ||
name: PROVINCE_DATA[key].name, | ||
}); }); | ||
} | ||
return province; | ||
}; | ||
return Province; | ||
}()); | ||
var prov = new Province(); | ||
/** | ||
* Get specific province data with IDataProvince object structure | ||
* | ||
* Return object data based on provided province key | ||
* | ||
* @param {string} provinceKey - Array key of the province | ||
* @return {IDataProvince} IDataProvince object | ||
**/ | ||
function getDataProvince(provinceKey) { | ||
return prov.getData(provinceKey); | ||
} | ||
/** | ||
* Get all province data with IDataProvince object structure | ||
* | ||
* Return all IDataProvince object in Array<IDataProvince> | ||
* | ||
* @return {IDataProvince[]} Array of IDataProvince object | ||
**/ | ||
function getDataProvinces() { | ||
return prov.getData(); | ||
} | ||
/** | ||
* Nusantara Valid: _telephoneNumber.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1684,3 +1681,3 @@ * @class The TelephoneNumber class | ||
data.origin = { | ||
key: key, | ||
bpsCode: key, | ||
name: element.name | ||
@@ -1757,3 +1754,3 @@ }; | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1773,3 +1770,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1808,3 +1805,3 @@ * @class The TandaNomorKendaraanBermotor class | ||
province: { | ||
key: key, | ||
bpsCode: key, | ||
name: element.name | ||
@@ -1847,3 +1844,3 @@ } | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1854,3 +1851,3 @@ * @class The ZIPCode class | ||
function ZIPCode() { | ||
this.ZIP_RANGE = PROVINCE_KEYS.reduce(function (a, b) { return a.concat(PROVINCE_DATA[b].zipCode); }, []); | ||
this.ZIP_RANGES = PROVINCE_KEYS.reduce(function (a, b) { return a.concat(PROVINCE_DATA[b].zipCode); }, []); | ||
} | ||
@@ -1861,8 +1858,7 @@ ZIPCode.prototype.isValid = function (zip, provinceKey) { | ||
return false; | ||
var zipArray = this.ZIP_RANGE; | ||
var zipArray; | ||
zip = zip.toString(); | ||
var validLength = correctLength(0, zip.length, { minLength: 5 }); | ||
if (provinceKey) | ||
zipArray = PROVINCE_DATA[provinceKey].zipCode; | ||
return validLength | ||
provinceKey ? zipArray = PROVINCE_DATA[provinceKey].zipCode : zipArray = this.ZIP_RANGES; | ||
return parseInt(zip).toString() === zip | ||
&& correctLength(0, zip.length, { minLength: 5 }) | ||
&& this.isValidZIPCode(zip, zipArray); | ||
@@ -1869,0 +1865,0 @@ }; |
/*! | ||
* Nusantara Valid v0.2.0 | ||
* Nusantara Valid v0.3.0 | ||
* Copyright 2020 - Fajar Setya Budi (https://magicjar.github.io) | ||
* Contributors (https://github.com/magicjar/nusantara-valid/graphs/contributors) | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Contributors (https://github.com/agraris/nusantara-valid/graphs/contributors) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
*/ | ||
function numbersOnly(e){return String(e).replace(/[^\d]/g,"")}function cleanPhoneNumbers(e,t){void 0===t&&(t={});var n=t.cellular,a=void 0!==n&&n,r=t.countryCode,i=void 0===r?0:r,o=String(e).replace(/[^\d]/g,"").replace(/^0+/,"");return a&&Number(o.substr(0,2))===i&&(o=o.substring(2)),o}function correctLength(e,t,n){var a=n.collection,r=void 0===a?[]:a,i=n.minLength,o=void 0===i?0:i,u=n.maxLength,l=void 0===u?0:u;switch(e){case 0:return t==o;case 1:return t>=o&&t<=l;case 2:return r.includes(t);default:return!1}}function formatDate(e){return new Date(numbersOnly(e).replace(/(\d{4})(?:(\d{2})?)(?:(\d{2})?)/,"$1-$2-$3"))}function includes(e,t){return e.indexOf(t)>-1}var range=function(e,t){for(var n=[],a=e;a<=t;a++)n=n.concat(a);return n},BANK_DATA={BCAK:{name:"Bank Central Asia",digits:10,dotIndex:[]},BCAS:{name:"Bank Central Asia Syariah",digits:10,dotIndex:[]},BNIK:{name:"Bank Negara Indonesia",digits:10,dotIndex:[]},BNIS:{name:"Bank Negara Indonesia Syariah",digits:10,dotIndex:[]},BRIK:{name:"Bank Rakyat Indonesia",digits:15,dotIndex:[]},BRIS:{name:"Bank Rakyat Indonesia Syariah",digits:10,dotIndex:[]},BTNK:{name:"Bank Tabungan Negara",digits:16,dotIndex:[]},BTNS:{name:"Bank Tabungan Negara Syariah",digits:10,dotIndex:[]},BTPK:{name:"Bank Tabungan Pensiunan Nasional",digits:11,dotIndex:[]},BTPS:{name:"Bank Tabungan Pensiunan Nasional Syariah",digits:10,dotIndex:[]},BUKK:{name:"Bank Bukopin",digits:10,dotIndex:[]},BUKS:{name:"Bank Bukopin Syariah",digits:10,dotIndex:[]},CMBK:{name:"Bank CIMB Niaga",digits:13,dotIndex:[]},CMBS:{name:"Bank CIMB Niaga Syariah",digits:13,dotIndex:[]},DNMK:{name:"Bank Danamon",digits:10,dotIndex:[]},DNMS:{name:"Bank Danamon Syariah",digits:10,dotIndex:[]},MDRK:{name:"Bank Mandiri",digits:13,dotIndex:[]},MDRS:{name:"Bank Mandiri Syariah",digits:10,dotIndex:[]},MGAK:{name:"Bank Mega",digits:15,dotIndex:[]},MGAS:{name:"Bank Mega Syariah",digits:10,dotIndex:[]},MUAM:{name:"Bank Muamalat",digits:10,dotIndex:[]},PMTK:{name:"Bank Permata",digits:10,dotIndex:[]},PMTS:{name:"Bank Permata Syariah",digits:10,dotIndex:[]},PNBK:{name:"Panin Bank",digits:10,dotIndex:[]},PNBS:{name:"Panin Bank Syariah",digits:10,dotIndex:[]}},BANK_KEYS=Object.keys(BANK_DATA),ATMNumber=function(){function e(){this.VALID_ATMNUMBER_LENGTH=BANK_KEYS.reduce((function(e,t){return includes(e,BANK_DATA[t].digits)?e:e.concat(BANK_DATA[t].digits)}),[])}return e.prototype.isValid=function(e,t){if(void 0===t&&(t=""),!e||"string"!=typeof e)return!1;var n=numbersOnly(e),a=correctLength(2,n.length,{collection:this.VALID_ATMNUMBER_LENGTH});return t&&(a=correctLength(0,n.length,{minLength:BANK_DATA[t].digits})),a},e}(),theATM=new ATMNumber;function isValidATMNumber(e){return theATM.isValid(e)}function isValidATMNumberWithComparison(e,t){return void 0===t&&(t=""),theATM.isValid(e,t)}var Bank=function(){function e(){}return e.prototype.getData=function(e){return void 0===e&&(e=""),e?{key:e,name:BANK_DATA[e].name}:BANK_KEYS.map((function(e){return{key:e,name:BANK_DATA[e].name}}))},e}(),bank=new Bank;function getDataBank(e){return bank.getData(e)}function getDataBanks(){return bank.getData()}var CELLULAR_PROVIDER_DATA={TELKOMSEL:{name:"Telkomsel",prefix:range(811,813).concat(range(821,823)).concat(range(851,853))},INDOSAT:{name:"Indosat Ooredoo",prefix:range(814,816).concat(range(855,858))},XL:{name:"XL Axiata",prefix:range(817,819).concat([859,877,878])},TRI:{name:"Hutchinson Tri",prefix:range(895,899)},SMARTFREN:{name:"Smartfren",prefix:range(881,889)},AXIS:{name:"AXIS",prefix:range(831,833).concat([838])}},CELLULAR_MIN_LENGTH=10,CELLULAR_MAX_LENGTH=12,CELLULAR_HYPEN_INDEXES=[2,6],CELLULAR_PROVIDER_KEYS=Object.keys(CELLULAR_PROVIDER_DATA),PROVINCE_DATA={AC:{name:"Aceh",bpsCode:11,vehiclePlate:["BL"],tel:range(641,659).concat([627,629]),zipCode:[{from:23111,to:24794}]},BA:{name:"Bali",bpsCode:51,vehiclePlate:["DK"],tel:range(361,368),zipCode:[{from:80111,to:82262}]},BB:{name:"Kepulauan Bangka Belitung",bpsCode:19,vehiclePlate:["BN"],tel:range(715,719),zipCode:[{from:33111,to:33792}]},BE:{name:"Bengkulu",bpsCode:17,vehiclePlate:["BD"],tel:range(736,739).concat([732]),zipCode:[{from:38113,to:39377}]},BT:{name:"Banten",bpsCode:36,vehiclePlate:["A"],tel:range(252,257),zipCode:[{from:15111,to:15820},{from:42111,to:42455}]},GO:{name:"Gorontalo",bpsCode:75,vehiclePlate:["DM"],tel:[435,443],zipCode:[{from:96111,to:96574}]},JA:{name:"Jambi",bpsCode:15,vehiclePlate:["BH"],tel:range(740,748),zipCode:[{from:36111,to:37574}]},JB:{name:"Jawa Barat",bpsCode:32,vehiclePlate:["D","E","F","T","Z"],tel:range(231,234).concat(range(260,267)).concat([22,251]),zipCode:[{from:16110,to:17730},{from:40111,to:46476}]},JI:{name:"Jawa Timur",bpsCode:35,vehiclePlate:["L","M","N","P","S","W","AE","AG"],tel:range(321,358).concat([31]),zipCode:[{from:60111,to:69493}]},JK:{name:"Jakarta",bpsCode:31,vehiclePlate:["B"],tel:[21],zipCode:[{from:10110,to:14540}]},JT:{name:"Jawa Tengah",bpsCode:33,vehiclePlate:["G","H","K","R","AA","AD"],tel:range(275,299).concat(range(271,273)).concat([24,356]),zipCode:[{from:50111,to:54474},{from:56111,to:59584}]},KB:{name:"Kalimantan Barat",bpsCode:61,vehiclePlate:["KB"],tel:range(564,568).concat([534]),zipCode:[{from:78111,to:79682}]},KI:{name:"Kalimantan Timur",bpsCode:64,vehiclePlate:["KT"],tel:range(541,556),zipCode:[{from:75111,to:77381}]},KR:{name:"Kepulauan Riau",bpsCode:21,vehiclePlate:["BP"],tel:range(771,779),zipCode:[{from:29111,to:29878}]},KS:{name:"Kalimantan Selatan",bpsCode:63,vehiclePlate:["DA"],tel:range(511,527),zipCode:[{from:70111,to:72276}]},KT:{name:"Kalimantan Tengah",bpsCode:62,vehiclePlate:["KH"],tel:range(513,539),zipCode:[{from:73111,to:74874}]},KU:{name:"Kalimantan Utara",bpsCode:65,vehiclePlate:["KU"],tel:range(551,556),zipCode:[{from:77111,to:77574}]},LA:{name:"Lampung",bpsCode:18,vehiclePlate:["BE"],tel:range(721,729),zipCode:[{from:34111,to:35686}]},MA:{name:"Maluku",bpsCode:81,vehiclePlate:["DE"],tel:range(910,931),zipCode:[{from:97114,to:97669}]},MU:{name:"Maluku Utara",bpsCode:82,vehiclePlate:["DG"],tel:range(910,931),zipCode:[{from:97711,to:97869}]},NB:{name:"Nusa Tenggara Barat",bpsCode:52,vehiclePlate:["DR","EA"],tel:range(370,376).concat([364]),zipCode:[{from:83115,to:84459}]},NT:{name:"Nusa Tenggara Timur",bpsCode:53,vehiclePlate:["DH","EB","ED"],tel:range(380,389),zipCode:[{from:85111,to:87284}]},PA:{name:"Papua",bpsCode:94,vehiclePlate:["PA"],tel:range(951,986).concat([901,902]),zipCode:[{from:98511,to:99976}]},PB:{name:"Papua Barat",bpsCode:91,vehiclePlate:["PB"],tel:range(951,986).concat([901,902]),zipCode:[{from:98011,to:98495}]},RI:{name:"Riau",bpsCode:14,vehiclePlate:["BM"],tel:range(760,769).concat([624]),zipCode:[{from:28111,to:29569}]},SA:{name:"Sulawesi Utara",bpsCode:71,vehiclePlate:["DB","DL"],tel:range(430,438),zipCode:[{from:95111,to:95999}]},SB:{name:"Sumatra Barat",bpsCode:13,vehiclePlate:["BA"],tel:range(751,759),zipCode:[{from:25111,to:27779}]},SG:{name:"Sulawesi Tenggara",bpsCode:74,vehiclePlate:["DT"],tel:range(401,408),zipCode:[{from:93111,to:93963}]},SN:{name:"Sulawesi Selatan",bpsCode:73,vehiclePlate:["DD","DP","DW"],tel:range(410,421).concat(range(471,485)).concat([423,427]),zipCode:[{from:90111,to:91273},{from:91611,to:92985}]},SR:{name:"Sulawesi Barat",bpsCode:76,vehiclePlate:["DC"],tel:[422,426,428],zipCode:[{from:91311,to:91591}]},SS:{name:"Sumatra Selatan",bpsCode:16,vehiclePlate:["BG"],tel:range(711,714).concat(range(730,735)).concat([702]),zipCode:[{from:30111,to:32388}]},ST:{name:"Sulawesi Tengah",bpsCode:72,vehiclePlate:["DN"],tel:range(445,465),zipCode:[{from:94111,to:94981}]},SU:{name:"Sumatra Utara",bpsCode:12,vehiclePlate:["BB","BK"],tel:range(620,639).concat([601]),zipCode:[{from:20111,to:22999}]},YO:{name:"Yogyakarta",bpsCode:34,vehiclePlate:["AB"],tel:[274],zipCode:[{from:55111,to:55893}]}},COUNTRY_CODE=62,PROVINCE_KEYS=Object.keys(PROVINCE_DATA),CellularNumber=function(){function e(){this.CELLULAR_PROVIDER_PREFIXES=CELLULAR_PROVIDER_KEYS.reduce((function(e,t){return e.concat(CELLULAR_PROVIDER_DATA[t].prefix)}),[])}return e.prototype.isValid=function(e,t){if(void 0===t&&(t=""),!e||"string"!=typeof e)return!1;var n,a=cleanPhoneNumbers(e,{cellular:!0,countryCode:COUNTRY_CODE}),r=correctLength(1,a.length,{minLength:CELLULAR_MIN_LENGTH,maxLength:CELLULAR_MAX_LENGTH});return n=t?CELLULAR_PROVIDER_DATA[t].prefix:this.CELLULAR_PROVIDER_PREFIXES,r&&this.isValidCellularProviderPrefix(Number(a.substr(0,3)),n)},e.prototype.isValidCellularProviderPrefix=function(e,t){return includes(t,e)},e.prototype.getData=function(e){var t={};t.number=this.format(e);for(var n=Number(cleanPhoneNumbers(e,{cellular:!0,countryCode:COUNTRY_CODE}).substr(0,3)),a=0,r=CELLULAR_PROVIDER_KEYS;a<r.length;a++){var i=r[a],o=CELLULAR_PROVIDER_DATA[i];if(includes(o.prefix,n)){t.provider={key:i,name:o.name};break}}return t},e.prototype.format=function(e,t){void 0===t&&(t=!1);var n=cleanPhoneNumbers(e,{cellular:!0,countryCode:COUNTRY_CODE}),a=n.slice(0,n.length).split("").reduce((function(e,t,a){var r=""+e+t;return a!==n.length-1&&includes(CELLULAR_HYPEN_INDEXES,a)?r+"-":r}),"");return t?"+"+COUNTRY_CODE.toString()+a:"0"+a},e}(),cellularNumber=new CellularNumber;function isValidCellularNumber(e){return cellularNumber.isValid(e)}function isValidCellularNumberWithComparison(e,t){return cellularNumber.isValid(e,t)}function getDataCellularNumber(e){return cellularNumber.getData(e)}function formatCellularNumber(e,t){return void 0===t&&(t=!1),cellularNumber.format(e,t)}var CellularProvider=function(){function e(){}return e.prototype.getData=function(e){return void 0===e&&(e=""),e?{key:e,name:CELLULAR_PROVIDER_DATA[e].name}:CELLULAR_PROVIDER_KEYS.map((function(e){return{key:e,name:CELLULAR_PROVIDER_DATA[e].name}}))},e}(),isp=new CellularProvider;function getDataCellularProvider(e){return isp.getData(e)}function getDataCellularProviders(){return isp.getData()}var CC_LENGTH=16,CC_VALID_MII=["4","5"],CC_SPACE_INDEXES=[3,7,11,11],CreditCard=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=numbersOnly(e);return this.isValidMII(e.charAt(0))&&correctLength(0,t.length,{minLength:CC_LENGTH})},e.prototype.isValidMII=function(e){return includes(CC_VALID_MII,e)},e.prototype.format=function(e){var t=numbersOnly(e);return t.slice(0,CC_LENGTH).split("").reduce((function(e,n,a){var r=""+e+n;return a!==t.length-1&&includes(CC_SPACE_INDEXES,a)?r+" ":r}),"")},e}(),cc=new CreditCard;function isValidCCNumber(e){return cc.isValid(e)}function formatCCNumber(e){return cc.format(e)}var EMAIL_REGEX=/^([a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*)@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+(?:[a-zA-Z]+)$/,MAX_LOCALPART_LENGTH=64,MAX_EMAIL_LENGTH=254,Email=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=EMAIL_REGEX.exec(e);return null!==t&&correctLength(1,t[0].length,{minLength:1,maxLength:MAX_EMAIL_LENGTH})&&correctLength(1,t[1].length,{minLength:1,maxLength:MAX_LOCALPART_LENGTH})},e}(),theEmail=new Email;function isValidEmail(e){return theEmail.isValid(e)}var NIK_REGEX=/^(\d{2})(\d{2})(\d{2})(\d{6})(\d{4})$/,NIK_LENGTH=16,NomorIndukKependudukan=function(){function e(){this.VALID_BPSCODE=PROVINCE_KEYS.reduce((function(e,t){return e.concat(PROVINCE_DATA[t].bpsCode)}),[])}return e.prototype.isValid=function(e,t,n){if(void 0===t&&(t=""),void 0===n&&(n=""),!e||"string"!=typeof e)return!1;var a=NIK_REGEX.exec(numbersOnly(e));if(!a)return!1;var r=correctLength(0,a[0].length,{minLength:NIK_LENGTH}),i=this.reformatBirthday(a[4]),o=includes(this.VALID_BPSCODE,parseInt(a[1])),u=!isNaN(formatDate("19"+i).getTime());(t&&PROVINCE_DATA[t].bpsCode!=a[1]&&(o=!1),n)&&(i!=numbersOnly(n).substring(2,8)&&(u=!1));return r&&o&&u},e.prototype.reformatBirthday=function(e){var t=/(\d{2})(\d{2})(\d{2})/.exec(e);if(t){var n=t[1],a=t[2],r=t[3];return Number(n)>40&&(n=(Number(n)-40).toString()),r+""+a+n}return""},e.prototype.getData=function(e){var t=NIK_REGEX.exec(numbersOnly(e)),n={};if(!t)return n;n.nik=t[0],n.sex=Number(t[4].substr(0,2))>40?"Female":"Male";var a=this.reformatBirthday(t[4]),r=includes(this.VALID_BPSCODE,parseInt(t[1])),i=!isNaN(formatDate("19"+a).getTime());if(r){for(var o={},u=0,l=PROVINCE_KEYS;u<l.length;u++){var d=l[u],c=PROVINCE_DATA[d];if(c.bpsCode==t[1]){o.key=d,o.name=c.name;break}}n.province=o}if(i){var s=(new Date).getFullYear(),m=Number(a.substr(0,2))+2e3,N=a.substring(2,6);m>s&&(m-=100),n.birthday=new Date(formatDate(m+""+N))}return n},e}(),theNIK=new NomorIndukKependudukan;function isValidNIK(e){return theNIK.isValid(e)}function isValidNIKWithComparison(e,t){var n=t.provinceKey,a=void 0===n?"":n,r=t.birthday,i=void 0===r?"":r;return theNIK.isValid(e,a,i)}function getDataNIK(e){return theNIK.getData(e)}var NIP_REGEX=/^(\d{8})(\d{6})([1,2]{1})(\d{3})$/,NIP_LENGTH=18,NomorIndukPegawaiNegeriSipil=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=NIP_REGEX.exec(numbersOnly(e));return null!==t&&!isNaN(formatDate(t[1]).getTime())&&!isNaN(formatDate(t[2]).getTime())&&correctLength(0,t[0].length,{minLength:NIP_LENGTH})},e.prototype.getData=function(e){var t={},n=NIP_REGEX.exec(numbersOnly(e));return n?(t.nip=n[0],t.birthday=formatDate(n[1]),t.recruit_date=n[2].substr(0,4)+"-"+n[2].substr(4,2),t.sex=1==Number(n[3])?"Male":"Female",t):t},e}(),theNIP=new NomorIndukPegawaiNegeriSipil;function isValidNIP(e){return theNIP.isValid(e)}function getDataNIP(e){return theNIP.getData(e)}var NISN_REGEX=/^(\d{3})(\d{3})(\d{4})$/,NISN_LENGTH=10,NISN_AGE_VALIDITY=22,NomorIndukSiswaNasional=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=NISN_REGEX.exec(numbersOnly(e));return null!==t&&this.isValidPeriod(t[1])&&correctLength(0,t[0].length,{minLength:NISN_LENGTH})},e.prototype.isValidPeriod=function(e){var t=(new Date).getFullYear(),n=t-NISN_AGE_VALIDITY,a=parseInt(e)+2e3;return a>t&&(a-=1e3),!(a<n)},e}(),theNISN=new NomorIndukSiswaNasional;function isValidNISN(e){return theNISN.isValid(e)}var NPWP_REGEX=/^(\d{2})(\d{3})(\d{3})(\d{1})(\d{3})(\d{3})$/,NPWP_LENGTH=15,NPWP_TAX_IDENTITIES=["01","02","21","31","00","20","04","05","06","07","08","09","24","25","26","31","34","35","36","47","48","49","57","58","67","77","78","79","87","88","89","97"],NPWP_DOT_INDEXES=[1,4,7,11],NPWP_HYPHEN_INDEXES=[8],NomorPokokWajibPajak=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=numbersOnly(e),n=NPWP_REGEX.exec(t);return null!==n&&this.isValidTaxIdentity(n[1])&&correctLength(0,n[0].length,{minLength:NPWP_LENGTH})},e.prototype.isValidTaxIdentity=function(e){return includes(NPWP_TAX_IDENTITIES,e)},e.prototype.format=function(e){var t=numbersOnly(e);return t.slice(0,NPWP_LENGTH).split("").reduce((function(e,n,a){var r=""+e+n;if(a!==t.length-1){if(includes(NPWP_DOT_INDEXES,a))return r+".";if(includes(NPWP_HYPHEN_INDEXES,a))return r+"-"}return r}),"")},e}(),theNPWP=new NomorPokokWajibPajak;function isValidNPWP(e){return theNPWP.isValid(e)}function formatNPWP(e){return theNPWP.format(e)}var Province=function(){function e(){}return e.prototype.getData=function(e){return void 0===e&&(e=""),e?{key:e,name:PROVINCE_DATA[e].name}:PROVINCE_KEYS.map((function(e){return{key:e,name:PROVINCE_DATA[e].name}}))},e}(),prov=new Province;function getDataProvince(e){return prov.getData(e)}function getDataProvinces(){return prov.getData()}var TelephoneNumber=function(){function e(){this.VALID_TELEPHONE_AREACODE=PROVINCE_KEYS.reduce((function(e,t){return e.concat(PROVINCE_DATA[t].tel)}),[])}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=cleanPhoneNumbers(e);return!isNaN(this.isValidCellularPrefix(t))},e.prototype.isValidCellularPrefix=function(e){var t=Number(e.substr(0,2));return includes(this.VALID_TELEPHONE_AREACODE,t)?t:(t=Number(e.substr(0,3)),includes(this.VALID_TELEPHONE_AREACODE,t)?t:NaN)},e.prototype.getData=function(e){var t={},n=cleanPhoneNumbers(e);t.number=this.format(n);for(var a=this.isValidCellularPrefix(n),r=0,i=PROVINCE_KEYS;r<i.length;r++){var o=i[r],u=PROVINCE_DATA[o];if(includes(u.tel,a)){t.origin={key:o,name:u.name};break}}return t},e.prototype.format=function(e,t){void 0===t&&(t=!1);var n=cleanPhoneNumbers(e),a=this.isValidCellularPrefix(n).toString(),r=[];r=2===a.length?[1]:[2];var i=n.slice(0,n.length).split("").reduce((function(e,t,a){var i=""+e+t;return a!==n.length-1&&includes(r,a)?i+"-":i}),"");return t?"+"+COUNTRY_CODE+i:"0"+i},e}(),telNumber=new TelephoneNumber;function isValidTelephoneNumber(e){return telNumber.isValid(e)}function getDataTelephoneNumber(e){return telNumber.getData(e)}function formatTelephoneNumber(e,t){return void 0===t&&(t=!1),telNumber.format(e,t)}var TNKB_REGEX=/^([A-Z]{1,2})(\d{1,4})([A-Z]{1,3})$/,TandaNomorKendaraanBermotor=function(){function e(){this.VALID_TNKB_AREACODE=PROVINCE_KEYS.reduce((function(e,t){return e.concat(PROVINCE_DATA[t].vehiclePlate)}),[])}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=e.toUpperCase(),n=TNKB_REGEX.exec(t);return null!==n&&this.isValidTNKBArea(n[1])},e.prototype.isValidTNKBArea=function(e){return includes(this.VALID_TNKB_AREACODE,e)},e.prototype.getData=function(e){var t={},n=e.toUpperCase(),a=TNKB_REGEX.exec(n);if(!a)return t;for(var r=0,i=PROVINCE_KEYS;r<i.length;r++){var o=i[r],u=PROVINCE_DATA[o];if(includes(u.vehiclePlate,a[1])){t={areaCode:a[1],index:Number(a[2]),detailedAreaCode:a[3],province:{key:o,name:u.name}};break}}return t},e}(),theTNKB=new TandaNomorKendaraanBermotor;function isValidTNKB(e){return theTNKB.isValid(e)}function getDataTNKB(e){return theTNKB.getData(e)}var ZIPCode=function(){function e(){this.ZIP_RANGE=PROVINCE_KEYS.reduce((function(e,t){return e.concat(PROVINCE_DATA[t].zipCode)}),[])}return e.prototype.isValid=function(e,t){if(void 0===t&&(t=""),!e)return!1;var n=this.ZIP_RANGE,a=correctLength(0,(e=e.toString()).length,{minLength:5});return t&&(n=PROVINCE_DATA[t].zipCode),a&&this.isValidZIPCode(e,n)},e.prototype.isValidZIPCode=function(e,t){for(var n=0,a=t;n<a.length;n++){var r=a[n];if(r.from<=e&&r.to>=e)return!0}return!1},e}(),theZIP=new ZIPCode;function isValidZIP(e){return theZIP.isValid(e)}function isValidZIPWithComparison(e,t){var n=t.provinceKey,a=void 0===n?"":n;return theZIP.isValid(e,a)}export{cleanPhoneNumbers,correctLength,formatCCNumber,formatCellularNumber,formatDate,formatNPWP,formatTelephoneNumber,getDataBank,getDataBanks,getDataCellularNumber,getDataCellularProvider,getDataCellularProviders,getDataNIK,getDataNIP,getDataProvince,getDataProvinces,getDataTNKB,getDataTelephoneNumber,includes,isValidATMNumber,isValidATMNumberWithComparison,isValidCCNumber,isValidCellularNumber,isValidCellularNumberWithComparison,isValidEmail,isValidNIK,isValidNIKWithComparison,isValidNIP,isValidNISN,isValidNPWP,isValidTNKB,isValidTelephoneNumber,isValidZIP,isValidZIPWithComparison,numbersOnly,range}; | ||
function numbersOnly(e){return String(e).replace(/[^\d]/g,"")}function cleanPhoneNumbers(e,n){void 0===n&&(n={});var t=n.cellular,a=void 0!==t&&t,r=n.countryCode,i=void 0===r?0:r,o=String(e).replace(/[^\d]/g,"").replace(/^0+/,"");return a&&Number(o.substr(0,2))===i&&(o=o.substring(2)),o}function correctLength(e,n,t){var a=t.collection,r=void 0===a?[]:a,i=t.minLength,o=void 0===i?0:i,u=t.maxLength,l=void 0===u?0:u;switch(e){case 0:return n==o;case 1:return n>=o&&n<=l;case 2:return r.includes(n);default:return!1}}function formatDate(e){return new Date(numbersOnly(e).replace(/(\d{4})(?:(\d{2})?)(?:(\d{2})?)/,"$1-$2-$3"))}function includes(e,n){return e.indexOf(n)>-1}var range=function(e,n){for(var t=[],a=e;a<=n;a++)t=t.concat(a);return t},BANK_DATA={BCAK:{name:"Bank Central Asia",digits:10,dotIndex:[2,5]},BCAS:{name:"Bank Central Asia Syariah",digits:10,dotIndex:[2,5]},BNIK:{name:"Bank Negara Indonesia",digits:10,dotIndex:[2,5]},BNIS:{name:"Bank Negara Indonesia Syariah",digits:10,dotIndex:[2,5]},BRIK:{name:"Bank Rakyat Indonesia",digits:15,dotIndex:[2,5,8,11]},BRIS:{name:"Bank Rakyat Indonesia Syariah",digits:10,dotIndex:[2,5]},BTNK:{name:"Bank Tabungan Negara",digits:16,dotIndex:[]},BTNS:{name:"Bank Tabungan Negara Syariah",digits:10,dotIndex:[]},BTPK:{name:"Bank Tabungan Pensiunan Nasional",digits:11,dotIndex:[]},BTPS:{name:"Bank Tabungan Pensiunan Nasional Syariah",digits:10,dotIndex:[]},BUKK:{name:"Bank Bukopin",digits:10,dotIndex:[]},BUKS:{name:"Bank Bukopin Syariah",digits:10,dotIndex:[]},CMBK:{name:"Bank CIMB Niaga",digits:13,dotIndex:[]},CMBS:{name:"Bank CIMB Niaga Syariah",digits:13,dotIndex:[]},DNMK:{name:"Bank Danamon",digits:10,dotIndex:[]},DNMS:{name:"Bank Danamon Syariah",digits:10,dotIndex:[]},MDRK:{name:"Bank Mandiri",digits:13,dotIndex:[2,5,8]},MDRS:{name:"Bank Mandiri Syariah",digits:10,dotIndex:[2,5]},MGAK:{name:"Bank Mega",digits:15,dotIndex:[]},MGAS:{name:"Bank Mega Syariah",digits:10,dotIndex:[]},MUAM:{name:"Bank Muamalat",digits:10,dotIndex:[]},PMTK:{name:"Bank Permata",digits:10,dotIndex:[]},PMTS:{name:"Bank Permata Syariah",digits:10,dotIndex:[]},PNBK:{name:"Panin Bank",digits:10,dotIndex:[]},PNBS:{name:"Panin Bank Syariah",digits:10,dotIndex:[]}},BANK_KEYS=Object.keys(BANK_DATA),BANK_NUMBER_LENGTHS=BANK_KEYS.reduce((function(e,n){return includes(e,BANK_DATA[n].digits)?e:e.concat(BANK_DATA[n].digits)}),[]),ATMNumber=function(){function e(){}return e.prototype.isValid=function(e,n){if(void 0===n&&(n=""),!e||"string"!=typeof e)return!1;var t=numbersOnly(e);return n?correctLength(0,t.length,{minLength:BANK_DATA[n].digits}):correctLength(2,t.length,{collection:BANK_NUMBER_LENGTHS})},e}(),theATM=new ATMNumber;function isValidATMNumber(e){return theATM.isValid(e)}function isValidATMNumberWithComparison(e,n){return void 0===n&&(n=""),theATM.isValid(e,n)}var Bank=function(){function e(){}return e.prototype.getData=function(e){return void 0===e&&(e=""),e?{key:e,name:BANK_DATA[e].name}:BANK_KEYS.map((function(e){return{key:e,name:BANK_DATA[e].name}}))},e}(),bank=new Bank;function getDataBank(e){return bank.getData(e)}function getDataBanks(){return bank.getData()}var CELLULAR_PROVIDER_DATA={TELKOMSEL:{name:"Telkomsel",prefix:range(811,813).concat(range(821,823)).concat(range(851,853))},INDOSAT:{name:"Indosat Ooredoo",prefix:range(814,816).concat(range(855,858))},XL:{name:"XL Axiata",prefix:range(817,819).concat([859,877,878])},TRI:{name:"Hutchinson Tri",prefix:range(895,899)},SMARTFREN:{name:"Smartfren",prefix:range(881,889)},AXIS:{name:"AXIS",prefix:range(831,833).concat([838])}},CELLULAR_MIN_LENGTH=10,CELLULAR_MAX_LENGTH=12,CELLULAR_HYPEN_INDEXES=[2,6],CELLULAR_PROVIDER_KEYS=Object.keys(CELLULAR_PROVIDER_DATA),CELLULAR_PROVIDER_PREFIXES=CELLULAR_PROVIDER_KEYS.reduce((function(e,n){return e.concat(CELLULAR_PROVIDER_DATA[n].prefix)}),[]),PROVINCE_DATA={11:{name:"Aceh",bpsCode:"11",vehiclePlate:["BL"],tel:range(641,659).concat([627,629]),zipCode:[{from:23111,to:24794}]},12:{name:"Sumatra Utara",bpsCode:"12",vehiclePlate:["BB","BK"],tel:range(620,639).concat([601]),zipCode:[{from:20111,to:22999}]},13:{name:"Sumatra Barat",bpsCode:"13",vehiclePlate:["BA"],tel:range(751,759),zipCode:[{from:25111,to:27779}]},14:{name:"Riau",bpsCode:"14",vehiclePlate:["BM"],tel:range(760,769).concat([624]),zipCode:[{from:28111,to:29569}]},15:{name:"Jambi",bpsCode:"15",vehiclePlate:["BH"],tel:range(740,748),zipCode:[{from:36111,to:37574}]},16:{name:"Sumatra Selatan",bpsCode:"16",vehiclePlate:["BG"],tel:range(711,714).concat(range(730,735)).concat([702]),zipCode:[{from:30111,to:32388}]},17:{name:"Bengkulu",bpsCode:"17",vehiclePlate:["BD"],tel:range(736,739).concat([732]),zipCode:[{from:38113,to:39377}]},18:{name:"Lampung",bpsCode:"18",vehiclePlate:["BE"],tel:range(721,729),zipCode:[{from:34111,to:35686}]},19:{name:"Kepulauan Bangka Belitung",bpsCode:"19",vehiclePlate:["BN"],tel:range(715,719),zipCode:[{from:33111,to:33792}]},21:{name:"Kepulauan Riau",bpsCode:"21",vehiclePlate:["BP"],tel:range(771,779),zipCode:[{from:29111,to:29878}]},31:{name:"Jakarta",bpsCode:"31",vehiclePlate:["B"],tel:[21],zipCode:[{from:10110,to:14540}]},32:{name:"Jawa Barat",bpsCode:"32",vehiclePlate:["D","E","F","T","Z"],tel:range(231,234).concat(range(260,267)).concat([22,251]),zipCode:[{from:16110,to:17730},{from:40111,to:46476}]},33:{name:"Jawa Tengah",bpsCode:"33",vehiclePlate:["G","H","K","R","AA","AD"],tel:range(275,299).concat(range(271,273)).concat([24,356]),zipCode:[{from:50111,to:54474},{from:56111,to:59584}]},34:{name:"Yogyakarta",bpsCode:"34",vehiclePlate:["AB"],tel:[274],zipCode:[{from:55111,to:55893}]},35:{name:"Jawa Timur",bpsCode:"35",vehiclePlate:["L","M","N","P","S","W","AE","AG"],tel:range(321,358).concat([31]),zipCode:[{from:60111,to:69493}]},36:{name:"Banten",bpsCode:"36",vehiclePlate:["A"],tel:range(252,257),zipCode:[{from:15111,to:15820},{from:42111,to:42455}]},51:{name:"Bali",bpsCode:"51",vehiclePlate:["DK"],tel:range(361,368),zipCode:[{from:80111,to:82262}]},52:{name:"Nusa Tenggara Barat",bpsCode:"52",vehiclePlate:["DR","EA"],tel:range(370,376).concat([364]),zipCode:[{from:83115,to:84459}]},53:{name:"Nusa Tenggara Timur",bpsCode:"53",vehiclePlate:["DH","EB","ED"],tel:range(380,389),zipCode:[{from:85111,to:87284}]},61:{name:"Kalimantan Barat",bpsCode:"61",vehiclePlate:["KB"],tel:range(564,568).concat([534]),zipCode:[{from:78111,to:79682}]},62:{name:"Kalimantan Tengah",bpsCode:"62",vehiclePlate:["KH"],tel:range(513,539),zipCode:[{from:73111,to:74874}]},63:{name:"Kalimantan Selatan",bpsCode:"63",vehiclePlate:["DA"],tel:range(511,527),zipCode:[{from:70111,to:72276}]},64:{name:"Kalimantan Timur",bpsCode:"64",vehiclePlate:["KT"],tel:range(541,556),zipCode:[{from:75111,to:77381}]},65:{name:"Kalimantan Utara",bpsCode:"65",vehiclePlate:["KU"],tel:range(551,556),zipCode:[{from:77111,to:77574}]},71:{name:"Sulawesi Utara",bpsCode:"71",vehiclePlate:["DB","DL"],tel:range(430,438),zipCode:[{from:95111,to:95999}]},72:{name:"Sulawesi Tengah",bpsCode:"72",vehiclePlate:["DN"],tel:range(445,465),zipCode:[{from:94111,to:94981}]},73:{name:"Sulawesi Selatan",bpsCode:"73",vehiclePlate:["DD","DP","DW"],tel:range(410,421).concat(range(471,485)).concat([423,427]),zipCode:[{from:90111,to:91273},{from:91611,to:92985}]},74:{name:"Sulawesi Tenggara",bpsCode:"74",vehiclePlate:["DT"],tel:range(401,408),zipCode:[{from:93111,to:93963}]},75:{name:"Gorontalo",bpsCode:"75",vehiclePlate:["DM"],tel:[435,443],zipCode:[{from:96111,to:96574}]},76:{name:"Sulawesi Barat",bpsCode:"76",vehiclePlate:["DC"],tel:[422,426,428],zipCode:[{from:91311,to:91591}]},81:{name:"Maluku",bpsCode:"81",vehiclePlate:["DE"],tel:range(910,931),zipCode:[{from:97114,to:97669}]},82:{name:"Maluku Utara",bpsCode:"82",vehiclePlate:["DG"],tel:range(910,931),zipCode:[{from:97711,to:97869}]},91:{name:"Papua Barat",bpsCode:"91",vehiclePlate:["PB"],tel:range(951,986).concat([901,902]),zipCode:[{from:98011,to:98495}]},92:{name:"Papua",bpsCode:"92",vehiclePlate:["PA"],tel:range(951,986).concat([901,902]),zipCode:[{from:98511,to:99976}]}},COUNTRY_CODE=62,PROVINCE_KEYS=Object.keys(PROVINCE_DATA),CellularNumber=function(){function e(){}return e.prototype.isValid=function(e,n){if(void 0===n&&(n=""),!e||"string"!=typeof e)return!1;var t,a=cleanPhoneNumbers(e,{cellular:!0,countryCode:COUNTRY_CODE});return t=n?CELLULAR_PROVIDER_DATA[n].prefix:CELLULAR_PROVIDER_PREFIXES,correctLength(1,a.length,{minLength:CELLULAR_MIN_LENGTH,maxLength:CELLULAR_MAX_LENGTH})&&includes(t,Number(a.substr(0,3)))},e.prototype.getData=function(e){var n={};n.number=this.format(e);for(var t=Number(cleanPhoneNumbers(e,{cellular:!0,countryCode:COUNTRY_CODE}).substr(0,3)),a=0,r=CELLULAR_PROVIDER_KEYS;a<r.length;a++){var i=r[a],o=CELLULAR_PROVIDER_DATA[i];if(includes(o.prefix,t)){n.provider={key:i,name:o.name};break}}return n},e.prototype.format=function(e,n){void 0===n&&(n=!1);var t=cleanPhoneNumbers(e,{cellular:!0,countryCode:COUNTRY_CODE}),a=t.slice(0,t.length).split("").reduce((function(e,n,a){var r=""+e+n;return a!==t.length-1&&includes(CELLULAR_HYPEN_INDEXES,a)?r+"-":r}),"");return n?"+"+COUNTRY_CODE.toString()+a:"0"+a},e}(),cellularNumber=new CellularNumber;function isValidCellularNumber(e){return cellularNumber.isValid(e)}function isValidCellularNumberWithComparison(e,n){return cellularNumber.isValid(e,n)}function getDataCellularNumber(e){return cellularNumber.getData(e)}function formatCellularNumber(e,n){return void 0===n&&(n=!1),cellularNumber.format(e,n)}var CellularProvider=function(){function e(){}return e.prototype.getData=function(e){return void 0===e&&(e=""),e?{key:e,name:CELLULAR_PROVIDER_DATA[e].name}:CELLULAR_PROVIDER_KEYS.map((function(e){return{key:e,name:CELLULAR_PROVIDER_DATA[e].name}}))},e}(),isp=new CellularProvider;function getDataCellularProvider(e){return isp.getData(e)}function getDataCellularProviders(){return isp.getData()}var CC_LENGTH=16,CC_VALID_MII=["4","5"],CC_SPACE_INDEXES=[3,7,11,11],CreditCard=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var n=numbersOnly(e);return this.isValidMII(e.charAt(0))&&correctLength(0,n.length,{minLength:CC_LENGTH})},e.prototype.isValidMII=function(e){return includes(CC_VALID_MII,e)},e.prototype.format=function(e){var n=numbersOnly(e);return n.slice(0,CC_LENGTH).split("").reduce((function(e,t,a){var r=""+e+t;return a!==n.length-1&&includes(CC_SPACE_INDEXES,a)?r+" ":r}),"")},e}(),cc=new CreditCard;function isValidCCNumber(e){return cc.isValid(e)}function formatCCNumber(e){return cc.format(e)}var EMAIL_REGEX=/^([a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*)@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+(?:[a-zA-Z]+)$/,MAX_LOCALPART_LENGTH=64,MAX_EMAIL_LENGTH=254,Email=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var n=EMAIL_REGEX.exec(e);return null!==n&&correctLength(1,n[0].length,{minLength:1,maxLength:MAX_EMAIL_LENGTH})&&correctLength(1,n[1].length,{minLength:1,maxLength:MAX_LOCALPART_LENGTH})},e}(),theEmail=new Email;function isValidEmail(e){return theEmail.isValid(e)}var NIK_REGEX=/^(\d{2})(\d{2})(\d{2})(\d{6})(\d{4})$/,NIK_LENGTH=16,Province=function(){function e(){}return e.prototype.getData=function(e){return void 0===e&&(e=""),e?{bpsCode:e,name:PROVINCE_DATA[e].name}:PROVINCE_KEYS.map((function(e){return{bpsCode:e,name:PROVINCE_DATA[e].name}}))},e}(),prov=new Province;function getDataProvince(e){return prov.getData(e)}function getDataProvinces(){return prov.getData()}var NomorIndukKependudukan=function(){function e(){}return e.prototype.isValid=function(e,n,t){if(void 0===n&&(n=""),void 0===t&&(t=""),!e||"string"!=typeof e)return!1;var a=NIK_REGEX.exec(numbersOnly(e));if(!a)return!1;var r=correctLength(0,a[0].length,{minLength:NIK_LENGTH}),i=this.reformatBirthday(a[4]),o=includes(PROVINCE_KEYS,a[1]),u=!isNaN(formatDate("19"+i).getTime());(n&&n!=a[1]&&(o=!1),t)&&(i!=numbersOnly(t).substring(2,8)&&(u=!1));return r&&o&&u},e.prototype.reformatBirthday=function(e){var n=/(\d{2})(\d{2})(\d{2})/.exec(e);if(n){var t=n[1],a=n[2],r=n[3];return Number(t)>40&&(t=(Number(t)-40).toString()),r+""+a+t}return""},e.prototype.getData=function(e){var n=NIK_REGEX.exec(numbersOnly(e)),t={};if(!n)return t;t.nik=n[0],t.sex=Number(n[4].substr(0,2))>40?"Female":"Male";var a=this.reformatBirthday(n[4]),r=includes(PROVINCE_KEYS,n[1]),i=!isNaN(formatDate("19"+a).getTime());if(r&&(t.province=getDataProvince(n[1])),i){var o=(new Date).getFullYear(),u=Number(a.substr(0,2))+2e3,l=a.substring(2,6);u>o&&(u-=100),t.birthday=new Date(formatDate(u+""+l))}return t},e}(),theNIK=new NomorIndukKependudukan;function isValidNIK(e){return theNIK.isValid(e)}function isValidNIKWithComparison(e,n){var t=n.provinceKey,a=void 0===t?"":t,r=n.birthday,i=void 0===r?"":r;return theNIK.isValid(e,a,i)}function getDataNIK(e){return theNIK.getData(e)}var NIP_REGEX=/^(\d{8})(\d{6})([1,2]{1})(\d{3})$/,NIP_LENGTH=18,NomorIndukPegawaiNegeriSipil=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var n=NIP_REGEX.exec(numbersOnly(e));return null!==n&&!isNaN(formatDate(n[1]).getTime())&&!isNaN(formatDate(n[2]).getTime())&&correctLength(0,n[0].length,{minLength:NIP_LENGTH})},e.prototype.getData=function(e){var n={},t=NIP_REGEX.exec(numbersOnly(e));return t?(n.nip=t[0],n.birthday=formatDate(t[1]),n.recruit_date=t[2].substr(0,4)+"-"+t[2].substr(4,2),n.sex=1==Number(t[3])?"Male":"Female",n):n},e}(),theNIP=new NomorIndukPegawaiNegeriSipil;function isValidNIP(e){return theNIP.isValid(e)}function getDataNIP(e){return theNIP.getData(e)}var NISN_REGEX=/^(\d{3})(\d{3})(\d{4})$/,NISN_LENGTH=10,NISN_AGE_VALIDITY=22,NomorIndukSiswaNasional=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var n=NISN_REGEX.exec(numbersOnly(e));return null!==n&&this.isValidPeriod(n[1])&&correctLength(0,n[0].length,{minLength:NISN_LENGTH})},e.prototype.isValidPeriod=function(e){var n=(new Date).getFullYear(),t=n-NISN_AGE_VALIDITY,a=parseInt(e)+2e3;return a>n&&(a-=1e3),!(a<t)},e}(),theNISN=new NomorIndukSiswaNasional;function isValidNISN(e){return theNISN.isValid(e)}var NPWP_REGEX=/^(\d{2})(\d{3})(\d{3})(\d{1})(\d{3})(\d{3})$/,NPWP_LENGTH=15,NPWP_TAX_IDENTITIES=["01","02","21","31","00","20","04","05","06","07","08","09","24","25","26","31","34","35","36","47","48","49","57","58","67","77","78","79","87","88","89","97"],NPWP_DOT_INDEXES=[1,4,7,11],NPWP_HYPHEN_INDEXES=[8],NomorPokokWajibPajak=function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var n=numbersOnly(e),t=NPWP_REGEX.exec(n);return null!==t&&this.isValidTaxIdentity(t[1])&&correctLength(0,t[0].length,{minLength:NPWP_LENGTH})},e.prototype.isValidTaxIdentity=function(e){return includes(NPWP_TAX_IDENTITIES,e)},e.prototype.format=function(e){var n=numbersOnly(e);return n.slice(0,NPWP_LENGTH).split("").reduce((function(e,t,a){var r=""+e+t;if(a!==n.length-1){if(includes(NPWP_DOT_INDEXES,a))return r+".";if(includes(NPWP_HYPHEN_INDEXES,a))return r+"-"}return r}),"")},e}(),theNPWP=new NomorPokokWajibPajak;function isValidNPWP(e){return theNPWP.isValid(e)}function formatNPWP(e){return theNPWP.format(e)}var TelephoneNumber=function(){function e(){this.VALID_TELEPHONE_AREACODE=PROVINCE_KEYS.reduce((function(e,n){return e.concat(PROVINCE_DATA[n].tel)}),[])}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var n=cleanPhoneNumbers(e);return!isNaN(this.isValidCellularPrefix(n))},e.prototype.isValidCellularPrefix=function(e){var n=Number(e.substr(0,2));return includes(this.VALID_TELEPHONE_AREACODE,n)?n:(n=Number(e.substr(0,3)),includes(this.VALID_TELEPHONE_AREACODE,n)?n:NaN)},e.prototype.getData=function(e){var n={},t=cleanPhoneNumbers(e);n.number=this.format(t);for(var a=this.isValidCellularPrefix(t),r=0,i=PROVINCE_KEYS;r<i.length;r++){var o=i[r],u=PROVINCE_DATA[o];if(includes(u.tel,a)){n.origin={bpsCode:o,name:u.name};break}}return n},e.prototype.format=function(e,n){void 0===n&&(n=!1);var t=cleanPhoneNumbers(e),a=this.isValidCellularPrefix(t).toString(),r=[];r=2===a.length?[1]:[2];var i=t.slice(0,t.length).split("").reduce((function(e,n,a){var i=""+e+n;return a!==t.length-1&&includes(r,a)?i+"-":i}),"");return n?"+"+COUNTRY_CODE+i:"0"+i},e}(),telNumber=new TelephoneNumber;function isValidTelephoneNumber(e){return telNumber.isValid(e)}function getDataTelephoneNumber(e){return telNumber.getData(e)}function formatTelephoneNumber(e,n){return void 0===n&&(n=!1),telNumber.format(e,n)}var TNKB_REGEX=/^([A-Z]{1,2})(\d{1,4})([A-Z]{1,3})$/,TandaNomorKendaraanBermotor=function(){function e(){this.VALID_TNKB_AREACODE=PROVINCE_KEYS.reduce((function(e,n){return e.concat(PROVINCE_DATA[n].vehiclePlate)}),[])}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var n=e.toUpperCase(),t=TNKB_REGEX.exec(n);return null!==t&&this.isValidTNKBArea(t[1])},e.prototype.isValidTNKBArea=function(e){return includes(this.VALID_TNKB_AREACODE,e)},e.prototype.getData=function(e){var n={},t=e.toUpperCase(),a=TNKB_REGEX.exec(t);if(!a)return n;for(var r=0,i=PROVINCE_KEYS;r<i.length;r++){var o=i[r],u=PROVINCE_DATA[o];if(includes(u.vehiclePlate,a[1])){n={areaCode:a[1],index:Number(a[2]),detailedAreaCode:a[3],province:{bpsCode:o,name:u.name}};break}}return n},e}(),theTNKB=new TandaNomorKendaraanBermotor;function isValidTNKB(e){return theTNKB.isValid(e)}function getDataTNKB(e){return theTNKB.getData(e)}var ZIPCode=function(){function e(){this.ZIP_RANGES=PROVINCE_KEYS.reduce((function(e,n){return e.concat(PROVINCE_DATA[n].zipCode)}),[])}return e.prototype.isValid=function(e,n){return void 0===n&&(n=""),!!e&&(e=e.toString(),t=n?PROVINCE_DATA[n].zipCode:this.ZIP_RANGES,parseInt(e).toString()===e&&correctLength(0,e.length,{minLength:5})&&this.isValidZIPCode(e,t));var t},e.prototype.isValidZIPCode=function(e,n){for(var t=0,a=n;t<a.length;t++){var r=a[t];if(r.from<=e&&r.to>=e)return!0}return!1},e}(),theZIP=new ZIPCode;function isValidZIP(e){return theZIP.isValid(e)}function isValidZIPWithComparison(e,n){var t=n.provinceKey,a=void 0===t?"":t;return theZIP.isValid(e,a)}export{cleanPhoneNumbers,correctLength,formatCCNumber,formatCellularNumber,formatDate,formatNPWP,formatTelephoneNumber,getDataBank,getDataBanks,getDataCellularNumber,getDataCellularProvider,getDataCellularProviders,getDataNIK,getDataNIP,getDataProvince,getDataProvinces,getDataTNKB,getDataTelephoneNumber,includes,isValidATMNumber,isValidATMNumberWithComparison,isValidCCNumber,isValidCellularNumber,isValidCellularNumberWithComparison,isValidEmail,isValidNIK,isValidNIKWithComparison,isValidNIP,isValidNISN,isValidNPWP,isValidTNKB,isValidTelephoneNumber,isValidZIP,isValidZIPWithComparison,numbersOnly,range}; | ||
//# sourceMappingURL=nusantara-valid.min.js.map |
/*! | ||
* Nusantara Valid v0.2.0 | ||
* Nusantara Valid v0.3.0 | ||
* Copyright 2020 - Fajar Setya Budi (https://magicjar.github.io) | ||
* Contributors (https://github.com/magicjar/nusantara-valid/graphs/contributors) | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Contributors (https://github.com/agraris/nusantara-valid/graphs/contributors) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
*/ | ||
@@ -99,3 +99,3 @@ (function (global, factory) { | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -105,4 +105,3 @@ /** | ||
* | ||
* List of bank in Indonesia including BPS code, vehicle plate, | ||
* telephone numbers, and zip code. | ||
* List of bank in Indonesia. | ||
**/ | ||
@@ -113,3 +112,3 @@ var BANK_DATA = { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -119,3 +118,3 @@ BCAS: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -125,3 +124,3 @@ BNIK: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -131,3 +130,3 @@ BNIS: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -137,3 +136,3 @@ BRIK: { | ||
digits: 15, | ||
dotIndex: [] | ||
dotIndex: [2, 5, 8, 11] | ||
}, | ||
@@ -143,3 +142,3 @@ BRIS: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -199,3 +198,3 @@ BTNK: { | ||
digits: 13, | ||
dotIndex: [] | ||
dotIndex: [2, 5, 8] | ||
}, | ||
@@ -205,3 +204,3 @@ MDRS: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -244,3 +243,14 @@ MGAK: { | ||
}; | ||
/** | ||
* BANK_KEYS | ||
* | ||
* List of bank object keys. | ||
**/ | ||
var BANK_KEYS = Object.keys(BANK_DATA); | ||
/** | ||
* BANK_NUMBER_LENGTHS | ||
* | ||
* List of bank's number (ATM number) length. | ||
**/ | ||
var BANK_NUMBER_LENGTHS = BANK_KEYS.reduce(function (pref, curr) { return includes(pref, BANK_DATA[curr].digits) ? pref : pref.concat(BANK_DATA[curr].digits); }, []); | ||
@@ -250,3 +260,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -257,3 +267,2 @@ * @class The ATMNumber class | ||
function ATMNumber() { | ||
this.VALID_ATMNUMBER_LENGTH = BANK_KEYS.reduce(function (pref, curr) { return includes(pref, BANK_DATA[curr].digits) ? pref : pref.concat(BANK_DATA[curr].digits); }, []); | ||
} | ||
@@ -265,6 +274,3 @@ ATMNumber.prototype.isValid = function (atm, bank) { | ||
var numOnly = numbersOnly(atm); | ||
var matchLength = correctLength(2, numOnly.length, { collection: this.VALID_ATMNUMBER_LENGTH }); | ||
if (bank) | ||
matchLength = correctLength(0, numOnly.length, { minLength: BANK_DATA[bank].digits }); | ||
return matchLength; | ||
return bank ? correctLength(0, numOnly.length, { minLength: BANK_DATA[bank].digits }) : correctLength(2, numOnly.length, { collection: BANK_NUMBER_LENGTHS }); | ||
}; | ||
@@ -302,3 +308,3 @@ return ATMNumber; | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -355,3 +361,3 @@ * @class The Bank class | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -408,3 +414,14 @@ /** | ||
var CELLULAR_HYPEN_INDEXES = [2, 6]; | ||
/** | ||
* CELLULAR_PROVIDER_KEYS | ||
* | ||
* List of cellular provider object keys. | ||
**/ | ||
var CELLULAR_PROVIDER_KEYS = Object.keys(CELLULAR_PROVIDER_DATA); | ||
/** | ||
* CELLULAR_PROVIDER_PREFIXES | ||
* | ||
* List of cellular provider prefixes. | ||
**/ | ||
var CELLULAR_PROVIDER_PREFIXES = CELLULAR_PROVIDER_KEYS.reduce(function (a, b) { return a.concat(CELLULAR_PROVIDER_DATA[b].prefix); }, []); | ||
@@ -414,3 +431,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -424,5 +441,5 @@ /** | ||
var PROVINCE_DATA = { | ||
AC: { | ||
'11': { | ||
name: 'Aceh', | ||
bpsCode: 11, | ||
bpsCode: '11', | ||
vehiclePlate: ['BL'], | ||
@@ -437,68 +454,41 @@ tel: range(641, 659).concat([627, 629]), | ||
}, | ||
BA: { | ||
name: 'Bali', | ||
bpsCode: 51, | ||
vehiclePlate: ['DK'], | ||
tel: range(361, 368), | ||
'12': { | ||
name: 'Sumatra Utara', | ||
bpsCode: '12', | ||
vehiclePlate: ['BB', 'BK'], | ||
tel: range(620, 639).concat([601]), | ||
zipCode: [ | ||
{ | ||
from: 80111, | ||
to: 82262 | ||
from: 20111, | ||
to: 22999 | ||
} | ||
] | ||
}, | ||
BB: { | ||
name: 'Kepulauan Bangka Belitung', | ||
bpsCode: 19, | ||
vehiclePlate: ['BN'], | ||
tel: range(715, 719), | ||
'13': { | ||
name: 'Sumatra Barat', | ||
bpsCode: '13', | ||
vehiclePlate: ['BA'], | ||
tel: range(751, 759), | ||
zipCode: [ | ||
{ | ||
from: 33111, | ||
to: 33792 | ||
from: 25111, | ||
to: 27779 | ||
} | ||
] | ||
}, | ||
BE: { | ||
name: 'Bengkulu', | ||
bpsCode: 17, | ||
vehiclePlate: ['BD'], | ||
tel: range(736, 739).concat([732]), | ||
'14': { | ||
name: 'Riau', | ||
bpsCode: '14', | ||
vehiclePlate: ['BM'], | ||
tel: range(760, 769).concat([624]), | ||
zipCode: [ | ||
{ | ||
from: 38113, | ||
to: 39377 | ||
from: 28111, | ||
to: 29569 | ||
} | ||
] | ||
}, | ||
BT: { | ||
name: 'Banten', | ||
bpsCode: 36, | ||
vehiclePlate: ['A'], | ||
tel: range(252, 257), | ||
zipCode: [ | ||
{ | ||
from: 15111, | ||
to: 15820 | ||
}, { | ||
from: 42111, | ||
to: 42455 | ||
} | ||
] | ||
}, | ||
GO: { | ||
name: 'Gorontalo', | ||
bpsCode: 75, | ||
vehiclePlate: ['DM'], | ||
tel: [435, 443], | ||
zipCode: [ | ||
{ | ||
from: 96111, | ||
to: 96574 | ||
} | ||
] | ||
}, | ||
JA: { | ||
'15': { | ||
name: 'Jambi', | ||
bpsCode: 15, | ||
bpsCode: '15', | ||
vehiclePlate: ['BH'], | ||
@@ -513,167 +503,158 @@ tel: range(740, 748), | ||
}, | ||
JB: { | ||
name: 'Jawa Barat', | ||
bpsCode: 32, | ||
vehiclePlate: ['D', 'E', 'F', 'T', 'Z'], | ||
tel: range(231, 234).concat(range(260, 267)).concat([22, 251]), | ||
'16': { | ||
name: 'Sumatra Selatan', | ||
bpsCode: '16', | ||
vehiclePlate: ['BG'], | ||
tel: range(711, 714).concat(range(730, 735)).concat([702]), | ||
zipCode: [ | ||
{ | ||
from: 16110, | ||
to: 17730 | ||
}, { | ||
from: 40111, | ||
to: 46476 | ||
from: 30111, | ||
to: 32388 | ||
} | ||
] | ||
}, | ||
JI: { | ||
name: 'Jawa Timur', | ||
bpsCode: 35, | ||
vehiclePlate: ['L', 'M', 'N', 'P', 'S', 'W', 'AE', 'AG'], | ||
tel: range(321, 358).concat([31]), | ||
'17': { | ||
name: 'Bengkulu', | ||
bpsCode: '17', | ||
vehiclePlate: ['BD'], | ||
tel: range(736, 739).concat([732]), | ||
zipCode: [ | ||
{ | ||
from: 60111, | ||
to: 69493 | ||
from: 38113, | ||
to: 39377 | ||
} | ||
] | ||
}, | ||
JK: { | ||
name: 'Jakarta', | ||
bpsCode: 31, | ||
vehiclePlate: ['B'], | ||
tel: [21], | ||
'18': { | ||
name: 'Lampung', | ||
bpsCode: '18', | ||
vehiclePlate: ['BE'], | ||
tel: range(721, 729), | ||
zipCode: [ | ||
{ | ||
from: 10110, | ||
to: 14540 | ||
from: 34111, | ||
to: 35686 | ||
} | ||
] | ||
}, | ||
JT: { | ||
name: 'Jawa Tengah', | ||
bpsCode: 33, | ||
vehiclePlate: ['G', 'H', 'K', 'R', 'AA', 'AD'], | ||
tel: range(275, 299).concat(range(271, 273)).concat([24, 356]), | ||
'19': { | ||
name: 'Kepulauan Bangka Belitung', | ||
bpsCode: '19', | ||
vehiclePlate: ['BN'], | ||
tel: range(715, 719), | ||
zipCode: [ | ||
{ | ||
from: 50111, | ||
to: 54474 | ||
}, { | ||
from: 56111, | ||
to: 59584 | ||
from: 33111, | ||
to: 33792 | ||
} | ||
] | ||
}, | ||
KB: { | ||
name: 'Kalimantan Barat', | ||
bpsCode: 61, | ||
vehiclePlate: ['KB'], | ||
tel: range(564, 568).concat([534]), | ||
'21': { | ||
name: 'Kepulauan Riau', | ||
bpsCode: '21', | ||
vehiclePlate: ['BP'], | ||
tel: range(771, 779), | ||
zipCode: [ | ||
{ | ||
from: 78111, | ||
to: 79682 | ||
from: 29111, | ||
to: 29878 | ||
} | ||
] | ||
}, | ||
KI: { | ||
name: 'Kalimantan Timur', | ||
bpsCode: 64, | ||
vehiclePlate: ['KT'], | ||
tel: range(541, 556), | ||
'31': { | ||
name: 'Jakarta', | ||
bpsCode: '31', | ||
vehiclePlate: ['B'], | ||
tel: [21], | ||
zipCode: [ | ||
{ | ||
from: 75111, | ||
to: 77381 | ||
from: 10110, | ||
to: 14540 | ||
} | ||
] | ||
}, | ||
KR: { | ||
name: 'Kepulauan Riau', | ||
bpsCode: 21, | ||
vehiclePlate: ['BP'], | ||
tel: range(771, 779), | ||
'32': { | ||
name: 'Jawa Barat', | ||
bpsCode: '32', | ||
vehiclePlate: ['D', 'E', 'F', 'T', 'Z'], | ||
tel: range(231, 234).concat(range(260, 267)).concat([22, 251]), | ||
zipCode: [ | ||
{ | ||
from: 29111, | ||
to: 29878 | ||
from: 16110, | ||
to: 17730 | ||
}, { | ||
from: 40111, | ||
to: 46476 | ||
} | ||
] | ||
}, | ||
KS: { | ||
name: 'Kalimantan Selatan', | ||
bpsCode: 63, | ||
vehiclePlate: ['DA'], | ||
tel: range(511, 527), | ||
'33': { | ||
name: 'Jawa Tengah', | ||
bpsCode: '33', | ||
vehiclePlate: ['G', 'H', 'K', 'R', 'AA', 'AD'], | ||
tel: range(275, 299).concat(range(271, 273)).concat([24, 356]), | ||
zipCode: [ | ||
{ | ||
from: 70111, | ||
to: 72276 | ||
from: 50111, | ||
to: 54474 | ||
}, { | ||
from: 56111, | ||
to: 59584 | ||
} | ||
] | ||
}, | ||
KT: { | ||
name: 'Kalimantan Tengah', | ||
bpsCode: 62, | ||
vehiclePlate: ['KH'], | ||
tel: range(513, 539), | ||
'34': { | ||
name: 'Yogyakarta', | ||
bpsCode: '34', | ||
vehiclePlate: ['AB'], | ||
tel: [274], | ||
zipCode: [ | ||
{ | ||
from: 73111, | ||
to: 74874 | ||
from: 55111, | ||
to: 55893 | ||
} | ||
] | ||
}, | ||
KU: { | ||
name: 'Kalimantan Utara', | ||
bpsCode: 65, | ||
vehiclePlate: ['KU'], | ||
tel: range(551, 556), | ||
'35': { | ||
name: 'Jawa Timur', | ||
bpsCode: '35', | ||
vehiclePlate: ['L', 'M', 'N', 'P', 'S', 'W', 'AE', 'AG'], | ||
tel: range(321, 358).concat([31]), | ||
zipCode: [ | ||
{ | ||
from: 77111, | ||
to: 77574 | ||
from: 60111, | ||
to: 69493 | ||
} | ||
] | ||
}, | ||
LA: { | ||
name: 'Lampung', | ||
bpsCode: 18, | ||
vehiclePlate: ['BE'], | ||
tel: range(721, 729), | ||
'36': { | ||
name: 'Banten', | ||
bpsCode: '36', | ||
vehiclePlate: ['A'], | ||
tel: range(252, 257), | ||
zipCode: [ | ||
{ | ||
from: 34111, | ||
to: 35686 | ||
from: 15111, | ||
to: 15820 | ||
}, { | ||
from: 42111, | ||
to: 42455 | ||
} | ||
] | ||
}, | ||
MA: { | ||
name: 'Maluku', | ||
bpsCode: 81, | ||
vehiclePlate: ['DE'], | ||
tel: range(910, 931), | ||
'51': { | ||
name: 'Bali', | ||
bpsCode: '51', | ||
vehiclePlate: ['DK'], | ||
tel: range(361, 368), | ||
zipCode: [ | ||
{ | ||
from: 97114, | ||
to: 97669 | ||
from: 80111, | ||
to: 82262 | ||
} | ||
] | ||
}, | ||
MU: { | ||
name: 'Maluku Utara', | ||
bpsCode: 82, | ||
vehiclePlate: ['DG'], | ||
tel: range(910, 931), | ||
zipCode: [ | ||
{ | ||
from: 97711, | ||
to: 97869 | ||
} | ||
] | ||
}, | ||
NB: { | ||
'52': { | ||
name: 'Nusa Tenggara Barat', | ||
bpsCode: 52, | ||
bpsCode: '52', | ||
vehiclePlate: ['DR', 'EA'], | ||
@@ -688,5 +669,5 @@ tel: range(370, 376).concat([364]), | ||
}, | ||
NT: { | ||
'53': { | ||
name: 'Nusa Tenggara Timur', | ||
bpsCode: 53, | ||
bpsCode: '53', | ||
vehiclePlate: ['DH', 'EB', 'ED'], | ||
@@ -701,41 +682,65 @@ tel: range(380, 389), | ||
}, | ||
PA: { | ||
name: 'Papua', | ||
bpsCode: 94, | ||
vehiclePlate: ['PA'], | ||
tel: range(951, 986).concat([901, 902]), | ||
'61': { | ||
name: 'Kalimantan Barat', | ||
bpsCode: '61', | ||
vehiclePlate: ['KB'], | ||
tel: range(564, 568).concat([534]), | ||
zipCode: [ | ||
{ | ||
from: 98511, | ||
to: 99976 | ||
from: 78111, | ||
to: 79682 | ||
} | ||
] | ||
}, | ||
PB: { | ||
name: 'Papua Barat', | ||
bpsCode: 91, | ||
vehiclePlate: ['PB'], | ||
tel: range(951, 986).concat([901, 902]), | ||
'62': { | ||
name: 'Kalimantan Tengah', | ||
bpsCode: '62', | ||
vehiclePlate: ['KH'], | ||
tel: range(513, 539), | ||
zipCode: [ | ||
{ | ||
from: 98011, | ||
to: 98495 | ||
from: 73111, | ||
to: 74874 | ||
} | ||
] | ||
}, | ||
RI: { | ||
name: 'Riau', | ||
bpsCode: 14, | ||
vehiclePlate: ['BM'], | ||
tel: range(760, 769).concat([624]), | ||
'63': { | ||
name: 'Kalimantan Selatan', | ||
bpsCode: '63', | ||
vehiclePlate: ['DA'], | ||
tel: range(511, 527), | ||
zipCode: [ | ||
{ | ||
from: 28111, | ||
to: 29569 | ||
from: 70111, | ||
to: 72276 | ||
} | ||
] | ||
}, | ||
SA: { | ||
'64': { | ||
name: 'Kalimantan Timur', | ||
bpsCode: '64', | ||
vehiclePlate: ['KT'], | ||
tel: range(541, 556), | ||
zipCode: [ | ||
{ | ||
from: 75111, | ||
to: 77381 | ||
} | ||
] | ||
}, | ||
'65': { | ||
name: 'Kalimantan Utara', | ||
bpsCode: '65', | ||
vehiclePlate: ['KU'], | ||
tel: range(551, 556), | ||
zipCode: [ | ||
{ | ||
from: 77111, | ||
to: 77574 | ||
} | ||
] | ||
}, | ||
'71': { | ||
name: 'Sulawesi Utara', | ||
bpsCode: 71, | ||
bpsCode: '71', | ||
vehiclePlate: ['DB', 'DL'], | ||
@@ -750,17 +755,32 @@ tel: range(430, 438), | ||
}, | ||
SB: { | ||
name: 'Sumatra Barat', | ||
bpsCode: 13, | ||
vehiclePlate: ['BA'], | ||
tel: range(751, 759), | ||
'72': { | ||
name: 'Sulawesi Tengah', | ||
bpsCode: '72', | ||
vehiclePlate: ['DN'], | ||
tel: range(445, 465), | ||
zipCode: [ | ||
{ | ||
from: 25111, | ||
to: 27779 | ||
from: 94111, | ||
to: 94981 | ||
} | ||
] | ||
}, | ||
SG: { | ||
'73': { | ||
name: 'Sulawesi Selatan', | ||
bpsCode: '73', | ||
vehiclePlate: ['DD', 'DP', 'DW'], | ||
tel: range(410, 421).concat(range(471, 485)).concat([423, 427]), | ||
zipCode: [ | ||
{ | ||
from: 90111, | ||
to: 91273 | ||
}, { | ||
from: 91611, | ||
to: 92985 | ||
} | ||
] | ||
}, | ||
'74': { | ||
name: 'Sulawesi Tenggara', | ||
bpsCode: 74, | ||
bpsCode: '74', | ||
vehiclePlate: ['DT'], | ||
@@ -775,20 +795,17 @@ tel: range(401, 408), | ||
}, | ||
SN: { | ||
name: 'Sulawesi Selatan', | ||
bpsCode: 73, | ||
vehiclePlate: ['DD', 'DP', 'DW'], | ||
tel: range(410, 421).concat(range(471, 485)).concat([423, 427]), | ||
'75': { | ||
name: 'Gorontalo', | ||
bpsCode: '75', | ||
vehiclePlate: ['DM'], | ||
tel: [435, 443], | ||
zipCode: [ | ||
{ | ||
from: 90111, | ||
to: 91273 | ||
}, { | ||
from: 91611, | ||
to: 92985 | ||
from: 96111, | ||
to: 96574 | ||
} | ||
] | ||
}, | ||
SR: { | ||
'76': { | ||
name: 'Sulawesi Barat', | ||
bpsCode: 76, | ||
bpsCode: '76', | ||
vehiclePlate: ['DC'], | ||
@@ -803,47 +820,47 @@ tel: [422, 426, 428], | ||
}, | ||
SS: { | ||
name: 'Sumatra Selatan', | ||
bpsCode: 16, | ||
vehiclePlate: ['BG'], | ||
tel: range(711, 714).concat(range(730, 735)).concat([702]), | ||
'81': { | ||
name: 'Maluku', | ||
bpsCode: '81', | ||
vehiclePlate: ['DE'], | ||
tel: range(910, 931), | ||
zipCode: [ | ||
{ | ||
from: 30111, | ||
to: 32388 | ||
from: 97114, | ||
to: 97669 | ||
} | ||
] | ||
}, | ||
ST: { | ||
name: 'Sulawesi Tengah', | ||
bpsCode: 72, | ||
vehiclePlate: ['DN'], | ||
tel: range(445, 465), | ||
'82': { | ||
name: 'Maluku Utara', | ||
bpsCode: '82', | ||
vehiclePlate: ['DG'], | ||
tel: range(910, 931), | ||
zipCode: [ | ||
{ | ||
from: 94111, | ||
to: 94981 | ||
from: 97711, | ||
to: 97869 | ||
} | ||
] | ||
}, | ||
SU: { | ||
name: 'Sumatra Utara', | ||
bpsCode: 12, | ||
vehiclePlate: ['BB', 'BK'], | ||
tel: range(620, 639).concat([601]), | ||
'91': { | ||
name: 'Papua Barat', | ||
bpsCode: '91', | ||
vehiclePlate: ['PB'], | ||
tel: range(951, 986).concat([901, 902]), | ||
zipCode: [ | ||
{ | ||
from: 20111, | ||
to: 22999 | ||
from: 98011, | ||
to: 98495 | ||
} | ||
] | ||
}, | ||
YO: { | ||
name: 'Yogyakarta', | ||
bpsCode: 34, | ||
vehiclePlate: ['AB'], | ||
tel: [274], | ||
'92': { | ||
name: 'Papua', | ||
bpsCode: '92', | ||
vehiclePlate: ['PA'], | ||
tel: range(951, 986).concat([901, 902]), | ||
zipCode: [ | ||
{ | ||
from: 55111, | ||
to: 55893 | ||
from: 98511, | ||
to: 99976 | ||
} | ||
@@ -864,3 +881,3 @@ ] | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -871,3 +888,2 @@ * @class The CellularNumber class | ||
function CellularNumber() { | ||
this.CELLULAR_PROVIDER_PREFIXES = CELLULAR_PROVIDER_KEYS.reduce(function (a, b) { return a.concat(CELLULAR_PROVIDER_DATA[b].prefix); }, []); | ||
} | ||
@@ -878,15 +894,8 @@ CellularNumber.prototype.isValid = function (mobile, providerKey) { | ||
return false; | ||
var cleanCellularNumber = cleanPhoneNumbers(mobile, { cellular: true, countryCode: COUNTRY_CODE }); | ||
var prefixCollection; | ||
var cleanCellularNumber = cleanPhoneNumbers(mobile, { cellular: true, countryCode: COUNTRY_CODE }); | ||
var validLength = correctLength(1, cleanCellularNumber.length, { minLength: CELLULAR_MIN_LENGTH, maxLength: CELLULAR_MAX_LENGTH }); | ||
if (providerKey) | ||
prefixCollection = CELLULAR_PROVIDER_DATA[providerKey].prefix; | ||
else | ||
prefixCollection = this.CELLULAR_PROVIDER_PREFIXES; | ||
return validLength | ||
&& this.isValidCellularProviderPrefix(Number(cleanCellularNumber.substr(0, 3)), prefixCollection); | ||
providerKey ? prefixCollection = CELLULAR_PROVIDER_DATA[providerKey].prefix : prefixCollection = CELLULAR_PROVIDER_PREFIXES; | ||
return correctLength(1, cleanCellularNumber.length, { minLength: CELLULAR_MIN_LENGTH, maxLength: CELLULAR_MAX_LENGTH }) | ||
&& includes(prefixCollection, Number(cleanCellularNumber.substr(0, 3))); | ||
}; | ||
CellularNumber.prototype.isValidCellularProviderPrefix = function (prefix, prefixCollection) { | ||
return includes(prefixCollection, prefix); | ||
}; | ||
CellularNumber.prototype.getData = function (mobile) { | ||
@@ -979,3 +988,3 @@ var data = {}; | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1032,3 +1041,3 @@ * @class The CellularProvider class | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1060,3 +1069,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1121,3 +1130,3 @@ * @class The CreditCard class | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1148,3 +1157,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1182,3 +1191,3 @@ * @class The Email class | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1190,4 +1199,4 @@ /** | ||
* NIK_REGEX[1] = 2 digits of Province Code (BPS Code) | ||
* NIK_REGEX[2] = 2 digits of City or Distric Code | ||
* NIK_REGEX[3] = 2 digits of Sub Distric Code | ||
* NIK_REGEX[2] = 2 digits of Regency Code | ||
* NIK_REGEX[3] = 2 digits of Distric Code | ||
* NIK_REGEX[4] = 6 digits of Birthday with DDMMYY format, for woman DD + 40 | ||
@@ -1205,5 +1214,57 @@ * NIK_REGEX[5] = 4 digits of Index | ||
/** | ||
* Nusantara Valid: _province.ts | ||
* | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
* @class The Province class | ||
**/ | ||
var Province = /** @class */ (function () { | ||
function Province() { | ||
} | ||
Province.prototype.getData = function (index) { | ||
if (index === void 0) { index = ''; } | ||
var province; | ||
if (index) { | ||
province = { | ||
bpsCode: index, | ||
name: PROVINCE_DATA[index].name | ||
}; | ||
} | ||
else { | ||
province = PROVINCE_KEYS.map(function (key) { return ({ | ||
bpsCode: key, | ||
name: PROVINCE_DATA[key].name, | ||
}); }); | ||
} | ||
return province; | ||
}; | ||
return Province; | ||
}()); | ||
var prov = new Province(); | ||
/** | ||
* Get specific province data with IDataProvince object structure | ||
* | ||
* Return object data based on provided province key | ||
* | ||
* @param {string} provinceKey - Array key of the province | ||
* @return {IDataProvince} IDataProvince object | ||
**/ | ||
function getDataProvince(provinceKey) { | ||
return prov.getData(provinceKey); | ||
} | ||
/** | ||
* Get all province data with IDataProvince object structure | ||
* | ||
* Return all IDataProvince object in Array<IDataProvince> | ||
* | ||
* @return {IDataProvince[]} Array of IDataProvince object | ||
**/ | ||
function getDataProvinces() { | ||
return prov.getData(); | ||
} | ||
/** | ||
* Nusantara Valid: _nomorIndukKependudukan.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1214,3 +1275,2 @@ * @class The NomorIndukKepemdudukan class | ||
function NomorIndukKependudukan() { | ||
this.VALID_BPSCODE = PROVINCE_KEYS.reduce(function (a, b) { return a.concat(PROVINCE_DATA[b].bpsCode); }, []); | ||
} | ||
@@ -1227,7 +1287,6 @@ NomorIndukKependudukan.prototype.isValid = function (nik, provinceKey, birthday) { | ||
var cBirthday = this.reformatBirthday(validNIK[4]); | ||
var validProvince = includes(this.VALID_BPSCODE, parseInt(validNIK[1])); | ||
var validProvince = includes(PROVINCE_KEYS, validNIK[1]); | ||
var validBirthday = !isNaN(formatDate('19' + cBirthday).getTime()); | ||
// Comparison | ||
if (provinceKey) { | ||
if (PROVINCE_DATA[provinceKey].bpsCode != validNIK[1]) { | ||
if (provinceKey != validNIK[1]) { | ||
validProvince = false; | ||
@@ -1267,16 +1326,6 @@ } | ||
var reformatedBirthday = this.reformatBirthday(validNIK[4]); | ||
var validProvince = includes(this.VALID_BPSCODE, parseInt(validNIK[1])); | ||
var validProvince = includes(PROVINCE_KEYS, validNIK[1]); | ||
var validBirthday = !isNaN(formatDate('19' + reformatedBirthday).getTime()); | ||
if (validProvince) { | ||
var province = {}; | ||
for (var _i = 0, PROVINCE_KEYS_1 = PROVINCE_KEYS; _i < PROVINCE_KEYS_1.length; _i++) { | ||
var key = PROVINCE_KEYS_1[_i]; | ||
var element = PROVINCE_DATA[key]; | ||
if (element.bpsCode == validNIK[1]) { | ||
province.key = key, | ||
province.name = element.name; | ||
break; | ||
} | ||
} | ||
data.province = province; | ||
data.province = getDataProvince(validNIK[1]); | ||
} | ||
@@ -1338,3 +1387,3 @@ if (validBirthday) { | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1361,3 +1410,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1418,3 +1467,3 @@ * @class The NomorIndukPegawaiNegeriSipil class | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1448,3 +1497,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1490,3 +1539,3 @@ * @class The NomorIndukSiswaNasional class | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1539,3 +1588,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1602,57 +1651,5 @@ * @class The NomorPokokWajibPajak class | ||
/** | ||
* Nusantara Valid: _province.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* | ||
* @class The Province class | ||
**/ | ||
var Province = /** @class */ (function () { | ||
function Province() { | ||
} | ||
Province.prototype.getData = function (index) { | ||
if (index === void 0) { index = ''; } | ||
var province; | ||
if (index) { | ||
province = { | ||
key: index, | ||
name: PROVINCE_DATA[index].name | ||
}; | ||
} | ||
else { | ||
province = PROVINCE_KEYS.map(function (key) { return ({ | ||
key: key, | ||
name: PROVINCE_DATA[key].name, | ||
}); }); | ||
} | ||
return province; | ||
}; | ||
return Province; | ||
}()); | ||
var prov = new Province(); | ||
/** | ||
* Get specific province data with IDataProvince object structure | ||
* | ||
* Return object data based on provided province key | ||
* | ||
* @param {string} provinceKey - Array key of the province | ||
* @return {IDataProvince} IDataProvince object | ||
**/ | ||
function getDataProvince(provinceKey) { | ||
return prov.getData(provinceKey); | ||
} | ||
/** | ||
* Get all province data with IDataProvince object structure | ||
* | ||
* Return all IDataProvince object in Array<IDataProvince> | ||
* | ||
* @return {IDataProvince[]} Array of IDataProvince object | ||
**/ | ||
function getDataProvinces() { | ||
return prov.getData(); | ||
} | ||
/** | ||
* Nusantara Valid: _telephoneNumber.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1690,3 +1687,3 @@ * @class The TelephoneNumber class | ||
data.origin = { | ||
key: key, | ||
bpsCode: key, | ||
name: element.name | ||
@@ -1763,3 +1760,3 @@ }; | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -1779,3 +1776,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1814,3 +1811,3 @@ * @class The TandaNomorKendaraanBermotor class | ||
province: { | ||
key: key, | ||
bpsCode: key, | ||
name: element.name | ||
@@ -1853,3 +1850,3 @@ } | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -1860,3 +1857,3 @@ * @class The ZIPCode class | ||
function ZIPCode() { | ||
this.ZIP_RANGE = PROVINCE_KEYS.reduce(function (a, b) { return a.concat(PROVINCE_DATA[b].zipCode); }, []); | ||
this.ZIP_RANGES = PROVINCE_KEYS.reduce(function (a, b) { return a.concat(PROVINCE_DATA[b].zipCode); }, []); | ||
} | ||
@@ -1867,8 +1864,7 @@ ZIPCode.prototype.isValid = function (zip, provinceKey) { | ||
return false; | ||
var zipArray = this.ZIP_RANGE; | ||
var zipArray; | ||
zip = zip.toString(); | ||
var validLength = correctLength(0, zip.length, { minLength: 5 }); | ||
if (provinceKey) | ||
zipArray = PROVINCE_DATA[provinceKey].zipCode; | ||
return validLength | ||
provinceKey ? zipArray = PROVINCE_DATA[provinceKey].zipCode : zipArray = this.ZIP_RANGES; | ||
return parseInt(zip).toString() === zip | ||
&& correctLength(0, zip.length, { minLength: 5 }) | ||
&& this.isValidZIPCode(zip, zipArray); | ||
@@ -1875,0 +1871,0 @@ }; |
/*! | ||
* Nusantara Valid v0.2.0 | ||
* Nusantara Valid v0.3.0 | ||
* Copyright 2020 - Fajar Setya Budi (https://magicjar.github.io) | ||
* Contributors (https://github.com/magicjar/nusantara-valid/graphs/contributors) | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Contributors (https://github.com/agraris/nusantara-valid/graphs/contributors) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).NusantaraValid={})}(this,(function(e){"use strict";function t(e){return String(e).replace(/[^\d]/g,"")}function n(e,t){void 0===t&&(t={});var n=t.cellular,a=void 0!==n&&n,r=t.countryCode,i=void 0===r?0:r,o=String(e).replace(/[^\d]/g,"").replace(/^0+/,"");return a&&Number(o.substr(0,2))===i&&(o=o.substring(2)),o}function a(e,t,n){var a=n.collection,r=void 0===a?[]:a,i=n.minLength,o=void 0===i?0:i,u=n.maxLength,d=void 0===u?0:u;switch(e){case 0:return t==o;case 1:return t>=o&&t<=d;case 2:return r.includes(t);default:return!1}}function r(e){return new Date(t(e).replace(/(\d{4})(?:(\d{2})?)(?:(\d{2})?)/,"$1-$2-$3"))}function i(e,t){return e.indexOf(t)>-1}var o=function(e,t){for(var n=[],a=e;a<=t;a++)n=n.concat(a);return n},u={BCAK:{name:"Bank Central Asia",digits:10,dotIndex:[]},BCAS:{name:"Bank Central Asia Syariah",digits:10,dotIndex:[]},BNIK:{name:"Bank Negara Indonesia",digits:10,dotIndex:[]},BNIS:{name:"Bank Negara Indonesia Syariah",digits:10,dotIndex:[]},BRIK:{name:"Bank Rakyat Indonesia",digits:15,dotIndex:[]},BRIS:{name:"Bank Rakyat Indonesia Syariah",digits:10,dotIndex:[]},BTNK:{name:"Bank Tabungan Negara",digits:16,dotIndex:[]},BTNS:{name:"Bank Tabungan Negara Syariah",digits:10,dotIndex:[]},BTPK:{name:"Bank Tabungan Pensiunan Nasional",digits:11,dotIndex:[]},BTPS:{name:"Bank Tabungan Pensiunan Nasional Syariah",digits:10,dotIndex:[]},BUKK:{name:"Bank Bukopin",digits:10,dotIndex:[]},BUKS:{name:"Bank Bukopin Syariah",digits:10,dotIndex:[]},CMBK:{name:"Bank CIMB Niaga",digits:13,dotIndex:[]},CMBS:{name:"Bank CIMB Niaga Syariah",digits:13,dotIndex:[]},DNMK:{name:"Bank Danamon",digits:10,dotIndex:[]},DNMS:{name:"Bank Danamon Syariah",digits:10,dotIndex:[]},MDRK:{name:"Bank Mandiri",digits:13,dotIndex:[]},MDRS:{name:"Bank Mandiri Syariah",digits:10,dotIndex:[]},MGAK:{name:"Bank Mega",digits:15,dotIndex:[]},MGAS:{name:"Bank Mega Syariah",digits:10,dotIndex:[]},MUAM:{name:"Bank Muamalat",digits:10,dotIndex:[]},PMTK:{name:"Bank Permata",digits:10,dotIndex:[]},PMTS:{name:"Bank Permata Syariah",digits:10,dotIndex:[]},PNBK:{name:"Panin Bank",digits:10,dotIndex:[]},PNBS:{name:"Panin Bank Syariah",digits:10,dotIndex:[]}},d=Object.keys(u),l=new(function(){function e(){this.VALID_ATMNUMBER_LENGTH=d.reduce((function(e,t){return i(e,u[t].digits)?e:e.concat(u[t].digits)}),[])}return e.prototype.isValid=function(e,n){if(void 0===n&&(n=""),!e||"string"!=typeof e)return!1;var r=t(e),i=a(2,r.length,{collection:this.VALID_ATMNUMBER_LENGTH});return n&&(i=a(0,r.length,{minLength:u[n].digits})),i},e}());var c=new(function(){function e(){}return e.prototype.getData=function(e){return void 0===e&&(e=""),e?{key:e,name:u[e].name}:d.map((function(e){return{key:e,name:u[e].name}}))},e}());var s={TELKOMSEL:{name:"Telkomsel",prefix:o(811,813).concat(o(821,823)).concat(o(851,853))},INDOSAT:{name:"Indosat Ooredoo",prefix:o(814,816).concat(o(855,858))},XL:{name:"XL Axiata",prefix:o(817,819).concat([859,877,878])},TRI:{name:"Hutchinson Tri",prefix:o(895,899)},SMARTFREN:{name:"Smartfren",prefix:o(881,889)},AXIS:{name:"AXIS",prefix:o(831,833).concat([838])}},f=[2,6],m=Object.keys(s),p={AC:{name:"Aceh",bpsCode:11,vehiclePlate:["BL"],tel:o(641,659).concat([627,629]),zipCode:[{from:23111,to:24794}]},BA:{name:"Bali",bpsCode:51,vehiclePlate:["DK"],tel:o(361,368),zipCode:[{from:80111,to:82262}]},BB:{name:"Kepulauan Bangka Belitung",bpsCode:19,vehiclePlate:["BN"],tel:o(715,719),zipCode:[{from:33111,to:33792}]},BE:{name:"Bengkulu",bpsCode:17,vehiclePlate:["BD"],tel:o(736,739).concat([732]),zipCode:[{from:38113,to:39377}]},BT:{name:"Banten",bpsCode:36,vehiclePlate:["A"],tel:o(252,257),zipCode:[{from:15111,to:15820},{from:42111,to:42455}]},GO:{name:"Gorontalo",bpsCode:75,vehiclePlate:["DM"],tel:[435,443],zipCode:[{from:96111,to:96574}]},JA:{name:"Jambi",bpsCode:15,vehiclePlate:["BH"],tel:o(740,748),zipCode:[{from:36111,to:37574}]},JB:{name:"Jawa Barat",bpsCode:32,vehiclePlate:["D","E","F","T","Z"],tel:o(231,234).concat(o(260,267)).concat([22,251]),zipCode:[{from:16110,to:17730},{from:40111,to:46476}]},JI:{name:"Jawa Timur",bpsCode:35,vehiclePlate:["L","M","N","P","S","W","AE","AG"],tel:o(321,358).concat([31]),zipCode:[{from:60111,to:69493}]},JK:{name:"Jakarta",bpsCode:31,vehiclePlate:["B"],tel:[21],zipCode:[{from:10110,to:14540}]},JT:{name:"Jawa Tengah",bpsCode:33,vehiclePlate:["G","H","K","R","AA","AD"],tel:o(275,299).concat(o(271,273)).concat([24,356]),zipCode:[{from:50111,to:54474},{from:56111,to:59584}]},KB:{name:"Kalimantan Barat",bpsCode:61,vehiclePlate:["KB"],tel:o(564,568).concat([534]),zipCode:[{from:78111,to:79682}]},KI:{name:"Kalimantan Timur",bpsCode:64,vehiclePlate:["KT"],tel:o(541,556),zipCode:[{from:75111,to:77381}]},KR:{name:"Kepulauan Riau",bpsCode:21,vehiclePlate:["BP"],tel:o(771,779),zipCode:[{from:29111,to:29878}]},KS:{name:"Kalimantan Selatan",bpsCode:63,vehiclePlate:["DA"],tel:o(511,527),zipCode:[{from:70111,to:72276}]},KT:{name:"Kalimantan Tengah",bpsCode:62,vehiclePlate:["KH"],tel:o(513,539),zipCode:[{from:73111,to:74874}]},KU:{name:"Kalimantan Utara",bpsCode:65,vehiclePlate:["KU"],tel:o(551,556),zipCode:[{from:77111,to:77574}]},LA:{name:"Lampung",bpsCode:18,vehiclePlate:["BE"],tel:o(721,729),zipCode:[{from:34111,to:35686}]},MA:{name:"Maluku",bpsCode:81,vehiclePlate:["DE"],tel:o(910,931),zipCode:[{from:97114,to:97669}]},MU:{name:"Maluku Utara",bpsCode:82,vehiclePlate:["DG"],tel:o(910,931),zipCode:[{from:97711,to:97869}]},NB:{name:"Nusa Tenggara Barat",bpsCode:52,vehiclePlate:["DR","EA"],tel:o(370,376).concat([364]),zipCode:[{from:83115,to:84459}]},NT:{name:"Nusa Tenggara Timur",bpsCode:53,vehiclePlate:["DH","EB","ED"],tel:o(380,389),zipCode:[{from:85111,to:87284}]},PA:{name:"Papua",bpsCode:94,vehiclePlate:["PA"],tel:o(951,986).concat([901,902]),zipCode:[{from:98511,to:99976}]},PB:{name:"Papua Barat",bpsCode:91,vehiclePlate:["PB"],tel:o(951,986).concat([901,902]),zipCode:[{from:98011,to:98495}]},RI:{name:"Riau",bpsCode:14,vehiclePlate:["BM"],tel:o(760,769).concat([624]),zipCode:[{from:28111,to:29569}]},SA:{name:"Sulawesi Utara",bpsCode:71,vehiclePlate:["DB","DL"],tel:o(430,438),zipCode:[{from:95111,to:95999}]},SB:{name:"Sumatra Barat",bpsCode:13,vehiclePlate:["BA"],tel:o(751,759),zipCode:[{from:25111,to:27779}]},SG:{name:"Sulawesi Tenggara",bpsCode:74,vehiclePlate:["DT"],tel:o(401,408),zipCode:[{from:93111,to:93963}]},SN:{name:"Sulawesi Selatan",bpsCode:73,vehiclePlate:["DD","DP","DW"],tel:o(410,421).concat(o(471,485)).concat([423,427]),zipCode:[{from:90111,to:91273},{from:91611,to:92985}]},SR:{name:"Sulawesi Barat",bpsCode:76,vehiclePlate:["DC"],tel:[422,426,428],zipCode:[{from:91311,to:91591}]},SS:{name:"Sumatra Selatan",bpsCode:16,vehiclePlate:["BG"],tel:o(711,714).concat(o(730,735)).concat([702]),zipCode:[{from:30111,to:32388}]},ST:{name:"Sulawesi Tengah",bpsCode:72,vehiclePlate:["DN"],tel:o(445,465),zipCode:[{from:94111,to:94981}]},SU:{name:"Sumatra Utara",bpsCode:12,vehiclePlate:["BB","BK"],tel:o(620,639).concat([601]),zipCode:[{from:20111,to:22999}]},YO:{name:"Yogyakarta",bpsCode:34,vehiclePlate:["AB"],tel:[274],zipCode:[{from:55111,to:55893}]}},g=Object.keys(p),h=new(function(){function e(){this.CELLULAR_PROVIDER_PREFIXES=m.reduce((function(e,t){return e.concat(s[t].prefix)}),[])}return e.prototype.isValid=function(e,t){if(void 0===t&&(t=""),!e||"string"!=typeof e)return!1;var r,i=n(e,{cellular:!0,countryCode:62}),o=a(1,i.length,{minLength:10,maxLength:12});return r=t?s[t].prefix:this.CELLULAR_PROVIDER_PREFIXES,o&&this.isValidCellularProviderPrefix(Number(i.substr(0,3)),r)},e.prototype.isValidCellularProviderPrefix=function(e,t){return i(t,e)},e.prototype.getData=function(e){var t={};t.number=this.format(e);for(var a=Number(n(e,{cellular:!0,countryCode:62}).substr(0,3)),r=0,o=m;r<o.length;r++){var u=o[r],d=s[u];if(i(d.prefix,a)){t.provider={key:u,name:d.name};break}}return t},e.prototype.format=function(e,t){void 0===t&&(t=!1);var a=n(e,{cellular:!0,countryCode:62}),r=a.slice(0,a.length).split("").reduce((function(e,t,n){var r=""+e+t;return n!==a.length-1&&i(f,n)?r+"-":r}),"");return t?"+"+62..toString()+r:"0"+r},e}());var v=new(function(){function e(){}return e.prototype.getData=function(e){return void 0===e&&(e=""),e?{key:e,name:s[e].name}:m.map((function(e){return{key:e,name:s[e].name}}))},e}());var C=["4","5"],B=[3,7,11,11],P=new(function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var n=t(e);return this.isValidMII(e.charAt(0))&&a(0,n.length,{minLength:16})},e.prototype.isValidMII=function(e){return i(C,e)},e.prototype.format=function(e){var n=t(e);return n.slice(0,16).split("").reduce((function(e,t,a){var r=""+e+t;return a!==n.length-1&&i(B,a)?r+" ":r}),"")},e}());var b=/^([a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*)@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+(?:[a-zA-Z]+)$/,y=new(function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=b.exec(e);return null!==t&&a(1,t[0].length,{minLength:1,maxLength:254})&&a(1,t[1].length,{minLength:1,maxLength:64})},e}());var N=/^(\d{2})(\d{2})(\d{2})(\d{6})(\d{4})$/,D=new(function(){function e(){this.VALID_BPSCODE=g.reduce((function(e,t){return e.concat(p[t].bpsCode)}),[])}return e.prototype.isValid=function(e,n,o){if(void 0===n&&(n=""),void 0===o&&(o=""),!e||"string"!=typeof e)return!1;var u=N.exec(t(e));if(!u)return!1;var d=a(0,u[0].length,{minLength:16}),l=this.reformatBirthday(u[4]),c=i(this.VALID_BPSCODE,parseInt(u[1])),s=!isNaN(r("19"+l).getTime());(n&&p[n].bpsCode!=u[1]&&(c=!1),o)&&(l!=t(o).substring(2,8)&&(s=!1));return d&&c&&s},e.prototype.reformatBirthday=function(e){var t=/(\d{2})(\d{2})(\d{2})/.exec(e);if(t){var n=t[1],a=t[2],r=t[3];return Number(n)>40&&(n=(Number(n)-40).toString()),r+""+a+n}return""},e.prototype.getData=function(e){var n=N.exec(t(e)),a={};if(!n)return a;a.nik=n[0],a.sex=Number(n[4].substr(0,2))>40?"Female":"Male";var o=this.reformatBirthday(n[4]),u=i(this.VALID_BPSCODE,parseInt(n[1])),d=!isNaN(r("19"+o).getTime());if(u){for(var l={},c=0,s=g;c<s.length;c++){var f=s[c],m=p[f];if(m.bpsCode==n[1]){l.key=f,l.name=m.name;break}}a.province=l}if(d){var h=(new Date).getFullYear(),v=Number(o.substr(0,2))+2e3,C=o.substring(2,6);v>h&&(v-=100),a.birthday=new Date(r(v+""+C))}return a},e}());var I=/^(\d{8})(\d{6})([1,2]{1})(\d{3})$/,A=new(function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var n=I.exec(t(e));return null!==n&&!isNaN(r(n[1]).getTime())&&!isNaN(r(n[2]).getTime())&&a(0,n[0].length,{minLength:18})},e.prototype.getData=function(e){var n={},a=I.exec(t(e));return a?(n.nip=a[0],n.birthday=r(a[1]),n.recruit_date=a[2].substr(0,4)+"-"+a[2].substr(4,2),n.sex=1==Number(a[3])?"Male":"Female",n):n},e}());var V=/^(\d{3})(\d{3})(\d{4})$/,x=new(function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var n=V.exec(t(e));return null!==n&&this.isValidPeriod(n[1])&&a(0,n[0].length,{minLength:10})},e.prototype.isValidPeriod=function(e){var t=(new Date).getFullYear(),n=t-22,a=parseInt(e)+2e3;return a>t&&(a-=1e3),!(a<n)},e}());var S=/^(\d{2})(\d{3})(\d{3})(\d{1})(\d{3})(\d{3})$/,T=["01","02","21","31","00","20","04","05","06","07","08","09","24","25","26","31","34","35","36","47","48","49","57","58","67","77","78","79","87","88","89","97"],k=[1,4,7,11],E=[8],K=new(function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var n=t(e),r=S.exec(n);return null!==r&&this.isValidTaxIdentity(r[1])&&a(0,r[0].length,{minLength:15})},e.prototype.isValidTaxIdentity=function(e){return i(T,e)},e.prototype.format=function(e){var n=t(e);return n.slice(0,15).split("").reduce((function(e,t,a){var r=""+e+t;if(a!==n.length-1){if(i(k,a))return r+".";if(i(E,a))return r+"-"}return r}),"")},e}());var L=new(function(){function e(){}return e.prototype.getData=function(e){return void 0===e&&(e=""),e?{key:e,name:p[e].name}:g.map((function(e){return{key:e,name:p[e].name}}))},e}());var z=new(function(){function e(){this.VALID_TELEPHONE_AREACODE=g.reduce((function(e,t){return e.concat(p[t].tel)}),[])}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=n(e);return!isNaN(this.isValidCellularPrefix(t))},e.prototype.isValidCellularPrefix=function(e){var t=Number(e.substr(0,2));return i(this.VALID_TELEPHONE_AREACODE,t)?t:(t=Number(e.substr(0,3)),i(this.VALID_TELEPHONE_AREACODE,t)?t:NaN)},e.prototype.getData=function(e){var t={},a=n(e);t.number=this.format(a);for(var r=this.isValidCellularPrefix(a),o=0,u=g;o<u.length;o++){var d=u[o],l=p[d];if(i(l.tel,r)){t.origin={key:d,name:l.name};break}}return t},e.prototype.format=function(e,t){void 0===t&&(t=!1);var a=n(e),r=this.isValidCellularPrefix(a).toString(),o=[];o=2===r.length?[1]:[2];var u=a.slice(0,a.length).split("").reduce((function(e,t,n){var r=""+e+t;return n!==a.length-1&&i(o,n)?r+"-":r}),"");return t?"+62"+u:"0"+u},e}());var M=/^([A-Z]{1,2})(\d{1,4})([A-Z]{1,3})$/,R=new(function(){function e(){this.VALID_TNKB_AREACODE=g.reduce((function(e,t){return e.concat(p[t].vehiclePlate)}),[])}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=e.toUpperCase(),n=M.exec(t);return null!==n&&this.isValidTNKBArea(n[1])},e.prototype.isValidTNKBArea=function(e){return i(this.VALID_TNKB_AREACODE,e)},e.prototype.getData=function(e){var t={},n=e.toUpperCase(),a=M.exec(n);if(!a)return t;for(var r=0,o=g;r<o.length;r++){var u=o[r],d=p[u];if(i(d.vehiclePlate,a[1])){t={areaCode:a[1],index:Number(a[2]),detailedAreaCode:a[3],province:{key:u,name:d.name}};break}}return t},e}());var _=new(function(){function e(){this.ZIP_RANGE=g.reduce((function(e,t){return e.concat(p[t].zipCode)}),[])}return e.prototype.isValid=function(e,t){if(void 0===t&&(t=""),!e)return!1;var n=this.ZIP_RANGE,r=a(0,(e=e.toString()).length,{minLength:5});return t&&(n=p[t].zipCode),r&&this.isValidZIPCode(e,n)},e.prototype.isValidZIPCode=function(e,t){for(var n=0,a=t;n<a.length;n++){var r=a[n];if(r.from<=e&&r.to>=e)return!0}return!1},e}());e.cleanPhoneNumbers=n,e.correctLength=a,e.formatCCNumber=function(e){return P.format(e)},e.formatCellularNumber=function(e,t){return void 0===t&&(t=!1),h.format(e,t)},e.formatDate=r,e.formatNPWP=function(e){return K.format(e)},e.formatTelephoneNumber=function(e,t){return void 0===t&&(t=!1),z.format(e,t)},e.getDataBank=function(e){return c.getData(e)},e.getDataBanks=function(){return c.getData()},e.getDataCellularNumber=function(e){return h.getData(e)},e.getDataCellularProvider=function(e){return v.getData(e)},e.getDataCellularProviders=function(){return v.getData()},e.getDataNIK=function(e){return D.getData(e)},e.getDataNIP=function(e){return A.getData(e)},e.getDataProvince=function(e){return L.getData(e)},e.getDataProvinces=function(){return L.getData()},e.getDataTNKB=function(e){return R.getData(e)},e.getDataTelephoneNumber=function(e){return z.getData(e)},e.includes=i,e.isValidATMNumber=function(e){return l.isValid(e)},e.isValidATMNumberWithComparison=function(e,t){return void 0===t&&(t=""),l.isValid(e,t)},e.isValidCCNumber=function(e){return P.isValid(e)},e.isValidCellularNumber=function(e){return h.isValid(e)},e.isValidCellularNumberWithComparison=function(e,t){return h.isValid(e,t)},e.isValidEmail=function(e){return y.isValid(e)},e.isValidNIK=function(e){return D.isValid(e)},e.isValidNIKWithComparison=function(e,t){var n=t.provinceKey,a=void 0===n?"":n,r=t.birthday,i=void 0===r?"":r;return D.isValid(e,a,i)},e.isValidNIP=function(e){return A.isValid(e)},e.isValidNISN=function(e){return x.isValid(e)},e.isValidNPWP=function(e){return K.isValid(e)},e.isValidTNKB=function(e){return R.isValid(e)},e.isValidTelephoneNumber=function(e){return z.isValid(e)},e.isValidZIP=function(e){return _.isValid(e)},e.isValidZIPWithComparison=function(e,t){var n=t.provinceKey,a=void 0===n?"":n;return _.isValid(e,a)},e.numbersOnly=t,e.range=o,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).NusantaraValid={})}(this,(function(e){"use strict";function t(e){return String(e).replace(/[^\d]/g,"")}function n(e,t){void 0===t&&(t={});var n=t.cellular,a=void 0!==n&&n,r=t.countryCode,i=void 0===r?0:r,o=String(e).replace(/[^\d]/g,"").replace(/^0+/,"");return a&&Number(o.substr(0,2))===i&&(o=o.substring(2)),o}function a(e,t,n){var a=n.collection,r=void 0===a?[]:a,i=n.minLength,o=void 0===i?0:i,u=n.maxLength,d=void 0===u?0:u;switch(e){case 0:return t==o;case 1:return t>=o&&t<=d;case 2:return r.includes(t);default:return!1}}function r(e){return new Date(t(e).replace(/(\d{4})(?:(\d{2})?)(?:(\d{2})?)/,"$1-$2-$3"))}function i(e,t){return e.indexOf(t)>-1}var o=function(e,t){for(var n=[],a=e;a<=t;a++)n=n.concat(a);return n},u={BCAK:{name:"Bank Central Asia",digits:10,dotIndex:[2,5]},BCAS:{name:"Bank Central Asia Syariah",digits:10,dotIndex:[2,5]},BNIK:{name:"Bank Negara Indonesia",digits:10,dotIndex:[2,5]},BNIS:{name:"Bank Negara Indonesia Syariah",digits:10,dotIndex:[2,5]},BRIK:{name:"Bank Rakyat Indonesia",digits:15,dotIndex:[2,5,8,11]},BRIS:{name:"Bank Rakyat Indonesia Syariah",digits:10,dotIndex:[2,5]},BTNK:{name:"Bank Tabungan Negara",digits:16,dotIndex:[]},BTNS:{name:"Bank Tabungan Negara Syariah",digits:10,dotIndex:[]},BTPK:{name:"Bank Tabungan Pensiunan Nasional",digits:11,dotIndex:[]},BTPS:{name:"Bank Tabungan Pensiunan Nasional Syariah",digits:10,dotIndex:[]},BUKK:{name:"Bank Bukopin",digits:10,dotIndex:[]},BUKS:{name:"Bank Bukopin Syariah",digits:10,dotIndex:[]},CMBK:{name:"Bank CIMB Niaga",digits:13,dotIndex:[]},CMBS:{name:"Bank CIMB Niaga Syariah",digits:13,dotIndex:[]},DNMK:{name:"Bank Danamon",digits:10,dotIndex:[]},DNMS:{name:"Bank Danamon Syariah",digits:10,dotIndex:[]},MDRK:{name:"Bank Mandiri",digits:13,dotIndex:[2,5,8]},MDRS:{name:"Bank Mandiri Syariah",digits:10,dotIndex:[2,5]},MGAK:{name:"Bank Mega",digits:15,dotIndex:[]},MGAS:{name:"Bank Mega Syariah",digits:10,dotIndex:[]},MUAM:{name:"Bank Muamalat",digits:10,dotIndex:[]},PMTK:{name:"Bank Permata",digits:10,dotIndex:[]},PMTS:{name:"Bank Permata Syariah",digits:10,dotIndex:[]},PNBK:{name:"Panin Bank",digits:10,dotIndex:[]},PNBS:{name:"Panin Bank Syariah",digits:10,dotIndex:[]}},d=Object.keys(u),l=d.reduce((function(e,t){return i(e,u[t].digits)?e:e.concat(u[t].digits)}),[]),c=new(function(){function e(){}return e.prototype.isValid=function(e,n){if(void 0===n&&(n=""),!e||"string"!=typeof e)return!1;var r=t(e);return n?a(0,r.length,{minLength:u[n].digits}):a(2,r.length,{collection:l})},e}());var s=new(function(){function e(){}return e.prototype.getData=function(e){return void 0===e&&(e=""),e?{key:e,name:u[e].name}:d.map((function(e){return{key:e,name:u[e].name}}))},e}());var f={TELKOMSEL:{name:"Telkomsel",prefix:o(811,813).concat(o(821,823)).concat(o(851,853))},INDOSAT:{name:"Indosat Ooredoo",prefix:o(814,816).concat(o(855,858))},XL:{name:"XL Axiata",prefix:o(817,819).concat([859,877,878])},TRI:{name:"Hutchinson Tri",prefix:o(895,899)},SMARTFREN:{name:"Smartfren",prefix:o(881,889)},AXIS:{name:"AXIS",prefix:o(831,833).concat([838])}},m=[2,6],p=Object.keys(f),g=p.reduce((function(e,t){return e.concat(f[t].prefix)}),[]),h={11:{name:"Aceh",bpsCode:"11",vehiclePlate:["BL"],tel:o(641,659).concat([627,629]),zipCode:[{from:23111,to:24794}]},12:{name:"Sumatra Utara",bpsCode:"12",vehiclePlate:["BB","BK"],tel:o(620,639).concat([601]),zipCode:[{from:20111,to:22999}]},13:{name:"Sumatra Barat",bpsCode:"13",vehiclePlate:["BA"],tel:o(751,759),zipCode:[{from:25111,to:27779}]},14:{name:"Riau",bpsCode:"14",vehiclePlate:["BM"],tel:o(760,769).concat([624]),zipCode:[{from:28111,to:29569}]},15:{name:"Jambi",bpsCode:"15",vehiclePlate:["BH"],tel:o(740,748),zipCode:[{from:36111,to:37574}]},16:{name:"Sumatra Selatan",bpsCode:"16",vehiclePlate:["BG"],tel:o(711,714).concat(o(730,735)).concat([702]),zipCode:[{from:30111,to:32388}]},17:{name:"Bengkulu",bpsCode:"17",vehiclePlate:["BD"],tel:o(736,739).concat([732]),zipCode:[{from:38113,to:39377}]},18:{name:"Lampung",bpsCode:"18",vehiclePlate:["BE"],tel:o(721,729),zipCode:[{from:34111,to:35686}]},19:{name:"Kepulauan Bangka Belitung",bpsCode:"19",vehiclePlate:["BN"],tel:o(715,719),zipCode:[{from:33111,to:33792}]},21:{name:"Kepulauan Riau",bpsCode:"21",vehiclePlate:["BP"],tel:o(771,779),zipCode:[{from:29111,to:29878}]},31:{name:"Jakarta",bpsCode:"31",vehiclePlate:["B"],tel:[21],zipCode:[{from:10110,to:14540}]},32:{name:"Jawa Barat",bpsCode:"32",vehiclePlate:["D","E","F","T","Z"],tel:o(231,234).concat(o(260,267)).concat([22,251]),zipCode:[{from:16110,to:17730},{from:40111,to:46476}]},33:{name:"Jawa Tengah",bpsCode:"33",vehiclePlate:["G","H","K","R","AA","AD"],tel:o(275,299).concat(o(271,273)).concat([24,356]),zipCode:[{from:50111,to:54474},{from:56111,to:59584}]},34:{name:"Yogyakarta",bpsCode:"34",vehiclePlate:["AB"],tel:[274],zipCode:[{from:55111,to:55893}]},35:{name:"Jawa Timur",bpsCode:"35",vehiclePlate:["L","M","N","P","S","W","AE","AG"],tel:o(321,358).concat([31]),zipCode:[{from:60111,to:69493}]},36:{name:"Banten",bpsCode:"36",vehiclePlate:["A"],tel:o(252,257),zipCode:[{from:15111,to:15820},{from:42111,to:42455}]},51:{name:"Bali",bpsCode:"51",vehiclePlate:["DK"],tel:o(361,368),zipCode:[{from:80111,to:82262}]},52:{name:"Nusa Tenggara Barat",bpsCode:"52",vehiclePlate:["DR","EA"],tel:o(370,376).concat([364]),zipCode:[{from:83115,to:84459}]},53:{name:"Nusa Tenggara Timur",bpsCode:"53",vehiclePlate:["DH","EB","ED"],tel:o(380,389),zipCode:[{from:85111,to:87284}]},61:{name:"Kalimantan Barat",bpsCode:"61",vehiclePlate:["KB"],tel:o(564,568).concat([534]),zipCode:[{from:78111,to:79682}]},62:{name:"Kalimantan Tengah",bpsCode:"62",vehiclePlate:["KH"],tel:o(513,539),zipCode:[{from:73111,to:74874}]},63:{name:"Kalimantan Selatan",bpsCode:"63",vehiclePlate:["DA"],tel:o(511,527),zipCode:[{from:70111,to:72276}]},64:{name:"Kalimantan Timur",bpsCode:"64",vehiclePlate:["KT"],tel:o(541,556),zipCode:[{from:75111,to:77381}]},65:{name:"Kalimantan Utara",bpsCode:"65",vehiclePlate:["KU"],tel:o(551,556),zipCode:[{from:77111,to:77574}]},71:{name:"Sulawesi Utara",bpsCode:"71",vehiclePlate:["DB","DL"],tel:o(430,438),zipCode:[{from:95111,to:95999}]},72:{name:"Sulawesi Tengah",bpsCode:"72",vehiclePlate:["DN"],tel:o(445,465),zipCode:[{from:94111,to:94981}]},73:{name:"Sulawesi Selatan",bpsCode:"73",vehiclePlate:["DD","DP","DW"],tel:o(410,421).concat(o(471,485)).concat([423,427]),zipCode:[{from:90111,to:91273},{from:91611,to:92985}]},74:{name:"Sulawesi Tenggara",bpsCode:"74",vehiclePlate:["DT"],tel:o(401,408),zipCode:[{from:93111,to:93963}]},75:{name:"Gorontalo",bpsCode:"75",vehiclePlate:["DM"],tel:[435,443],zipCode:[{from:96111,to:96574}]},76:{name:"Sulawesi Barat",bpsCode:"76",vehiclePlate:["DC"],tel:[422,426,428],zipCode:[{from:91311,to:91591}]},81:{name:"Maluku",bpsCode:"81",vehiclePlate:["DE"],tel:o(910,931),zipCode:[{from:97114,to:97669}]},82:{name:"Maluku Utara",bpsCode:"82",vehiclePlate:["DG"],tel:o(910,931),zipCode:[{from:97711,to:97869}]},91:{name:"Papua Barat",bpsCode:"91",vehiclePlate:["PB"],tel:o(951,986).concat([901,902]),zipCode:[{from:98011,to:98495}]},92:{name:"Papua",bpsCode:"92",vehiclePlate:["PA"],tel:o(951,986).concat([901,902]),zipCode:[{from:98511,to:99976}]}},v=Object.keys(h),C=new(function(){function e(){}return e.prototype.isValid=function(e,t){if(void 0===t&&(t=""),!e||"string"!=typeof e)return!1;var r,o=n(e,{cellular:!0,countryCode:62});return r=t?f[t].prefix:g,a(1,o.length,{minLength:10,maxLength:12})&&i(r,Number(o.substr(0,3)))},e.prototype.getData=function(e){var t={};t.number=this.format(e);for(var a=Number(n(e,{cellular:!0,countryCode:62}).substr(0,3)),r=0,o=p;r<o.length;r++){var u=o[r],d=f[u];if(i(d.prefix,a)){t.provider={key:u,name:d.name};break}}return t},e.prototype.format=function(e,t){void 0===t&&(t=!1);var a=n(e,{cellular:!0,countryCode:62}),r=a.slice(0,a.length).split("").reduce((function(e,t,n){var r=""+e+t;return n!==a.length-1&&i(m,n)?r+"-":r}),"");return t?"+"+62..toString()+r:"0"+r},e}());var b=new(function(){function e(){}return e.prototype.getData=function(e){return void 0===e&&(e=""),e?{key:e,name:f[e].name}:p.map((function(e){return{key:e,name:f[e].name}}))},e}());var B=["4","5"],y=[3,7,11,11],P=new(function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var n=t(e);return this.isValidMII(e.charAt(0))&&a(0,n.length,{minLength:16})},e.prototype.isValidMII=function(e){return i(B,e)},e.prototype.format=function(e){var n=t(e);return n.slice(0,16).split("").reduce((function(e,t,a){var r=""+e+t;return a!==n.length-1&&i(y,a)?r+" ":r}),"")},e}());var N=/^([a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*)@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+(?:[a-zA-Z]+)$/,D=new(function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=N.exec(e);return null!==t&&a(1,t[0].length,{minLength:1,maxLength:254})&&a(1,t[1].length,{minLength:1,maxLength:64})},e}());var I=/^(\d{2})(\d{2})(\d{2})(\d{6})(\d{4})$/,x=new(function(){function e(){}return e.prototype.getData=function(e){return void 0===e&&(e=""),e?{bpsCode:e,name:h[e].name}:v.map((function(e){return{bpsCode:e,name:h[e].name}}))},e}());function V(e){return x.getData(e)}var A=new(function(){function e(){}return e.prototype.isValid=function(e,n,o){if(void 0===n&&(n=""),void 0===o&&(o=""),!e||"string"!=typeof e)return!1;var u=I.exec(t(e));if(!u)return!1;var d=a(0,u[0].length,{minLength:16}),l=this.reformatBirthday(u[4]),c=i(v,u[1]),s=!isNaN(r("19"+l).getTime());(n&&n!=u[1]&&(c=!1),o)&&(l!=t(o).substring(2,8)&&(s=!1));return d&&c&&s},e.prototype.reformatBirthday=function(e){var t=/(\d{2})(\d{2})(\d{2})/.exec(e);if(t){var n=t[1],a=t[2],r=t[3];return Number(n)>40&&(n=(Number(n)-40).toString()),r+""+a+n}return""},e.prototype.getData=function(e){var n=I.exec(t(e)),a={};if(!n)return a;a.nik=n[0],a.sex=Number(n[4].substr(0,2))>40?"Female":"Male";var o=this.reformatBirthday(n[4]),u=i(v,n[1]),d=!isNaN(r("19"+o).getTime());if(u&&(a.province=V(n[1])),d){var l=(new Date).getFullYear(),c=Number(o.substr(0,2))+2e3,s=o.substring(2,6);c>l&&(c-=100),a.birthday=new Date(r(c+""+s))}return a},e}());var S=/^(\d{8})(\d{6})([1,2]{1})(\d{3})$/,k=new(function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var n=S.exec(t(e));return null!==n&&!isNaN(r(n[1]).getTime())&&!isNaN(r(n[2]).getTime())&&a(0,n[0].length,{minLength:18})},e.prototype.getData=function(e){var n={},a=S.exec(t(e));return a?(n.nip=a[0],n.birthday=r(a[1]),n.recruit_date=a[2].substr(0,4)+"-"+a[2].substr(4,2),n.sex=1==Number(a[3])?"Male":"Female",n):n},e}());var T=/^(\d{3})(\d{3})(\d{4})$/,z=new(function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var n=T.exec(t(e));return null!==n&&this.isValidPeriod(n[1])&&a(0,n[0].length,{minLength:10})},e.prototype.isValidPeriod=function(e){var t=(new Date).getFullYear(),n=t-22,a=parseInt(e)+2e3;return a>t&&(a-=1e3),!(a<n)},e}());var K=/^(\d{2})(\d{3})(\d{3})(\d{1})(\d{3})(\d{3})$/,M=["01","02","21","31","00","20","04","05","06","07","08","09","24","25","26","31","34","35","36","47","48","49","57","58","67","77","78","79","87","88","89","97"],E=[1,4,7,11],L=[8],w=new(function(){function e(){}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var n=t(e),r=K.exec(n);return null!==r&&this.isValidTaxIdentity(r[1])&&a(0,r[0].length,{minLength:15})},e.prototype.isValidTaxIdentity=function(e){return i(M,e)},e.prototype.format=function(e){var n=t(e);return n.slice(0,15).split("").reduce((function(e,t,a){var r=""+e+t;if(a!==n.length-1){if(i(E,a))return r+".";if(i(L,a))return r+"-"}return r}),"")},e}());var R=new(function(){function e(){this.VALID_TELEPHONE_AREACODE=v.reduce((function(e,t){return e.concat(h[t].tel)}),[])}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=n(e);return!isNaN(this.isValidCellularPrefix(t))},e.prototype.isValidCellularPrefix=function(e){var t=Number(e.substr(0,2));return i(this.VALID_TELEPHONE_AREACODE,t)?t:(t=Number(e.substr(0,3)),i(this.VALID_TELEPHONE_AREACODE,t)?t:NaN)},e.prototype.getData=function(e){var t={},a=n(e);t.number=this.format(a);for(var r=this.isValidCellularPrefix(a),o=0,u=v;o<u.length;o++){var d=u[o],l=h[d];if(i(l.tel,r)){t.origin={bpsCode:d,name:l.name};break}}return t},e.prototype.format=function(e,t){void 0===t&&(t=!1);var a=n(e),r=this.isValidCellularPrefix(a).toString(),o=[];o=2===r.length?[1]:[2];var u=a.slice(0,a.length).split("").reduce((function(e,t,n){var r=""+e+t;return n!==a.length-1&&i(o,n)?r+"-":r}),"");return t?"+62"+u:"0"+u},e}());var O=/^([A-Z]{1,2})(\d{1,4})([A-Z]{1,3})$/,_=new(function(){function e(){this.VALID_TNKB_AREACODE=v.reduce((function(e,t){return e.concat(h[t].vehiclePlate)}),[])}return e.prototype.isValid=function(e){if(!e||"string"!=typeof e)return!1;var t=e.toUpperCase(),n=O.exec(t);return null!==n&&this.isValidTNKBArea(n[1])},e.prototype.isValidTNKBArea=function(e){return i(this.VALID_TNKB_AREACODE,e)},e.prototype.getData=function(e){var t={},n=e.toUpperCase(),a=O.exec(n);if(!a)return t;for(var r=0,o=v;r<o.length;r++){var u=o[r],d=h[u];if(i(d.vehiclePlate,a[1])){t={areaCode:a[1],index:Number(a[2]),detailedAreaCode:a[3],province:{bpsCode:u,name:d.name}};break}}return t},e}());var Z=new(function(){function e(){this.ZIP_RANGES=v.reduce((function(e,t){return e.concat(h[t].zipCode)}),[])}return e.prototype.isValid=function(e,t){return void 0===t&&(t=""),!!e&&(e=e.toString(),n=t?h[t].zipCode:this.ZIP_RANGES,parseInt(e).toString()===e&&a(0,e.length,{minLength:5})&&this.isValidZIPCode(e,n));var n},e.prototype.isValidZIPCode=function(e,t){for(var n=0,a=t;n<a.length;n++){var r=a[n];if(r.from<=e&&r.to>=e)return!0}return!1},e}());e.cleanPhoneNumbers=n,e.correctLength=a,e.formatCCNumber=function(e){return P.format(e)},e.formatCellularNumber=function(e,t){return void 0===t&&(t=!1),C.format(e,t)},e.formatDate=r,e.formatNPWP=function(e){return w.format(e)},e.formatTelephoneNumber=function(e,t){return void 0===t&&(t=!1),R.format(e,t)},e.getDataBank=function(e){return s.getData(e)},e.getDataBanks=function(){return s.getData()},e.getDataCellularNumber=function(e){return C.getData(e)},e.getDataCellularProvider=function(e){return b.getData(e)},e.getDataCellularProviders=function(){return b.getData()},e.getDataNIK=function(e){return A.getData(e)},e.getDataNIP=function(e){return k.getData(e)},e.getDataProvince=V,e.getDataProvinces=function(){return x.getData()},e.getDataTNKB=function(e){return _.getData(e)},e.getDataTelephoneNumber=function(e){return R.getData(e)},e.includes=i,e.isValidATMNumber=function(e){return c.isValid(e)},e.isValidATMNumberWithComparison=function(e,t){return void 0===t&&(t=""),c.isValid(e,t)},e.isValidCCNumber=function(e){return P.isValid(e)},e.isValidCellularNumber=function(e){return C.isValid(e)},e.isValidCellularNumberWithComparison=function(e,t){return C.isValid(e,t)},e.isValidEmail=function(e){return D.isValid(e)},e.isValidNIK=function(e){return A.isValid(e)},e.isValidNIKWithComparison=function(e,t){var n=t.provinceKey,a=void 0===n?"":n,r=t.birthday,i=void 0===r?"":r;return A.isValid(e,a,i)},e.isValidNIP=function(e){return k.isValid(e)},e.isValidNISN=function(e){return z.isValid(e)},e.isValidNPWP=function(e){return w.isValid(e)},e.isValidTNKB=function(e){return _.isValid(e)},e.isValidTelephoneNumber=function(e){return R.isValid(e)},e.isValidZIP=function(e){return Z.isValid(e)},e.isValidZIPWithComparison=function(e,t){var n=t.provinceKey,a=void 0===n?"":n;return Z.isValid(e,a)},e.numbersOnly=t,e.range=o,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=nusantara-valid.min.js.map |
{ | ||
"name": "nusantara-valid", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Nusantara Valid is a data validator to validate any Indonesian specific civil data such as nik, nip, and many more.", | ||
@@ -29,6 +29,6 @@ "author": { | ||
"type": "git", | ||
"url": "https://github.com/magicjar/nusantara-valid.git" | ||
"url": "https://github.com/agraris/nusantara-valid.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/magicjar/nusantara-valid/issues" | ||
"url": "https://github.com/agraris/nusantara-valid/issues" | ||
}, | ||
@@ -41,6 +41,12 @@ "files": [ | ||
"clean": "shx rm -rf dist", | ||
"compile": "npm-run-all clean --parallel compile:*", | ||
"compile:cjs": "rollup --environment FORMAT:cjs --config rollup.config.js --sourcemap", | ||
"compile:es": "rollup --environment FORMAT:esm --config rollup.config.js --sourcemap", | ||
"compile:umd": "rollup --environment FORMAT:umd --config rollup.config.js --sourcemap", | ||
"compile-all": "npm-run-all --parallel compile compile-ext", | ||
"compile": "npm-run-all --parallel compile:*", | ||
"compile:cjs": "rollup --config --environment FORMAT:cjs", | ||
"compile:es": "rollup --config --environment FORMAT:esm", | ||
"compile:umd": "rollup --config", | ||
"compile-ext": "npm-run-all --parallel compile-ext:*", | ||
"compile-ext:cjs": "rollup --config --environment FORMAT:cjs,EXTENDED:true", | ||
"compile-ext:es": "rollup --config --environment FORMAT:esm,EXTENDED:true", | ||
"compile-ext:umd": "rollup --config --environment EXTENDED:true", | ||
"minify-all": "npm-run-all --parallel minify minify-ext", | ||
"minify": "npm-run-all --parallel minify:*", | ||
@@ -50,18 +56,20 @@ "minify:cjs": "terser --compress typeofs=false --mangle --comments \"/^!/\" --source-map \"content=dist/cjs/nusantara-valid.js.map, includeSources, url=nusantara-valid.min.js.map\" --output dist/cjs/nusantara-valid.min.js dist/cjs/nusantara-valid.js", | ||
"minify:umd": "terser --compress typeofs=false --mangle --comments \"/^!/\" --source-map \"content=dist/umd/nusantara-valid.js.map, includeSources, url=nusantara-valid.min.js.map\" --output dist/umd/nusantara-valid.min.js dist/umd/nusantara-valid.js", | ||
"pre-release": "npm-run-all compile minify", | ||
"serve": "http-server --silent -p 3000", | ||
"test": "mocha --require ts-node/register src/test/*" | ||
"minify-ext": "npm-run-all --parallel minify-ext:*", | ||
"minify-ext:cjs": "terser --compress typeofs=false --mangle --comments \"/^!/\" --source-map \"content=dist/cjs/nusantara-valid.extended.js.map, includeSources, url=nusantara-valid.extended.min.js.map\" --output dist/cjs/nusantara-valid.extended.min.js dist/cjs/nusantara-valid.extended.js", | ||
"minify-ext:es": "terser --compress typeofs=false --mangle --comments \"/^!/\" --source-map \"content=dist/esm/nusantara-valid.extended.js.map, includeSources, url=nusantara-valid.extended.min.js.map\" --output dist/esm/nusantara-valid.extended.min.js dist/esm/nusantara-valid.extended.js", | ||
"minify-ext:umd": "terser --compress typeofs=false --mangle --comments \"/^!/\" --source-map \"content=dist/umd/nusantara-valid.extended.js.map, includeSources, url=nusantara-valid.extended.min.js.map\" --output dist/umd/nusantara-valid.extended.min.js dist/umd/nusantara-valid.extended.js", | ||
"pre-release": "npm-run-all clean compile-all minify-all", | ||
"test": "mocha --require ts-node/register src/test/**" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.10.3", | ||
"@babel/preset-env": "^7.10.3", | ||
"@rollup/plugin-babel": "^5.0.4", | ||
"@rollup/plugin-typescript": "^5.0.1", | ||
"@babel/core": "^7.10.5", | ||
"@babel/preset-env": "^7.10.4", | ||
"@rollup/plugin-babel": "^5.1.0", | ||
"@rollup/plugin-typescript": "^5.0.2", | ||
"@types/chai": "^4.2.11", | ||
"@types/mocha": "^7.0.2", | ||
"chai": "^4.2.0", | ||
"http-server": "^0.12.3", | ||
"mocha": "^7.2.0", | ||
"npm-run-all": "^4.1.5", | ||
"rollup": "^2.18.1", | ||
"rollup": "^2.21.0", | ||
"shx": "^0.3.2", | ||
@@ -71,4 +79,4 @@ "terser": "^4.8.0", | ||
"tslib": "^2.0.0", | ||
"typescript": "^3.9.5" | ||
"typescript": "^3.9.6" | ||
} | ||
} |
394
README.md
@@ -1,2 +0,7 @@ | ||
[![npm version](https://img.shields.io/npm/v/nusantara-valid.svg)](https://www.npmjs.com/package/nusantara-valid) | ||
[![JS gzip size](https://img.badgesize.io/agraris/nusantara-valid/master/dist/umd/nusantara-valid.min.js?compression=gzip&label=JS%20gzip%20size)](https://github.com/agraris/nusantara-valid/tree/master/dist/umd/nusantara-valid.min.js) | ||
[![Extended JS gzip size](https://img.badgesize.io/agraris/nusantara-valid/master/dist/umd/nusantara-valid.extended.min.js?compression=gzip&label=Extended%20JS%20gzip%20size)](https://github.com/agraris/nusantara-valid/tree/master/dist/umd/nusantara-valid.extended.min.js) | ||
[![Code license](https://img.shields.io/github/license/agraris/nusantara-valid)](#license) | ||
</br> | ||
</br> | ||
<p align="center"> | ||
@@ -13,4 +18,6 @@ <img src="https://magicjar.github.io/assets/images/portfolios/nusantara-valid-logo.svg" alt="Nusantara Valid logo" width=72 height=72> | ||
- [Getting started](#getting-started) | ||
- [What's included](#whats-included) | ||
- [Usage](#usage) | ||
- [API](#api) | ||
- [API (Extended Only)](#api-extended-only) | ||
- [License](#license) | ||
@@ -30,3 +37,3 @@ | ||
- Telephon Number | ||
- Zip Code | ||
- ZIP Code (Kode Pos) | ||
@@ -36,6 +43,6 @@ ## **Getting started** | ||
There are some ways to import the package | ||
- [Download the latest release.](https://github.com/magicjar/nusantara-valid/releases) | ||
- [Download the latest release.](https://github.com/agraris/nusantara-valid/releases) | ||
- Clone the repo: | ||
`git clone https://github.com/magicjar/nusantara-valid.git` | ||
`git clone https://github.com/agraris/nusantara-valid.git` | ||
@@ -46,11 +53,49 @@ - Install with [npm](https://www.npmjs.com/): | ||
- or CDN from [jsDelivr](https://www.jsdelivr.com) | ||
- CDN from [jsDelivr](https://www.jsdelivr.com) | ||
[https://cdn.jsdelivr.net/npm/nusantara-valid@0.2.0/dist/umd/nusantara-valid.min.js](https://cdn.jsdelivr.net/npm/nusantara-valid@0.2.0/dist/umd/nusantara-valid.min.js) | ||
[https://cdn.jsdelivr.net/npm/nusantara-valid@0.3.0/dist/umd/nusantara-valid.min.js](https://cdn.jsdelivr.net/npm/nusantara-valid@0.3.0/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.mjs** - ES 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** | ||
@@ -67,3 +112,3 @@ | ||
``` javascript | ||
import NusantaraValid from './node_modules/nusantara-valid/dist/esm/nusantara-valid.mjs' | ||
import NusantaraValid from './node_modules/nusantara-valid/dist/esm/nusantara-valid.js' | ||
``` | ||
@@ -82,3 +127,3 @@ | ||
``` html | ||
<script src="https://cdn.jsdelivr.net/npm/nusantara-valid@0.2.0/dist/umd/nusantara-valid.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/nusantara-valid@0.3.0/dist/umd/nusantara-valid.min.js"></script> | ||
``` | ||
@@ -88,162 +133,365 @@ | ||
### ATM Number (Nomor Rekening) | ||
<table><tbody><tr><td><details><summary><b>ATM Number (Nomor Rekening)</b> | ||
``` javascript | ||
isValidATMNumber(atm: string); // boolean | ||
isValidATMNumber(atm: string); | ||
isValidATMNumberWithComparison(atm: string, bankKey: string); | ||
``` | ||
</summary> | ||
Result: | ||
``` javascript | ||
isValidATMNumber('87.800.000.00'); | ||
// true | ||
isValidATMNumberWithComparison(atm: string, bankKey: string); // boolean | ||
isValidATMNumberWithComparison('1230005123000', 'MDRK'); | ||
// true | ||
``` | ||
</details></td></tr></tbody></table> | ||
### Bank | ||
<table><tbody><tr><td><details><summary><b>Bank</b> | ||
``` javascript | ||
getDataBank(bankKey: string); // object | ||
getDataBank(bankKey: string); | ||
getDataBanks(); | ||
``` | ||
</summary> | ||
Result: | ||
``` javascript | ||
getDataBank('BCAK'); | ||
// { key: 'BCAK', name: 'Bank Central Asia' } | ||
getDataBanks(); // array of object | ||
getDataBanks(); | ||
// [ | ||
// { key: 'BCAK', name: 'Bank Central Asia' }, | ||
// { key: 'BCAS', name: 'Bank Central Asia Syariah' }, | ||
// { key: 'BNIK', name: 'Bank Negara Indonesia' }, | ||
// ... | ||
// ] | ||
``` | ||
</details></td></tr></tbody></table> | ||
### Cellular Number (Nomor HP) | ||
<table><tbody><tr><td><details><summary><b>Cellular Number (Nomor HP)</b> | ||
``` javascript | ||
isValidCellularNumber(cel: string); // boolean | ||
isValidCellularNumber(cel: string); | ||
isValidCellularNumberWithComparison(cel: string, providerKey: string); | ||
getDataCellularNumber(cel: string); | ||
formatCellularNumber(cel: string, int:boolean = false) | ||
``` | ||
</summary> | ||
Result: | ||
``` javascript | ||
isValidCellularNumber('081212341234'); | ||
// true | ||
isValidCellularNumberWithComparison(cel: string, providerKey: string); // boolean | ||
isValidCellularNumberWithComparison('081212341234', 'TELKOMSEL'); | ||
// true | ||
// You should validate the cellular number before retriving the data | ||
getDataCellularNumber(cel: string); // object | ||
getDataCellularNumber('085612341234'); | ||
// { | ||
// "number": "0856-1234-1234", | ||
// "provider": { | ||
// "key": "INDOSAT", | ||
// "name": "Indosat Ooredoo" | ||
// } | ||
// } | ||
// You should validate the cellular number before formating | ||
formatCellularNumber(cel: string, int:boolean = false) // string | ||
formatCellularNumber('+6281812341234'); // 0818-1234-1234 | ||
formatCellularNumber('085612341234', true); // +62856-1234-1234 | ||
formatCellularNumber('+6281812341234'); | ||
// '0818-1234-1234' | ||
formatCellularNumber('085612341234', true); | ||
// '+62856-1234-1234' | ||
``` | ||
</details></td></tr></tbody></table> | ||
### Cellular Provider | ||
<table><tbody><tr><td><details><summary><b>Cellular Provider</b> | ||
``` javascript | ||
getDataCellularProvider(key: string); // object | ||
getDataCellularProvider(key: string); | ||
getDataCellularProviders(); | ||
``` | ||
</summary> | ||
Result: | ||
``` javascript | ||
getDataCellularProvider('TELKOMSEL'); | ||
// { "key": "TELKOMSEL", "name": "Telkomsel" } | ||
getDataCellularProviders(); // array of object | ||
getDataCellularProviders(); | ||
// [ | ||
// { key: 'TELKOMSEL', name: 'Telkomsel' }, | ||
// { key: 'INDOSAT', name: 'Indosat Ooredoo' }, | ||
// { key: 'XL', name: 'XL Axiata' }, | ||
// ... | ||
// ] | ||
``` | ||
</details></td></tr></tbody></table> | ||
### Credit Card Number | ||
<table><tbody><tr><td><details><summary><b>Credit Card Number</b> | ||
``` javascript | ||
isValidCCNumber(cc: string); // boolean | ||
isValidCCNumber(cc: string); | ||
formatCCNumber(cc: string); | ||
``` | ||
</summary> | ||
Result: | ||
``` javascript | ||
isValidCCNumber('4000123456789010'); | ||
// true | ||
isValidCCNumber('5000 1234 5678 9010'); | ||
// true | ||
// You should validate the CC number before formating | ||
formatCCNumber(cc: string); // string | ||
formatCCNumber('4000123456789010'); // 4000 1234 5678 9010 | ||
formatCCNumber('5000 1234 5678 9010'); // 5000 1234 5678 9010 | ||
formatCCNumber('4000123456789010'); | ||
// '4000 1234 5678 9010' | ||
formatCCNumber('5000 1234 5678 9010'); | ||
// '5000 1234 5678 9010' | ||
``` | ||
</details></td></tr></tbody></table> | ||
<table><tbody><tr><td><details><summary><b>E-Mail</b> | ||
``` javascript | ||
isValidEmail(email: string); // boolean | ||
isValidEmail(email: string); | ||
``` | ||
</summary> | ||
Result: | ||
``` javascript | ||
isValidEmail('myawesom-email@domain.tld'); | ||
// true | ||
``` | ||
</details></td></tr></tbody></table> | ||
### Nomor Induk Kependudukan (NIK) | ||
<table><tbody><tr><td><details><summary><b>Nomor Induk Kependudukan (NIK)</b> | ||
``` javascript | ||
isValidNIK(nik: string); // boolean | ||
isValidNIK(nik: string); | ||
isValidNIKWithComparison(nik: string, comparison: { provinceKy?: string, birthday?: string }); | ||
getDataNIK(nik: string); | ||
``` | ||
</summary> | ||
Result: | ||
``` javascript | ||
isValidNIK('3101011212930001'); | ||
// true | ||
isValidNIKWithComparison(nik: string, comparison: { provinceKy?: string, birthday?: string }); // boolean | ||
isValidNIKWithComparison('3101011212930001', { provinceKey: 'JK', birthday: '1993-12-12' }); | ||
isValidNIKWithComparison('3401012012930001', { provinceKey: 'YO' }); | ||
// true | ||
// You should validate the NIK before retriving the data | ||
getDataNIK(nik: string); // object | ||
getDataNIK('3101011212930001'); | ||
// { | ||
// nik: '3101011212930001', | ||
// birthday: 2006-12-20T00:00:00.000Z, | ||
// sex: 'Male', | ||
// province: { | ||
// key: 'JK', | ||
// name: 'Jakarta' | ||
// } | ||
// } | ||
``` | ||
</details></td></tr></tbody></table> | ||
### Nomor Induk Pegawai Negeri Sipil (NIP) | ||
<table><tbody><tr><td><details><summary><b>Nomor Induk Pegawai Negeri Sipil (NIP)</b> | ||
``` javascript | ||
isValidNIP(nip: string); // boolean | ||
isValidNIP(nip: string); | ||
``` | ||
</summary> | ||
Result: | ||
``` javascript | ||
isValidNIP('198512262000051001'); | ||
// true | ||
``` | ||
</details></td></tr></tbody></table> | ||
### Nomor Induk Siswa Nasional (NISN) | ||
<table><tbody><tr><td><details><summary><b>Nomor Induk Siswa Nasional (NISN)</b> | ||
``` javascript | ||
isValidNISN(nisn: string); // boolean | ||
isValidNISN(nisn: string); | ||
``` | ||
</summary> | ||
Result: | ||
``` javascript | ||
isValidNISN('0061230001'); | ||
// true | ||
``` | ||
</details></td></tr></tbody></table> | ||
### Nomor Pokok Wajib Pajak (NPWP) | ||
<table><tbody><tr><td><details><summary><b>Nomor Pokok Wajib Pajak (NPWP)</b> | ||
``` javascript | ||
isValidNPWP(npwp: string); // boolean | ||
isValidNPWP(npwp: string); | ||
formatNPWP(npwp: string); | ||
``` | ||
</summary> | ||
Result: | ||
``` javascript | ||
isValidNPWP('09.123.123.1-123.123'); | ||
// true | ||
isValidNPWP('091231231123123'); | ||
// true | ||
// You should validate the NPWP number before formating | ||
formatNPWP(npwp: string); // string | ||
formatNPWP('091231231123123'); | ||
// '09.123.123.1-123.123' | ||
``` | ||
</details></td></tr></tbody></table> | ||
### Province | ||
<table><tbody><tr><td><details><summary><b>Province</b> | ||
``` javascript | ||
getDataProvince(key: string); // object | ||
getDataProvince(key: string); | ||
getDataProvinces(); | ||
``` | ||
</summary> | ||
Result: | ||
``` javascript | ||
getDataProvince('YO'); | ||
// { key: 'YO', name: 'Yogyakarta' } | ||
getDataProvinces(); // array of object | ||
getDataProvinces(); | ||
// [ | ||
// { key: 'AC', name: 'Aceh' }, | ||
// { key: 'BA', name: 'Bali' }, | ||
// { key: 'BB', name: 'Kepulauan Bangka Belitung' }, | ||
// ... | ||
// ] | ||
``` | ||
</details></td></tr></tbody></table> | ||
### Tanda Nomor Kendaraan Bermotor (TNKB) | ||
<table><tbody><tr><td><details><summary><b>Tanda Nomor Kendaraan Bermotor (TNKB)</b> | ||
``` javascript | ||
isValidTNKB(tnkb: string); // boolean | ||
isValidTNKB(tnkb: string); | ||
getDataTNKB(tnkb: string); | ||
``` | ||
</summary> | ||
Result: | ||
``` javascript | ||
isValidTNKB('AB1234XYZ'); | ||
// true | ||
// You should validate the TNKB number before retriving the data | ||
getDataTNKB(tnkb: string); // object | ||
getDataTNKB('AB1234XYZ'); | ||
// { | ||
// areaCode: 'AB', | ||
// index: 1234, | ||
// detailedAreaCode: 'XYZ', | ||
// province: { | ||
// key: 'YO', | ||
// name: 'Yogyakarta' | ||
// } | ||
// } | ||
``` | ||
</details></td></tr></tbody></table> | ||
### Telephone Number (Nomor Telefon) | ||
<table><tbody><tr><td><details><summary><b>Telephone Number (Nomor Telefon)</b> | ||
``` javascript | ||
isValidTelephoneNumber(tel: string); // boolean | ||
isValidTelephoneNumber(tel: string); | ||
getDataTelephoneNumber(cel: string); | ||
formatTelephoneNumber(tel: string, int:boolean = false) | ||
``` | ||
</summary> | ||
Result: | ||
``` javascript | ||
isValidTelephoneNumber('0274123123'); | ||
// true | ||
// You should validate the telephone number before retriving the data | ||
getDataTelephoneNumber(cel: string); // object | ||
getDataTelephoneNumber('0274123123'); | ||
// { | ||
// "number": "0274-123123", | ||
// "origin": { | ||
// "key": "YO", | ||
// "name": "Yogyakarta" | ||
// } | ||
// } | ||
// You should validate the telephone number before formating | ||
formatTelephoneNumber(tel: string, int:boolean = false) // string | ||
formatTelephoneNumber('0274123123'); // 0274-123123 | ||
formatTelephoneNumber('0274123123', true); // +62274-123123 | ||
formatTelephoneNumber('0274123123'); | ||
// '0274-123123' | ||
formatTelephoneNumber('0274123123', true); | ||
// '+62274-123123' | ||
``` | ||
</details></td></tr></tbody></table> | ||
### ZIP Code (Kode POS) | ||
<table><tbody><tr><td><details><summary><b>ZIP Code (Kode POS)</b> | ||
``` javascript | ||
isValidZIP(zip: string | number); // boolean | ||
isValidZIP('55524'); | ||
isValidZIP(55524); | ||
isValidZIP(zip: string | number); | ||
isValidZIPWithComparison(zip: string | number, comparison: { provinceKy?: string }); // boolean | ||
isValidZIPWithComparison('55524', { provinceKey: 'YO' }); | ||
isValidZIPWithComparison(55524, { provinceKey: 'YO' }); | ||
isValidZIPWithComparison(zip: string | number, comparison: { provinceKy?: string }); | ||
``` | ||
</summary> | ||
Result: | ||
``` javascript | ||
isValidZIP('55264'); | ||
// true | ||
isValidZIP(55264); | ||
// true | ||
isValidZIPWithComparison('55264', { provinceKey: 'YO' }); | ||
// true | ||
isValidZIPWithComparison(55264, { provinceKey: 'YO' }); | ||
// true | ||
``` | ||
</details></td></tr></tbody></table> | ||
## **API (Extended Only)** | ||
<table><tbody><tr><td><details><summary><b>Province</b> | ||
``` javascript | ||
getDataRegenciesInProvince(provinceBPSCode: string); | ||
getDataDistrictsInRegency(regencyBPSCode: string); | ||
``` | ||
</summary> | ||
Result: | ||
``` javascript | ||
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' }, | ||
// ... | ||
// ] | ||
``` | ||
</details></td></tr></tbody></table> | ||
## **License** | ||
Copyright (c) 2020 - Fajar Setya Budi | ||
Copyright (c) 2020 - Fajar Setya Budi. | ||
Nusantara Valid released under the [MIT License](https://github.com/magicjar/nusantara-valid/blob/master/LICENSE). | ||
Nusantara Valid released under the [MIT License](https://github.com/agraris/nusantara-valid/blob/master/LICENSE). |
/** | ||
* Nusantara Valid: bank.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
import { includes } from '../helpers'; | ||
/** | ||
* BANK_DATA | ||
* | ||
* List of bank in Indonesia including BPS code, vehicle plate, | ||
* telephone numbers, and zip code. | ||
* List of bank in Indonesia. | ||
**/ | ||
export const BANK_DATA = | ||
export const BANK_DATA : { [key: string]: any } = | ||
{ | ||
@@ -18,3 +19,3 @@ BCAK: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -24,3 +25,3 @@ BCAS: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -30,3 +31,3 @@ BNIK: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -36,3 +37,3 @@ BNIS: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -42,3 +43,3 @@ BRIK: { | ||
digits: 15, | ||
dotIndex: [] | ||
dotIndex: [2, 5, 8, 11] | ||
}, | ||
@@ -48,3 +49,3 @@ BRIS: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -104,3 +105,3 @@ BTNK: { | ||
digits: 13, | ||
dotIndex: [] | ||
dotIndex: [2, 5, 8] | ||
}, | ||
@@ -110,3 +111,3 @@ MDRS: { | ||
digits: 10, | ||
dotIndex: [] | ||
dotIndex: [2, 5] | ||
}, | ||
@@ -151,3 +152,16 @@ MGAK: { | ||
export type Bank = keyof typeof BANK_DATA; | ||
export const BANK_KEYS = Object.keys(BANK_DATA) as Bank[]; | ||
/** | ||
* BANK_KEYS | ||
* | ||
* List of bank object keys. | ||
**/ | ||
export const BANK_KEYS = Object.keys(BANK_DATA); | ||
/** | ||
* BANK_NUMBER_LENGTHS | ||
* | ||
* List of bank's number (ATM number) length. | ||
**/ | ||
export const BANK_NUMBER_LENGTHS = BANK_KEYS.reduce( | ||
(pref, curr) => includes(pref, BANK_DATA[curr].digits) ? pref : pref.concat(BANK_DATA[curr].digits), [] | ||
) |
/** | ||
* Nusantara Valid: cellular.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -14,3 +14,3 @@ | ||
**/ | ||
export const CELLULAR_PROVIDER_DATA = | ||
export const CELLULAR_PROVIDER_DATA : { [key: string]: any } = | ||
{ | ||
@@ -65,3 +65,16 @@ TELKOMSEL: { | ||
export type CellularProvider = keyof typeof CELLULAR_PROVIDER_DATA; | ||
export const CELLULAR_PROVIDER_KEYS = Object.keys(CELLULAR_PROVIDER_DATA) as CellularProvider[]; | ||
/** | ||
* CELLULAR_PROVIDER_KEYS | ||
* | ||
* List of cellular provider object keys. | ||
**/ | ||
export const CELLULAR_PROVIDER_KEYS = Object.keys(CELLULAR_PROVIDER_DATA); | ||
/** | ||
* CELLULAR_PROVIDER_PREFIXES | ||
* | ||
* List of cellular provider prefixes. | ||
**/ | ||
export const CELLULAR_PROVIDER_PREFIXES = CELLULAR_PROVIDER_KEYS.reduce( | ||
(a, b) => a.concat(CELLULAR_PROVIDER_DATA[b].prefix), [] | ||
) |
/** | ||
* Nusantara Valid: creditCard.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -6,0 +6,0 @@ |
/** | ||
* Nusantara Valid: email.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -6,0 +6,0 @@ |
/** | ||
* Nusantara Valid: nik.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -12,4 +12,4 @@ | ||
* NIK_REGEX[1] = 2 digits of Province Code (BPS Code) | ||
* NIK_REGEX[2] = 2 digits of City or Distric Code | ||
* NIK_REGEX[3] = 2 digits of Sub Distric Code | ||
* NIK_REGEX[2] = 2 digits of Regency Code | ||
* NIK_REGEX[3] = 2 digits of Distric Code | ||
* NIK_REGEX[4] = 6 digits of Birthday with DDMMYY format, for woman DD + 40 | ||
@@ -16,0 +16,0 @@ * NIK_REGEX[5] = 4 digits of Index |
/** | ||
* Nusantara Valid: nip.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -6,0 +6,0 @@ |
/** | ||
* Nusantara Valid: nisn.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -6,0 +6,0 @@ |
/** | ||
* Nusantara Valid: npwp.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -6,0 +6,0 @@ |
/** | ||
* Nusantara Valid: province.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -15,7 +15,7 @@ | ||
**/ | ||
export const PROVINCE_DATA = | ||
export const PROVINCE_DATA : { [key: string]: any } = | ||
{ | ||
AC: { | ||
'11': { | ||
name: 'Aceh', | ||
bpsCode: 11, | ||
bpsCode: '11', | ||
vehiclePlate: ['BL'], | ||
@@ -30,68 +30,41 @@ tel: range(641, 659).concat([627, 629]), | ||
}, | ||
BA: { | ||
name: 'Bali', | ||
bpsCode: 51, | ||
vehiclePlate: ['DK'], | ||
tel: range(361, 368), | ||
'12': { | ||
name: 'Sumatra Utara', | ||
bpsCode: '12', | ||
vehiclePlate: ['BB', 'BK'], | ||
tel: range(620, 639).concat([601]), | ||
zipCode: [ | ||
{ | ||
from: 80111, | ||
to: 82262 | ||
from: 20111, | ||
to: 22999 | ||
} | ||
] | ||
}, | ||
BB: { | ||
name: 'Kepulauan Bangka Belitung', | ||
bpsCode: 19, | ||
vehiclePlate: ['BN'], | ||
tel: range(715, 719), | ||
'13': { | ||
name: 'Sumatra Barat', | ||
bpsCode: '13', | ||
vehiclePlate: ['BA'], | ||
tel: range(751, 759), | ||
zipCode: [ | ||
{ | ||
from: 33111, | ||
to: 33792 | ||
from: 25111, | ||
to: 27779 | ||
} | ||
] | ||
}, | ||
BE: { | ||
name: 'Bengkulu', | ||
bpsCode: 17, | ||
vehiclePlate: ['BD'], | ||
tel: range(736, 739).concat([732]), | ||
'14': { | ||
name: 'Riau', | ||
bpsCode: '14', | ||
vehiclePlate: ['BM'], | ||
tel: range(760, 769).concat([624]), | ||
zipCode: [ | ||
{ | ||
from: 38113, | ||
to: 39377 | ||
from: 28111, | ||
to: 29569 | ||
} | ||
] | ||
}, | ||
BT: { | ||
name: 'Banten', | ||
bpsCode: 36, | ||
vehiclePlate: ['A'], | ||
tel: range(252, 257), | ||
zipCode: [ | ||
{ | ||
from: 15111, | ||
to: 15820 | ||
}, { | ||
from: 42111, | ||
to: 42455 | ||
} | ||
] | ||
}, | ||
GO: { | ||
name: 'Gorontalo', | ||
bpsCode: 75, | ||
vehiclePlate: ['DM'], | ||
tel: [435, 443], | ||
zipCode: [ | ||
{ | ||
from: 96111, | ||
to: 96574 | ||
} | ||
] | ||
}, | ||
JA: { | ||
'15': { | ||
name: 'Jambi', | ||
bpsCode: 15, | ||
bpsCode: '15', | ||
vehiclePlate: ['BH'], | ||
@@ -106,167 +79,160 @@ tel: range(740, 748), | ||
}, | ||
JB: { | ||
name: 'Jawa Barat', | ||
bpsCode: 32, | ||
vehiclePlate: ['D', 'E', 'F', 'T', 'Z'], | ||
tel: range(231, 234).concat(range(260, 267)).concat([22, 251]), | ||
'16': { | ||
name: 'Sumatra Selatan', | ||
bpsCode: '16', | ||
vehiclePlate: ['BG'], | ||
tel: range(711, 714).concat(range(730, 735)).concat([702]), | ||
zipCode: [ | ||
{ | ||
from: 16110, | ||
to: 17730 | ||
}, { | ||
from: 40111, | ||
to: 46476 | ||
from: 30111, | ||
to: 32388 | ||
} | ||
] | ||
}, | ||
JI: { | ||
name: 'Jawa Timur', | ||
bpsCode: 35, | ||
vehiclePlate: ['L', 'M', 'N', 'P', 'S', 'W', 'AE', 'AG'], | ||
tel: range(321, 358).concat([31]), | ||
'17': { | ||
name: 'Bengkulu', | ||
bpsCode: '17', | ||
vehiclePlate: ['BD'], | ||
tel: range(736, 739).concat([732]), | ||
zipCode: [ | ||
{ | ||
from: 60111, | ||
to: 69493 | ||
from: 38113, | ||
to: 39377 | ||
} | ||
] | ||
}, | ||
JK: { | ||
name: 'Jakarta', | ||
bpsCode: 31, | ||
vehiclePlate: ['B'], | ||
tel: [21], | ||
'18': { | ||
name: 'Lampung', | ||
bpsCode: '18', | ||
vehiclePlate: ['BE'], | ||
tel: range(721, 729), | ||
zipCode: [ | ||
{ | ||
from: 10110, | ||
to: 14540 | ||
from: 34111, | ||
to: 35686 | ||
} | ||
] | ||
}, | ||
JT: { | ||
name: 'Jawa Tengah', | ||
bpsCode: 33, | ||
vehiclePlate: ['G', 'H', 'K', 'R', 'AA', 'AD'], | ||
tel: range(275, 299).concat(range(271, 273)).concat([24, 356]), | ||
'19': { | ||
name: 'Kepulauan Bangka Belitung', | ||
bpsCode: '19', | ||
vehiclePlate: ['BN'], | ||
tel: range(715, 719), | ||
zipCode: [ | ||
{ | ||
from: 50111, | ||
to: 54474 | ||
}, { | ||
from: 56111, | ||
to: 59584 | ||
from: 33111, | ||
to: 33792 | ||
} | ||
] | ||
}, | ||
KB: { | ||
name: 'Kalimantan Barat', | ||
bpsCode: 61, | ||
vehiclePlate: ['KB'], | ||
tel: range(564, 568).concat([534]), | ||
'21': { | ||
name: 'Kepulauan Riau', | ||
bpsCode: '21', | ||
vehiclePlate: ['BP'], | ||
tel: range(771, 779), | ||
zipCode: [ | ||
{ | ||
from: 78111, | ||
to: 79682 | ||
from: 29111, | ||
to: 29878 | ||
} | ||
] | ||
}, | ||
KI: { | ||
name: 'Kalimantan Timur', | ||
bpsCode: 64, | ||
vehiclePlate: ['KT'], | ||
tel: range(541, 556), | ||
'31': { | ||
name: 'Jakarta', | ||
bpsCode: '31', | ||
vehiclePlate: ['B'], | ||
tel: [21], | ||
zipCode: [ | ||
{ | ||
from: 75111, | ||
to: 77381 | ||
from: 10110, | ||
to: 14540 | ||
} | ||
] | ||
}, | ||
KR: { | ||
name: 'Kepulauan Riau', | ||
bpsCode: 21, | ||
vehiclePlate: ['BP'], | ||
tel: range(771, 779), | ||
'32': { | ||
name: 'Jawa Barat', | ||
bpsCode: '32', | ||
vehiclePlate: ['D', 'E', 'F', 'T', 'Z'], | ||
tel: range(231, 234).concat(range(260, 267)).concat([22, 251]), | ||
zipCode: [ | ||
{ | ||
from: 29111, | ||
to: 29878 | ||
from: 16110, | ||
to: 17730 | ||
}, { | ||
from: 40111, | ||
to: 46476 | ||
} | ||
] | ||
}, | ||
KS: { | ||
name: 'Kalimantan Selatan', | ||
bpsCode: 63, | ||
vehiclePlate: ['DA'], | ||
tel: range(511, 527), | ||
'33': { | ||
name: 'Jawa Tengah', | ||
bpsCode: '33', | ||
vehiclePlate: ['G', 'H', 'K', 'R', 'AA', 'AD'], | ||
tel: range(275, 299).concat(range(271, 273)).concat([24, 356]), | ||
zipCode: [ | ||
{ | ||
from: 70111, | ||
to: 72276 | ||
from: 50111, | ||
to: 54474 | ||
}, { | ||
from: 56111, | ||
to: 59584 | ||
} | ||
] | ||
}, | ||
KT: { | ||
name: 'Kalimantan Tengah', | ||
bpsCode: 62, | ||
vehiclePlate: ['KH'], | ||
tel: range(513, 539), | ||
'34': { | ||
name: 'Yogyakarta', | ||
bpsCode: '34', | ||
vehiclePlate: ['AB'], | ||
tel: [274], | ||
zipCode: [ | ||
{ | ||
from: 73111, | ||
to: 74874 | ||
from: 55111, | ||
to: 55893 | ||
} | ||
] | ||
}, | ||
KU: { | ||
name: 'Kalimantan Utara', | ||
bpsCode: 65, | ||
vehiclePlate: ['KU'], | ||
tel: range(551, 556), | ||
'35': { | ||
name: 'Jawa Timur', | ||
bpsCode: '35', | ||
vehiclePlate: ['L', 'M', 'N', 'P', 'S', 'W', 'AE', 'AG'], | ||
tel: range(321, 358).concat([31]), | ||
zipCode: [ | ||
{ | ||
from: 77111, | ||
to: 77574 | ||
from: 60111, | ||
to: 69493 | ||
} | ||
] | ||
}, | ||
LA: { | ||
name: 'Lampung', | ||
bpsCode: 18, | ||
vehiclePlate: ['BE'], | ||
tel: range(721, 729), | ||
'36': { | ||
name: 'Banten', | ||
bpsCode: '36', | ||
vehiclePlate: ['A'], | ||
tel: range(252, 257), | ||
zipCode: [ | ||
{ | ||
from: 34111, | ||
to: 35686 | ||
from: 15111, | ||
to: 15820 | ||
}, { | ||
from: 42111, | ||
to: 42455 | ||
} | ||
] | ||
}, | ||
MA: { | ||
name: 'Maluku', | ||
bpsCode: 81, | ||
vehiclePlate: ['DE'], | ||
tel: range(910, 931), | ||
'51': { | ||
name: 'Bali', | ||
bpsCode: '51', | ||
vehiclePlate: ['DK'], | ||
tel: range(361, 368), | ||
zipCode: [ | ||
{ | ||
from: 97114, | ||
to: 97669 | ||
from: 80111, | ||
to: 82262 | ||
} | ||
] | ||
}, | ||
MU: { | ||
name: 'Maluku Utara', | ||
bpsCode: 82, | ||
vehiclePlate: ['DG'], | ||
tel: range(910, 931), | ||
zipCode: [ | ||
{ | ||
from: 97711, | ||
to: 97869 | ||
} | ||
] | ||
}, | ||
NB: { | ||
'52': { | ||
name: 'Nusa Tenggara Barat', | ||
bpsCode: 52, | ||
bpsCode: '52', | ||
vehiclePlate: ['DR', 'EA'], | ||
@@ -281,5 +247,5 @@ tel: range(370, 376).concat([364]), | ||
}, | ||
NT: { | ||
'53': { | ||
name: 'Nusa Tenggara Timur', | ||
bpsCode: 53, | ||
bpsCode: '53', | ||
vehiclePlate: ['DH', 'EB', 'ED'], | ||
@@ -294,41 +260,67 @@ tel: range(380, 389), | ||
}, | ||
PA: { | ||
name: 'Papua', | ||
bpsCode: 94, | ||
vehiclePlate: ['PA'], | ||
tel: range(951, 986).concat([901, 902]), | ||
'61': { | ||
name: 'Kalimantan Barat', | ||
bpsCode: '61', | ||
vehiclePlate: ['KB'], | ||
tel: range(564, 568).concat([534]), | ||
zipCode: [ | ||
{ | ||
from: 98511, | ||
to: 99976 | ||
from: 78111, | ||
to: 79682 | ||
} | ||
] | ||
}, | ||
PB: { | ||
name: 'Papua Barat', | ||
bpsCode: 91, | ||
vehiclePlate: ['PB'], | ||
tel: range(951, 986).concat([901, 902]), | ||
'62': { | ||
name: 'Kalimantan Tengah', | ||
bpsCode: '62', | ||
vehiclePlate: ['KH'], | ||
tel: range(513, 539), | ||
zipCode: [ | ||
{ | ||
from: 98011, | ||
to: 98495 | ||
from: 73111, | ||
to: 74874 | ||
} | ||
] | ||
}, | ||
RI: { | ||
name: 'Riau', | ||
bpsCode: 14, | ||
vehiclePlate: ['BM'], | ||
tel: range(760, 769).concat([624]), | ||
'63': { | ||
name: 'Kalimantan Selatan', | ||
bpsCode: '63', | ||
vehiclePlate: ['DA'], | ||
tel: range(511, 527), | ||
zipCode: [ | ||
{ | ||
from: 28111, | ||
to: 29569 | ||
from: 70111, | ||
to: 72276 | ||
} | ||
] | ||
}, | ||
SA: { | ||
'64': { | ||
name: 'Kalimantan Timur', | ||
bpsCode: '64', | ||
vehiclePlate: ['KT'], | ||
tel: range(541, 556), | ||
zipCode: [ | ||
{ | ||
from: 75111, | ||
to: 77381 | ||
} | ||
] | ||
}, | ||
'65': { | ||
name: 'Kalimantan Utara', | ||
bpsCode: '65', | ||
vehiclePlate: ['KU'], | ||
tel: range(551, 556), | ||
zipCode: [ | ||
{ | ||
from: 77111, | ||
to: 77574 | ||
} | ||
] | ||
}, | ||
'71': { | ||
name: 'Sulawesi Utara', | ||
bpsCode: 71, | ||
bpsCode: '71', | ||
vehiclePlate: ['DB', 'DL'], | ||
@@ -343,17 +335,32 @@ tel: range(430, 438), | ||
}, | ||
SB: { | ||
name: 'Sumatra Barat', | ||
bpsCode: 13, | ||
vehiclePlate: ['BA'], | ||
tel: range(751, 759), | ||
'72': { | ||
name: 'Sulawesi Tengah', | ||
bpsCode: '72', | ||
vehiclePlate: ['DN'], | ||
tel: range(445, 465), | ||
zipCode: [ | ||
{ | ||
from: 25111, | ||
to: 27779 | ||
from: 94111, | ||
to: 94981 | ||
} | ||
] | ||
}, | ||
SG: { | ||
'73': { | ||
name: 'Sulawesi Selatan', | ||
bpsCode: '73', | ||
vehiclePlate: ['DD', 'DP', 'DW'], | ||
tel: range(410, 421).concat(range(471, 485)).concat([423, 427]), | ||
zipCode: [ | ||
{ | ||
from: 90111, | ||
to: 91273 | ||
}, { | ||
from: 91611, | ||
to: 92985 | ||
} | ||
] | ||
}, | ||
'74': { | ||
name: 'Sulawesi Tenggara', | ||
bpsCode: 74, | ||
bpsCode: '74', | ||
vehiclePlate: ['DT'], | ||
@@ -368,20 +375,17 @@ tel: range(401, 408), | ||
}, | ||
SN: { | ||
name: 'Sulawesi Selatan', | ||
bpsCode: 73, | ||
vehiclePlate: ['DD', 'DP', 'DW'], | ||
tel: range(410, 421).concat(range(471, 485)).concat([423, 427]), | ||
'75': { | ||
name: 'Gorontalo', | ||
bpsCode: '75', | ||
vehiclePlate: ['DM'], | ||
tel: [435, 443], | ||
zipCode: [ | ||
{ | ||
from: 90111, | ||
to: 91273 | ||
}, { | ||
from: 91611, | ||
to: 92985 | ||
from: 96111, | ||
to: 96574 | ||
} | ||
] | ||
}, | ||
SR: { | ||
'76': { | ||
name: 'Sulawesi Barat', | ||
bpsCode: 76, | ||
bpsCode: '76', | ||
vehiclePlate: ['DC'], | ||
@@ -396,47 +400,49 @@ tel: [422, 426, 428], | ||
}, | ||
SS: { | ||
name: 'Sumatra Selatan', | ||
bpsCode: 16, | ||
vehiclePlate: ['BG'], | ||
tel: range(711, 714).concat(range(730, 735)).concat([702]), | ||
'81': { | ||
name: 'Maluku', | ||
bpsCode: '81', | ||
vehiclePlate: ['DE'], | ||
tel: range(910, 931), | ||
zipCode: [ | ||
{ | ||
from: 30111, | ||
to: 32388 | ||
from: 97114, | ||
to: 97669 | ||
} | ||
] | ||
}, | ||
ST: { | ||
name: 'Sulawesi Tengah', | ||
bpsCode: 72, | ||
vehiclePlate: ['DN'], | ||
tel: range(445, 465), | ||
'82': { | ||
name: 'Maluku Utara', | ||
bpsCode: '82', | ||
vehiclePlate: ['DG'], | ||
tel: range(910, 931), | ||
zipCode: [ | ||
{ | ||
from: 94111, | ||
to: 94981 | ||
from: 97711, | ||
to: 97869 | ||
} | ||
] | ||
}, | ||
SU: { | ||
name: 'Sumatra Utara', | ||
bpsCode: 12, | ||
vehiclePlate: ['BB', 'BK'], | ||
tel: range(620, 639).concat([601]), | ||
'91': { | ||
name: 'Papua Barat', | ||
bpsCode: '91', | ||
vehiclePlate: ['PB'], | ||
tel: range(951, 986).concat([901, 902]), | ||
zipCode: [ | ||
{ | ||
from: 20111, | ||
to: 22999 | ||
from: 98011, | ||
to: 98495 | ||
} | ||
] | ||
}, | ||
YO: { | ||
name: 'Yogyakarta', | ||
bpsCode: 34, | ||
vehiclePlate: ['AB'], | ||
tel: [274], | ||
'92': { | ||
name: 'Papua', | ||
bpsCode: '92', | ||
vehiclePlate: ['PA'], | ||
tel: range(951, 986).concat([901, 902]), | ||
zipCode: [ | ||
{ | ||
from: 55111, | ||
to: 55893 | ||
from: 98511, | ||
to: 99976 | ||
} | ||
@@ -454,3 +460,2 @@ ] | ||
export type Province = keyof typeof PROVINCE_DATA; | ||
export const PROVINCE_KEYS = Object.keys(PROVINCE_DATA) as Province[]; | ||
export const PROVINCE_KEYS = Object.keys(PROVINCE_DATA) |
/** | ||
* Nusantara Valid: tnkb.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -6,0 +6,0 @@ |
import { IValid } from "../interface" | ||
import { numbersOnly, correctLength, includes } from "../helpers" | ||
import { BANK_DATA, BANK_KEYS } from "../datas/bank" | ||
import { numbersOnly, correctLength } from "../helpers" | ||
import { BANK_DATA, BANK_NUMBER_LENGTHS } from "../datas/bank" | ||
@@ -8,3 +8,3 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -14,7 +14,2 @@ * @class The ATMNumber class | ||
class ATMNumber implements IValid { | ||
VALID_ATMNUMBER_LENGTH = BANK_KEYS.reduce( | ||
(pref, curr) => includes(pref, (BANK_DATA as any)[curr].digits) ? pref : pref.concat((BANK_DATA as any)[curr].digits), [] | ||
) as number[] | ||
isValid(atm: string, bank: string = ''): boolean { | ||
@@ -25,8 +20,3 @@ if (!atm || typeof atm !== 'string') return false | ||
let matchLength = correctLength(2, numOnly.length, { collection: this.VALID_ATMNUMBER_LENGTH }) | ||
if (bank) | ||
matchLength = correctLength(0, numOnly.length, { minLength: (BANK_DATA as any)[bank].digits } ) | ||
return matchLength | ||
return bank ? correctLength(0, numOnly.length, { minLength: BANK_DATA[bank].digits }) : correctLength(2, numOnly.length, { collection: BANK_NUMBER_LENGTHS }) | ||
} | ||
@@ -33,0 +23,0 @@ } |
@@ -7,3 +7,3 @@ import { IGetData, IDataBank } from "../interface" | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -19,3 +19,3 @@ * @class The Bank class | ||
key: index, | ||
name: (BANK_DATA as any)[index].name | ||
name: BANK_DATA[index].name | ||
} | ||
@@ -25,3 +25,3 @@ } else { | ||
key, | ||
name: (BANK_DATA as any)[key].name, | ||
name: BANK_DATA[key].name, | ||
})) | ||
@@ -28,0 +28,0 @@ } |
import { IValid, IGetData, IFormat, IDataCellularNumber } from '../interface' | ||
import { cleanPhoneNumbers, correctLength, includes } from '../helpers' | ||
import { CELLULAR_MIN_LENGTH, CELLULAR_MAX_LENGTH, CELLULAR_HYPEN_INDEXES, CELLULAR_PROVIDER_DATA, CELLULAR_PROVIDER_KEYS } from '../datas/cellular' | ||
import { CELLULAR_MIN_LENGTH, CELLULAR_MAX_LENGTH, CELLULAR_HYPEN_INDEXES, CELLULAR_PROVIDER_DATA, CELLULAR_PROVIDER_KEYS, CELLULAR_PROVIDER_PREFIXES } from '../datas/cellular' | ||
import { COUNTRY_CODE } from '../datas/province' | ||
@@ -9,3 +9,3 @@ | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -15,28 +15,14 @@ * @class The CellularNumber class | ||
class CellularNumber implements IValid, IGetData, IFormat { | ||
CELLULAR_PROVIDER_PREFIXES = CELLULAR_PROVIDER_KEYS.reduce( | ||
(a, b) => a.concat((CELLULAR_PROVIDER_DATA as any)[b].prefix), [] | ||
) as number[] | ||
isValid(mobile: string, providerKey: string = ''): boolean { | ||
if (!mobile || typeof mobile !== 'string') return false | ||
let prefixCollection | ||
const cleanCellularNumber = cleanPhoneNumbers(mobile, { cellular: true, countryCode: COUNTRY_CODE}) | ||
const validLength = correctLength(1, cleanCellularNumber.length, { minLength: CELLULAR_MIN_LENGTH, maxLength: CELLULAR_MAX_LENGTH }) | ||
if (providerKey) | ||
prefixCollection = (CELLULAR_PROVIDER_DATA as any)[providerKey].prefix | ||
else | ||
prefixCollection = this.CELLULAR_PROVIDER_PREFIXES | ||
return validLength | ||
&& this.isValidCellularProviderPrefix(Number(cleanCellularNumber.substr(0, 3)), prefixCollection) | ||
let prefixCollection | ||
providerKey ? prefixCollection = CELLULAR_PROVIDER_DATA[providerKey].prefix : prefixCollection = CELLULAR_PROVIDER_PREFIXES | ||
return correctLength(1, cleanCellularNumber.length, { minLength: CELLULAR_MIN_LENGTH, maxLength: CELLULAR_MAX_LENGTH }) | ||
&& includes(prefixCollection, Number(cleanCellularNumber.substr(0, 3))) | ||
} | ||
isValidCellularProviderPrefix(prefix: number, prefixCollection: number[]): boolean { | ||
return includes(prefixCollection, prefix) | ||
} | ||
getData(mobile: string): IDataCellularNumber { | ||
@@ -50,3 +36,3 @@ let data = {} as IDataCellularNumber | ||
for (const key of CELLULAR_PROVIDER_KEYS) { | ||
const cellProvider = (CELLULAR_PROVIDER_DATA as any)[key] | ||
const cellProvider = CELLULAR_PROVIDER_DATA[key] | ||
if (includes(cellProvider.prefix, pfx)) { | ||
@@ -53,0 +39,0 @@ data.provider = { |
@@ -7,3 +7,3 @@ import { IGetData, IDataCellularProvider } from '../interface' | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -19,3 +19,3 @@ * @class The CellularProvider class | ||
key: index, | ||
name: (CELLULAR_PROVIDER_DATA as any)[index].name | ||
name: CELLULAR_PROVIDER_DATA[index].name | ||
} | ||
@@ -25,3 +25,3 @@ } else { | ||
key, | ||
name: (CELLULAR_PROVIDER_DATA as any)[key].name, | ||
name: CELLULAR_PROVIDER_DATA[key].name, | ||
})) | ||
@@ -28,0 +28,0 @@ } |
@@ -8,3 +8,3 @@ import { IValid, IFormat } from "../interface" | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -11,0 +11,0 @@ * @class The CreditCard class |
@@ -8,3 +8,3 @@ import { IValid } from "../interface" | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -11,0 +11,0 @@ * @class The Email class |
@@ -1,5 +0,6 @@ | ||
import { IValid, IGetData, IDataNIK, IDataProvince } from "../interface" | ||
import { IValid, IGetData, IDataNIK } from "../interface" | ||
import { NIK_REGEX, NIK_LENGTH } from "../datas/nik" | ||
import { numbersOnly, correctLength, formatDate, includes } from "../helpers" | ||
import { PROVINCE_DATA, PROVINCE_KEYS } from "../datas/province" | ||
import { PROVINCE_KEYS } from "../datas/province" | ||
import { getDataProvince } from './_province' | ||
@@ -9,12 +10,7 @@ /** | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
* @class The NomorIndukKepemdudukan class | ||
**/ | ||
class NomorIndukKependudukan implements IValid, IGetData { | ||
VALID_BPSCODE = PROVINCE_KEYS.reduce( | ||
(a, b) => a.concat((PROVINCE_DATA as any)[b].bpsCode), [] | ||
) as number[] | ||
export class NomorIndukKependudukan implements IValid, IGetData { | ||
isValid(nik: string, provinceKey: string = '', birthday: string = ''): boolean { | ||
@@ -30,8 +26,7 @@ if (!nik || typeof nik !== 'string') return false | ||
let validProvince = includes(this.VALID_BPSCODE, parseInt(validNIK[1])) | ||
let validProvince = includes(PROVINCE_KEYS, validNIK[1]) | ||
let validBirthday = !isNaN(formatDate('19' + cBirthday).getTime()) | ||
// Comparison | ||
if (provinceKey) { | ||
if ((PROVINCE_DATA as any)[provinceKey].bpsCode != validNIK[1]) { | ||
if (provinceKey != validNIK[1]) { | ||
validProvince = false | ||
@@ -82,18 +77,7 @@ } | ||
const reformatedBirthday = this.reformatBirthday(validNIK[4]) | ||
const validProvince = includes(this.VALID_BPSCODE, parseInt(validNIK[1])) | ||
const validProvince = includes(PROVINCE_KEYS, validNIK[1]) | ||
const validBirthday = !isNaN(formatDate('19' + reformatedBirthday).getTime()) | ||
if (validProvince) { | ||
let province = {} as IDataProvince | ||
for (const key of PROVINCE_KEYS) { | ||
const element = (PROVINCE_DATA as any)[key]; | ||
if (element.bpsCode == validNIK[1]) { | ||
province.key = key, | ||
province.name = element.name | ||
break | ||
} | ||
} | ||
data.province = province | ||
data.province = getDataProvince(validNIK[1]) | ||
} | ||
@@ -100,0 +84,0 @@ |
@@ -8,3 +8,3 @@ import { IValid, IGetData, IDataNIP } from "../interface" | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -11,0 +11,0 @@ * @class The NomorIndukPegawaiNegeriSipil class |
@@ -8,3 +8,3 @@ import { IValid } from "../interface" | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -11,0 +11,0 @@ * @class The NomorIndukSiswaNasional class |
@@ -8,3 +8,3 @@ import { IValid, IFormat } from "../interface" | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -11,0 +11,0 @@ * @class The NomorPokokWajibPajak class |
@@ -7,7 +7,7 @@ import { IGetData, IDataProvince } from "../interface" | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
* @class The Province class | ||
**/ | ||
class Province implements IGetData { | ||
export class Province implements IGetData { | ||
getData(index: string = ''): IDataProvince | IDataProvince[] { | ||
@@ -18,9 +18,9 @@ let province | ||
province = { | ||
key: index, | ||
name: (PROVINCE_DATA as any)[index].name | ||
bpsCode: index, | ||
name: PROVINCE_DATA[index].name | ||
} | ||
} else { | ||
province = PROVINCE_KEYS.map((key) => ({ | ||
key, | ||
name: (PROVINCE_DATA as any)[key].name, | ||
bpsCode: key, | ||
name: PROVINCE_DATA[key].name, | ||
})) | ||
@@ -27,0 +27,0 @@ } |
@@ -9,3 +9,3 @@ import { IValid, IGetData, IDataTNKB } from "../interface" | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -17,3 +17,3 @@ * @class The TandaNomorKendaraanBermotor class | ||
VALID_TNKB_AREACODE = PROVINCE_KEYS.reduce( | ||
(a, b) => a.concat((PROVINCE_DATA as any)[b].vehiclePlate), [] | ||
(a, b) => a.concat(PROVINCE_DATA[b].vehiclePlate), [] | ||
) as string[] | ||
@@ -46,3 +46,3 @@ | ||
for (const key of PROVINCE_KEYS) { | ||
const element = (PROVINCE_DATA as any)[key] | ||
const element = PROVINCE_DATA[key] | ||
if (includes(element.vehiclePlate, validTNKB[1])) { | ||
@@ -54,3 +54,3 @@ data = { | ||
province: { | ||
key: key, | ||
bpsCode: key, | ||
name: element.name | ||
@@ -57,0 +57,0 @@ } |
@@ -8,3 +8,3 @@ import { IValid, IFormat, IGetData, IDataTelephoneNumber } from "../interface"; | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -16,3 +16,3 @@ * @class The TelephoneNumber class | ||
VALID_TELEPHONE_AREACODE = PROVINCE_KEYS.reduce( | ||
(a, b) => a.concat((PROVINCE_DATA as any)[b].tel), [] | ||
(a, b) => a.concat(PROVINCE_DATA[b].tel), [] | ||
) as number[] | ||
@@ -52,6 +52,6 @@ | ||
for (const key of PROVINCE_KEYS) { | ||
const element = (PROVINCE_DATA as any)[key] | ||
const element = PROVINCE_DATA[key] | ||
if (includes(element.tel, pfx)) { | ||
data.origin = { | ||
key: key, | ||
bpsCode: key, | ||
name: element.name | ||
@@ -58,0 +58,0 @@ } |
@@ -8,3 +8,3 @@ import { IValid } from "../interface" | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
* | ||
@@ -15,4 +15,4 @@ * @class The ZIPCode class | ||
ZIP_RANGE = PROVINCE_KEYS.reduce( | ||
(a, b) => a.concat((PROVINCE_DATA as any)[b].zipCode), [] | ||
ZIP_RANGES = PROVINCE_KEYS.reduce( | ||
(a, b) => a.concat(PROVINCE_DATA[b].zipCode), [] | ||
) as object[] | ||
@@ -23,11 +23,9 @@ | ||
let zipArray = this.ZIP_RANGE | ||
let zipArray | ||
zip = zip.toString() | ||
const validLength = correctLength(0, zip.length, { minLength: 5 }) | ||
if (provinceKey) | ||
zipArray = (PROVINCE_DATA as any)[provinceKey].zipCode | ||
provinceKey ? zipArray = PROVINCE_DATA[provinceKey].zipCode : zipArray = this.ZIP_RANGES | ||
return validLength | ||
return parseInt(zip).toString() === zip | ||
&& correctLength(0, zip.length, { minLength: 5 }) | ||
&& this.isValidZIPCode(zip, zipArray) | ||
@@ -34,0 +32,0 @@ } |
/** | ||
* Nusantara Valid: functions/index.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -12,9 +12,9 @@ export * from './_atmNumber' | ||
export * from './_email' | ||
export * from './_nomorIndukKependudukan' | ||
export { isValidNIK, isValidNIKWithComparison, getDataNIK } from './_nomorIndukKependudukan' | ||
export * from './_nomorIndukPegawaiNegeriSipil' | ||
export * from './_nomorIndukSiswaNasional' | ||
export * from './_nomorPokokWajibPajak' | ||
export * from './_province' | ||
export { getDataProvince, getDataProvinces } from './_province' | ||
export * from './_telephoneNumber' | ||
export * from './_tandaNomorKendaraanBermotor' | ||
export * from './_zipCode' |
/** | ||
* Nusantara Valid: helpers/index.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -6,0 +6,0 @@ export * from './_numbersOnly' |
/** | ||
* Nusantara Valid: index.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
export * from './helpers' | ||
export * from './functions' |
@@ -44,2 +44,16 @@ /** | ||
/** | ||
* IDataNIKExtended data interface | ||
* | ||
* @interface | ||
**/ | ||
export interface IDataNIKExtended { | ||
nik: string, | ||
birthday: Date, | ||
sex: string, | ||
province: IDataProvince, | ||
regency: IDataRegency, | ||
district: IDataDistrict | ||
} | ||
/** | ||
* IDataNIP data interface | ||
@@ -62,3 +76,3 @@ * | ||
export interface IDataProvince { | ||
key: string, | ||
bpsCode: string, | ||
name: string | ||
@@ -68,2 +82,22 @@ } | ||
/** | ||
* IDataRegency data interface | ||
* | ||
* @interface | ||
**/ | ||
export interface IDataRegency { | ||
bpsCode: string, | ||
name: string | ||
} | ||
/** | ||
* IDataDistrict data interface | ||
* | ||
* @interface | ||
**/ | ||
export interface IDataDistrict { | ||
bpsCode: string, | ||
name: string | ||
} | ||
/** | ||
* IDataTelephoneNumber data interface | ||
@@ -70,0 +104,0 @@ * |
/** | ||
* Nusantara Valid: interface/index.ts | ||
* | ||
* Licensed under MIT (https://github.com/magicjar/nusantara-valid/blob/master/LICENSE) | ||
* Licensed under MIT (https://github.com/agraris/nusantara-valid/blob/master/LICENSE) | ||
**/ | ||
@@ -6,0 +6,0 @@ export * from './_IData' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
6150474
15
70
57543
490