nusantara-valid
Advanced tools
Comparing version 0.3.0 to 0.4.0
/*! | ||
* Nusantara Valid v0.3.0 | ||
* Nusantara Valid v0.4.0 | ||
* Copyright 2020 - Fajar Setya Budi (https://magicjar.github.io) | ||
@@ -76,2 +76,3 @@ * Contributors (https://github.com/agraris/nusantara-valid/graphs/contributors) | ||
**/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function includes(searchElement, theElement) { | ||
@@ -105,2 +106,3 @@ return searchElement.indexOf(theElement) > -1; | ||
**/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var BANK_DATA = { | ||
@@ -287,3 +289,4 @@ BCAK: { | ||
function isValidATMNumberWithComparison(atm, key) { | ||
if (key === void 0) { key = ''; } | ||
if (!key) | ||
return false; | ||
return theATM.isValid(atm, key); | ||
@@ -354,2 +357,3 @@ } | ||
**/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var CELLULAR_PROVIDER_DATA = { | ||
@@ -424,2 +428,3 @@ TELKOMSEL: { | ||
**/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var PROVINCE_DATA = { | ||
@@ -1272,11 +1277,10 @@ '11': { | ||
var newBirthday = /(\d{2})(\d{2})(\d{2})/.exec(birthday); | ||
if (newBirthday) { | ||
var cDD = newBirthday[1]; | ||
var cMM = newBirthday[2]; | ||
var cYY = newBirthday[3]; | ||
if (Number(cDD) > 40) // Check if it is a man of woman | ||
cDD = (Number(cDD) - 40).toString(); | ||
return cYY + '' + cMM + '' + cDD; | ||
} | ||
return ''; | ||
if (!newBirthday) | ||
return ''; | ||
var cDD = newBirthday[1]; | ||
var cMM = newBirthday[2]; | ||
var cYY = newBirthday[3]; | ||
if (Number(cDD) > 40) // Check if it is a man of woman | ||
cDD = (('0') + (Number(cDD) - 40).toString()).slice(-2); | ||
return cYY + '' + cMM + '' + cDD; | ||
}; | ||
@@ -1822,2 +1826,3 @@ NomorIndukKependudukan.prototype.getData = function (nik) { | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
ZIPCode.prototype.isValidZIPCode = function (zip, zipRange) { | ||
@@ -1824,0 +1829,0 @@ for (var _i = 0, zipRange_1 = zipRange; _i < zipRange_1.length; _i++) { |
/*! | ||
* Nusantara Valid v0.3.0 | ||
* Nusantara Valid v0.4.0 | ||
* Copyright 2020 - Fajar Setya Budi (https://magicjar.github.io) | ||
@@ -7,3 +7,3 @@ * Contributors (https://github.com/agraris/nusantara-valid/graphs/contributors) | ||
*/ | ||
"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; | ||
"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!!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)return"";var n=t[1],a=t[2],r=t[3];return Number(n)>40&&(n=("0"+(Number(n)-40).toString()).slice(-2)),r+""+a+n},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.3.0 | ||
* Nusantara Valid v0.4.0 | ||
* Copyright 2020 - Fajar Setya Budi (https://magicjar.github.io) | ||
@@ -72,2 +72,3 @@ * Contributors (https://github.com/agraris/nusantara-valid/graphs/contributors) | ||
**/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function includes(searchElement, theElement) { | ||
@@ -101,2 +102,3 @@ return searchElement.indexOf(theElement) > -1; | ||
**/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var BANK_DATA = { | ||
@@ -283,3 +285,4 @@ BCAK: { | ||
function isValidATMNumberWithComparison(atm, key) { | ||
if (key === void 0) { key = ''; } | ||
if (!key) | ||
return false; | ||
return theATM.isValid(atm, key); | ||
@@ -350,2 +353,3 @@ } | ||
**/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var CELLULAR_PROVIDER_DATA = { | ||
@@ -420,2 +424,3 @@ TELKOMSEL: { | ||
**/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var PROVINCE_DATA = { | ||
@@ -1268,11 +1273,10 @@ '11': { | ||
var newBirthday = /(\d{2})(\d{2})(\d{2})/.exec(birthday); | ||
if (newBirthday) { | ||
var cDD = newBirthday[1]; | ||
var cMM = newBirthday[2]; | ||
var cYY = newBirthday[3]; | ||
if (Number(cDD) > 40) // Check if it is a man of woman | ||
cDD = (Number(cDD) - 40).toString(); | ||
return cYY + '' + cMM + '' + cDD; | ||
} | ||
return ''; | ||
if (!newBirthday) | ||
return ''; | ||
var cDD = newBirthday[1]; | ||
var cMM = newBirthday[2]; | ||
var cYY = newBirthday[3]; | ||
if (Number(cDD) > 40) // Check if it is a man of woman | ||
cDD = (('0') + (Number(cDD) - 40).toString()).slice(-2); | ||
return cYY + '' + cMM + '' + cDD; | ||
}; | ||
@@ -1818,2 +1822,3 @@ NomorIndukKependudukan.prototype.getData = function (nik) { | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
ZIPCode.prototype.isValidZIPCode = function (zip, zipRange) { | ||
@@ -1820,0 +1825,0 @@ for (var _i = 0, zipRange_1 = zipRange; _i < zipRange_1.length; _i++) { |
/*! | ||
* Nusantara Valid v0.3.0 | ||
* Nusantara Valid v0.4.0 | ||
* Copyright 2020 - Fajar Setya Budi (https://magicjar.github.io) | ||
@@ -7,3 +7,3 @@ * Contributors (https://github.com/agraris/nusantara-valid/graphs/contributors) | ||
*/ | ||
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}; | ||
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!!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)return"";var t=n[1],a=n[2],r=n[3];return Number(t)>40&&(t=("0"+(Number(t)-40).toString()).slice(-2)),r+""+a+t},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.3.0 | ||
* Nusantara Valid v0.4.0 | ||
* Copyright 2020 - Fajar Setya Budi (https://magicjar.github.io) | ||
@@ -10,3 +10,3 @@ * Contributors (https://github.com/agraris/nusantara-valid/graphs/contributors) | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = global || self, factory(global.NusantaraValid = {})); | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.NusantaraValid = {})); | ||
}(this, (function (exports) { 'use strict'; | ||
@@ -79,2 +79,3 @@ | ||
**/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function includes(searchElement, theElement) { | ||
@@ -108,2 +109,3 @@ return searchElement.indexOf(theElement) > -1; | ||
**/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var BANK_DATA = { | ||
@@ -290,3 +292,4 @@ BCAK: { | ||
function isValidATMNumberWithComparison(atm, key) { | ||
if (key === void 0) { key = ''; } | ||
if (!key) | ||
return false; | ||
return theATM.isValid(atm, key); | ||
@@ -357,2 +360,3 @@ } | ||
**/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var CELLULAR_PROVIDER_DATA = { | ||
@@ -427,2 +431,3 @@ TELKOMSEL: { | ||
**/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var PROVINCE_DATA = { | ||
@@ -1275,11 +1280,10 @@ '11': { | ||
var newBirthday = /(\d{2})(\d{2})(\d{2})/.exec(birthday); | ||
if (newBirthday) { | ||
var cDD = newBirthday[1]; | ||
var cMM = newBirthday[2]; | ||
var cYY = newBirthday[3]; | ||
if (Number(cDD) > 40) // Check if it is a man of woman | ||
cDD = (Number(cDD) - 40).toString(); | ||
return cYY + '' + cMM + '' + cDD; | ||
} | ||
return ''; | ||
if (!newBirthday) | ||
return ''; | ||
var cDD = newBirthday[1]; | ||
var cMM = newBirthday[2]; | ||
var cYY = newBirthday[3]; | ||
if (Number(cDD) > 40) // Check if it is a man of woman | ||
cDD = (('0') + (Number(cDD) - 40).toString()).slice(-2); | ||
return cYY + '' + cMM + '' + cDD; | ||
}; | ||
@@ -1825,2 +1829,3 @@ NomorIndukKependudukan.prototype.getData = function (nik) { | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
ZIPCode.prototype.isValidZIPCode = function (zip, zipRange) { | ||
@@ -1827,0 +1832,0 @@ for (var _i = 0, zipRange_1 = zipRange; _i < zipRange_1.length; _i++) { |
/*! | ||
* Nusantara Valid v0.3.0 | ||
* Nusantara Valid v0.4.0 | ||
* Copyright 2020 - Fajar Setya Budi (https://magicjar.github.io) | ||
@@ -7,3 +7,3 @@ * Contributors (https://github.com/agraris/nusantara-valid/graphs/contributors) | ||
*/ | ||
!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})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis: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,i=t.countryCode,r=void 0===i?0:i,o=String(e).replace(/[^\d]/g,"").replace(/^0+/,"");return a&&Number(o.substr(0,2))===r&&(o=o.substring(2)),o}function a(e,t,n){var a=n.collection,i=void 0===a?[]:a,r=n.minLength,o=void 0===r?0:r,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 i.includes(t);default:return!1}}function i(e){return new Date(t(e).replace(/(\d{4})(?:(\d{2})?)(?:(\d{2})?)/,"$1-$2-$3"))}function r(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 r(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 i=t(e);return n?a(0,i.length,{minLength:u[n].digits}):a(2,i.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 i,o=n(e,{cellular:!0,countryCode:62});return i=t?f[t].prefix:g,a(1,o.length,{minLength:10,maxLength:12})&&r(i,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)),i=0,o=p;i<o.length;i++){var u=o[i],d=f[u];if(r(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}),i=a.slice(0,a.length).split("").reduce((function(e,t,n){var i=""+e+t;return n!==a.length-1&&r(m,n)?i+"-":i}),"");return t?"+"+62..toString()+i:"0"+i},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 r(B,e)},e.prototype.format=function(e){var n=t(e);return n.slice(0,16).split("").reduce((function(e,t,a){var i=""+e+t;return a!==n.length-1&&r(y,a)?i+" ":i}),"")},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=r(v,u[1]),s=!isNaN(i("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)return"";var n=t[1],a=t[2],i=t[3];return Number(n)>40&&(n=("0"+(Number(n)-40).toString()).slice(-2)),i+""+a+n},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=r(v,n[1]),d=!isNaN(i("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(i(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(i(n[1]).getTime())&&!isNaN(i(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=i(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),i=K.exec(n);return null!==i&&this.isValidTaxIdentity(i[1])&&a(0,i[0].length,{minLength:15})},e.prototype.isValidTaxIdentity=function(e){return r(M,e)},e.prototype.format=function(e){var n=t(e);return n.slice(0,15).split("").reduce((function(e,t,a){var i=""+e+t;if(a!==n.length-1){if(r(E,a))return i+".";if(r(L,a))return i+"-"}return i}),"")},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 r(this.VALID_TELEPHONE_AREACODE,t)?t:(t=Number(e.substr(0,3)),r(this.VALID_TELEPHONE_AREACODE,t)?t:NaN)},e.prototype.getData=function(e){var t={},a=n(e);t.number=this.format(a);for(var i=this.isValidCellularPrefix(a),o=0,u=v;o<u.length;o++){var d=u[o],l=h[d];if(r(l.tel,i)){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),i=this.isValidCellularPrefix(a).toString(),o=[];o=2===i.length?[1]:[2];var u=a.slice(0,a.length).split("").reduce((function(e,t,n){var i=""+e+t;return n!==a.length-1&&r(o,n)?i+"-":i}),"");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 r(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 i=0,o=v;i<o.length;i++){var u=o[i],d=h[u];if(r(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 i=a[n];if(i.from<=e&&i.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=i,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=r,e.isValidATMNumber=function(e){return c.isValid(e)},e.isValidATMNumberWithComparison=function(e,t){return!!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,i=t.birthday,r=void 0===i?"":i;return A.isValid(e,a,r)},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.3.0", | ||
"version": "0.4.0", | ||
"description": "Nusantara Valid is a data validator to validate any Indonesian specific civil data such as nik, nip, and many more.", | ||
@@ -49,2 +49,3 @@ "author": { | ||
"compile-ext:umd": "rollup --config --environment EXTENDED:true", | ||
"lint": "eslint --ext .ts,.tsx --cache --cache-location .cache/.eslintcache --report-unused-disable-directives src/ts", | ||
"minify-all": "npm-run-all --parallel minify minify-ext", | ||
@@ -60,15 +61,21 @@ "minify": "npm-run-all --parallel minify:*", | ||
"pre-release": "npm-run-all clean compile-all minify-all", | ||
"test": "mocha --require ts-node/register src/test/**" | ||
"test": "nyc --reporter=lcov --reporter=text --clean mocha --require ts-node/register src/test/**/*", | ||
"watch": "nodemon --watch src/ --ext ts --exec \"npm-run-all test lint\"" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.10.5", | ||
"@babel/preset-env": "^7.10.4", | ||
"@babel/core": "^7.11.0", | ||
"@babel/preset-env": "^7.11.0", | ||
"@rollup/plugin-babel": "^5.1.0", | ||
"@rollup/plugin-typescript": "^5.0.2", | ||
"@types/chai": "^4.2.11", | ||
"@types/chai": "^4.2.12", | ||
"@types/mocha": "^7.0.2", | ||
"@typescript-eslint/eslint-plugin": "^3.8.0", | ||
"@typescript-eslint/parser": "^3.8.0", | ||
"chai": "^4.2.0", | ||
"eslint": "^7.6.0", | ||
"mocha": "^7.2.0", | ||
"nodemon": "^2.0.4", | ||
"npm-run-all": "^4.1.5", | ||
"rollup": "^2.21.0", | ||
"nyc": "^15.1.0", | ||
"rollup": "^2.23.0", | ||
"shx": "^0.3.2", | ||
@@ -78,4 +85,4 @@ "terser": "^4.8.0", | ||
"tslib": "^2.0.0", | ||
"typescript": "^3.9.6" | ||
"typescript": "^3.9.7" | ||
} | ||
} |
[![npm version](https://img.shields.io/npm/v/nusantara-valid.svg)](https://www.npmjs.com/package/nusantara-valid) | ||
[![Coverage Status](https://img.shields.io/coveralls/github/agraris/nusantara-valid/master)](https://coveralls.io/github/agraris/nusantara-valid?branch=master) | ||
[![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) | ||
@@ -14,2 +15,4 @@ [![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) | ||
*Baca petunjuk berbahasa [Indonesia](README_id.md)* | ||
## **Table of contents** | ||
@@ -53,3 +56,3 @@ | ||
[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) | ||
[https://cdn.jsdelivr.net/npm/nusantara-valid@0.4.0/dist/umd/nusantara-valid.min.js](https://cdn.jsdelivr.net/npm/nusantara-valid@0.4.0/dist/umd/nusantara-valid.min.js) | ||
@@ -124,3 +127,3 @@ ## **What's included** | ||
``` html | ||
<script src="https://cdn.jsdelivr.net/npm/nusantara-valid@0.3.0/dist/umd/nusantara-valid.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/nusantara-valid@0.4.0/dist/umd/nusantara-valid.min.js"></script> | ||
``` | ||
@@ -287,3 +290,3 @@ | ||
isValidNIKWithComparison('3101011212930001', { provinceKey: 'JK', birthday: '1993-12-12' }); | ||
isValidNIKWithComparison('3101011212930001', { provinceKey: '31', birthday: '1993-12-12' }); | ||
// true | ||
@@ -297,3 +300,3 @@ | ||
// province: { | ||
// key: 'JK', | ||
// key: '31', | ||
// name: 'Jakarta' | ||
@@ -365,10 +368,10 @@ // } | ||
``` javascript | ||
getDataProvince('YO'); | ||
// { key: 'YO', name: 'Yogyakarta' } | ||
getDataProvince('34'); | ||
// { key: '34', name: 'Yogyakarta' } | ||
getDataProvinces(); | ||
// [ | ||
// { key: 'AC', name: 'Aceh' }, | ||
// { key: 'BA', name: 'Bali' }, | ||
// { key: 'BB', name: 'Kepulauan Bangka Belitung' }, | ||
// { bpsCode: '11', name: 'Aceh' }, | ||
// { bpsCode: '12', name: 'Sumatra Utara' }, | ||
// { bpsCode: '13', name: 'Sumatra Barat' }, | ||
// ... | ||
@@ -399,3 +402,3 @@ // ] | ||
// province: { | ||
// key: 'YO', | ||
// key: '34', | ||
// name: 'Yogyakarta' | ||
@@ -427,3 +430,3 @@ // } | ||
// "origin": { | ||
// "key": "YO", | ||
// "key": "34", | ||
// "name": "Yogyakarta" | ||
@@ -456,5 +459,5 @@ // } | ||
isValidZIPWithComparison('55264', { provinceKey: 'YO' }); | ||
isValidZIPWithComparison('55264', { provinceKey: '34' }); | ||
// true | ||
isValidZIPWithComparison(55264, { provinceKey: 'YO' }); | ||
isValidZIPWithComparison(55264, { provinceKey: '34' }); | ||
// true | ||
@@ -461,0 +464,0 @@ ``` |
@@ -14,3 +14,4 @@ /** | ||
**/ | ||
export const BANK_DATA : { [key: string]: any } = | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export const BANK_DATA : { [key: string]: any } = // | ||
{ | ||
@@ -17,0 +18,0 @@ BCAK: { |
@@ -14,2 +14,3 @@ /** | ||
**/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export const CELLULAR_PROVIDER_DATA : { [key: string]: any } = | ||
@@ -16,0 +17,0 @@ { |
@@ -15,2 +15,3 @@ /** | ||
**/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export const PROVINCE_DATA : { [key: string]: any } = | ||
@@ -17,0 +18,0 @@ { |
@@ -13,3 +13,3 @@ import { IValid } from "../interface" | ||
class ATMNumber implements IValid { | ||
isValid(atm: string, bank: string = ''): boolean { | ||
isValid(atm: string, bank = ''): boolean { | ||
if (!atm || typeof atm !== 'string') return false | ||
@@ -46,4 +46,5 @@ | ||
**/ | ||
export function isValidATMNumberWithComparison(atm: string, key: string = ''): boolean { | ||
export function isValidATMNumberWithComparison(atm: string, key: string): boolean { | ||
if (!key) return false | ||
return theATM.isValid(atm, key) | ||
} |
@@ -12,3 +12,3 @@ import { IGetData, IDataBank } from "../interface" | ||
class Bank implements IGetData { | ||
getData(index: string = ''): IDataBank | IDataBank[] { | ||
getData(index = ''): IDataBank | IDataBank[] { | ||
let bank | ||
@@ -15,0 +15,0 @@ |
@@ -14,3 +14,3 @@ import { IValid, IGetData, IFormat, IDataCellularNumber } from '../interface' | ||
class CellularNumber implements IValid, IGetData, IFormat { | ||
isValid(mobile: string, providerKey: string = ''): boolean { | ||
isValid(mobile: string, providerKey = ''): boolean { | ||
if (!mobile || typeof mobile !== 'string') return false | ||
@@ -28,3 +28,3 @@ | ||
getData(mobile: string): IDataCellularNumber { | ||
let data = {} as IDataCellularNumber | ||
const data = {} as IDataCellularNumber | ||
@@ -49,6 +49,6 @@ data.number = this.format(mobile) | ||
format(input: string, int: boolean = false): string { | ||
format(input: string, int = false): string { | ||
const cleanCelNumber = cleanPhoneNumbers(input, { cellular: true, countryCode: COUNTRY_CODE }) | ||
let formatedNumber = cleanCelNumber | ||
const formatedNumber = cleanCelNumber | ||
.slice(0, cleanCelNumber.length) | ||
@@ -118,4 +118,4 @@ .split('') | ||
**/ | ||
export function formatCellularNumber(number: string, int: boolean = false): string { | ||
export function formatCellularNumber(number: string, int = false): string { | ||
return cellularNumber.format(number, int) | ||
} |
@@ -12,3 +12,3 @@ import { IGetData, IDataCellularProvider } from '../interface' | ||
class CellularProvider implements IGetData { | ||
getData(index: string = ''): IDataCellularProvider | IDataCellularProvider[] { | ||
getData(index = ''): IDataCellularProvider | IDataCellularProvider[] { | ||
let providers | ||
@@ -15,0 +15,0 @@ |
@@ -27,3 +27,3 @@ import { IValid, IFormat } from "../interface" | ||
format(cc: string): string { | ||
let newCC = numbersOnly(cc) | ||
const newCC = numbersOnly(cc) | ||
@@ -30,0 +30,0 @@ return newCC |
@@ -15,3 +15,3 @@ import { IValid, IGetData, IDataNIK } from "../interface" | ||
export class NomorIndukKependudukan implements IValid, IGetData { | ||
isValid(nik: string, provinceKey: string = '', birthday: string = ''): boolean { | ||
isValid(nik: string, provinceKey = '', birthday = ''): boolean { | ||
if (!nik || typeof nik !== 'string') return false | ||
@@ -42,4 +42,4 @@ | ||
return validLength | ||
&& validProvince | ||
return validLength | ||
&& validProvince | ||
&& validBirthday | ||
@@ -52,14 +52,12 @@ } | ||
if (newBirthday) { | ||
let cDD = newBirthday[1] | ||
const cMM = newBirthday[2] | ||
const cYY = newBirthday[3] | ||
if (!newBirthday) return '' | ||
if (Number(cDD) > 40) // Check if it is a man of woman | ||
cDD = (Number(cDD) - 40).toString() | ||
let cDD = newBirthday[1] | ||
const cMM = newBirthday[2] | ||
const cYY = newBirthday[3] | ||
return cYY + '' + cMM + '' + cDD | ||
} | ||
if (Number(cDD) > 40) // Check if it is a man of woman | ||
cDD = (('0') + (Number(cDD) - 40).toString()).slice(-2) | ||
return '' | ||
return cYY + '' + cMM + '' + cDD | ||
} | ||
@@ -70,3 +68,3 @@ | ||
let data = {} as IDataNIK | ||
const data = {} as IDataNIK | ||
@@ -128,3 +126,3 @@ if (!validNIK) return data | ||
export function isValidNIKWithComparison(nik: string, comparison: { provinceKey?: string, birthday?: string }): boolean { | ||
let { provinceKey = '', birthday = '' } = comparison | ||
const { provinceKey = '', birthday = '' } = comparison | ||
@@ -144,2 +142,2 @@ return theNIK.isValid(nik, provinceKey, birthday) | ||
return theNIK.getData(nik) | ||
} | ||
} |
@@ -25,3 +25,3 @@ import { IValid, IGetData, IDataNIP } from "../interface" | ||
getData(nip: string): IDataNIP { | ||
let data = {} as IDataNIP | ||
const data = {} as IDataNIP | ||
@@ -28,0 +28,0 @@ const validNIP = NIP_REGEX.exec(numbersOnly(nip)) |
@@ -30,3 +30,3 @@ import { IValid, IFormat } from "../interface" | ||
format(npwp: string): string { | ||
let newNPWP = numbersOnly(npwp) | ||
const newNPWP = numbersOnly(npwp) | ||
@@ -33,0 +33,0 @@ return newNPWP |
@@ -12,3 +12,3 @@ import { IGetData, IDataProvince } from "../interface" | ||
export class Province implements IGetData { | ||
getData(index: string = ''): IDataProvince | IDataProvince[] { | ||
getData(index = ''): IDataProvince | IDataProvince[] { | ||
let province | ||
@@ -15,0 +15,0 @@ |
@@ -41,3 +41,3 @@ import { IValid, IFormat, IGetData, IDataTelephoneNumber } from "../interface"; | ||
getData(tel: string): IDataTelephoneNumber { | ||
let data = {} as IDataTelephoneNumber | ||
const data = {} as IDataTelephoneNumber | ||
@@ -64,7 +64,7 @@ const cleanTelNumber = cleanPhoneNumbers(tel) | ||
format(tel: string, int:boolean = false): string { | ||
format(tel: string, int = false): string { | ||
const cleanTelNumber = cleanPhoneNumbers(tel) | ||
const pfx = this.isValidCellularPrefix(cleanTelNumber).toString() | ||
let TEL_HYPEN_INDEX = [] as any | ||
let TEL_HYPEN_INDEX = [] as Array<number> | ||
@@ -76,3 +76,3 @@ if (pfx.length === 2) | ||
let formatedNumber = cleanTelNumber | ||
const formatedNumber = cleanTelNumber | ||
.slice(0, cleanTelNumber.length) | ||
@@ -129,4 +129,4 @@ .split('') | ||
**/ | ||
export function formatTelephoneNumber(number: string, int:boolean = false): string { | ||
export function formatTelephoneNumber(number: string, int = false): string { | ||
return telNumber.format(number, int) | ||
} |
@@ -16,5 +16,5 @@ import { IValid } from "../interface" | ||
(a, b) => a.concat(PROVINCE_DATA[b].zipCode), [] | ||
) as object[] | ||
) | ||
isValid(zip: string | number, provinceKey: string = ''): boolean { | ||
isValid(zip: string | number, provinceKey = ''): boolean { | ||
if (!zip) return false | ||
@@ -32,4 +32,5 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
isValidZIPCode(zip: string, zipRange: any[]): boolean { | ||
for (let val of zipRange) { | ||
for (const val of zipRange) { | ||
if (val.from <= zip && val.to >= zip) { | ||
@@ -36,0 +37,0 @@ return true |
import { IDataNIKExtended } from "../../interface" | ||
import { NIK_REGEX } from "../../datas/nik" | ||
import { numbersOnly, includes } from "../../helpers" | ||
@@ -15,11 +14,9 @@ import { NomorIndukKependudukan } from '../_nomorIndukKependudukan' | ||
class NomorIndukKependudukanExtended extends NomorIndukKependudukan { | ||
isValid(nik: string, provinceKey: string = '', birthday: string = ''): boolean { | ||
isValid(nik: string, provinceKey = '', birthday = ''): boolean { | ||
if (!super.isValid(nik, provinceKey, birthday)) return false | ||
const validNIK = NIK_REGEX.exec(numbersOnly(nik)) | ||
const newNIK = numbersOnly(nik) | ||
if (!validNIK) return false | ||
const provinceBPSCode = validNIK[1] | ||
const regencyBPSCode = provinceBPSCode + '.' + validNIK[2] | ||
const provinceBPSCode = newNIK.substr(0, 2) | ||
const regencyBPSCode = provinceBPSCode + '.' + newNIK.substr(2, 2) | ||
const REGENCIES = getDataRegenciesInProvince(provinceBPSCode) | ||
@@ -29,3 +26,3 @@ const regenciesBPSCodes = REGENCIES.map(({ bpsCode }) => bpsCode) | ||
const districtBPSCode = regencyBPSCode + '.' + validNIK[3] | ||
const districtBPSCode = regencyBPSCode + '.' + newNIK.substr(4, 2) | ||
const DISTRICTS = getDataDistrictsInRegency(regencyBPSCode) | ||
@@ -90,3 +87,3 @@ const districtsBPSCode = DISTRICTS.map(({ bpsCode }) => bpsCode) | ||
export function isValidNIKWithComparison(nik: string, comparison: { provinceKey?: string, birthday?: string }): boolean { | ||
let { provinceKey = '', birthday = '' } = comparison | ||
const { provinceKey = '', birthday = '' } = comparison | ||
@@ -93,0 +90,0 @@ return theNIK.isValid(nik, provinceKey, birthday) |
@@ -8,4 +8,5 @@ /** | ||
**/ | ||
export function includes(searchElement: any[], theElement: any): boolean { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function includes(searchElement: any[], theElement: string | number): boolean { | ||
return searchElement.indexOf(theElement) > -1 | ||
} |
@@ -7,3 +7,3 @@ /** | ||
export interface IFormat { | ||
format: (args: any) => string; | ||
format: (args: any) => string; // eslint-disable-line @typescript-eslint/no-explicit-any | ||
} |
@@ -7,3 +7,3 @@ /** | ||
export interface IGetData { | ||
getData: (args: any) => any; | ||
getData: (args: any) => any; // eslint-disable-line @typescript-eslint/no-explicit-any | ||
} |
@@ -7,3 +7,3 @@ /** | ||
export interface IValid { | ||
isValid: (args: any) => boolean; | ||
isValid: (args: any) => boolean; // eslint-disable-line @typescript-eslint/no-explicit-any | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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 too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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 too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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 too big to display
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
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
6153944
57574
493
0
20