kreiseck_validator 0.10.0
kreiseck_validator: ^0.10.0 copied to clipboard
Zero-dependency validation, normalization and formatting for email, phone, URL, host, IBAN, credit-card, license-plate, IMEI, ICCID, MAC, VIN and postal-code input. Global phone support; DACH-aware. B [...]
Changelog #
0.10.0 #
- Added
FieldDescriptor(keyboard,autofill,capitalization,maxLength,example,allowedChars) and afieldDescriptor(...)method on every type, taking the same options asvalidate. - Added
formatPartial(...)on every type: as-you-type formatting that never throws and, for the nine grouping types, agrees withformaton valid input. PostalPatterngainedexample,charsetandlength; the postal metadata table was regenerated.length(the canonical formatted length, separators included) is mechanically derived from each country's pattern, soPostalCode.fieldDescriptor(country:).maxLengthandformatPartial's truncation are now set for all 51 countries instead of only the 23 with a curatedexample.Phone.fieldDescriptor(...).exampleis now alwaysnull: the previous synthetic construction (+{callingCode}1234567) produced a plausible- looking but fabricated example for most countries andnullfor the rest, contradicting the never-invented-example principle applied to postal codes.Host.formatPartialno longer drops non-ASCII characters (e.g.münchen.depreviously became the different, plausible-lookingmnchen.de); it now leaves them in place since the module is ASCII-only and would reject the value either way.
0.9.0 #
Imeigains an opt-inallowSvoption (defaultfalse, backward-compatible) accepting a 16-digit IMEISV (the 15-digit IMEI structure plus a 2-digit software version number) alongside the existing 15-digit Luhn IMEI. A 16-digit value is never Luhn-checked — IMEISV has no check digit.ImeiInfogainssoftwareVersion(set for a 16-digit IMEISV,nullotherwise) andcheckDigitbecomes nullable (nullfor a 16-digit IMEISV, unchanged for a 15-digit IMEI). With the defaultallowSv == false, every existing IMEI vector and behavior is unchanged.- New
Hostmodule: validation, normalization, formatting andparsefor a bare host — hostname (RFC 1123), IPv4 or IPv6 address — with an optional port. Classification tries IPv4, then IPv6, then hostname. A port is only recognized for IPv6 in the bracketed form ([::1]:8080); for hostname/IPv4 a single trailing:portis split off.Host.parsereturns aHostInfo(host,type,port,hasPort). More lenient thanUrl— no scheme required, acceptslocalhostand IP literals — and independent of it. - Three new
IssueCodes:hostEmpty,hostBadFormat,hostBadPort.
0.8.0 #
- Five new modules:
Imei,Iccid,MacAddress,VinandPostalCode, each with the standardisValid/validate/normalize/format(+tryFormat) API plusparsefor structural extraction. Imei: 15-digit Luhn checksum,parseinto anImeiInfo(TAC, serial number, check digit, reporting-body identifier). IMEISV (16-digit) is out of scope.Iccid: 19- or 20-digit SIM identifiers (ITU-T E.118) starting with the telecom MII89; 20-digit ICCIDs carry a Luhn check digit, 19-digit ones don't.parsereturns anIccidInforesolving the issuing country from the embedded E.164 calling code.MacAddress: EUI-48/64 hardware addresses across colon, hyphen, Cisco-dot and bare notation, withformat(..., notation:)conversion between them andparseexposing the OUI/NIC split plus the unicast/multicast and universal/local bits.Vin: ISO 3779 structure validation (17 chars,I/O/Qforbidden).validateis structure-only — the check digit is mandatory only for North American VINs — soparse'sVinInfoexposescheckDigitValid(ISO 3779 mod-11 weighted checksum) and the decodedmodelYearfrom character 10, disambiguated by whether character 7 is a letter (2010-2039 cycle) or a digit (1980-2009 cycle).PostalCode: a curated per-country pattern table covering Europe plus Turkey (51 countries), with canonical per-country spacing (e.g. NL1234ab→1234 AB, PL00950→00-950, GBsw1a1aa→SW1A 1AA) andparseinto aPostalInfo.country(ISO2) is required on every operation since a bare code is ambiguous across countries.- Internal refactor:
CreditCard's Luhn checksum is now a small shared helper (lib/src/common/luhn.dart,js/src/common/luhn.ts) reused byImeiandIccid;CreditCard's own validation behavior is unchanged. - Sixteen new
IssueCodes:imeiEmpty,imeiBadChars,imeiBadLength,imeiBadChecksum;iccidEmpty,iccidBadChars,iccidBadLength,iccidBadChecksum;macEmpty,macBadFormat;vinEmpty,vinBadChars,vinBadLength;postalEmpty,postalBadFormat,postalUnknownCountry.
0.7.0 #
- New
LicensePlatemodule: validation, normalization, formatting andparsefor vehicle registration plates ("Kennzeichen") across Austria, Germany, Switzerland, Croatia and Turkey (country: 'AT' | 'DE' | 'CH' | 'HR' | 'TR'). LicensePlate.parsereturns aPlateInfo— district/canton/province code, the resolved region name (from a curated code → region table;nullwhen the code is unrecognized), the serial part, aPlateTypeclassification and the canonicalformatteddisplay form.- Plates have no checksum:
validateis a per-country grammar plus the region table. AT/DE accept a structurally valid but unlisted code (regionnull, still valid); CH/HR/TR require the code to be one of their known cantons/cities/provinces. PlateTypeclassification (diplomatic, authority, military, temporary, seasonal, historic, electric) is rule-based per country and best-effort — it never blocks validation and defaults tostandardwhen a country's special forms aren't identifiable from the plate text alone.- Five new
IssueCodes:plateEmpty,plateBadChars,plateBadFormat,plateUnknownCountry,plateAmbiguousCountry. - A TypeScript port,
@kreiseck/validator, now lives underjs/; parity with this package is enforced by the shared vectors intest/vectors/.
0.6.0 #
IbanCountry.of(code)/IbanCountry.valuesexpose each country's IBAN format — total length, bank / branch / account field lengths, whether a branch code exists, and a valid example IBAN (canonical for AT/DE/CH, deterministically generated for the rest).
0.5.0 #
Iban.parsenow resolvesbankNameandbicfor German and Swiss IBANs, in addition to Austrian ones, from bundled snapshots of the Deutsche Bundesbank Bankleitzahlen directory and the SIX Bank Master.- The internal bank-enrichment table is now country-keyed (
AT/DE/CH).
0.4.0 #
Iban.parsereturns anIbanInfowith the country, check digits and bank / branch / account codes for every country whose BBAN layout is known (SWIFT IBAN Registry). Austrian IBANs additionally resolve the bank name and BIC from a bundled snapshot of the OeNB SEPA directory.- IBAN length validation now covers all registry countries, not only DE/AT/CH.
0.3.0 #
- Global phone support: validation, normalization and formatting for every country, derived from libphonenumber (Apache-2.0; see NOTICE).
Countrynow covers all countries with uniform metadata:iso2,callingCode,displayName,flag, and syntheticexamplenumbers. Look up viaCountry.fromIso2/Country.fromCallingCode; enumerate viaCountry.values. Breaking:Countrychanged from a 3-value enum to a class; onlyCountry.de/at/chremain as named constants.- Uniform, strict validation (
possibleLengths+ national pattern) with a newIssueCode.phoneInvalidfor structural mismatches. - AT/DE/CH display formatting re-baselined to libphonenumber grouping.
- Austrian type classification unchanged; other countries report
PhoneNumberType.unknown.
0.2.0 #
Phone.typeandPhone.parse(PhoneInfo): Austrian number-type classification (mobile, landline, VoIP, freephone, shared-cost, premium, corporate) from the public RTR numbering plan.- Type-aware Austrian formatting:
Phone.formatnow uses the geographic area-code length for landlines (e.g.01 …Vienna,0316 …Graz); mobile output is unchanged.
0.1.1 #
- Add a runnable
example/covering all five types.
0.1.0 #
- Initial release, zero runtime dependencies:
Email: syntax validation, trim/lowercase normalization, offline typo-domain suggestions for popular providers.Phone: E.164 and DACH (DE/AT/CH) national validation, normalization to E.164, national/international display formatting.Url: http/https scheme, host and TLD plausibility checks, normalization (scheme, lower-case host, trailing slash) and a compact display format.Iban: Mod-97 checksum validation with DACH (DE/AT/CH) length checks, upper-case normalization and 4-block formatting.CreditCard: Luhn checksum and per-network length validation, network detection (Visa/Mastercard/Amex/Discover), digits-only normalization and network-typical block formatting.- Shared
ValidationResult/Valid/Invalid/ValidationIssue/IssueCoderesult model across all five types.