All notable changes to this project are documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Documentation release: no changes to validation behavior or the public API. Upgrading from 2.0.0 needs no code changes.
llms.txt ships in the package and on the docs site, with llms-full.txt (llms.txt,
README, and changelog in one file), so AI coding assistants can read the API, its
conventions, and its limits.@example, shown in editor hovers and the API reference. Each entry point
(lanka-validations/nic, /phone, and so on) has an overview with its import path.homepage points to the API reference.llms.txt, and TSDoc examples now run as tests, so documented results
always match the library.formatNic documentation showed the wrong output for the spaced-old and
spaced-new styles. The function itself is unchanged.calculateAge example depended on the current date.lanka-validations/nic size; a Socket badge was added.This release hardens input validation. Some inputs that 1.0.0 accepted are now rejected, and several public types are stricter. Read Breaking changes before upgrading.
ValidationResult<T> is now a discriminated union of ValidationSuccess<T> and
ValidationFailure. Checking isValid narrows the result: on success data is
always present; on failure error, errors and code are always present.
Code that builds its own { isValid: boolean, ... } object and types it as
ValidationResult no longer compiles.ReadonlyProvinceInfo / readonly records. Mutating a returned record is a type
error, and mutation no longer affects later lookups.MOBILE_PREFIXES, AREA_CODES,
FIXED_OPERATOR_DIGITS, SRI_LANKA_SHORT_CODES, POSTAL_PREFIXES, MAJOR_CITIES,
DMT_LICENSE_CATEGORIES, VEHICLE_PROVINCES, and the nested entries of
VALIDATION_MESSAGES and REFERENCE_DATA_METADATA) are deeply frozen and typed
Readonly. Writing to them is a type error and throws in strict mode. Previously,
any code in the process could change validation results, for example by adding a
mobile prefix.isValidPhone(['0771234567']) now returns false.MAX_INPUT_LENGTH (1024 UTF-16 code units) are rejected
before normalization.Date objects and the documented formats
YYYY-MM-DD, YYYY/MM/DD, DD-MM-YYYY and DD/MM/YYYY. Free-form strings
such as 'March 5 2000' are rejected. Date-only comparisons and ages use the
UTC calendar date.isValidTIN / validateTIN no longer accept an NIC number as a TIN. IRD issues a
separate 9- or 10-digit TIN to individuals who register using their NIC; no IRD
source supports treating the NIC itself as a TIN. Validate NIC fields with
isValidNic instead.'abc119xyz' is no longer read as short code 119).'abc20000xyz' and 200.5).MAX_LKR_AMOUNT, and
malformed digit grouping such as '1,2,3'.createSchemaValidator().validate() returns a SCHEMA_INVALID_ROOT failure
for non-object input (for example, null) instead of reporting it as valid.lanka-validations/privacy subpath: redactSensitiveValue, maskNic,
maskPhone, maskBankAccount, validationResultForLog and REDACTED_VALUE.lanka-validations/i18n subpath: translateValidationCode,
localizeValidationResult, localizeSchemaResult and VALIDATION_MESSAGES.lanka-validations/reference-data subpath: getReferenceDataMetadata and
REFERENCE_DATA_METADATA, describing the source, version, coverage and
limitations of each bundled data table.parseLKRMinorUnits,
formatLKRMinorUnits, validateLKRDecimal and MAX_LKR_MINOR_UNITS.isValidContactPhone, which accepts full phone numbers and rejects short codes.rules.required(), rules.optional(), rules.nullable(),
rules.contactPhone() and rules.mobile().validateBankCode, returning a detailed ValidationResult.referenceDate option for NIC parsing and validation (NicOptions), for
deterministic age and future-date checks.createSchemaValidator.MAX_INPUT_LENGTH and MAX_LKR_AMOUNT constants.lanka-validations/package.json is exported for tools that read package metadata.moduleResolution: node16/nodenext now get ESM type
declarations (.d.mts) instead of CommonJS ones, so default and named imports
type-check correctly.lanka-validations/nic now resolve types under the
legacy moduleResolution: node (node10) setting.'__proto__' or 'constructor'.maskNic, maskPhone and maskBankAccount revealed the full value when
visibleDigits was 0, negative, or NaN. They now reveal nothing in those cases
and round fractional values down.toString.getLicenseCategoryInfo and getAllLicenseCategories return copies, so changing
a returned record no longer affects later lookups.getReferenceDataMetadata(table) is typed to return a single table's metadata,
instead of a union that callers had to narrow.lkrToWords rounds to cents once and carries into rupees:
lkrToWords(1.999) returns 'Two Rupees Only' instead of
'One Rupee and One Hundred Cents Only'.'__proto__' in errors as well as errorList.