superjs-core 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +192 -0
- package/dist/index.js.map +1 -1
- package/dist/validation/index.d.ts +62 -1
- package/dist/validation/index.js +193 -1
- package/dist/validation/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { generateReport } from './dep-exray/reporter/index.js';
|
|
|
13
13
|
export { analyzeUsage } from './dep-exray/analyzer/index.js';
|
|
14
14
|
export { DependencyInfo, ReplacementSuggestion, ScanResult, ScannerConfig, SecurityIssue } from './dep-exray/types.js';
|
|
15
15
|
export { KNOWN_CVES, KNOWN_MAPPINGS } from './dep-exray/known-mappings.js';
|
|
16
|
-
export { isEmail, isNIK, isNPWP, isPhone, isURL } from './validation/index.js';
|
|
16
|
+
export { NIKInfo, isEmail, isKodepos, isNIK, isNPWP, isNoRekening, isPhone, isPlatNomor, isURL, parseNIK } from './validation/index.js';
|
|
17
17
|
export { ErrorCode, MultiError, TypedError, collectErrors, createError, isTypedError } from './error/index.js';
|
|
18
18
|
export { L as LogLevel, a as Logger, T as Transport, c as consoleTransport, b as createBufferedTransport, d as createConsoleTransport, e as createFileTransport, f as createJsonTransport, l as logger } from './index-BgG21uJC.js';
|
|
19
19
|
export { contrastRatio, darken, hexToRgb, lighten, meetsWCAG, rgbToHex } from './color/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1980,6 +1980,194 @@ function isURL(value) {
|
|
|
1980
1980
|
}
|
|
1981
1981
|
}
|
|
1982
1982
|
|
|
1983
|
+
// src/validation/parseNIK.ts
|
|
1984
|
+
function parseNIK(value) {
|
|
1985
|
+
const digits = value.replace(/\D/g, "");
|
|
1986
|
+
const info = {
|
|
1987
|
+
nik: value,
|
|
1988
|
+
valid: false,
|
|
1989
|
+
gender: null,
|
|
1990
|
+
birthDate: null,
|
|
1991
|
+
province: null,
|
|
1992
|
+
provinceCode: null,
|
|
1993
|
+
city: null,
|
|
1994
|
+
cityCode: null,
|
|
1995
|
+
district: null,
|
|
1996
|
+
districtCode: null,
|
|
1997
|
+
uniqueCode: null
|
|
1998
|
+
};
|
|
1999
|
+
if (digits.length !== 16) return info;
|
|
2000
|
+
const provinceCode = digits.slice(0, 2);
|
|
2001
|
+
const cityCode = digits.slice(2, 4);
|
|
2002
|
+
const districtCode = digits.slice(4, 6);
|
|
2003
|
+
const rawDay = Number.parseInt(digits.slice(6, 8), 10);
|
|
2004
|
+
const month = Number.parseInt(digits.slice(8, 10), 10);
|
|
2005
|
+
const year = Number.parseInt(digits.slice(10, 12), 10);
|
|
2006
|
+
const uniqueCode = digits.slice(12, 16);
|
|
2007
|
+
if (rawDay < 1 || rawDay > 71 || month < 1 || month > 12) return info;
|
|
2008
|
+
const gender = rawDay >= 41 ? "PEREMPUAN" : "LAKI-LAKI";
|
|
2009
|
+
let day = rawDay;
|
|
2010
|
+
if (day >= 41) day -= 40;
|
|
2011
|
+
const fullYear = year < 70 ? 2e3 + year : 1900 + year;
|
|
2012
|
+
const birthDate = new Date(fullYear, month - 1, day);
|
|
2013
|
+
if (birthDate.getFullYear() !== fullYear || birthDate.getMonth() !== month - 1 || birthDate.getDate() !== day) {
|
|
2014
|
+
return info;
|
|
2015
|
+
}
|
|
2016
|
+
return {
|
|
2017
|
+
nik: value,
|
|
2018
|
+
valid: true,
|
|
2019
|
+
gender,
|
|
2020
|
+
birthDate,
|
|
2021
|
+
province: PROVINCE_CODES[provinceCode] ?? null,
|
|
2022
|
+
provinceCode,
|
|
2023
|
+
city: null,
|
|
2024
|
+
cityCode,
|
|
2025
|
+
district: null,
|
|
2026
|
+
districtCode,
|
|
2027
|
+
uniqueCode
|
|
2028
|
+
};
|
|
2029
|
+
}
|
|
2030
|
+
var PROVINCE_CODES = {
|
|
2031
|
+
"11": "ACEH",
|
|
2032
|
+
"12": "SUMATERA UTARA",
|
|
2033
|
+
"13": "SUMATERA BARAT",
|
|
2034
|
+
"14": "RIAU",
|
|
2035
|
+
"15": "JAMBI",
|
|
2036
|
+
"16": "SUMATERA SELATAN",
|
|
2037
|
+
"17": "BENGKULU",
|
|
2038
|
+
"18": "LAMPUNG",
|
|
2039
|
+
"19": "KEPULAUAN BANGKA BELITUNG",
|
|
2040
|
+
"21": "KEPULAUAN RIAU",
|
|
2041
|
+
"31": "DKI JAKARTA",
|
|
2042
|
+
"32": "JAWA BARAT",
|
|
2043
|
+
"33": "JAWA TENGAH",
|
|
2044
|
+
"34": "DI YOGYAKARTA",
|
|
2045
|
+
"35": "JAWA TIMUR",
|
|
2046
|
+
"36": "BANTEN",
|
|
2047
|
+
"51": "BALI",
|
|
2048
|
+
"52": "NUSA TENGGARA BARAT",
|
|
2049
|
+
"53": "NUSA TENGGARA TIMUR",
|
|
2050
|
+
"61": "KALIMANTAN BARAT",
|
|
2051
|
+
"62": "KALIMANTAN TENGAH",
|
|
2052
|
+
"63": "KALIMANTAN SELATAN",
|
|
2053
|
+
"64": "KALIMANTAN TIMUR",
|
|
2054
|
+
"65": "KALIMANTAN UTARA",
|
|
2055
|
+
"71": "SULAWESI UTARA",
|
|
2056
|
+
"72": "SULAWESI TENGAH",
|
|
2057
|
+
"73": "SULAWESI SELATAN",
|
|
2058
|
+
"74": "SULAWESI TENGGARA",
|
|
2059
|
+
"75": "GORONTALO",
|
|
2060
|
+
"76": "SULAWESI BARAT",
|
|
2061
|
+
"81": "MALUKU",
|
|
2062
|
+
"82": "MALUKU UTARA",
|
|
2063
|
+
"91": "PAPUA",
|
|
2064
|
+
"92": "PAPUA BARAT",
|
|
2065
|
+
"93": "PAPUA SELATAN",
|
|
2066
|
+
"94": "PAPUA TENGAH",
|
|
2067
|
+
"95": "PAPUA PEGUNUNGAN"
|
|
2068
|
+
};
|
|
2069
|
+
|
|
2070
|
+
// src/validation/isPlatNomor.ts
|
|
2071
|
+
function isPlatNomor(value) {
|
|
2072
|
+
const trimmed = value.trim().toUpperCase();
|
|
2073
|
+
const regex = /^([A-Z]{1,2})\s*(\d{1,4})\s*([A-Z]{0,3})$/;
|
|
2074
|
+
const match = trimmed.match(regex);
|
|
2075
|
+
if (!match) return false;
|
|
2076
|
+
const kodeDepan = match[1];
|
|
2077
|
+
const angka = parseInt(match[2], 10);
|
|
2078
|
+
const kodeBelakang = match[3] || "";
|
|
2079
|
+
if (!KODE_DAERAH.includes(kodeDepan)) return false;
|
|
2080
|
+
if (angka < 1 || angka > 9999) return false;
|
|
2081
|
+
if (kodeBelakang.length > 3) return false;
|
|
2082
|
+
return true;
|
|
2083
|
+
}
|
|
2084
|
+
var KODE_DAERAH = [
|
|
2085
|
+
"A",
|
|
2086
|
+
"AA",
|
|
2087
|
+
"AB",
|
|
2088
|
+
"AD",
|
|
2089
|
+
"AE",
|
|
2090
|
+
"AG",
|
|
2091
|
+
"B",
|
|
2092
|
+
"BA",
|
|
2093
|
+
"BB",
|
|
2094
|
+
"BD",
|
|
2095
|
+
"BE",
|
|
2096
|
+
"BG",
|
|
2097
|
+
"BH",
|
|
2098
|
+
"BK",
|
|
2099
|
+
"BL",
|
|
2100
|
+
"BM",
|
|
2101
|
+
"BN",
|
|
2102
|
+
"BP",
|
|
2103
|
+
"BR",
|
|
2104
|
+
"BT",
|
|
2105
|
+
"BU",
|
|
2106
|
+
"BV",
|
|
2107
|
+
"BW",
|
|
2108
|
+
"D",
|
|
2109
|
+
"DA",
|
|
2110
|
+
"DB",
|
|
2111
|
+
"DC",
|
|
2112
|
+
"DD",
|
|
2113
|
+
"DE",
|
|
2114
|
+
"DF",
|
|
2115
|
+
"DG",
|
|
2116
|
+
"DH",
|
|
2117
|
+
"DK",
|
|
2118
|
+
"DL",
|
|
2119
|
+
"DM",
|
|
2120
|
+
"DN",
|
|
2121
|
+
"DP",
|
|
2122
|
+
"DR",
|
|
2123
|
+
"DT",
|
|
2124
|
+
"DU",
|
|
2125
|
+
"DW",
|
|
2126
|
+
"E",
|
|
2127
|
+
"EA",
|
|
2128
|
+
"EB",
|
|
2129
|
+
"ED",
|
|
2130
|
+
"EE",
|
|
2131
|
+
"F",
|
|
2132
|
+
"G",
|
|
2133
|
+
"H",
|
|
2134
|
+
"K",
|
|
2135
|
+
"KB",
|
|
2136
|
+
"KH",
|
|
2137
|
+
"KI",
|
|
2138
|
+
"KU",
|
|
2139
|
+
"KT",
|
|
2140
|
+
"L",
|
|
2141
|
+
"M",
|
|
2142
|
+
"N",
|
|
2143
|
+
"NB",
|
|
2144
|
+
"NG",
|
|
2145
|
+
"NK",
|
|
2146
|
+
"NM",
|
|
2147
|
+
"P",
|
|
2148
|
+
"PA",
|
|
2149
|
+
"PB",
|
|
2150
|
+
"R",
|
|
2151
|
+
"S",
|
|
2152
|
+
"ST",
|
|
2153
|
+
"T",
|
|
2154
|
+
"W",
|
|
2155
|
+
"Z"
|
|
2156
|
+
];
|
|
2157
|
+
|
|
2158
|
+
// src/validation/isKodepos.ts
|
|
2159
|
+
function isKodepos(value) {
|
|
2160
|
+
if (value.length !== 5) return false;
|
|
2161
|
+
return /^\d{5}$/.test(value);
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2164
|
+
// src/validation/isNoRekening.ts
|
|
2165
|
+
function isNoRekening(value) {
|
|
2166
|
+
const digits = value.replace(/\D/g, "");
|
|
2167
|
+
if (digits.length < 8 || digits.length > 16) return false;
|
|
2168
|
+
return true;
|
|
2169
|
+
}
|
|
2170
|
+
|
|
1983
2171
|
// src/error/createError.ts
|
|
1984
2172
|
var defaultStatus = {
|
|
1985
2173
|
"BAD_REQUEST": 400,
|
|
@@ -2425,15 +2613,18 @@ export {
|
|
|
2425
2613
|
isEmail,
|
|
2426
2614
|
isEmpty,
|
|
2427
2615
|
isFunction,
|
|
2616
|
+
isKodepos,
|
|
2428
2617
|
isLeapYear,
|
|
2429
2618
|
isMap,
|
|
2430
2619
|
isNIK,
|
|
2431
2620
|
isNPWP,
|
|
2432
2621
|
isNil,
|
|
2622
|
+
isNoRekening,
|
|
2433
2623
|
isNull,
|
|
2434
2624
|
isNumber,
|
|
2435
2625
|
isObject,
|
|
2436
2626
|
isPhone,
|
|
2627
|
+
isPlatNomor,
|
|
2437
2628
|
isPromise,
|
|
2438
2629
|
isRegExp,
|
|
2439
2630
|
isSet,
|
|
@@ -2464,6 +2655,7 @@ export {
|
|
|
2464
2655
|
parse,
|
|
2465
2656
|
parseCsv,
|
|
2466
2657
|
parseDate,
|
|
2658
|
+
parseNIK,
|
|
2467
2659
|
pascalCase,
|
|
2468
2660
|
pick,
|
|
2469
2661
|
pipeline,
|