@indodev/toolkit 0.5.0 → 0.6.0
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.cjs +46 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +46 -14
- package/dist/index.js.map +1 -1
- package/dist/nik/index.cjs +156 -12
- package/dist/nik/index.cjs.map +1 -1
- package/dist/nik/index.d.cts +24 -330
- package/dist/nik/index.d.ts +24 -330
- package/dist/nik/index.js +153 -13
- package/dist/nik/index.js.map +1 -1
- package/dist/utils-DT8-jt63.d.cts +495 -0
- package/dist/utils-DT8-jt63.d.ts +495 -0
- package/package.json +1 -1
package/dist/nik/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/nik/constants.ts","../../src/nik/utils/date.ts","../../src/nik/validate.ts","../../src/nik/parse.ts","../../src/nik/format.ts","../../src/nik/utils.ts","../../src/nik/types.ts"],"names":["NIK_PATTERN"],"mappings":";AAIO,IAAM,SAAA,GAAoC;AAAA,EAC/C,IAAA,EAAM,MAAA;AAAA,EACN,IAAA,EAAM,gBAAA;AAAA,EACN,IAAA,EAAM,gBAAA;AAAA,EACN,IAAA,EAAM,MAAA;AAAA,EACN,IAAA,EAAM,OAAA;AAAA,EACN,IAAA,EAAM,kBAAA;AAAA,EACN,IAAA,EAAM,UAAA;AAAA,EACN,IAAA,EAAM,SAAA;AAAA,EACN,IAAA,EAAM,2BAAA;AAAA,EACN,IAAA,EAAM,gBAAA;AAAA,EACN,IAAA,EAAM,aAAA;AAAA,EACN,IAAA,EAAM,YAAA;AAAA,EACN,IAAA,EAAM,aAAA;AAAA,EACN,IAAA,EAAM,eAAA;AAAA,EACN,IAAA,EAAM,YAAA;AAAA,EACN,IAAA,EAAM,QAAA;AAAA,EACN,IAAA,EAAM,MAAA;AAAA,EACN,IAAA,EAAM,qBAAA;AAAA,EACN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AASO,SAAS,mBAAA,CAAoB,KAAa,SAAA,EAA0B;AACzE,EAAA,MAAM,IAAA,GAAO,SAAS,GAAG,CAAA;AACzB,EAAA,IAAI,CAAC,IAAA,IAAQ,CAAC,IAAA,CAAK,SAAA,EAAW;AAC5B,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,OACE,KAAK,SAAA,CAAU,WAAA,OAAkB,SAAA,CAAU,WAAA,MAC3C,IAAA,CAAK,SAAA,CAAU,UAAS,KAAM,SAAA,CAAU,UAAS,IACjD,IAAA,CAAK,UAAU,OAAA,EAAQ,KAAM,UAAU,OAAA,EAAQ;AAEnD;;;ACoEO,IAAM,eAAA,GAAN,cAA8B,KAAA,CAAM;AAAA,EAIzC,WAAA,CAAY,UAAkB,sBAAA,EAAwB;AACpD,IAAA,KAAA,CAAM,OAAO,CAAA;AAHf;AAAA,IAAA,IAAA,CAAS,IAAA,GAAO,aAAA;AAId,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AAAA,EACd;AACF","file":"index.js","sourcesContent":["/**\n * Indonesian province codes and names\n * Based on Dukcapil Kemendagri data\n */\nexport const PROVINCES: Record<string, string> = {\n '11': 'Aceh',\n '12': 'Sumatera Utara',\n '13': 'Sumatera Barat',\n '14': 'Riau',\n '15': 'Jambi',\n '16': 'Sumatera Selatan',\n '17': 'Bengkulu',\n '18': 'Lampung',\n '19': 'Kepulauan Bangka Belitung',\n '21': 'Kepulauan Riau',\n '31': 'DKI Jakarta',\n '32': 'Jawa Barat',\n '33': 'Jawa Tengah',\n '34': 'DI Yogyakarta',\n '35': 'Jawa Timur',\n '36': 'Banten',\n '51': 'Bali',\n '52': 'Nusa Tenggara Barat',\n '53': 'Nusa Tenggara Timur',\n '61': 'Kalimantan Barat',\n '62': 'Kalimantan Tengah',\n '63': 'Kalimantan Selatan',\n '64': 'Kalimantan Timur',\n '65': 'Kalimantan Utara',\n '71': 'Sulawesi Utara',\n '72': 'Sulawesi Tengah',\n '73': 'Sulawesi Selatan',\n '74': 'Sulawesi Tenggara',\n '75': 'Gorontalo',\n '76': 'Sulawesi Barat',\n '81': 'Maluku',\n '82': 'Maluku Utara',\n '91': 'Papua',\n '92': 'Papua Barat',\n '93': 'Papua Selatan',\n '94': 'Papua Tengah',\n '95': 'Papua Pegunungan',\n '96': 'Papua Barat Daya',\n};\n\n/**\n * Regency codes for each province (simplified - only major ones)\n * In a real implementation, you'd have complete data\n */\nexport const REGENCIES: Record<string, Record<string, string>> = {\n '32': {\n '01': 'Kab. Bogor',\n '02': 'Kab. Sukabumi',\n '03': 'Kab. Cianjur',\n '71': 'Kota Bandung',\n '72': 'Kota Bekasi',\n '73': 'Kota Depok',\n },\n '31': { \n '01': 'Kota Jakarta Selatan',\n '02': 'Kota Jakarta Timur',\n '03': 'Kota Jakarta Pusat',\n '04': 'Kota Jakarta Barat',\n '05': 'Kota Jakarta Utara',\n },\n};","/**\n * Shared date parsing and validation utilities for NIK module.\n *\n * @module nik/utils/date\n * @packageDocumentation\n */\n\n/**\n * Result of parsing date components from a NIK string.\n *\n * @public\n */\nexport interface ParsedNIKDate {\n /** 2-digit year code (00-99) from NIK positions 7-8 */\n year: number;\n /** Full 4-digit year (1900-1999 or 2000-2099) */\n fullYear: number;\n /** Month (1-12) from NIK positions 9-10 */\n month: number;\n /** Actual day (1-31), decoded from encoded day */\n day: number;\n /** Gender derived from day encoding */\n gender: 'male' | 'female';\n /** Original encoded day (1-31 for male, 41-71 for female) */\n dayEncoded: number;\n}\n\n/**\n * Parses date components from a NIK string.\n *\n * Extracts year, month, and encoded day from positions 7-12 of the NIK.\n * For females, the day is encoded as (actual day + 40).\n *\n * @param nik - 16-digit NIK string\n * @returns ParsedNIKDate or null if NIK format is invalid\n *\n * @example\n * ```typescript\n * const result = parseNIKDate('3201018901310123');\n * // { year: 89, fullYear: 1989, month: 1, day: 31, gender: 'male', dayEncoded: 31 }\n * ```\n *\n * @public\n */\nexport function parseNIKDate(nik: string): ParsedNIKDate | null {\n if (nik.length !== 16) {\n return null;\n }\n\n const yearStr = nik.substring(6, 8);\n const monthStr = nik.substring(8, 10);\n const dayEncodedStr = nik.substring(10, 12);\n\n const year = parseInt(yearStr, 10);\n if (isNaN(year)) return null;\n\n const fullYear = year > 30 ? 1900 + year : 2000 + year;\n\n const month = parseInt(monthStr, 10);\n if (isNaN(month)) return null;\n\n const dayEncoded = parseInt(dayEncodedStr, 10);\n if (isNaN(dayEncoded)) return null;\n\n const gender: 'male' | 'female' = dayEncoded > 40 ? 'female' : 'male';\n const day = dayEncoded > 40 ? dayEncoded - 40 : dayEncoded;\n\n return { year, fullYear, month, day, gender, dayEncoded };\n}\n\n/**\n * Validates if year/month/day form a valid calendar date.\n *\n * Uses JavaScript's Date object to check if the date actually exists\n * (handles leap years, invalid month/day combinations).\n *\n * @param year - Full 4-digit year\n * @param month - Month (1-12)\n * @param day - Day (1-31)\n * @returns true if valid calendar date\n *\n * @example\n * ```typescript\n * validateNIKDateComponents(2024, 2, 29); // true (leap year)\n * validateNIKDateComponents(2023, 2, 29); // false\n * validateNIKDateComponents(2024, 13, 1); // false\n * ```\n *\n * @public\n */\nexport function validateNIKDateComponents(\n year: number,\n month: number,\n day: number\n): boolean {\n if (month < 1 || month > 12) return false;\n if (day < 1 || day > 31) return false;\n\n const testDate = new Date(year, month - 1, day);\n return (\n testDate.getFullYear() === year &&\n testDate.getMonth() === month - 1 &&\n testDate.getDate() === day\n );\n}\n","import { PROVINCES } from './constants';\nimport { parseNIKDate, validateNIKDateComponents } from './utils/date';\n\nconst NIK_PATTERN = /^\\d{16}$/;\n\n/**\n * Validates a NIK (Nomor Induk Kependudukan) format.\n *\n * A valid NIK must:\n * - Be exactly 16 digits\n * - Have a valid province code (positions 1-2)\n * - Have a valid date (positions 7-12)\n * - Not be in the future\n * - Not be before 1900\n *\n * For female NIKs, the day is encoded as (actual day + 40).\n * For example, a female born on the 15th would have day = 55.\n *\n * @param nik - The 16-digit NIK string to validate\n * @returns `true` if the NIK is valid, `false` otherwise\n *\n * @example\n * ```typescript\n * validateNIK('3201234567890123'); // true - valid NIK\n * validateNIK('1234'); // false - wrong length\n * validateNIK('9912345678901234'); // false - invalid province\n * ```\n *\n * @public\n */\nexport function validateNIK(nik: string): boolean {\n if (!NIK_PATTERN.test(nik)) {\n return false;\n }\n\n const provinceCode = nik.substring(0, 2);\n if (!PROVINCES[provinceCode]) {\n return false;\n }\n\n const parsed = parseNIKDate(nik);\n if (!parsed) {\n return false;\n }\n\n const { fullYear, month, day } = parsed;\n\n if (!validateNIKDateComponents(fullYear, month, day)) {\n return false;\n }\n\n const now = new Date();\n if (new Date(fullYear, month - 1, day) > now || fullYear < 1900) {\n return false;\n }\n\n return true;\n}\n","import { PROVINCES, REGENCIES } from './constants';\nimport { NIKInfo } from './types';\nimport { parseNIKDate, validateNIKDateComponents } from './utils/date';\n\nconst NIK_PATTERN = /^\\d{16}$/;\n\n/**\n * Parses a NIK and extracts all embedded information.\n *\n * Extracts province, regency, district codes, birth date, gender,\n * and serial number from a 16-digit NIK string.\n *\n * @param nik - The 16-digit NIK string to parse\n * @returns Parsed NIK information, or `null` if the NIK format is invalid\n *\n * @example\n * Parse a valid male NIK:\n * ```typescript\n * const info = parseNIK('3201018901310123');\n * console.log(info);\n * // {\n * // province: { code: '32', name: 'Jawa Barat' },\n * // regency: { code: '01', name: 'Kab. Bogor' },\n * // district: { code: '01', name: null },\n * // birthDate: Date(1989, 0, 31), // Jan 31, 1989\n * // gender: 'male',\n * // serialNumber: '0123',\n * // isValid: true\n * // }\n * ```\n *\n * @example\n * Parse a female NIK (day + 40):\n * ```typescript\n * const info = parseNIK('3201019508550123');\n * console.log(info.gender); // 'female'\n * console.log(info.birthDate); // Date(1995, 7, 15) - Aug 15, 1995\n * ```\n *\n * @example\n * Invalid NIK returns null:\n * ```typescript\n * const info = parseNIK('invalid');\n * console.log(info); // null\n * ```\n *\n * @public\n */\nexport function parseNIK(nik: string): NIKInfo | null {\n if (!NIK_PATTERN.test(nik)) {\n return null;\n }\n\n const provinceCode = nik.substring(0, 2);\n const regencyCode = nik.substring(2, 4);\n const districtCode = nik.substring(4, 6);\n const serialNumber = nik.substring(12, 16);\n\n const province = PROVINCES[provinceCode];\n if (!province) {\n return null;\n }\n\n const regencies = REGENCIES[provinceCode] || {};\n const regency = regencies[regencyCode] || 'Unknown';\n\n const parsed = parseNIKDate(nik);\n if (!parsed) {\n return null;\n }\n\n const { fullYear, month, day, gender } = parsed;\n\n if (!validateNIKDateComponents(fullYear, month, day)) {\n return null;\n }\n\n const birthDate = new Date(fullYear, month - 1, day);\n\n return {\n province: {\n code: provinceCode,\n name: province,\n },\n regency: {\n code: regencyCode,\n name: regency,\n },\n district: {\n code: districtCode,\n name: null,\n },\n birthDate,\n gender,\n serialNumber,\n isValid: true,\n };\n}\n","import { MaskOptions } from './types';\n\n/**\n * Formats a NIK with separators for better readability.\n *\n * Groups the NIK into logical segments: province, regency, district,\n * year, month, day, and serial number.\n *\n * @param nik - The 16-digit NIK string to format\n * @param separator - Character to use as separator\n * @returns Formatted NIK string, or original string if invalid format\n *\n * @example\n * Default separator (dash):\n * ```typescript\n * formatNIK('3201234567890123');\n * // '32-01-23-45-67-89-0123'\n * ```\n *\n * @example\n * Custom separator:\n * ```typescript\n * formatNIK('3201234567890123', ' ');\n * // '32 01 23 45 67 89 0123'\n * ```\n *\n * @example\n * Invalid NIK returns as-is:\n * ```typescript\n * formatNIK('1234');\n * // '1234'\n * ```\n *\n * @public\n */\nexport function formatNIK(nik: string, separator: string = '-'): string {\n if (!/^\\d{16}$/.test(nik)) {\n return nik;\n }\n\n // Format: PP-KK-DD-YY-MM-DD-XXXX\n // PP = Province (2 digits)\n // KK = Regency (2 digits)\n // DD = District (2 digits)\n // YY = Year (2 digits)\n // MM = Month (2 digits)\n // DD = Day (2 digits, +40 for female)\n // XXXX = Serial number (4 digits)\n return [\n nik.substring(0, 2), // Province\n nik.substring(2, 4), // Regency\n nik.substring(4, 6), // District\n nik.substring(6, 8), // Year\n nik.substring(8, 10), // Month\n nik.substring(10, 12), // Day\n nik.substring(12, 16), // Serial\n ].join(separator);\n}\n\n/**\n * Masks a NIK to protect privacy while keeping partial visibility.\n *\n * By default, shows the first 4 and last 4 digits, masking the middle 8.\n * Optionally formats the masked NIK with separators.\n *\n * @param nik - The 16-digit NIK string to mask\n * @param options - Masking configuration options\n * @returns Masked NIK string, or original string if invalid format\n *\n * @example\n * Default masking (first 4, last 4):\n * ```typescript\n * maskNIK('3201234567890123');\n * // '3201********0123'\n * ```\n *\n * @example\n * Custom mask character:\n * ```typescript\n * maskNIK('3201234567890123', { char: 'X' });\n * // '3201XXXXXXXX0123'\n * ```\n *\n * @example\n * With separator:\n * ```typescript\n * maskNIK('3201234567890123', { separator: '-' });\n * // '32-01-**-**-**-**-0123'\n * ```\n *\n * @example\n * Custom start and end:\n * ```typescript\n * maskNIK('3201234567890123', { start: 6, end: 4 });\n * // '320123******0123'\n * ```\n *\n * @public\n */\nexport function maskNIK(nik: string, options: MaskOptions = {}): string {\n if (!/^\\d{16}$/.test(nik)) {\n return nik;\n }\n\n const { start = 4, end = 4, char = '*', separator } = options;\n\n if (start + end >= 16) {\n return nik;\n }\n\n if (separator) {\n // Format with separator first, then apply masking\n const formatted = formatNIK(nik, separator);\n const parts = formatted.split(separator);\n\n // Calculate which parts to mask\n // Format: PP-KK-DD-YY-MM-DD-XXXX (7 parts)\n // Mask parts based on character positions\n let charCount = 0;\n const maskedParts = parts.map((part) => {\n const partStart = charCount;\n const partEnd = charCount + part.length;\n charCount += part.length;\n\n // Check if this part should be fully/partially masked\n if (partEnd <= start) {\n // Fully visible (before start)\n return part;\n } else if (partStart >= 16 - end) {\n // Fully visible (after end)\n return part;\n } else if (partStart >= start && partEnd <= 16 - end) {\n // Fully masked\n return char.repeat(part.length);\n } else {\n // Partially masked\n return part\n .split('')\n .map((ch, idx) => {\n const pos = partStart + idx;\n if (pos < start || pos >= 16 - end) {\n return ch;\n }\n return char;\n })\n .join('');\n }\n });\n\n return maskedParts.join(separator);\n }\n\n // Without separator: simple masking\n const startPart = nik.substring(0, start);\n const endPart = nik.substring(16 - end);\n const maskLength = 16 - start - end;\n return startPart + char.repeat(maskLength) + endPart;\n}","import { parseNIK } from './parse';\n\n/**\n * Calculates the age of a person based on their NIK.\n *\n * @param nik - The 16-digit NIK string\n * @param referenceDate - The date to calculate age from (default: current date)\n * @returns The age in years, or null if the NIK is invalid or birth date cannot be parsed\n *\n * @example\n * ```typescript\n * getAge('3201018901310123'); // 35 (as of 2024)\n * ```\n */\nexport function getAge(\n nik: string,\n referenceDate: Date = new Date()\n): number | null {\n const info = parseNIK(nik);\n if (!info || !info.birthDate) {\n return null;\n }\n\n const birthDate = info.birthDate;\n let age = referenceDate.getFullYear() - birthDate.getFullYear();\n const m = referenceDate.getMonth() - birthDate.getMonth();\n\n if (m < 0 || (m === 0 && referenceDate.getDate() < birthDate.getDate())) {\n age--;\n }\n\n return age;\n}\n\n/**\n * Formats the birth date from a NIK into a human-readable string.\n *\n * @param nik - The 16-digit NIK string\n * @param locale - The locale to use for formatting (default: 'id-ID')\n * @returns Formatted birth date string, or null if invalid\n *\n * @example\n * ```typescript\n * formatBirthDate('3201018901310123'); // '31 Januari 1989'\n * ```\n */\nexport function formatBirthDate(\n nik: string,\n options: Intl.DateTimeFormatOptions = {\n day: 'numeric',\n month: 'long',\n year: 'numeric',\n },\n locale: string = 'id-ID'\n): string | null {\n const info = parseNIK(nik);\n if (!info || !info.birthDate) {\n return null;\n }\n\n return new Intl.DateTimeFormat(locale, options).format(info.birthDate);\n}\n\n/**\n * Checks if a NIK matches a specific gender.\n *\n * @param nik - The 16-digit NIK string\n * @param gender - The gender to check ('male' | 'female')\n * @returns True if the NIK matches the gender, false otherwise\n */\nexport function isValidForGender(\n nik: string,\n gender: 'male' | 'female'\n): boolean {\n const info = parseNIK(nik);\n if (!info) {\n return false;\n }\n return info.gender === gender;\n}\n\n/**\n * Checks if a NIK matches a specific birth date.\n *\n * @param nik - The 16-digit NIK string\n * @param birthDate - The birth date to check\n * @returns True if the NIK matches the birth date, false otherwise\n */\nexport function isValidForBirthDate(nik: string, birthDate: Date): boolean {\n const info = parseNIK(nik);\n if (!info || !info.birthDate) {\n return false;\n }\n\n return (\n info.birthDate.getFullYear() === birthDate.getFullYear() &&\n info.birthDate.getMonth() === birthDate.getMonth() &&\n info.birthDate.getDate() === birthDate.getDate()\n );\n}\n","/**\n * Information extracted from a valid NIK.\n *\n * Contains parsed data including location codes, birth date, gender,\n * and serial number from a 16-digit NIK string.\n *\n * @public\n */\nexport interface NIKInfo {\n /**\n * Province information extracted from positions 1-2 of the NIK.\n *\n * @example\n * ```typescript\n * { code: '32', name: 'Jawa Barat' }\n * ```\n */\n province: {\n /** Two-digit province code (e.g., '32') */\n code: string;\n /** Full province name (e.g., 'Jawa Barat') */\n name: string;\n };\n\n /**\n * Regency (Kabupaten/Kota) information extracted from positions 3-4 of the NIK.\n *\n * @example\n * ```typescript\n * { code: '01', name: 'Kab. Bogor' }\n * ```\n */\n regency: {\n /** Two-digit regency code (e.g., '01') */\n code: string;\n /** Full regency name (e.g., 'Kab. Bogor') */\n name: string;\n };\n\n /**\n * District (Kecamatan) information extracted from positions 5-6 of the NIK.\n * May be `null` if district data is not available.\n *\n * @example\n * ```typescript\n * { code: '23', name: 'Ciawi' }\n * ```\n */\n district: {\n /** Two-digit district code (e.g., '23') */\n code: string;\n /** Full district name, or `null` if data unavailable */\n name: string | null;\n };\n\n /**\n * Birth date extracted from positions 7-12 of the NIK.\n * For females, the day is encoded as (actual day + 40).\n * Returns `null` if the date is invalid.\n *\n * @example\n * ```typescript\n * new Date(1989, 0, 31) // January 31, 1989\n * ```\n */\n birthDate: Date | null;\n\n /**\n * Gender derived from the day encoding in the NIK.\n * - 'male': day is 1-31\n * - 'female': day is 41-71 (actual day + 40)\n * - `null`: if unable to determine\n */\n gender: 'male' | 'female' | null;\n\n /**\n * Serial number from positions 13-16 of the NIK.\n * Uniquely identifies individuals with the same location and birth date.\n * Returns `null` if unable to extract.\n *\n * @example\n * ```typescript\n * '0123'\n * ```\n */\n serialNumber: string | null;\n\n /**\n * Whether the NIK passed validation checks.\n * If `false`, other fields may be `null` or contain partial data.\n */\n isValid: boolean;\n}\n\n/**\n * Options for masking a NIK to protect privacy.\n *\n * Controls how many characters to show at the start and end,\n * what character to use for masking, and optional separators.\n *\n * @example\n * ```typescript\n * // Default: shows first 4 and last 4 digits\n * { start: 4, end: 4, char: '*' }\n * // Result: '3201********0123'\n *\n * // With separator\n * { start: 4, end: 4, char: '*', separator: '-' }\n * // Result: '3201-****-****-0123'\n * ```\n *\n * @public\n */\nexport interface MaskOptions {\n /**\n * Number of characters to show at the start.\n *\n * @defaultValue 4\n */\n start?: number;\n\n /**\n * Number of characters to show at the end.\n *\n * @defaultValue 4\n */\n end?: number;\n\n /**\n * Character to use for masking hidden digits.\n *\n * @defaultValue '*'\n */\n char?: string;\n\n /**\n * Optional separator to add between groups of digits.\n * If provided, the NIK will be formatted with separators.\n *\n * @defaultValue undefined (no separator)\n *\n * @example\n * ```typescript\n * '-' // Results in format: '3201-****-****-0123'\n * ' ' // Results in format: '3201 **** **** 0123'\n * ```\n */\n separator?: string;\n}\n\n/**\n * Error thrown when an invalid NIK is provided to a function.\n * Extends native Error with a `code` property for programmatic error handling.\n *\n * @example\n * ```typescript\n * try {\n * requireNIK('invalid');\n * } catch (error) {\n * if (error instanceof InvalidNIKError) {\n * console.log(error.code); // 'INVALID_NIK'\n * }\n * }\n * ```\n *\n * @public\n */\nexport class InvalidNIKError extends Error {\n /** Error code for programmatic identification */\n readonly code = 'INVALID_NIK' as const;\n\n constructor(message: string = 'Invalid NIK provided') {\n super(message);\n this.name = 'InvalidNIKError';\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/nik/constants.ts","../../src/nik/utils/date.ts","../../src/nik/validate.ts","../../src/nik/parse.ts","../../src/nik/format.ts","../../src/nik/clean.ts","../../src/nik/validate-detailed.ts","../../src/nik/utils.ts","../../src/nik/types.ts"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W,KAAK,CAAC,IAAI,IAAI,CAAA,CAAA;AAC5C;AASO,SAAS,gBAAA,CACd,KACA,MAAA,EACS;AACT,EAAA,MAAM,IAAA,GAAO,SAAS,GAAG,CAAA;AACzB,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OAAO,KAAK,MAAA,KAAW,MAAA;AACzB;AASO,SAAS,mBAAA,CAAoB,KAAa,SAAA,EAA0B;AACzE,EAAA,MAAM,IAAA,GAAO,SAAS,GAAG,CAAA;AACzB,EAAA,IAAI,CAAC,IAAA,IAAQ,CAAC,IAAA,CAAK,SAAA,EAAW;AAC5B,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,OACE,KAAK,SAAA,CAAU,WAAA,OAAkB,SAAA,CAAU,WAAA,MAC3C,IAAA,CAAK,SAAA,CAAU,UAAS,KAAM,SAAA,CAAU,UAAS,IACjD,IAAA,CAAK,UAAU,OAAA,EAAQ,KAAM,UAAU,OAAA,EAAQ;AAEnD;;;AC9FO,IAAM,eAAA,GAAN,cAA8B,KAAA,CAAM;AAAA,EAIzC,WAAA,CAAY,UAAkB,sBAAA,EAAwB;AACpD,IAAA,KAAA,CAAM,OAAO,CAAA;AAHf;AAAA,IAAA,IAAA,CAAS,IAAA,GAAO,aAAA;AAId,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AAAA,EACd;AACF","file":"index.js","sourcesContent":["/**\n * Indonesian province codes and names\n * Based on Dukcapil Kemendagri data\n */\nexport const PROVINCES: Record<string, string> = {\n '11': 'Aceh',\n '12': 'Sumatera Utara',\n '13': 'Sumatera Barat',\n '14': 'Riau',\n '15': 'Jambi',\n '16': 'Sumatera Selatan',\n '17': 'Bengkulu',\n '18': 'Lampung',\n '19': 'Kepulauan Bangka Belitung',\n '21': 'Kepulauan Riau',\n '31': 'DKI Jakarta',\n '32': 'Jawa Barat',\n '33': 'Jawa Tengah',\n '34': 'DI Yogyakarta',\n '35': 'Jawa Timur',\n '36': 'Banten',\n '51': 'Bali',\n '52': 'Nusa Tenggara Barat',\n '53': 'Nusa Tenggara Timur',\n '61': 'Kalimantan Barat',\n '62': 'Kalimantan Tengah',\n '63': 'Kalimantan Selatan',\n '64': 'Kalimantan Timur',\n '65': 'Kalimantan Utara',\n '71': 'Sulawesi Utara',\n '72': 'Sulawesi Tengah',\n '73': 'Sulawesi Selatan',\n '74': 'Sulawesi Tenggara',\n '75': 'Gorontalo',\n '76': 'Sulawesi Barat',\n '81': 'Maluku',\n '82': 'Maluku Utara',\n '91': 'Papua',\n '92': 'Papua Barat',\n '93': 'Papua Selatan',\n '94': 'Papua Tengah',\n '95': 'Papua Pegunungan',\n '96': 'Papua Barat Daya',\n};\n\n/**\n * Regency codes for each province (simplified - only major ones)\n * In a real implementation, you'd have complete data\n */\nexport const REGENCIES: Record<string, Record<string, string>> = {\n '32': {\n '01': 'Kab. Bogor',\n '02': 'Kab. Sukabumi',\n '03': 'Kab. Cianjur',\n '71': 'Kota Bandung',\n '72': 'Kota Bekasi',\n '73': 'Kota Depok',\n },\n '31': { \n '01': 'Kota Jakarta Selatan',\n '02': 'Kota Jakarta Timur',\n '03': 'Kota Jakarta Pusat',\n '04': 'Kota Jakarta Barat',\n '05': 'Kota Jakarta Utara',\n },\n};","/**\n * Shared date parsing and validation utilities for NIK module.\n *\n * @module nik/utils/date\n * @packageDocumentation\n */\n\n/**\n * Result of parsing date components from a NIK string.\n *\n * @public\n */\nexport interface ParsedNIKDate {\n /** 2-digit year code (00-99) from NIK positions 7-8 */\n year: number;\n /** Full 4-digit year (1900-1999 or 2000-2099) */\n fullYear: number;\n /** Month (1-12) from NIK positions 9-10 */\n month: number;\n /** Actual day (1-31), decoded from encoded day */\n day: number;\n /** Gender derived from day encoding */\n gender: 'male' | 'female';\n /** Original encoded day (1-31 for male, 41-71 for female) */\n dayEncoded: number;\n}\n\n/**\n * Parses date components from a NIK string.\n *\n * Extracts year, month, and encoded day from positions 7-12 of the NIK.\n * For females, the day is encoded as (actual day + 40).\n *\n * @param nik - 16-digit NIK string\n * @returns ParsedNIKDate or null if NIK format is invalid\n *\n * @example\n * ```typescript\n * const result = parseNIKDate('3201018901310123');\n * // { year: 89, fullYear: 1989, month: 1, day: 31, gender: 'male', dayEncoded: 31 }\n * ```\n *\n * @public\n */\nexport function parseNIKDate(nik: string): ParsedNIKDate | null {\n if (nik.length !== 16) {\n return null;\n }\n\n const yearStr = nik.substring(6, 8);\n const monthStr = nik.substring(8, 10);\n const dayEncodedStr = nik.substring(10, 12);\n\n const year = parseInt(yearStr, 10);\n if (isNaN(year)) return null;\n\n const fullYear = year > 30 ? 1900 + year : 2000 + year;\n\n const month = parseInt(monthStr, 10);\n if (isNaN(month)) return null;\n\n const dayEncoded = parseInt(dayEncodedStr, 10);\n if (isNaN(dayEncoded)) return null;\n\n const gender: 'male' | 'female' = dayEncoded > 40 ? 'female' : 'male';\n const day = dayEncoded > 40 ? dayEncoded - 40 : dayEncoded;\n\n return { year, fullYear, month, day, gender, dayEncoded };\n}\n\n/**\n * Validates if year/month/day form a valid calendar date.\n *\n * Uses JavaScript's Date object to check if the date actually exists\n * (handles leap years, invalid month/day combinations).\n *\n * @param year - Full 4-digit year\n * @param month - Month (1-12)\n * @param day - Day (1-31)\n * @returns true if valid calendar date\n *\n * @example\n * ```typescript\n * validateNIKDateComponents(2024, 2, 29); // true (leap year)\n * validateNIKDateComponents(2023, 2, 29); // false\n * validateNIKDateComponents(2024, 13, 1); // false\n * ```\n *\n * @public\n */\nexport function validateNIKDateComponents(\n year: number,\n month: number,\n day: number\n): boolean {\n if (month < 1 || month > 12) return false;\n if (day < 1 || day > 31) return false;\n\n const testDate = new Date(year, month - 1, day);\n return (\n testDate.getFullYear() === year &&\n testDate.getMonth() === month - 1 &&\n testDate.getDate() === day\n );\n}\n","import { PROVINCES } from './constants';\nimport { parseNIKDate, validateNIKDateComponents } from './utils/date';\n\nconst NIK_PATTERN = /^\\d{16}$/;\n\n/**\n * Validates a NIK (Nomor Induk Kependudukan) format.\n *\n * A valid NIK must:\n * - Be exactly 16 digits\n * - Have a valid province code (positions 1-2)\n * - Have a valid date (positions 7-12)\n * - Not be in the future\n * - Not be before 1900\n *\n * For female NIKs, the day is encoded as (actual day + 40).\n * For example, a female born on the 15th would have day = 55.\n *\n * @param nik - The 16-digit NIK string to validate\n * @returns `true` if the NIK is valid, `false` otherwise\n *\n * @example\n * ```typescript\n * validateNIK('3201234567890123'); // true - valid NIK\n * validateNIK('1234'); // false - wrong length\n * validateNIK('9912345678901234'); // false - invalid province\n * ```\n *\n * @public\n */\nexport function validateNIK(nik: string): boolean {\n if (!NIK_PATTERN.test(nik)) {\n return false;\n }\n\n const provinceCode = nik.substring(0, 2);\n if (!PROVINCES[provinceCode]) {\n return false;\n }\n\n const parsed = parseNIKDate(nik);\n if (!parsed) {\n return false;\n }\n\n const { fullYear, month, day } = parsed;\n\n if (!validateNIKDateComponents(fullYear, month, day)) {\n return false;\n }\n\n const now = new Date();\n if (new Date(fullYear, month - 1, day) > now || fullYear < 1900) {\n return false;\n }\n\n return true;\n}\n","import { PROVINCES, REGENCIES } from './constants';\nimport { NIKInfo } from './types';\nimport { parseNIKDate, validateNIKDateComponents } from './utils/date';\n\nconst NIK_PATTERN = /^\\d{16}$/;\n\n/**\n * Parses a NIK and extracts all embedded information.\n *\n * Extracts province, regency, district codes, birth date, gender,\n * and serial number from a 16-digit NIK string.\n *\n * @param nik - The 16-digit NIK string to parse\n * @returns Parsed NIK information, or `null` if the NIK format is invalid\n *\n * @example\n * Parse a valid male NIK:\n * ```typescript\n * const info = parseNIK('3201018901310123');\n * console.log(info);\n * // {\n * // province: { code: '32', name: 'Jawa Barat' },\n * // regency: { code: '01', name: 'Kab. Bogor' },\n * // district: { code: '01', name: null },\n * // birthDate: Date(1989, 0, 31), // Jan 31, 1989\n * // gender: 'male',\n * // serialNumber: '0123',\n * // isValid: true\n * // }\n * ```\n *\n * @example\n * Parse a female NIK (day + 40):\n * ```typescript\n * const info = parseNIK('3201019508550123');\n * console.log(info.gender); // 'female'\n * console.log(info.birthDate); // Date(1995, 7, 15) - Aug 15, 1995\n * ```\n *\n * @example\n * Invalid NIK returns null:\n * ```typescript\n * const info = parseNIK('invalid');\n * console.log(info); // null\n * ```\n *\n * @public\n */\nexport function parseNIK(nik: string): NIKInfo | null {\n if (!NIK_PATTERN.test(nik)) {\n return null;\n }\n\n const provinceCode = nik.substring(0, 2);\n const regencyCode = nik.substring(2, 4);\n const districtCode = nik.substring(4, 6);\n const serialNumber = nik.substring(12, 16);\n\n const province = PROVINCES[provinceCode];\n if (!province) {\n return null;\n }\n\n const regencies = REGENCIES[provinceCode] || {};\n const regency = regencies[regencyCode] || 'Unknown';\n\n const parsed = parseNIKDate(nik);\n if (!parsed) {\n return null;\n }\n\n const { fullYear, month, day, gender } = parsed;\n\n if (!validateNIKDateComponents(fullYear, month, day)) {\n return null;\n }\n\n const birthDate = new Date(fullYear, month - 1, day);\n\n return {\n province: {\n code: provinceCode,\n name: province,\n },\n regency: {\n code: regencyCode,\n name: regency,\n },\n district: {\n code: districtCode,\n name: null,\n },\n birthDate,\n gender,\n serialNumber,\n isValid: true,\n };\n}\n","import { MaskOptions } from './types';\n\n/**\n * Formats a NIK with separators for better readability.\n *\n * Groups the NIK into logical segments: province, regency, district,\n * year, month, day, and serial number.\n *\n * @param nik - The 16-digit NIK string to format\n * @param separator - Character to use as separator\n * @returns Formatted NIK string, or original string if invalid format\n *\n * @example\n * Default separator (dash):\n * ```typescript\n * formatNIK('3201234567890123');\n * // '32-01-23-45-67-89-0123'\n * ```\n *\n * @example\n * Custom separator:\n * ```typescript\n * formatNIK('3201234567890123', ' ');\n * // '32 01 23 45 67 89 0123'\n * ```\n *\n * @example\n * Invalid NIK returns as-is:\n * ```typescript\n * formatNIK('1234');\n * // '1234'\n * ```\n *\n * @public\n */\nexport function formatNIK(nik: string, separator: string = '-'): string {\n if (!/^\\d{16}$/.test(nik)) {\n return nik;\n }\n\n // Format: PP-KK-DD-YY-MM-DD-XXXX\n // PP = Province (2 digits)\n // KK = Regency (2 digits)\n // DD = District (2 digits)\n // YY = Year (2 digits)\n // MM = Month (2 digits)\n // DD = Day (2 digits, +40 for female)\n // XXXX = Serial number (4 digits)\n return [\n nik.substring(0, 2), // Province\n nik.substring(2, 4), // Regency\n nik.substring(4, 6), // District\n nik.substring(6, 8), // Year\n nik.substring(8, 10), // Month\n nik.substring(10, 12), // Day\n nik.substring(12, 16), // Serial\n ].join(separator);\n}\n\n/**\n * Masks a NIK to protect privacy while keeping partial visibility.\n *\n * By default, shows the first 4 and last 4 digits, masking the middle 8.\n * Optionally formats the masked NIK with separators.\n *\n * @param nik - The 16-digit NIK string to mask\n * @param options - Masking configuration options\n * @returns Masked NIK string, or original string if invalid format\n *\n * @example\n * Default masking (first 4, last 4):\n * ```typescript\n * maskNIK('3201234567890123');\n * // '3201********0123'\n * ```\n *\n * @example\n * Custom mask character:\n * ```typescript\n * maskNIK('3201234567890123', { char: 'X' });\n * // '3201XXXXXXXX0123'\n * ```\n *\n * @example\n * With separator:\n * ```typescript\n * maskNIK('3201234567890123', { separator: '-' });\n * // '32-01-**-**-**-**-0123'\n * ```\n *\n * @example\n * Custom start and end:\n * ```typescript\n * maskNIK('3201234567890123', { start: 6, end: 4 });\n * // '320123******0123'\n * ```\n *\n * @public\n */\nexport function maskNIK(nik: string, options: MaskOptions = {}): string {\n if (!/^\\d{16}$/.test(nik)) {\n return nik;\n }\n\n const { start = 4, end = 4, char = '*', separator } = options;\n\n if (start + end >= 16) {\n return nik;\n }\n\n if (separator) {\n // Format with separator first, then apply masking\n const formatted = formatNIK(nik, separator);\n const parts = formatted.split(separator);\n\n // Calculate which parts to mask\n // Format: PP-KK-DD-YY-MM-DD-XXXX (7 parts)\n // Mask parts based on character positions\n let charCount = 0;\n const maskedParts = parts.map((part) => {\n const partStart = charCount;\n const partEnd = charCount + part.length;\n charCount += part.length;\n\n // Check if this part should be fully/partially masked\n if (partEnd <= start) {\n // Fully visible (before start)\n return part;\n } else if (partStart >= 16 - end) {\n // Fully visible (after end)\n return part;\n } else if (partStart >= start && partEnd <= 16 - end) {\n // Fully masked\n return char.repeat(part.length);\n } else {\n // Partially masked - This branch is theoretically possible for variable-width\n // parts, but with fixed 2-char NIK segments it cannot be triggered since\n // no 2-char part can span both the start-visible and end-visible boundaries.\n return part\n .split('')\n .map((ch, idx) => {\n const pos = partStart + idx;\n if (pos < start || pos >= 16 - end) {\n return ch;\n }\n return char;\n })\n .join('');\n }\n });\n\n return maskedParts.join(separator);\n }\n\n // Without separator: simple masking\n const startPart = nik.substring(0, start);\n const endPart = nik.substring(16 - end);\n const maskLength = 16 - start - end;\n return startPart + char.repeat(maskLength) + endPart;\n}\n","/**\n * Cleans a NIK by removing all non-digit characters.\n *\n * Accepts NIK in any format (with separators like `.`, `-`, ` `) and\n * returns a clean 16-digit string. Returns empty string for invalid inputs.\n *\n * @param nik - NIK in any format\n * @returns Clean 16-digit NIK or empty string if invalid\n *\n * @example\n * ```typescript\n * cleanNIK('32-01-01-89-01-31-0123'); // '3201018901310123'\n * cleanNIK('3201.8901.3101.23'); // '32018901310123' (only 14 digits - invalid)\n * cleanNIK('invalid'); // ''\n * ```\n *\n * @public\n */\nexport function cleanNIK(nik: string): string {\n if (typeof nik !== 'string') {\n return '';\n }\n\n const cleaned = nik.replace(/\\D/g, '');\n\n if (cleaned.length !== 16) {\n return '';\n }\n\n return cleaned;\n}\n","import { PROVINCES } from './constants';\nimport { NIKValidationResult, NIKValidationError, NIKErrorCode } from './types';\nimport { cleanNIK } from './clean';\nimport { parseNIK } from './parse';\n\nfunction createError(code: NIKErrorCode, message: string): NIKValidationError {\n return { code, message };\n}\n\n/**\n * Validates a NIK and returns detailed error information.\n *\n * Unlike `validateNIK` which returns a boolean, this function provides\n * structured error reporting for form validation use cases.\n *\n * @param nik - The NIK string to validate (accepts any format with separators)\n * @returns Detailed validation result with errors array\n *\n * @example\n * ```typescript\n * const result = validateNIKDetailed('3201018901310123');\n * if (!result.isValid) {\n * result.errors.forEach(err => {\n * console.log(`${err.code}: ${err.message}`);\n * });\n * }\n * ```\n *\n * @public\n */\nexport function validateNIKDetailed(nik: string): NIKValidationResult {\n const cleaned = cleanNIK(nik);\n\n if (cleaned === '') {\n return {\n isValid: false,\n errors: [createError('INVALID_FORMAT', 'NIK must be exactly 16 digits')],\n nik: null,\n };\n }\n\n const provinceCode = cleaned.substring(0, 2);\n if (!PROVINCES[provinceCode]) {\n return {\n isValid: false,\n errors: [\n createError(\n 'INVALID_PROVINCE',\n `Province code ${provinceCode} not found`\n ),\n ],\n nik: null,\n };\n }\n\n const info = parseNIK(cleaned);\n if (!info) {\n return {\n isValid: false,\n errors: [createError('INVALID_DATE', 'Invalid date components')],\n nik: null,\n };\n }\n\n const birthDate = info.birthDate;\n if (!birthDate) {\n return {\n isValid: false,\n errors: [createError('INVALID_DATE', 'Invalid birth date')],\n nik: null,\n };\n }\n\n const now = new Date();\n if (birthDate > now) {\n return {\n isValid: false,\n errors: [\n createError('FUTURE_DATE', 'Birth date cannot be in the future'),\n ],\n nik: null,\n };\n }\n\n return {\n isValid: true,\n errors: [],\n nik: cleaned,\n };\n}\n","import { parseNIK } from './parse';\nimport { cleanNIK } from './clean';\nimport { Age, GetAgeOptions } from './types';\n\n/**\n * Calculates the age of a person based on their NIK.\n *\n * Returns detailed age breakdown with years, months, and days, or a\n * formatted Indonesian string. This is consistent with `datetime.getAge()`.\n *\n * @param nik - The 16-digit NIK string\n * @param options - Options object with `referenceDate` and `asString`\n * @returns Age object `{ years, months, days }`, formatted string, or null if invalid\n *\n * @example\n * ```typescript\n * // Returns object by default\n * getAge('3201018901310123');\n * // { years: 35, months: 2, days: 6 } (as of 2026-04-06)\n *\n * // Returns formatted string\n * getAge('3201018901310123', { asString: true });\n * // '35 Tahun 2 Bulan 6 Hari'\n *\n * // Custom reference date\n * getAge('3201018901310123', { referenceDate: new Date('2025-01-01') });\n * // { years: 35, months: 11, days: 1 }\n * ```\n *\n * @public\n */\nexport function getAge(\n nik: string,\n options: GetAgeOptions = {}\n): Age | string | null {\n const { referenceDate = new Date(), asString = false } = options;\n\n const info = parseNIK(nik);\n if (!info || !info.birthDate) {\n return null;\n }\n\n const birthDate = info.birthDate;\n let years = referenceDate.getFullYear() - birthDate.getFullYear();\n let months = referenceDate.getMonth() - birthDate.getMonth();\n let days = referenceDate.getDate() - birthDate.getDate();\n\n if (days < 0) {\n months--;\n const prevMonth = new Date(\n referenceDate.getFullYear(),\n referenceDate.getMonth(),\n 0\n );\n days += prevMonth.getDate();\n }\n\n if (months < 0) {\n years--;\n months += 12;\n }\n\n if (asString) {\n const parts: string[] = [];\n if (years > 0) parts.push(`${years} Tahun`);\n if (months > 0) parts.push(`${months} Bulan`);\n if (days > 0 || parts.length === 0) parts.push(`${days} Hari`);\n return parts.join(' ');\n }\n\n return { years, months, days };\n}\n\n/**\n * Compares two NIKs to check if they belong to the same person.\n *\n * Two NIKs are considered the same person if they have identical:\n * - Province code (positions 1-2)\n * - Regency code (positions 3-4)\n * - District code (positions 5-6)\n * - Birth date (year + month + day)\n * - Gender (derived from day encoding)\n * - Serial number (positions 13-16)\n *\n * @param nik1 - First NIK (accepts any format)\n * @param nik2 - Second NIK (accepts any format)\n * @returns True if both NIKs belong to the same person, false otherwise\n *\n * @example\n * ```typescript\n * // Same person, same format\n * compareNIK('3201018901310123', '3201018901310123'); // true\n *\n * // Same person, different format\n * compareNIK('3201018901310123', '3201-01-89-01-31-0123'); // true\n *\n * // Different serial number\n * compareNIK('3201018901310123', '3201018901310124'); // false\n *\n * // Invalid NIK\n * compareNIK('invalid', '3201018901310123'); // false\n * ```\n *\n * @public\n */\nexport function compareNIK(nik1: string, nik2: string): boolean {\n const cleaned1 = cleanNIK(nik1);\n const cleaned2 = cleanNIK(nik2);\n\n if (\n cleaned1 === '' ||\n cleaned2 === '' ||\n cleaned1.length !== 16 ||\n cleaned2.length !== 16\n ) {\n return false;\n }\n\n if (cleaned1 === cleaned2) {\n return true;\n }\n\n const pos1_6_1 = cleaned1.substring(0, 6);\n const pos1_6_2 = cleaned2.substring(0, 6);\n\n if (pos1_6_1 !== pos1_6_2) {\n return false;\n }\n\n const birthDate1 = cleaned1.substring(6, 12);\n const birthDate2 = cleaned2.substring(6, 12);\n\n if (birthDate1 !== birthDate2) {\n return false;\n }\n\n const serial1 = cleaned1.substring(12, 16);\n const serial2 = cleaned2.substring(12, 16);\n\n return serial1 === serial2;\n}\n\n/**\n * Checks if a person is an adult based on their NIK.\n *\n * By default, uses 17 years as the threshold (Indonesian KTP eligibility age).\n * Indonesian law allows KTP at age 17, or upon marriage, or already married.\n *\n * @param nik - The 16-digit NIK string\n * @param minAge - Minimum age threshold (default: 17)\n * @returns True if the person is at least minAge years old, false otherwise\n *\n * @example\n * ```typescript\n * // Born 1995-01-01, reference 2026-04-06 (age 31)\n * isAdult('3201950101950123'); // true (31 >= 17)\n * isAdult('3201950101950123', 21); // true (31 >= 21)\n *\n * // Born 2010-01-01, reference 2026-04-06 (age 16)\n * isAdult('3210010101950123'); // false (16 < 17)\n * isAdult('3210010101950123', 16); // true (16 >= 16)\n *\n * // Invalid NIK\n * isAdult('invalid'); // false\n * ```\n *\n * @public\n */\nexport function isAdult(nik: string, minAge: number = 17): boolean {\n const age = getAge(nik);\n if (age === null) {\n return false;\n }\n\n if (typeof age === 'string') {\n const yearsMatch = age.match(/^(\\d+)/);\n if (yearsMatch) {\n return parseInt(yearsMatch[1], 10) >= minAge;\n }\n return false;\n }\n\n return age.years >= minAge;\n}\n\n/**\n * Formats the birth date from a NIK into a human-readable string.\n *\n * @param nik - The 16-digit NIK string\n * @param locale - The locale to use for formatting (default: 'id-ID')\n * @returns Formatted birth date string, or null if invalid\n *\n * @example\n * ```typescript\n * formatBirthDate('3201018901310123'); // '31 Januari 1989'\n * ```\n */\nexport function formatBirthDate(nik: string): string | null {\n const info = parseNIK(nik);\n if (!info || !info.birthDate) {\n return null;\n }\n\n const day = info.birthDate.getDate();\n const month = info.birthDate.getMonth();\n const year = info.birthDate.getFullYear();\n\n const monthNames = [\n 'Januari',\n 'Februari',\n 'Maret',\n 'April',\n 'Mei',\n 'Juni',\n 'Juli',\n 'Agustus',\n 'September',\n 'Oktober',\n 'November',\n 'Desember',\n ];\n\n return `${day} ${monthNames[month]} ${year}`;\n}\n\n/**\n * Checks if a NIK matches a specific gender.\n *\n * @param nik - The 16-digit NIK string\n * @param gender - The gender to check ('male' | 'female')\n * @returns True if the NIK matches the gender, false otherwise\n */\nexport function isValidForGender(\n nik: string,\n gender: 'male' | 'female'\n): boolean {\n const info = parseNIK(nik);\n if (!info) {\n return false;\n }\n return info.gender === gender;\n}\n\n/**\n * Checks if a NIK matches a specific birth date.\n *\n * @param nik - The 16-digit NIK string\n * @param birthDate - The birth date to check\n * @returns True if the NIK matches the birth date, false otherwise\n */\nexport function isValidForBirthDate(nik: string, birthDate: Date): boolean {\n const info = parseNIK(nik);\n if (!info || !info.birthDate) {\n return false;\n }\n\n return (\n info.birthDate.getFullYear() === birthDate.getFullYear() &&\n info.birthDate.getMonth() === birthDate.getMonth() &&\n info.birthDate.getDate() === birthDate.getDate()\n );\n}\n","/**\n * Information extracted from a valid NIK.\n *\n * Contains parsed data including location codes, birth date, gender,\n * and serial number from a 16-digit NIK string.\n *\n * @public\n */\nexport interface NIKInfo {\n /**\n * Province information extracted from positions 1-2 of the NIK.\n *\n * @example\n * ```typescript\n * { code: '32', name: 'Jawa Barat' }\n * ```\n */\n province: {\n /** Two-digit province code (e.g., '32') */\n code: string;\n /** Full province name (e.g., 'Jawa Barat') */\n name: string;\n };\n\n /**\n * Regency (Kabupaten/Kota) information extracted from positions 3-4 of the NIK.\n *\n * @example\n * ```typescript\n * { code: '01', name: 'Kab. Bogor' }\n * ```\n */\n regency: {\n /** Two-digit regency code (e.g., '01') */\n code: string;\n /** Full regency name (e.g., 'Kab. Bogor') */\n name: string;\n };\n\n /**\n * District (Kecamatan) information extracted from positions 5-6 of the NIK.\n * May be `null` if district data is not available.\n *\n * @example\n * ```typescript\n * { code: '23', name: 'Ciawi' }\n * ```\n */\n district: {\n /** Two-digit district code (e.g., '23') */\n code: string;\n /** Full district name, or `null` if data unavailable */\n name: string | null;\n };\n\n /**\n * Birth date extracted from positions 7-12 of the NIK.\n * For females, the day is encoded as (actual day + 40).\n * Returns `null` if the date is invalid.\n *\n * @example\n * ```typescript\n * new Date(1989, 0, 31) // January 31, 1989\n * ```\n */\n birthDate: Date | null;\n\n /**\n * Gender derived from the day encoding in the NIK.\n * - 'male': day is 1-31\n * - 'female': day is 41-71 (actual day + 40)\n * - `null`: if unable to determine\n */\n gender: 'male' | 'female' | null;\n\n /**\n * Serial number from positions 13-16 of the NIK.\n * Uniquely identifies individuals with the same location and birth date.\n * Returns `null` if unable to extract.\n *\n * @example\n * ```typescript\n * '0123'\n * ```\n */\n serialNumber: string | null;\n\n /**\n * Whether the NIK passed validation checks.\n * If `false`, other fields may be `null` or contain partial data.\n */\n isValid: boolean;\n}\n\n/**\n * Options for masking a NIK to protect privacy.\n *\n * Controls how many characters to show at the start and end,\n * what character to use for masking, and optional separators.\n *\n * @example\n * ```typescript\n * // Default: shows first 4 and last 4 digits\n * { start: 4, end: 4, char: '*' }\n * // Result: '3201********0123'\n *\n * // With separator\n * { start: 4, end: 4, char: '*', separator: '-' }\n * // Result: '3201-****-****-0123'\n * ```\n *\n * @public\n */\nexport interface MaskOptions {\n /**\n * Number of characters to show at the start.\n *\n * @defaultValue 4\n */\n start?: number;\n\n /**\n * Number of characters to show at the end.\n *\n * @defaultValue 4\n */\n end?: number;\n\n /**\n * Character to use for masking hidden digits.\n *\n * @defaultValue '*'\n */\n char?: string;\n\n /**\n * Optional separator to add between groups of digits.\n * If provided, the NIK will be formatted with separators.\n *\n * @defaultValue undefined (no separator)\n *\n * @example\n * ```typescript\n * '-' // Results in format: '3201-****-****-0123'\n * ' ' // Results in format: '3201 **** **** 0123'\n * ```\n */\n separator?: string;\n}\n\n/**\n * Error thrown when an invalid NIK is provided to a function.\n * Extends native Error with a `code` property for programmatic error handling.\n *\n * @example\n * ```typescript\n * try {\n * requireNIK('invalid');\n * } catch (error) {\n * if (error instanceof InvalidNIKError) {\n * console.log(error.code); // 'INVALID_NIK'\n * }\n * }\n * ```\n *\n * @public\n */\nexport class InvalidNIKError extends Error {\n /** Error code for programmatic identification */\n readonly code = 'INVALID_NIK' as const;\n\n constructor(message: string = 'Invalid NIK provided') {\n super(message);\n this.name = 'InvalidNIKError';\n }\n}\n\n/**\n * Error codes for detailed NIK validation.\n *\n * @public\n */\nexport type NIKErrorCode =\n | 'INVALID_FORMAT'\n | 'INVALID_PROVINCE'\n | 'INVALID_MONTH'\n | 'INVALID_DAY'\n | 'INVALID_DATE'\n | 'FUTURE_DATE';\n\n/**\n * A single validation error with code and message.\n *\n * @public\n */\nexport interface NIKValidationError {\n /** Error code for programmatic handling */\n code: NIKErrorCode;\n /** Human-readable error message */\n message: string;\n}\n\n/**\n * Detailed validation result for NIK with structured error reporting.\n *\n * Use this for form validation where you need to show specific error\n * messages per field.\n *\n * @example\n * ```typescript\n * const result = validateNIKDetailed('1234');\n * if (!result.isValid) {\n * result.errors.forEach(err => {\n * console.log(err.code, err.message);\n * });\n * }\n * ```\n *\n * @public\n */\nexport interface NIKValidationResult {\n /** Whether the NIK is valid */\n isValid: boolean;\n /** List of validation errors (empty if valid) */\n errors: NIKValidationError[];\n /** Cleaned 16-digit NIK if valid, null otherwise */\n nik: string | null;\n}\n\n/**\n * Options for getAge function.\n *\n * @public\n */\nexport interface GetAgeOptions {\n /** Date to calculate age from (default: current date) */\n referenceDate?: Date;\n /** Return formatted Indonesian string instead of object */\n asString?: boolean;\n}\n\n/**\n * Age result object with years, months, and days.\n *\n * @public\n */\nexport interface Age {\n /** Full years */\n years: number;\n /** Remaining months after full years */\n months: number;\n /** Remaining days after full months */\n days: number;\n}\n"]}
|
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates a NIK (Nomor Induk Kependudukan) format.
|
|
3
|
+
*
|
|
4
|
+
* A valid NIK must:
|
|
5
|
+
* - Be exactly 16 digits
|
|
6
|
+
* - Have a valid province code (positions 1-2)
|
|
7
|
+
* - Have a valid date (positions 7-12)
|
|
8
|
+
* - Not be in the future
|
|
9
|
+
* - Not be before 1900
|
|
10
|
+
*
|
|
11
|
+
* For female NIKs, the day is encoded as (actual day + 40).
|
|
12
|
+
* For example, a female born on the 15th would have day = 55.
|
|
13
|
+
*
|
|
14
|
+
* @param nik - The 16-digit NIK string to validate
|
|
15
|
+
* @returns `true` if the NIK is valid, `false` otherwise
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* validateNIK('3201234567890123'); // true - valid NIK
|
|
20
|
+
* validateNIK('1234'); // false - wrong length
|
|
21
|
+
* validateNIK('9912345678901234'); // false - invalid province
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
declare function validateNIK(nik: string): boolean;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Information extracted from a valid NIK.
|
|
30
|
+
*
|
|
31
|
+
* Contains parsed data including location codes, birth date, gender,
|
|
32
|
+
* and serial number from a 16-digit NIK string.
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
interface NIKInfo {
|
|
37
|
+
/**
|
|
38
|
+
* Province information extracted from positions 1-2 of the NIK.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* { code: '32', name: 'Jawa Barat' }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
province: {
|
|
46
|
+
/** Two-digit province code (e.g., '32') */
|
|
47
|
+
code: string;
|
|
48
|
+
/** Full province name (e.g., 'Jawa Barat') */
|
|
49
|
+
name: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Regency (Kabupaten/Kota) information extracted from positions 3-4 of the NIK.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* { code: '01', name: 'Kab. Bogor' }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
regency: {
|
|
60
|
+
/** Two-digit regency code (e.g., '01') */
|
|
61
|
+
code: string;
|
|
62
|
+
/** Full regency name (e.g., 'Kab. Bogor') */
|
|
63
|
+
name: string;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* District (Kecamatan) information extracted from positions 5-6 of the NIK.
|
|
67
|
+
* May be `null` if district data is not available.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* { code: '23', name: 'Ciawi' }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
district: {
|
|
75
|
+
/** Two-digit district code (e.g., '23') */
|
|
76
|
+
code: string;
|
|
77
|
+
/** Full district name, or `null` if data unavailable */
|
|
78
|
+
name: string | null;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Birth date extracted from positions 7-12 of the NIK.
|
|
82
|
+
* For females, the day is encoded as (actual day + 40).
|
|
83
|
+
* Returns `null` if the date is invalid.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* new Date(1989, 0, 31) // January 31, 1989
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
birthDate: Date | null;
|
|
91
|
+
/**
|
|
92
|
+
* Gender derived from the day encoding in the NIK.
|
|
93
|
+
* - 'male': day is 1-31
|
|
94
|
+
* - 'female': day is 41-71 (actual day + 40)
|
|
95
|
+
* - `null`: if unable to determine
|
|
96
|
+
*/
|
|
97
|
+
gender: 'male' | 'female' | null;
|
|
98
|
+
/**
|
|
99
|
+
* Serial number from positions 13-16 of the NIK.
|
|
100
|
+
* Uniquely identifies individuals with the same location and birth date.
|
|
101
|
+
* Returns `null` if unable to extract.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* '0123'
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
serialNumber: string | null;
|
|
109
|
+
/**
|
|
110
|
+
* Whether the NIK passed validation checks.
|
|
111
|
+
* If `false`, other fields may be `null` or contain partial data.
|
|
112
|
+
*/
|
|
113
|
+
isValid: boolean;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Options for masking a NIK to protect privacy.
|
|
117
|
+
*
|
|
118
|
+
* Controls how many characters to show at the start and end,
|
|
119
|
+
* what character to use for masking, and optional separators.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* // Default: shows first 4 and last 4 digits
|
|
124
|
+
* { start: 4, end: 4, char: '*' }
|
|
125
|
+
* // Result: '3201********0123'
|
|
126
|
+
*
|
|
127
|
+
* // With separator
|
|
128
|
+
* { start: 4, end: 4, char: '*', separator: '-' }
|
|
129
|
+
* // Result: '3201-****-****-0123'
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* @public
|
|
133
|
+
*/
|
|
134
|
+
interface MaskOptions {
|
|
135
|
+
/**
|
|
136
|
+
* Number of characters to show at the start.
|
|
137
|
+
*
|
|
138
|
+
* @defaultValue 4
|
|
139
|
+
*/
|
|
140
|
+
start?: number;
|
|
141
|
+
/**
|
|
142
|
+
* Number of characters to show at the end.
|
|
143
|
+
*
|
|
144
|
+
* @defaultValue 4
|
|
145
|
+
*/
|
|
146
|
+
end?: number;
|
|
147
|
+
/**
|
|
148
|
+
* Character to use for masking hidden digits.
|
|
149
|
+
*
|
|
150
|
+
* @defaultValue '*'
|
|
151
|
+
*/
|
|
152
|
+
char?: string;
|
|
153
|
+
/**
|
|
154
|
+
* Optional separator to add between groups of digits.
|
|
155
|
+
* If provided, the NIK will be formatted with separators.
|
|
156
|
+
*
|
|
157
|
+
* @defaultValue undefined (no separator)
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* '-' // Results in format: '3201-****-****-0123'
|
|
162
|
+
* ' ' // Results in format: '3201 **** **** 0123'
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
separator?: string;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Error thrown when an invalid NIK is provided to a function.
|
|
169
|
+
* Extends native Error with a `code` property for programmatic error handling.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```typescript
|
|
173
|
+
* try {
|
|
174
|
+
* requireNIK('invalid');
|
|
175
|
+
* } catch (error) {
|
|
176
|
+
* if (error instanceof InvalidNIKError) {
|
|
177
|
+
* console.log(error.code); // 'INVALID_NIK'
|
|
178
|
+
* }
|
|
179
|
+
* }
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
* @public
|
|
183
|
+
*/
|
|
184
|
+
declare class InvalidNIKError extends Error {
|
|
185
|
+
/** Error code for programmatic identification */
|
|
186
|
+
readonly code: "INVALID_NIK";
|
|
187
|
+
constructor(message?: string);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Error codes for detailed NIK validation.
|
|
191
|
+
*
|
|
192
|
+
* @public
|
|
193
|
+
*/
|
|
194
|
+
type NIKErrorCode = 'INVALID_FORMAT' | 'INVALID_PROVINCE' | 'INVALID_MONTH' | 'INVALID_DAY' | 'INVALID_DATE' | 'FUTURE_DATE';
|
|
195
|
+
/**
|
|
196
|
+
* A single validation error with code and message.
|
|
197
|
+
*
|
|
198
|
+
* @public
|
|
199
|
+
*/
|
|
200
|
+
interface NIKValidationError {
|
|
201
|
+
/** Error code for programmatic handling */
|
|
202
|
+
code: NIKErrorCode;
|
|
203
|
+
/** Human-readable error message */
|
|
204
|
+
message: string;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Detailed validation result for NIK with structured error reporting.
|
|
208
|
+
*
|
|
209
|
+
* Use this for form validation where you need to show specific error
|
|
210
|
+
* messages per field.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* const result = validateNIKDetailed('1234');
|
|
215
|
+
* if (!result.isValid) {
|
|
216
|
+
* result.errors.forEach(err => {
|
|
217
|
+
* console.log(err.code, err.message);
|
|
218
|
+
* });
|
|
219
|
+
* }
|
|
220
|
+
* ```
|
|
221
|
+
*
|
|
222
|
+
* @public
|
|
223
|
+
*/
|
|
224
|
+
interface NIKValidationResult {
|
|
225
|
+
/** Whether the NIK is valid */
|
|
226
|
+
isValid: boolean;
|
|
227
|
+
/** List of validation errors (empty if valid) */
|
|
228
|
+
errors: NIKValidationError[];
|
|
229
|
+
/** Cleaned 16-digit NIK if valid, null otherwise */
|
|
230
|
+
nik: string | null;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Options for getAge function.
|
|
234
|
+
*
|
|
235
|
+
* @public
|
|
236
|
+
*/
|
|
237
|
+
interface GetAgeOptions {
|
|
238
|
+
/** Date to calculate age from (default: current date) */
|
|
239
|
+
referenceDate?: Date;
|
|
240
|
+
/** Return formatted Indonesian string instead of object */
|
|
241
|
+
asString?: boolean;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Age result object with years, months, and days.
|
|
245
|
+
*
|
|
246
|
+
* @public
|
|
247
|
+
*/
|
|
248
|
+
interface Age {
|
|
249
|
+
/** Full years */
|
|
250
|
+
years: number;
|
|
251
|
+
/** Remaining months after full years */
|
|
252
|
+
months: number;
|
|
253
|
+
/** Remaining days after full months */
|
|
254
|
+
days: number;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Parses a NIK and extracts all embedded information.
|
|
259
|
+
*
|
|
260
|
+
* Extracts province, regency, district codes, birth date, gender,
|
|
261
|
+
* and serial number from a 16-digit NIK string.
|
|
262
|
+
*
|
|
263
|
+
* @param nik - The 16-digit NIK string to parse
|
|
264
|
+
* @returns Parsed NIK information, or `null` if the NIK format is invalid
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* Parse a valid male NIK:
|
|
268
|
+
* ```typescript
|
|
269
|
+
* const info = parseNIK('3201018901310123');
|
|
270
|
+
* console.log(info);
|
|
271
|
+
* // {
|
|
272
|
+
* // province: { code: '32', name: 'Jawa Barat' },
|
|
273
|
+
* // regency: { code: '01', name: 'Kab. Bogor' },
|
|
274
|
+
* // district: { code: '01', name: null },
|
|
275
|
+
* // birthDate: Date(1989, 0, 31), // Jan 31, 1989
|
|
276
|
+
* // gender: 'male',
|
|
277
|
+
* // serialNumber: '0123',
|
|
278
|
+
* // isValid: true
|
|
279
|
+
* // }
|
|
280
|
+
* ```
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* Parse a female NIK (day + 40):
|
|
284
|
+
* ```typescript
|
|
285
|
+
* const info = parseNIK('3201019508550123');
|
|
286
|
+
* console.log(info.gender); // 'female'
|
|
287
|
+
* console.log(info.birthDate); // Date(1995, 7, 15) - Aug 15, 1995
|
|
288
|
+
* ```
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* Invalid NIK returns null:
|
|
292
|
+
* ```typescript
|
|
293
|
+
* const info = parseNIK('invalid');
|
|
294
|
+
* console.log(info); // null
|
|
295
|
+
* ```
|
|
296
|
+
*
|
|
297
|
+
* @public
|
|
298
|
+
*/
|
|
299
|
+
declare function parseNIK(nik: string): NIKInfo | null;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Formats a NIK with separators for better readability.
|
|
303
|
+
*
|
|
304
|
+
* Groups the NIK into logical segments: province, regency, district,
|
|
305
|
+
* year, month, day, and serial number.
|
|
306
|
+
*
|
|
307
|
+
* @param nik - The 16-digit NIK string to format
|
|
308
|
+
* @param separator - Character to use as separator
|
|
309
|
+
* @returns Formatted NIK string, or original string if invalid format
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* Default separator (dash):
|
|
313
|
+
* ```typescript
|
|
314
|
+
* formatNIK('3201234567890123');
|
|
315
|
+
* // '32-01-23-45-67-89-0123'
|
|
316
|
+
* ```
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* Custom separator:
|
|
320
|
+
* ```typescript
|
|
321
|
+
* formatNIK('3201234567890123', ' ');
|
|
322
|
+
* // '32 01 23 45 67 89 0123'
|
|
323
|
+
* ```
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* Invalid NIK returns as-is:
|
|
327
|
+
* ```typescript
|
|
328
|
+
* formatNIK('1234');
|
|
329
|
+
* // '1234'
|
|
330
|
+
* ```
|
|
331
|
+
*
|
|
332
|
+
* @public
|
|
333
|
+
*/
|
|
334
|
+
declare function formatNIK(nik: string, separator?: string): string;
|
|
335
|
+
/**
|
|
336
|
+
* Masks a NIK to protect privacy while keeping partial visibility.
|
|
337
|
+
*
|
|
338
|
+
* By default, shows the first 4 and last 4 digits, masking the middle 8.
|
|
339
|
+
* Optionally formats the masked NIK with separators.
|
|
340
|
+
*
|
|
341
|
+
* @param nik - The 16-digit NIK string to mask
|
|
342
|
+
* @param options - Masking configuration options
|
|
343
|
+
* @returns Masked NIK string, or original string if invalid format
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* Default masking (first 4, last 4):
|
|
347
|
+
* ```typescript
|
|
348
|
+
* maskNIK('3201234567890123');
|
|
349
|
+
* // '3201********0123'
|
|
350
|
+
* ```
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* Custom mask character:
|
|
354
|
+
* ```typescript
|
|
355
|
+
* maskNIK('3201234567890123', { char: 'X' });
|
|
356
|
+
* // '3201XXXXXXXX0123'
|
|
357
|
+
* ```
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* With separator:
|
|
361
|
+
* ```typescript
|
|
362
|
+
* maskNIK('3201234567890123', { separator: '-' });
|
|
363
|
+
* // '32-01-**-**-**-**-0123'
|
|
364
|
+
* ```
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* Custom start and end:
|
|
368
|
+
* ```typescript
|
|
369
|
+
* maskNIK('3201234567890123', { start: 6, end: 4 });
|
|
370
|
+
* // '320123******0123'
|
|
371
|
+
* ```
|
|
372
|
+
*
|
|
373
|
+
* @public
|
|
374
|
+
*/
|
|
375
|
+
declare function maskNIK(nik: string, options?: MaskOptions): string;
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Calculates the age of a person based on their NIK.
|
|
379
|
+
*
|
|
380
|
+
* Returns detailed age breakdown with years, months, and days, or a
|
|
381
|
+
* formatted Indonesian string. This is consistent with `datetime.getAge()`.
|
|
382
|
+
*
|
|
383
|
+
* @param nik - The 16-digit NIK string
|
|
384
|
+
* @param options - Options object with `referenceDate` and `asString`
|
|
385
|
+
* @returns Age object `{ years, months, days }`, formatted string, or null if invalid
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```typescript
|
|
389
|
+
* // Returns object by default
|
|
390
|
+
* getAge('3201018901310123');
|
|
391
|
+
* // { years: 35, months: 2, days: 6 } (as of 2026-04-06)
|
|
392
|
+
*
|
|
393
|
+
* // Returns formatted string
|
|
394
|
+
* getAge('3201018901310123', { asString: true });
|
|
395
|
+
* // '35 Tahun 2 Bulan 6 Hari'
|
|
396
|
+
*
|
|
397
|
+
* // Custom reference date
|
|
398
|
+
* getAge('3201018901310123', { referenceDate: new Date('2025-01-01') });
|
|
399
|
+
* // { years: 35, months: 11, days: 1 }
|
|
400
|
+
* ```
|
|
401
|
+
*
|
|
402
|
+
* @public
|
|
403
|
+
*/
|
|
404
|
+
declare function getAge(nik: string, options?: GetAgeOptions): Age | string | null;
|
|
405
|
+
/**
|
|
406
|
+
* Compares two NIKs to check if they belong to the same person.
|
|
407
|
+
*
|
|
408
|
+
* Two NIKs are considered the same person if they have identical:
|
|
409
|
+
* - Province code (positions 1-2)
|
|
410
|
+
* - Regency code (positions 3-4)
|
|
411
|
+
* - District code (positions 5-6)
|
|
412
|
+
* - Birth date (year + month + day)
|
|
413
|
+
* - Gender (derived from day encoding)
|
|
414
|
+
* - Serial number (positions 13-16)
|
|
415
|
+
*
|
|
416
|
+
* @param nik1 - First NIK (accepts any format)
|
|
417
|
+
* @param nik2 - Second NIK (accepts any format)
|
|
418
|
+
* @returns True if both NIKs belong to the same person, false otherwise
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* ```typescript
|
|
422
|
+
* // Same person, same format
|
|
423
|
+
* compareNIK('3201018901310123', '3201018901310123'); // true
|
|
424
|
+
*
|
|
425
|
+
* // Same person, different format
|
|
426
|
+
* compareNIK('3201018901310123', '3201-01-89-01-31-0123'); // true
|
|
427
|
+
*
|
|
428
|
+
* // Different serial number
|
|
429
|
+
* compareNIK('3201018901310123', '3201018901310124'); // false
|
|
430
|
+
*
|
|
431
|
+
* // Invalid NIK
|
|
432
|
+
* compareNIK('invalid', '3201018901310123'); // false
|
|
433
|
+
* ```
|
|
434
|
+
*
|
|
435
|
+
* @public
|
|
436
|
+
*/
|
|
437
|
+
declare function compareNIK(nik1: string, nik2: string): boolean;
|
|
438
|
+
/**
|
|
439
|
+
* Checks if a person is an adult based on their NIK.
|
|
440
|
+
*
|
|
441
|
+
* By default, uses 17 years as the threshold (Indonesian KTP eligibility age).
|
|
442
|
+
* Indonesian law allows KTP at age 17, or upon marriage, or already married.
|
|
443
|
+
*
|
|
444
|
+
* @param nik - The 16-digit NIK string
|
|
445
|
+
* @param minAge - Minimum age threshold (default: 17)
|
|
446
|
+
* @returns True if the person is at least minAge years old, false otherwise
|
|
447
|
+
*
|
|
448
|
+
* @example
|
|
449
|
+
* ```typescript
|
|
450
|
+
* // Born 1995-01-01, reference 2026-04-06 (age 31)
|
|
451
|
+
* isAdult('3201950101950123'); // true (31 >= 17)
|
|
452
|
+
* isAdult('3201950101950123', 21); // true (31 >= 21)
|
|
453
|
+
*
|
|
454
|
+
* // Born 2010-01-01, reference 2026-04-06 (age 16)
|
|
455
|
+
* isAdult('3210010101950123'); // false (16 < 17)
|
|
456
|
+
* isAdult('3210010101950123', 16); // true (16 >= 16)
|
|
457
|
+
*
|
|
458
|
+
* // Invalid NIK
|
|
459
|
+
* isAdult('invalid'); // false
|
|
460
|
+
* ```
|
|
461
|
+
*
|
|
462
|
+
* @public
|
|
463
|
+
*/
|
|
464
|
+
declare function isAdult(nik: string, minAge?: number): boolean;
|
|
465
|
+
/**
|
|
466
|
+
* Formats the birth date from a NIK into a human-readable string.
|
|
467
|
+
*
|
|
468
|
+
* @param nik - The 16-digit NIK string
|
|
469
|
+
* @param locale - The locale to use for formatting (default: 'id-ID')
|
|
470
|
+
* @returns Formatted birth date string, or null if invalid
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* ```typescript
|
|
474
|
+
* formatBirthDate('3201018901310123'); // '31 Januari 1989'
|
|
475
|
+
* ```
|
|
476
|
+
*/
|
|
477
|
+
declare function formatBirthDate(nik: string): string | null;
|
|
478
|
+
/**
|
|
479
|
+
* Checks if a NIK matches a specific gender.
|
|
480
|
+
*
|
|
481
|
+
* @param nik - The 16-digit NIK string
|
|
482
|
+
* @param gender - The gender to check ('male' | 'female')
|
|
483
|
+
* @returns True if the NIK matches the gender, false otherwise
|
|
484
|
+
*/
|
|
485
|
+
declare function isValidForGender(nik: string, gender: 'male' | 'female'): boolean;
|
|
486
|
+
/**
|
|
487
|
+
* Checks if a NIK matches a specific birth date.
|
|
488
|
+
*
|
|
489
|
+
* @param nik - The 16-digit NIK string
|
|
490
|
+
* @param birthDate - The birth date to check
|
|
491
|
+
* @returns True if the NIK matches the birth date, false otherwise
|
|
492
|
+
*/
|
|
493
|
+
declare function isValidForBirthDate(nik: string, birthDate: Date): boolean;
|
|
494
|
+
|
|
495
|
+
export { type Age as A, type GetAgeOptions as G, InvalidNIKError as I, type MaskOptions as M, type NIKInfo as N, formatBirthDate as a, isValidForBirthDate as b, type NIKValidationResult as c, compareNIK as d, isAdult as e, formatNIK as f, getAge as g, type NIKValidationError as h, isValidForGender as i, type NIKErrorCode as j, maskNIK as m, parseNIK as p, validateNIK as v };
|