@lilydesignsystem/web-components-headless-identifiers 0.2.0 → 0.4.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/LICENSE.md +26 -5
- package/dist/index.d.ts +246 -1
- package/dist/index.js +792 -1
- package/package.json +2 -2
package/LICENSE.md
CHANGED
|
@@ -18,12 +18,16 @@ License is any of these, at your option, or contact us for custom license option
|
|
|
18
18
|
|
|
19
19
|
- [BSD 3-Clause License](https://opensource.org/license/bsd-3-clause) ([SPDX: BSD-3-Clause](https://spdx.org/licenses/BSD-3-Clause.html))
|
|
20
20
|
|
|
21
|
+
- [UK Open Government Licence v3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/) ([SPDX: OGL-UK-3.0](https://spdx.org/licenses/OGL-UK-3.0.html))
|
|
22
|
+
|
|
23
|
+
- [Creative Commons Attribution Non Commercial Share Alike 4.0 International](https://creativecommons.org/licenses/by-nc-sa/4.0/) ([SPDX: CC-BY-NC-SA-4.0](https://spdx.org/licenses/CC-BY-NC-SA-4.0.html))
|
|
24
|
+
|
|
21
25
|
## SPDX
|
|
22
26
|
|
|
23
27
|
The machine-readable expression for the choice above is:
|
|
24
28
|
|
|
25
29
|
```
|
|
26
|
-
SPDX-License-Identifier: MIT OR Apache-2.0 OR GPL-2.0-only OR GPL-3.0-only OR BSD-3-Clause
|
|
30
|
+
SPDX-License-Identifier: MIT OR Apache-2.0 OR GPL-2.0-only OR GPL-3.0-only OR BSD-3-Clause OR OGL-UK-3.0 OR CC-BY-NC-SA-4.0
|
|
27
31
|
```
|
|
28
32
|
|
|
29
33
|
Every package manifest in this repository should carry that expression, or a
|
|
@@ -37,10 +41,15 @@ stylesheets, the `bin/` tooling, and the documentation.
|
|
|
37
41
|
|
|
38
42
|
## Scope note
|
|
39
43
|
|
|
40
|
-
This file supersedes an earlier `CC BY-NC-SA` notice
|
|
41
|
-
|
|
42
|
-
contradicted both the specification and the published packages
|
|
43
|
-
|
|
44
|
+
This file supersedes an earlier `CC BY-NC-SA` notice, which was the only license
|
|
45
|
+
stated at the time. That notice was a content license with a non-commercial
|
|
46
|
+
clause, and it contradicted both the specification and the published packages, so
|
|
47
|
+
it was replaced with the list above.
|
|
48
|
+
|
|
49
|
+
`CC-BY-NC-SA-4.0` is now offered again, as one option among seven rather than as
|
|
50
|
+
the sole license. It restricts use to non-commercial purposes; anyone who needs
|
|
51
|
+
commercial use chooses another license from the list, such as `MIT`. If you
|
|
52
|
+
obtained Lily under the earlier notice and that raises a question for you,
|
|
44
53
|
contact <joel@joelparkerhenderson.com>.
|
|
45
54
|
|
|
46
55
|
## Trademarks
|
|
@@ -62,3 +71,15 @@ public-sector design systems including NHS UK, GOV.UK, and USWDS. Lily is not
|
|
|
62
71
|
affiliated with, endorsed by, or connected to any of those organisations. Their
|
|
63
72
|
names and marks belong to them, and this license grants nothing in respect of
|
|
64
73
|
them.
|
|
74
|
+
|
|
75
|
+
## Full license texts
|
|
76
|
+
|
|
77
|
+
The full text of each license is in its own directory:
|
|
78
|
+
|
|
79
|
+
- [MIT](https://github.com/LilyDesignSystem/lily-design-system/blob/main/LICENSES/mit/index.md)
|
|
80
|
+
- [Apache-2.0](https://github.com/LilyDesignSystem/lily-design-system/blob/main/LICENSES/apache-2.0/index.md)
|
|
81
|
+
- [BSD-3-Clause](https://github.com/LilyDesignSystem/lily-design-system/blob/main/LICENSES/bsd-3-clause/index.md)
|
|
82
|
+
- [GPL-2.0-only](https://github.com/LilyDesignSystem/lily-design-system/blob/main/LICENSES/gpl-2.0-only/index.md)
|
|
83
|
+
- [GPL-3.0-only](https://github.com/LilyDesignSystem/lily-design-system/blob/main/LICENSES/gpl-3.0-only/index.md)
|
|
84
|
+
- [OGL-UK-3.0](https://github.com/LilyDesignSystem/lily-design-system/blob/main/LICENSES/ogl-uk-3.0/index.md)
|
|
85
|
+
- [CC-BY-NC-SA-4.0](https://github.com/LilyDesignSystem/lily-design-system/blob/main/LICENSES/cc-by-nc-sa-4.0/index.md)
|
package/dist/index.d.ts
CHANGED
|
@@ -1314,4 +1314,249 @@ declare class ZhongguoJuminShenfenzhengHaomaView extends HTMLElement {
|
|
|
1314
1314
|
set value(v: string);
|
|
1315
1315
|
}
|
|
1316
1316
|
|
|
1317
|
-
|
|
1317
|
+
/**
|
|
1318
|
+
* Validation and check-digit logic for national personal identifiers (spec/national-identifiers). Pure functions: no DOM, no
|
|
1319
|
+
* locale, no persistence. The components stay headless and never call these; a consumer validates when it wants to.
|
|
1320
|
+
*
|
|
1321
|
+
* Each `validate*` takes the identifier as typed (spaces, dots, dashes and slashes are separators and are ignored) and returns
|
|
1322
|
+
* an `IdentifierResult`: `{ valid: true }`, or `{ valid: false, reason }` saying which rule failed. A string that breaks a
|
|
1323
|
+
* rule is invalid data, so it is reported, never repaired or defaulted: nothing is trimmed to length, padded, re-cased or
|
|
1324
|
+
* guessed. A value that is not a string at all is a programming error and throws a `TypeError`.
|
|
1325
|
+
*
|
|
1326
|
+
* Only algorithms that are published and checkable against a worked example are here. A type with no check digit gets its
|
|
1327
|
+
* format rules only, and a type whose algorithm is not documented is not here at all (see spec/national-identifiers).
|
|
1328
|
+
*/
|
|
1329
|
+
type IdentifierReason =
|
|
1330
|
+
/** Characters that cannot appear in this identifier. */
|
|
1331
|
+
"characters"
|
|
1332
|
+
/** The wrong number of characters. */
|
|
1333
|
+
| "length"
|
|
1334
|
+
/** The check digit or check letter does not match. */
|
|
1335
|
+
| "checksum"
|
|
1336
|
+
/** An embedded date of birth that is not a real calendar date. */
|
|
1337
|
+
| "date"
|
|
1338
|
+
/** Another structural rule of the scheme (an unassigned prefix, a reserved block, an impossible serial). */
|
|
1339
|
+
| "structure";
|
|
1340
|
+
type IdentifierResult = {
|
|
1341
|
+
valid: true;
|
|
1342
|
+
} | {
|
|
1343
|
+
valid: false;
|
|
1344
|
+
reason: IdentifierReason;
|
|
1345
|
+
};
|
|
1346
|
+
/** The identifier with its separators (space, dot, dash, slash) removed; nothing else is touched. */
|
|
1347
|
+
declare function stripSeparators(value: string): string;
|
|
1348
|
+
/** True when `digits` (the whole number, check digit last) passes the Luhn check (ISO/IEC 7812-1). */
|
|
1349
|
+
declare function luhnValid(digits: string): boolean;
|
|
1350
|
+
/** The sum of each digit times its weight, over as many digits as there are weights. */
|
|
1351
|
+
declare function weightedSum(digits: readonly number[], weights: readonly number[]): number;
|
|
1352
|
+
/** True when `digits` (check digit last) passes the Verhoeff check. */
|
|
1353
|
+
declare function verhoeffValid(digits: string): boolean;
|
|
1354
|
+
/** True when year, month and day (month 1 to 12) name a real calendar day; the year is a full year. */
|
|
1355
|
+
declare function isCalendarDate(year: number, month: number, day: number): boolean;
|
|
1356
|
+
/**
|
|
1357
|
+
* The NHS number of England, Wales and the Isle of Man, and the Health and Care Number of Northern Ireland: ten digits, the
|
|
1358
|
+
* tenth a Modulus-11 check digit over the first nine with weights 10 down to 2. A remainder that would give check digit 10
|
|
1359
|
+
* is never issued, so it is invalid.
|
|
1360
|
+
*/
|
|
1361
|
+
declare function validateNhsNumber(value: string): IdentifierResult;
|
|
1362
|
+
/** The Canadian Social Insurance Number: nine digits passing the Luhn check. */
|
|
1363
|
+
declare function validateCanadaSocialInsuranceNumber(value: string): IdentifierResult;
|
|
1364
|
+
/** The Dutch citizen service number (BSN): nine digits satisfying the 11-proof, weights 9 to 2 and then -1, and not all zeros. */
|
|
1365
|
+
declare function validateNederlandBurgerservicenummer(value: string): IdentifierResult;
|
|
1366
|
+
/**
|
|
1367
|
+
* The Belgian National Register Number: eleven digits, YYMMDD, a three-digit serial (odd for men, even for women), and a
|
|
1368
|
+
* two-digit check equal to 97 minus the first nine digits modulo 97, computed with a leading 2 for someone born in 2000 or
|
|
1369
|
+
* later. The century is not written, so both are tried; a number valid under neither is a checksum failure. Where the
|
|
1370
|
+
* date part is zero (a person whose birth date is not known) the date is not checked.
|
|
1371
|
+
*/
|
|
1372
|
+
declare function validateBelgiqueRegistreNational(value: string): IdentifierResult;
|
|
1373
|
+
/**
|
|
1374
|
+
* The Swedish personal identity number (personnummer): ten digits as YYMMDDNNNC, or twelve as YYYYMMDDNNNC, the last a Luhn
|
|
1375
|
+
* check over the ten-digit form, and a real date (a day above 60 is a samordningsnummer, the real day plus 60).
|
|
1376
|
+
*/
|
|
1377
|
+
declare function validateSverigePersonnummer(value: string): IdentifierResult;
|
|
1378
|
+
/**
|
|
1379
|
+
* The Polish PESEL: eleven digits, YYMMDD with the month carrying the century (+80 for 1800s, +20 for 2000s, +40 for 2100s,
|
|
1380
|
+
* +60 for 2200s), a serial, and a check digit from weights 1 3 7 9 1 3 7 9 1 3.
|
|
1381
|
+
*/
|
|
1382
|
+
declare function validatePolskaPesel(value: string): IdentifierResult;
|
|
1383
|
+
/** The Australian Tax File Number: nine digits (eight are issued to some), weights 1 4 3 7 5 8 6 9 10, sum divisible by 11. */
|
|
1384
|
+
declare function validateAustraliaTaxFileNumber(value: string): IdentifierResult;
|
|
1385
|
+
/** The Indian Aadhaar number: twelve digits, the first 2 to 9, the last a Verhoeff check. */
|
|
1386
|
+
declare function validateBharatAadhaar(value: string): IdentifierResult;
|
|
1387
|
+
/** The Swiss AHV (social security) number: thirteen digits starting 756, the last an EAN-13 check. */
|
|
1388
|
+
declare function validateSchweizAhvNummer(value: string): IdentifierResult;
|
|
1389
|
+
/**
|
|
1390
|
+
* The French NIR (social security number): 15 characters, a 13-character body (sex, birth year and month, department,
|
|
1391
|
+
* commune, order; Corsica's department is 2A or 2B) and a two-digit key equal to 97 minus the body modulo 97, with 2A read
|
|
1392
|
+
* as 19 and 2B as 18.
|
|
1393
|
+
*/
|
|
1394
|
+
declare function validateFranceNir(value: string): IdentifierResult;
|
|
1395
|
+
/** The Turkish citizen number (TC Kimlik): eleven digits, the first not 0, and two check digits. */
|
|
1396
|
+
declare function validateTurkiyeTcKimlikNumarasi(value: string): IdentifierResult;
|
|
1397
|
+
/**
|
|
1398
|
+
* The Bulgarian Uniform Civil Number (EGN): ten digits, YYMMDD with the century in the month (+20 for the 1800s, +40 for the
|
|
1399
|
+
* 2000s), a three-digit serial and a check digit, the weighted sum 2 4 8 5 10 9 7 3 6 modulo 11 (a remainder of 10 gives 0).
|
|
1400
|
+
*/
|
|
1401
|
+
declare function validateBulgariaEdinenGrazhdanskiNomer(value: string): IdentifierResult;
|
|
1402
|
+
/**
|
|
1403
|
+
* The Norwegian national identity number (fodselsnummer): eleven digits, DDMMYY, a three-digit individual number and two
|
|
1404
|
+
* Modulus-11 check digits (weights 3 7 6 1 8 9 4 5 2, then 5 4 3 2 7 6 5 4 3 2 over the ten digits so far); a check that would
|
|
1405
|
+
* be 10 is never issued. A D-number adds 4 to the first digit of the day, an H-number adds 4 to the first digit of the month.
|
|
1406
|
+
*/
|
|
1407
|
+
declare function validateNorgeFodselsnummer(value: string): IdentifierResult;
|
|
1408
|
+
/**
|
|
1409
|
+
* The Estonian personal identification code (isikukood): eleven digits, a century-and-sex digit (1 to 8), YYMMDD, a serial and a
|
|
1410
|
+
* check digit from weights 1 2 3 4 5 6 7 8 9 1 modulo 11, or, when that is 10, weights 3 4 5 6 7 8 9 1 2 3 (and 0 if that is 10 too).
|
|
1411
|
+
*/
|
|
1412
|
+
declare function validateEestiIsikukood(value: string): IdentifierResult;
|
|
1413
|
+
/**
|
|
1414
|
+
* The Czech and Slovak birth number (rodne cislo), YYMMDD/SSSC: nine digits for someone born before 1954 (no check), or ten
|
|
1415
|
+
* with the whole number divisible by 11 (a check of 0 stands for a remainder of 10 in the first nine, used up to 1985). The
|
|
1416
|
+
* month carries the sex (+50 for women) and, from 2004, +20 when the serials of a day ran out.
|
|
1417
|
+
*/
|
|
1418
|
+
declare function validateRodneCislo(value: string): IdentifierResult;
|
|
1419
|
+
/** The Hungarian social security (TAJ) number: nine digits, the ninth the sum of the first eight times 3 and 7 alternately, modulo 10. */
|
|
1420
|
+
declare function validateMagyarorszagTajSzam(value: string): IdentifierResult;
|
|
1421
|
+
/**
|
|
1422
|
+
* The Russian insurance number of individual ledger account (SNILS): eleven digits, the last two a check of the first nine
|
|
1423
|
+
* times 9 down to 1: the sum itself under 100, 0 for 100 or 101, otherwise the sum modulo 101 (with 100 again giving 0).
|
|
1424
|
+
*/
|
|
1425
|
+
declare function validateRossiyaSnils(value: string): IdentifierResult;
|
|
1426
|
+
/**
|
|
1427
|
+
* The Finnish personal identity code (henkilotunnus): DDMMYY, a century sign (+ for the 1800s; - and U to Y for the 1900s; A to
|
|
1428
|
+
* F for the 2000s), a three-digit individual number (002 to 899) and a check character, the nine digits DDMMYYZZZ as a number
|
|
1429
|
+
* modulo 31 looked up in 0123456789ABCDEFHJKLMNPRSTUVWXY. Letters are upper case; nothing is re-cased.
|
|
1430
|
+
*/
|
|
1431
|
+
declare function validateSuomiHenkilotunnus(value: string): IdentifierResult;
|
|
1432
|
+
/**
|
|
1433
|
+
* The Italian tax code (codice fiscale) of a person: sixteen upper-case characters, surname and name letters, year, a month
|
|
1434
|
+
* letter (ABCDEHLMPRST), the day (plus 40 for a woman), the place code, and a check letter from the odd and even position
|
|
1435
|
+
* tables modulo 26. In a case of omocodia a digit is replaced by one of LMNPQRSTUV; it is read back before the date is checked.
|
|
1436
|
+
*/
|
|
1437
|
+
declare function validateItaliaCodiceFiscale(value: string): IdentifierResult;
|
|
1438
|
+
/** The Portuguese tax number (NIF): nine digits, the ninth 11 minus the first eight (weights 9 to 2) modulo 11, 0 when that is 10 or 11. */
|
|
1439
|
+
declare function validatePortugalNumeroDeIdentificacaoFiscal(value: string): IdentifierResult;
|
|
1440
|
+
/** The Chilean RUT (rol unico nacional): one to eight digits and a check digit or K, weights 2 to 7 from the right, 11 minus the sum modulo 11 (11 is 0, 10 is K). */
|
|
1441
|
+
declare function validateChileRolUnicoNacional(value: string): IdentifierResult;
|
|
1442
|
+
/** The Uruguayan cedula de identidad: six or seven digits and a check digit, the digits (left-padded to seven) times 2 9 8 7 6 3 4, 10 minus the sum modulo 10. */
|
|
1443
|
+
declare function validateUruguayCedulaDeIdentidad(value: string): IdentifierResult;
|
|
1444
|
+
/** The Ecuadorian cedula de identidad: ten digits, a province 01 to 24 or 30, a third digit under 6, and a check from weights 2 1 2 1 2 1 2 1 2 (a product over 9 loses 9). */
|
|
1445
|
+
declare function validateEcuadorCedulaDeIdentidad(value: string): IdentifierResult;
|
|
1446
|
+
/** The Argentine CUIL or CUIT: eleven digits, a type prefix (20, 23, 24, 27, 30, 33, 34), weights 5 4 3 2 7 6 5 4 3 2, 11 minus the sum modulo 11 (11 is 0; a 10 is never issued). */
|
|
1447
|
+
declare function validateArgentinaCodigoUnicoDeIdentificacionLaboral(value: string): IdentifierResult;
|
|
1448
|
+
/** The Mexican CURP: eighteen characters, YYMMDD, a sex letter (H, M or X), a state code, and a check digit from the position-weighted (18 down to 2) alphabet values, 10 minus the sum modulo 10. */
|
|
1449
|
+
declare function validateMexicoClaveUnicaDeRegistroDePoblacion(value: string): IdentifierResult;
|
|
1450
|
+
/** The South African identity number: thirteen digits, YYMMDD, a sequence, a citizenship digit (0 or 1), and a Luhn check. */
|
|
1451
|
+
declare function validateSouthAfricaIdentityNumber(value: string): IdentifierResult;
|
|
1452
|
+
/**
|
|
1453
|
+
* The Singapore NRIC or FIN: a prefix letter (S or T for citizens and permanent residents, F or G for foreigners), seven digits
|
|
1454
|
+
* and a check letter, from the weights 2 7 6 5 4 3 2 (plus 4 for T and G) modulo 11 looked up in JZIHGFEDCBA (S, T) or XWUTRQPNMLK (F, G).
|
|
1455
|
+
*/
|
|
1456
|
+
declare function validateSingaporeNationalRegistrationIdentityCard(value: string): IdentifierResult;
|
|
1457
|
+
/** The Taiwanese national identification number: a letter (the issuing county, A to Z), a digit 1, 2, 8 or 9, eight digits, and a check making the weighted sum divisible by 10. */
|
|
1458
|
+
declare function validateTaiwanGuominShenfenzhengTongyiBianhao(value: string): IdentifierResult;
|
|
1459
|
+
/** The Japanese Individual Number (My Number): twelve digits, the last a check of the first eleven weighted 2 to 7 then 2 to 6 from the right, 11 minus the sum modulo 11 (0 when that is under 2). */
|
|
1460
|
+
declare function validateNihonKojinBango(value: string): IdentifierResult;
|
|
1461
|
+
/** The Chinese resident identity card number: eighteen characters, a six-digit region, a birth date YYYYMMDD, a three-digit sequence and a check (digit or X) from weights 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 modulo 11 looked up in 10X98765432. */
|
|
1462
|
+
declare function validateZhongguoJuminShenfenzhengHaoma(value: string): IdentifierResult;
|
|
1463
|
+
/**
|
|
1464
|
+
* The Latvian personal code: eleven digits. A code beginning 32 (issued since July 2017) carries no date or check. An older
|
|
1465
|
+
* code is DDMMYY, a century digit (0 for the 1800s, 1 for the 1900s, 2 for the 2000s), a serial, and a check digit equal to
|
|
1466
|
+
* (1101 minus the weighted sum 1 6 3 7 9 10 5 8 4 2 over the first ten digits) modulo 11 modulo 10.
|
|
1467
|
+
*/
|
|
1468
|
+
declare function validateLatvijaPersonasKods(value: string): IdentifierResult;
|
|
1469
|
+
/**
|
|
1470
|
+
* The Lithuanian personal code (asmens kodas): eleven digits with the Estonian layout and check: a century-and-sex digit 1 to 6
|
|
1471
|
+
* (1 and 2 for the 1800s, 3 and 4 for the 1900s, 5 and 6 for the 2000s), YYMMDD, a serial, and the same two-pass Modulus-11 check.
|
|
1472
|
+
*/
|
|
1473
|
+
declare function validateLietuvaAsmensKodas(value: string): IdentifierResult;
|
|
1474
|
+
/** The Croatian personal identification number (OIB): eleven digits, the last the ISO 7064 MOD 11,10 check of the first ten. */
|
|
1475
|
+
declare function validateHrvatskaOsobniIdentifikacijskiBroj(value: string): IdentifierResult;
|
|
1476
|
+
/**
|
|
1477
|
+
* The Slovenian unique master citizen number (EMSO): thirteen digits, DDMMYYY (a three-digit year, 000 to 999 meaning 2000 to
|
|
1478
|
+
* 2099 below 100 and 1000 to 1999 above), a two-digit region, a serial, and a check from weights 7 6 5 4 3 2 7 6 5 4 3 2 modulo
|
|
1479
|
+
* 11 (11 minus the remainder; 11 gives 0, and 10 is never issued).
|
|
1480
|
+
*/
|
|
1481
|
+
declare function validateSlovenijaEmso(value: string): IdentifierResult;
|
|
1482
|
+
/**
|
|
1483
|
+
* The Romanian personal numeric code (CNP): thirteen digits, a sex-and-century digit (1 to 9), YYMMDD, a county code (01 to 46,
|
|
1484
|
+
* 51 or 52) and a serial, and a check from weights 2 7 9 1 4 6 3 5 8 2 7 9 modulo 11 (10 gives 1). A resident's century comes from
|
|
1485
|
+
* the first digit (1 and 2 the 1900s, 3 and 4 the 1800s, 5 and 6 the 2000s); a foreign resident's (7, 8, 9) is not encoded.
|
|
1486
|
+
*/
|
|
1487
|
+
declare function validateRomaniaCodNumericPersonal(value: string): IdentifierResult;
|
|
1488
|
+
/**
|
|
1489
|
+
* The Austrian social security number (Sozialversicherungsnummer): ten digits, a three-digit serial, a check digit, and the date
|
|
1490
|
+
* of birth DDMMYY. The check is the sum of the other nine digits times 3 7 9 5 8 4 2 1 6 modulo 11; a remainder of 10 is never issued.
|
|
1491
|
+
*/
|
|
1492
|
+
declare function validateOsterreichSozialversicherungsnummer(value: string): IdentifierResult;
|
|
1493
|
+
/**
|
|
1494
|
+
* The Icelandic identity number (kennitala): ten digits, DDMMYY (a company's day has 40 added), two random digits, a check
|
|
1495
|
+
* digit, and a century digit (8 for the 1800s, 9 for the 1900s, 0 for the 2000s). The check is 11 minus the first eight digits
|
|
1496
|
+
* times 3 2 7 6 5 4 3 2 modulo 11 (11 gives 0; 10 is never issued).
|
|
1497
|
+
*/
|
|
1498
|
+
declare function validateIslandKennitala(value: string): IdentifierResult;
|
|
1499
|
+
/** The Israeli identity number (teudat zehut): nine digits (a shorter number is not padded), the digits times 1 2 1 2 ... with each product's digits added, the total divisible by 10. */
|
|
1500
|
+
declare function validateYisraelTeudatZehut(value: string): IdentifierResult;
|
|
1501
|
+
/** The Iranian national code (kod-e melli): ten digits, not one digit repeated, a check from the first nine times 10 down to 2 modulo 11 (a remainder under 2 is the check itself, else 11 minus it). */
|
|
1502
|
+
declare function validateIranKodEMelli(value: string): IdentifierResult;
|
|
1503
|
+
/** The Emirates ID of the United Arab Emirates: fifteen digits beginning 784 (the country code) and a Luhn check. */
|
|
1504
|
+
declare function validateAlImaratRaqmAlHuwiyah(value: string): IdentifierResult;
|
|
1505
|
+
/**
|
|
1506
|
+
* The Hong Kong identity card number: one or two letters, six digits and a check digit or A (written in brackets, which are
|
|
1507
|
+
* ignored). Each letter is 10 (A) to 35 (Z), a single letter is preceded by a 36 in place of a first letter, and the weights
|
|
1508
|
+
* run 9 down to 2 over the eight values and six digits; the check is 11 minus the sum modulo 11 (10 is A, 11 is 0).
|
|
1509
|
+
*/
|
|
1510
|
+
declare function validateHongKongIdentityCard(value: string): IdentifierResult;
|
|
1511
|
+
/** The Thai national identification number: thirteen digits, the last (11 minus the first twelve times 13 down to 2, modulo 11) modulo 10. */
|
|
1512
|
+
declare function validatePrathetThaiLekPrajamTuaPrachachon(value: string): IdentifierResult;
|
|
1513
|
+
/** The Australian Individual Healthcare Identifier (IHI): sixteen digits beginning 800360 (the individual identifier prefix) and a Luhn check. */
|
|
1514
|
+
declare function validateAustraliaIndividualHealthcareIdentifier(value: string): IdentifierResult;
|
|
1515
|
+
/**
|
|
1516
|
+
* The German health insurance number (KVNR): an upper-case letter, eight digits and a check digit. The letter is read as its
|
|
1517
|
+
* two-digit place in the alphabet (A is 01), the ten digits are multiplied by 1 2 1 2 ..., each product's digits are added, and
|
|
1518
|
+
* the sum modulo 10 is the check digit.
|
|
1519
|
+
*/
|
|
1520
|
+
declare function validateDeutschlandKrankenversichertennummer(value: string): IdentifierResult;
|
|
1521
|
+
/** The Polish tax identification number (NIP): ten digits, the tenth the first nine times 6 5 7 2 3 4 5 6 7 modulo 11 (10 is never issued). */
|
|
1522
|
+
declare function validatePolskaNumerIdentyfikacjiPodatkowej(value: string): IdentifierResult;
|
|
1523
|
+
/**
|
|
1524
|
+
* The United Kingdom National Insurance number: two letters, six digits and a suffix letter A to D, in upper case. It has no
|
|
1525
|
+
* check digit; the rules are the prefix letters (neither D, F, I, Q, U or V, the second also not O) and the prefixes
|
|
1526
|
+
* BG, GB, KN, NK, NT, TN and ZZ, which are never issued.
|
|
1527
|
+
*/
|
|
1528
|
+
declare function validateUnitedKingdomNationalInsuranceNumber(value: string): IdentifierResult;
|
|
1529
|
+
/**
|
|
1530
|
+
* The United States Social Security number: nine digits as area (3), group (2) and serial (4). It has no check digit; the rules
|
|
1531
|
+
* are an area of 001 to 899 other than 666 (000, 666 and 900 to 999 are never issued), a group of 01 to 99 and a serial of 0001 to 9999.
|
|
1532
|
+
*/
|
|
1533
|
+
declare function validateUnitedStatesSocialSecurityNumber(value: string): IdentifierResult;
|
|
1534
|
+
/**
|
|
1535
|
+
* The Kazakhstan individual identification number (IIN): twelve digits, YYMMDD, a century-and-sex digit 1 to 6 (1 and 2 for the
|
|
1536
|
+
* 1800s, 3 and 4 for the 1900s, 5 and 6 for the 2000s), four more digits, and a check: the first eleven digits times 1 to 11 modulo
|
|
1537
|
+
* 11, or when that is 10 times 3 to 11, 1, 2 modulo 11; a check of 10 again is never issued.
|
|
1538
|
+
*/
|
|
1539
|
+
declare function validateQazaqstanZhekeSaikestendiruNomiri(value: string): IdentifierResult;
|
|
1540
|
+
/** The Ukrainian taxpayer registration number (RNOKPP): ten digits, the tenth the first nine times -1 5 7 9 4 6 10 5 7 modulo 11, modulo 10. */
|
|
1541
|
+
declare function validateUkrayinaReyestratsiyniyNomerOblikovoyiKartkyPlatnykaPodatkiv(value: string): IdentifierResult;
|
|
1542
|
+
/** The Saudi national identity or resident number: ten digits beginning 1 (a citizen) or 2 (a resident), and a Luhn check. */
|
|
1543
|
+
declare function validateAsSaudiyahRaqmAlHuwiyahAlWataniyah(value: string): IdentifierResult;
|
|
1544
|
+
/**
|
|
1545
|
+
* The Spanish tax identification number as the component documents it: eight digits and a control letter, the number modulo 23
|
|
1546
|
+
* looked up in TRWAGMYFPDXBNJZSQVHLCKE (so the letters I, N-tilde, O and U are never used). Upper case; a foreigner's NIE and a company's
|
|
1547
|
+
* CIF have other shapes and are not covered.
|
|
1548
|
+
*/
|
|
1549
|
+
declare function validateEspanaCodigoDeIdentificacionFiscal(value: string): IdentifierResult;
|
|
1550
|
+
/**
|
|
1551
|
+
* The Danish personal number (CPR): ten digits, DDMMYY and four more, the first of which (the seventh digit overall) with the year
|
|
1552
|
+
* gives the century (0 to 3 the 1900s; 4 and 9 the 2000s up to 36, else the 1900s; 5 to 8 the 2000s up to 57, else the 1800s). Numbers
|
|
1553
|
+
* issued since 2007 need not satisfy the old Modulus-11 check, so only the date is checked, and no check digit is applied.
|
|
1554
|
+
*/
|
|
1555
|
+
declare function validateDanmarkPersonnummer(value: string): IdentifierResult;
|
|
1556
|
+
/** The Malaysian identity card number (MyKad): twelve digits, YYMMDD, a two-digit place code and four more; there is no check digit, so the date (its century is not encoded) is the only rule. */
|
|
1557
|
+
declare function validateMalaysiaKadPengenalan(value: string): IdentifierResult;
|
|
1558
|
+
/** The Indonesian population identification number (NIK): sixteen digits, a region code (not 00 for the province), DDMMYY with 40 added to the day for a woman, and a four-digit sequence; no published check digit, so the date is the only other rule. */
|
|
1559
|
+
declare function validateIndonesiaNomorIndukKependudukan(value: string): IdentifierResult;
|
|
1560
|
+
|
|
1561
|
+
export { AlImaratRaqmAlHuwiyahInput, AlImaratRaqmAlHuwiyahView, AlbaCommunityHealthIndexInput, AlbaCommunityHealthIndexView, AotearoaNationalHealthIndexInput, AotearoaNationalHealthIndexView, ArgentinaCodigoUnicoDeIdentificacionLaboralInput, ArgentinaCodigoUnicoDeIdentificacionLaboralView, AsSaudiyahRaqmAlHuwiyahAlWataniyahInput, AsSaudiyahRaqmAlHuwiyahAlWataniyahView, AustraliaIndividualHealthcareIdentifierInput, AustraliaIndividualHealthcareIdentifierView, AustraliaTaxFileNumberInput, AustraliaTaxFileNumberView, BangladeshNationalIdentityCardInput, BangladeshNationalIdentityCardView, BelgiqueNumeroDeRegistreNationalInput, BelgiqueNumeroDeRegistreNationalView, BharatAadhaarInput, BharatAadhaarView, BrasilCartaoNacionalDeSaudeInput, BrasilCartaoNacionalDeSaudeView, BulgariaEdinenGrazhdanskiNomerInput, BulgariaEdinenGrazhdanskiNomerView, CanadaSocialInsuranceNumberInput, CanadaSocialInsuranceNumberView, CeskoCestovniPasInput, CeskoCestovniPasView, CeskoRodneCisloInput, CeskoRodneCisloView, ChileRolUnicoNacionalInput, ChileRolUnicoNacionalView, ColombiaCedulaDeCiudadaniaInput, ColombiaCedulaDeCiudadaniaView, CostaRicaCedulaDeIdentidadInput, CostaRicaCedulaDeIdentidadView, CymruRhifYGwasanaethIechydGwladolInput, CymruRhifYGwasanaethIechydGwladolView, DanmarkPersonnummerInput, DanmarkPersonnummerView, DeutschlandKrankenversichertennummerInput, DeutschlandKrankenversichertennummerView, EcuadorCedulaDeIdentidadInput, EcuadorCedulaDeIdentidadView, EestiIsikukoodInput, EestiIsikukoodView, EireIndividualHealthIdentifierInput, EireIndividualHealthIdentifierView, ElladaDematerialisedSecuritiesSystemInput, ElladaDematerialisedSecuritiesSystemView, EnglandNationalHealthServiceNumberInput, EnglandNationalHealthServiceNumberView, EspanaCodigoDeIdentificacionFiscalInput, EspanaCodigoDeIdentificacionFiscalView, EspanaTarjetaSanitariaIndividualInput, EspanaTarjetaSanitariaIndividualView, FranceNumeroDIdentificationAuRepertoireInput, FranceNumeroDIdentificationAuRepertoireView, GhanaCardPersonalIdentificationNumberInput, GhanaCardPersonalIdentificationNumberView, GuatemalaCodigoUnicoDeIdentificacionInput, GuatemalaCodigoUnicoDeIdentificacionView, HangukJuminDeungnokBeonhoInput, HangukJuminDeungnokBeonhoView, HongKongIdentityCardInput, HongKongIdentityCardView, HrvatskaOsobniIdentifikacijskiBrojInput, HrvatskaOsobniIdentifikacijskiBrojView, IndonesiaNomorIndukKependudukanInput, IndonesiaNomorIndukKependudukanView, IranKodEMelliInput, IranKodEMelliView, IslandKennitalaInput, IslandKennitalaView, ItaliaCodiceFiscaleInput, ItaliaCodiceFiscaleView, ItyopyaFaydaIdentificationNumberInput, ItyopyaFaydaIdentificationNumberView, KyprosNationalPassportNumberInput, KyprosNationalPassportNumberView, LatvijaPersonasKodsInput, LatvijaPersonasKodsView, LiechtensteinNationalIdentityCardNumberInput, LiechtensteinNationalIdentityCardNumberView, LiechtensteinPassportNumberInput, LiechtensteinPassportNumberView, LietuvaAsmensKodasInput, LietuvaAsmensKodasView, LietuvaPasasInput, LietuvaPasasView, LuxembourgMatriculeInput, LuxembourgMatriculeView, MagyarorszagTajSzamInput, MagyarorszagTajSzamView, MalaysiaKadPengenalanInput, MalaysiaKadPengenalanView, MaltaNationalIdentificationNumberInput, MaltaNationalIdentificationNumberView, MaltaPassportNumberInput, MaltaPassportNumberView, MauritiusNationalIdentityCardNumberInput, MauritiusNationalIdentityCardNumberView, MexicoClaveUnicaDeRegistroDePoblacionInput, MexicoClaveUnicaDeRegistroDePoblacionView, MisrAlRaqmAlQawmiInput, MisrAlRaqmAlQawmiView, NederlandBurgerserviceNummerInput, NederlandBurgerserviceNummerView, NederlandIdentiteitskaartNummerInput, NederlandIdentiteitskaartNummerView, NederlandPaspoortNummerInput, NederlandPaspoortNummerView, NigeriaNationalIdentificationNumberInput, NigeriaNationalIdentificationNumberView, NihonKojinBangoInput, NihonKojinBangoView, NorgeFodselsnummerInput, NorgeFodselsnummerView, OsterreichSozialversicherungsnummerInput, OsterreichSozialversicherungsnummerView, OzbekistonJismoniyShaxsningShaxsiyIdentifikatsionRaqamiInput, OzbekistonJismoniyShaxsningShaxsiyIdentifikatsionRaqamiView, PakistanComputerizedNationalIdentityCardInput, PakistanComputerizedNationalIdentityCardView, PeruDocumentoNacionalDeIdentidadInput, PeruDocumentoNacionalDeIdentidadView, PilipinasPhilhealthIdentificationNumberInput, PilipinasPhilhealthIdentificationNumberView, PolskaNumerIdentyfikacjiPodatkowejInput, PolskaNumerIdentyfikacjiPodatkowejView, PolskaPeselInput, PolskaPeselView, PortugalNumeroDeIdentificacaoFiscalInput, PortugalNumeroDeIdentificacaoFiscalView, PortugalPassaporteInput, PortugalPassaporteView, PrathetThaiLekPrajamTuaPrachachonInput, PrathetThaiLekPrajamTuaPrachachonView, QazaqstanZhekeSaikestendiruNomiriInput, QazaqstanZhekeSaikestendiruNomiriView, RepublicaDominicanaCedulaDeIdentidadYElectoralInput, RepublicaDominicanaCedulaDeIdentidadYElectoralView, RomaniaCodNumericPersonalInput, RomaniaCodNumericPersonalView, RomaniaPasaportInput, RomaniaPasaportView, RossiyaSnilsInput, RossiyaSnilsView, SchweizAhvNummerInput, SchweizAhvNummerView, SingaporeNationalRegistrationIdentityCardInput, SingaporeNationalRegistrationIdentityCardView, SlovenijaEmsoInput, SlovenijaEmsoView, SlovenskoPasInput, SlovenskoPasView, SlovenskoRodneCisloInput, SlovenskoRodneCisloView, SouthAfricaIdentityNumberInput, SouthAfricaIdentityNumberView, SriLankaNationalIdentityCardInput, SriLankaNationalIdentityCardView, SuomiHenkilotunnusInput, SuomiHenkilotunnusView, SverigePersonnummerInput, SverigePersonnummerView, TaiwanGuominShenfenzhengTongyiBianhaoInput, TaiwanGuominShenfenzhengTongyiBianhaoView, TuaisceartEireannHealthAndCareNumberInput, TuaisceartEireannHealthAndCareNumberView, TurkiyeTcKimlikNumarasiInput, TurkiyeTcKimlikNumarasiView, UkrayinaReyestratsiyniyNomerOblikovoyiKartkyPlatnykaPodatkivInput, UkrayinaReyestratsiyniyNomerOblikovoyiKartkyPlatnykaPodatkivView, UnitedKingdomNationalHealthServiceNumberInput, UnitedKingdomNationalHealthServiceNumberView, UnitedKingdomNationalInsuranceNumberInput, UnitedKingdomNationalInsuranceNumberView, UnitedStatesSocialSecurityNumberInput, UnitedStatesSocialSecurityNumberView, UruguayCedulaDeIdentidadInput, UruguayCedulaDeIdentidadView, VietNamCanCuocCongDanInput, VietNamCanCuocCongDanView, YisraelTeudatZehutInput, YisraelTeudatZehutView, ZhongguoJuminShenfenzhengHaomaInput, ZhongguoJuminShenfenzhengHaomaView, isCalendarDate, luhnValid, stripSeparators, validateAlImaratRaqmAlHuwiyah, validateArgentinaCodigoUnicoDeIdentificacionLaboral, validateAsSaudiyahRaqmAlHuwiyahAlWataniyah, validateAustraliaIndividualHealthcareIdentifier, validateAustraliaTaxFileNumber, validateBelgiqueRegistreNational, validateBharatAadhaar, validateBulgariaEdinenGrazhdanskiNomer, validateCanadaSocialInsuranceNumber, validateChileRolUnicoNacional, validateDanmarkPersonnummer, validateDeutschlandKrankenversichertennummer, validateEcuadorCedulaDeIdentidad, validateEestiIsikukood, validateEspanaCodigoDeIdentificacionFiscal, validateFranceNir, validateHongKongIdentityCard, validateHrvatskaOsobniIdentifikacijskiBroj, validateIndonesiaNomorIndukKependudukan, validateIranKodEMelli, validateIslandKennitala, validateItaliaCodiceFiscale, validateLatvijaPersonasKods, validateLietuvaAsmensKodas, validateMagyarorszagTajSzam, validateMalaysiaKadPengenalan, validateMexicoClaveUnicaDeRegistroDePoblacion, validateNederlandBurgerservicenummer, validateNhsNumber, validateNihonKojinBango, validateNorgeFodselsnummer, validateOsterreichSozialversicherungsnummer, validatePolskaNumerIdentyfikacjiPodatkowej, validatePolskaPesel, validatePortugalNumeroDeIdentificacaoFiscal, validatePrathetThaiLekPrajamTuaPrachachon, validateQazaqstanZhekeSaikestendiruNomiri, validateRodneCislo, validateRomaniaCodNumericPersonal, validateRossiyaSnils, validateSchweizAhvNummer, validateSingaporeNationalRegistrationIdentityCard, validateSlovenijaEmso, validateSouthAfricaIdentityNumber, validateSuomiHenkilotunnus, validateSverigePersonnummer, validateTaiwanGuominShenfenzhengTongyiBianhao, validateTurkiyeTcKimlikNumarasi, validateUkrayinaReyestratsiyniyNomerOblikovoyiKartkyPlatnykaPodatkiv, validateUnitedKingdomNationalInsuranceNumber, validateUnitedStatesSocialSecurityNumber, validateUruguayCedulaDeIdentidad, validateYisraelTeudatZehut, validateZhongguoJuminShenfenzhengHaoma, verhoeffValid, weightedSum };
|
|
1562
|
+
export type { IdentifierReason, IdentifierResult };
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,18 @@ function passThroughAttributes(host, target, handled) {
|
|
|
8
8
|
if (attr.name === "class" || handled.has(attr.name)) continue;
|
|
9
9
|
target.setAttribute(attr.name, attr.value);
|
|
10
10
|
}
|
|
11
|
+
if (!handled.has("id") && host.hasAttribute("id") && LABELABLE.has(target.localName))
|
|
12
|
+
host.removeAttribute("id");
|
|
11
13
|
}
|
|
14
|
+
var LABELABLE = /* @__PURE__ */ new Set([
|
|
15
|
+
"button",
|
|
16
|
+
"input",
|
|
17
|
+
"meter",
|
|
18
|
+
"output",
|
|
19
|
+
"progress",
|
|
20
|
+
"select",
|
|
21
|
+
"textarea"
|
|
22
|
+
]);
|
|
12
23
|
|
|
13
24
|
// components/al-imarat-raqm-al-huwiyah-input.ts
|
|
14
25
|
var HANDLED = /* @__PURE__ */ new Set(["label", "value", "required", "disabled", "autocomplete"]);
|
|
@@ -5720,6 +5731,727 @@ var ZhongguoJuminShenfenzhengHaomaView = class extends HTMLElement {
|
|
|
5720
5731
|
}
|
|
5721
5732
|
};
|
|
5722
5733
|
|
|
5734
|
+
// lib/national-identifiers.ts
|
|
5735
|
+
var OK = { valid: true };
|
|
5736
|
+
var no = (reason) => ({ valid: false, reason });
|
|
5737
|
+
function text(value, name) {
|
|
5738
|
+
if (typeof value !== "string")
|
|
5739
|
+
throw new TypeError(`${name}: expected a string, got ${typeof value}`);
|
|
5740
|
+
return value;
|
|
5741
|
+
}
|
|
5742
|
+
function stripSeparators(value) {
|
|
5743
|
+
return value.replace(/[ .\-/]/g, "");
|
|
5744
|
+
}
|
|
5745
|
+
var isDigits = (s) => /^[0-9]+$/.test(s);
|
|
5746
|
+
var digitsOf = (s) => [...s].map(Number);
|
|
5747
|
+
function luhnValid(digits) {
|
|
5748
|
+
if (!isDigits(digits)) return false;
|
|
5749
|
+
let sum = 0;
|
|
5750
|
+
let double = false;
|
|
5751
|
+
for (let i = digits.length - 1; i >= 0; i--) {
|
|
5752
|
+
let d = digits.charCodeAt(i) - 48;
|
|
5753
|
+
if (double) {
|
|
5754
|
+
d *= 2;
|
|
5755
|
+
if (d > 9) d -= 9;
|
|
5756
|
+
}
|
|
5757
|
+
sum += d;
|
|
5758
|
+
double = !double;
|
|
5759
|
+
}
|
|
5760
|
+
return sum % 10 === 0;
|
|
5761
|
+
}
|
|
5762
|
+
function weightedSum(digits, weights) {
|
|
5763
|
+
let sum = 0;
|
|
5764
|
+
for (let i = 0; i < weights.length; i++) sum += digits[i] * weights[i];
|
|
5765
|
+
return sum;
|
|
5766
|
+
}
|
|
5767
|
+
var VERHOEFF_D = [
|
|
5768
|
+
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
|
5769
|
+
[1, 2, 3, 4, 0, 6, 7, 8, 9, 5],
|
|
5770
|
+
[2, 3, 4, 0, 1, 7, 8, 9, 5, 6],
|
|
5771
|
+
[3, 4, 0, 1, 2, 8, 9, 5, 6, 7],
|
|
5772
|
+
[4, 0, 1, 2, 3, 9, 5, 6, 7, 8],
|
|
5773
|
+
[5, 9, 8, 7, 6, 0, 4, 3, 2, 1],
|
|
5774
|
+
[6, 5, 9, 8, 7, 1, 0, 4, 3, 2],
|
|
5775
|
+
[7, 6, 5, 9, 8, 2, 1, 0, 4, 3],
|
|
5776
|
+
[8, 7, 6, 5, 9, 3, 2, 1, 0, 4],
|
|
5777
|
+
[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
|
|
5778
|
+
];
|
|
5779
|
+
var VERHOEFF_P = [
|
|
5780
|
+
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
|
5781
|
+
[1, 5, 7, 6, 2, 8, 3, 0, 9, 4],
|
|
5782
|
+
[5, 8, 0, 3, 7, 9, 6, 1, 4, 2],
|
|
5783
|
+
[8, 9, 1, 6, 0, 4, 3, 5, 2, 7],
|
|
5784
|
+
[9, 4, 5, 3, 1, 2, 6, 8, 7, 0],
|
|
5785
|
+
[4, 2, 8, 6, 5, 7, 3, 9, 0, 1],
|
|
5786
|
+
[2, 7, 9, 3, 8, 0, 6, 4, 1, 5],
|
|
5787
|
+
[7, 0, 4, 6, 9, 1, 3, 2, 5, 8]
|
|
5788
|
+
];
|
|
5789
|
+
function verhoeffValid(digits) {
|
|
5790
|
+
if (!isDigits(digits)) return false;
|
|
5791
|
+
let c = 0;
|
|
5792
|
+
const reversed = digitsOf(digits).reverse();
|
|
5793
|
+
for (let i = 0; i < reversed.length; i++) c = VERHOEFF_D[c][VERHOEFF_P[i % 8][reversed[i]]];
|
|
5794
|
+
return c === 0;
|
|
5795
|
+
}
|
|
5796
|
+
function isCalendarDate(year, month, day) {
|
|
5797
|
+
if (!Number.isInteger(year) || !Number.isInteger(month) || !Number.isInteger(day)) return false;
|
|
5798
|
+
if (month < 1 || month > 12 || day < 1) return false;
|
|
5799
|
+
return day <= new Date(Date.UTC(2e3 + year % 400, month, 0)).getUTCDate();
|
|
5800
|
+
}
|
|
5801
|
+
function validateNhsNumber(value) {
|
|
5802
|
+
const s = stripSeparators(text(value, "validateNhsNumber"));
|
|
5803
|
+
if (!isDigits(s)) return no("characters");
|
|
5804
|
+
if (s.length !== 10) return no("length");
|
|
5805
|
+
const d = digitsOf(s);
|
|
5806
|
+
const remainder = weightedSum(d, [10, 9, 8, 7, 6, 5, 4, 3, 2]) % 11;
|
|
5807
|
+
const check = remainder === 0 ? 0 : 11 - remainder;
|
|
5808
|
+
if (check === 10 || check !== d[9]) return no("checksum");
|
|
5809
|
+
return OK;
|
|
5810
|
+
}
|
|
5811
|
+
function validateCanadaSocialInsuranceNumber(value) {
|
|
5812
|
+
const s = stripSeparators(text(value, "validateCanadaSocialInsuranceNumber"));
|
|
5813
|
+
if (!isDigits(s)) return no("characters");
|
|
5814
|
+
if (s.length !== 9) return no("length");
|
|
5815
|
+
return luhnValid(s) ? OK : no("checksum");
|
|
5816
|
+
}
|
|
5817
|
+
function validateNederlandBurgerservicenummer(value) {
|
|
5818
|
+
const s = stripSeparators(text(value, "validateNederlandBurgerservicenummer"));
|
|
5819
|
+
if (!isDigits(s)) return no("characters");
|
|
5820
|
+
if (s.length !== 9) return no("length");
|
|
5821
|
+
const d = digitsOf(s);
|
|
5822
|
+
const sum = weightedSum(d, [9, 8, 7, 6, 5, 4, 3, 2, -1]);
|
|
5823
|
+
return sum % 11 === 0 && sum !== 0 ? OK : no("checksum");
|
|
5824
|
+
}
|
|
5825
|
+
function validateBelgiqueRegistreNational(value) {
|
|
5826
|
+
const s = stripSeparators(text(value, "validateBelgiqueRegistreNational"));
|
|
5827
|
+
if (!isDigits(s)) return no("characters");
|
|
5828
|
+
if (s.length !== 11) return no("length");
|
|
5829
|
+
const month = Number(s.slice(2, 4));
|
|
5830
|
+
const day = Number(s.slice(4, 6));
|
|
5831
|
+
if (month > 12 && !(month >= 20 && month <= 32) && !(month >= 40 && month <= 52))
|
|
5832
|
+
return no("date");
|
|
5833
|
+
if (day > 31) return no("date");
|
|
5834
|
+
if (Number(s.slice(6, 9)) === 0) return no("structure");
|
|
5835
|
+
const check = Number(s.slice(9));
|
|
5836
|
+
const base = Number(s.slice(0, 9));
|
|
5837
|
+
const expected = (n) => 97 - n % 97;
|
|
5838
|
+
return check === expected(base) || check === expected(2e9 + base) ? OK : no("checksum");
|
|
5839
|
+
}
|
|
5840
|
+
function validateSverigePersonnummer(value) {
|
|
5841
|
+
const s = stripSeparators(text(value, "validateSverigePersonnummer").replace(/\+/g, ""));
|
|
5842
|
+
if (!isDigits(s)) return no("characters");
|
|
5843
|
+
if (s.length !== 10 && s.length !== 12) return no("length");
|
|
5844
|
+
const ten = s.length === 12 ? s.slice(2) : s;
|
|
5845
|
+
const yy = Number(ten.slice(0, 2));
|
|
5846
|
+
const mm = Number(ten.slice(2, 4));
|
|
5847
|
+
let dd = Number(ten.slice(4, 6));
|
|
5848
|
+
if (dd > 60) dd -= 60;
|
|
5849
|
+
const year = s.length === 12 ? Number(s.slice(0, 4)) : 2e3 + yy;
|
|
5850
|
+
if (s.length === 12 ? !isCalendarDate(year, mm, dd) : mm < 1 || mm > 12 || dd < 1 || dd > 31)
|
|
5851
|
+
return no("date");
|
|
5852
|
+
return luhnValid(ten) ? OK : no("checksum");
|
|
5853
|
+
}
|
|
5854
|
+
function validatePolskaPesel(value) {
|
|
5855
|
+
const s = stripSeparators(text(value, "validatePolskaPesel"));
|
|
5856
|
+
if (!isDigits(s)) return no("characters");
|
|
5857
|
+
if (s.length !== 11) return no("length");
|
|
5858
|
+
const d = digitsOf(s);
|
|
5859
|
+
const yy = Number(s.slice(0, 2));
|
|
5860
|
+
const monthField = Number(s.slice(2, 4));
|
|
5861
|
+
const dd = Number(s.slice(4, 6));
|
|
5862
|
+
const century = [1900, 2e3, 2100, 2200, 1800][Math.floor(monthField / 20)];
|
|
5863
|
+
const mm = monthField % 20;
|
|
5864
|
+
if (century === void 0 || !isCalendarDate(century + yy, mm, dd)) return no("date");
|
|
5865
|
+
const check = (10 - weightedSum(d, [1, 3, 7, 9, 1, 3, 7, 9, 1, 3]) % 10) % 10;
|
|
5866
|
+
return check === d[10] ? OK : no("checksum");
|
|
5867
|
+
}
|
|
5868
|
+
function validateAustraliaTaxFileNumber(value) {
|
|
5869
|
+
const s = stripSeparators(text(value, "validateAustraliaTaxFileNumber"));
|
|
5870
|
+
if (!isDigits(s)) return no("characters");
|
|
5871
|
+
if (s.length !== 9) return no("length");
|
|
5872
|
+
return weightedSum(digitsOf(s), [1, 4, 3, 7, 5, 8, 6, 9, 10]) % 11 === 0 ? OK : no("checksum");
|
|
5873
|
+
}
|
|
5874
|
+
function validateBharatAadhaar(value) {
|
|
5875
|
+
const s = stripSeparators(text(value, "validateBharatAadhaar"));
|
|
5876
|
+
if (!isDigits(s)) return no("characters");
|
|
5877
|
+
if (s.length !== 12) return no("length");
|
|
5878
|
+
if (s[0] === "0" || s[0] === "1") return no("structure");
|
|
5879
|
+
return verhoeffValid(s) ? OK : no("checksum");
|
|
5880
|
+
}
|
|
5881
|
+
function validateSchweizAhvNummer(value) {
|
|
5882
|
+
const s = stripSeparators(text(value, "validateSchweizAhvNummer"));
|
|
5883
|
+
if (!isDigits(s)) return no("characters");
|
|
5884
|
+
if (s.length !== 13) return no("length");
|
|
5885
|
+
if (!s.startsWith("756")) return no("structure");
|
|
5886
|
+
const d = digitsOf(s);
|
|
5887
|
+
const sum = d.slice(0, 12).reduce((total, n, i) => total + n * (i % 2 === 0 ? 1 : 3), 0);
|
|
5888
|
+
return (10 - sum % 10) % 10 === d[12] ? OK : no("checksum");
|
|
5889
|
+
}
|
|
5890
|
+
function modulo(digits, n) {
|
|
5891
|
+
let r = 0;
|
|
5892
|
+
for (const c of digits) r = (r * 10 + (c.charCodeAt(0) - 48)) % n;
|
|
5893
|
+
return r;
|
|
5894
|
+
}
|
|
5895
|
+
function validateFranceNir(value) {
|
|
5896
|
+
const s = stripSeparators(text(value, "validateFranceNir")).toUpperCase();
|
|
5897
|
+
if (!/^[0-9A-B]+$/.test(s)) return no("characters");
|
|
5898
|
+
if (s.length !== 15) return no("length");
|
|
5899
|
+
if (!/^[0-9]{5}(?:[0-9]{2}|2A|2B)[0-9]{8}$/.test(s)) return no("structure");
|
|
5900
|
+
const body = s.slice(0, 13).replace("2A", "19").replace("2B", "18");
|
|
5901
|
+
return 97 - modulo(body, 97) === Number(s.slice(13)) ? OK : no("checksum");
|
|
5902
|
+
}
|
|
5903
|
+
function validateTurkiyeTcKimlikNumarasi(value) {
|
|
5904
|
+
const s = stripSeparators(text(value, "validateTurkiyeTcKimlikNumarasi"));
|
|
5905
|
+
if (!isDigits(s)) return no("characters");
|
|
5906
|
+
if (s.length !== 11) return no("length");
|
|
5907
|
+
if (s[0] === "0") return no("structure");
|
|
5908
|
+
const d = digitsOf(s);
|
|
5909
|
+
const odd = d[0] + d[2] + d[4] + d[6] + d[8];
|
|
5910
|
+
const even = d[1] + d[3] + d[5] + d[7];
|
|
5911
|
+
const tenth = ((odd * 7 - even) % 10 + 10) % 10;
|
|
5912
|
+
if (tenth !== d[9]) return no("checksum");
|
|
5913
|
+
const eleventh = d.slice(0, 10).reduce((a, b) => a + b, 0) % 10;
|
|
5914
|
+
return eleventh === d[10] ? OK : no("checksum");
|
|
5915
|
+
}
|
|
5916
|
+
function maxDay(month) {
|
|
5917
|
+
return month === 2 ? 29 : [4, 6, 9, 11].includes(month) ? 30 : 31;
|
|
5918
|
+
}
|
|
5919
|
+
function validateBulgariaEdinenGrazhdanskiNomer(value) {
|
|
5920
|
+
const s = stripSeparators(text(value, "validateBulgariaEdinenGrazhdanskiNomer"));
|
|
5921
|
+
if (!isDigits(s)) return no("characters");
|
|
5922
|
+
if (s.length !== 10) return no("length");
|
|
5923
|
+
const d = digitsOf(s);
|
|
5924
|
+
const yy = Number(s.slice(0, 2));
|
|
5925
|
+
const monthField = Number(s.slice(2, 4));
|
|
5926
|
+
const century = monthField > 40 ? 2e3 : monthField > 20 ? 1800 : 1900;
|
|
5927
|
+
const month = monthField - (century === 2e3 ? 40 : century === 1800 ? 20 : 0);
|
|
5928
|
+
const day = Number(s.slice(4, 6));
|
|
5929
|
+
if (month < 1 || month > 12 || day < 1 || !isCalendarDate(century + yy, month, day))
|
|
5930
|
+
return no("date");
|
|
5931
|
+
const check = weightedSum(d, [2, 4, 8, 5, 10, 9, 7, 3, 6]) % 11 % 10;
|
|
5932
|
+
return check === d[9] ? OK : no("checksum");
|
|
5933
|
+
}
|
|
5934
|
+
function validateNorgeFodselsnummer(value) {
|
|
5935
|
+
const s = stripSeparators(text(value, "validateNorgeFodselsnummer"));
|
|
5936
|
+
if (!isDigits(s)) return no("characters");
|
|
5937
|
+
if (s.length !== 11) return no("length");
|
|
5938
|
+
const d = digitsOf(s);
|
|
5939
|
+
let day = Number(s.slice(0, 2));
|
|
5940
|
+
let month = Number(s.slice(2, 4));
|
|
5941
|
+
if (day > 40) day -= 40;
|
|
5942
|
+
if (month > 40) month -= 40;
|
|
5943
|
+
const yy = Number(s.slice(4, 6));
|
|
5944
|
+
const serial = Number(s.slice(6, 9));
|
|
5945
|
+
const century = serial < 500 ? 1900 : serial < 750 && yy >= 54 ? 1800 : serial >= 900 && yy >= 40 ? 1900 : yy < 40 ? 2e3 : 0;
|
|
5946
|
+
if (century === 0 || !isCalendarDate(century + yy, month, day)) return no("date");
|
|
5947
|
+
const first = 11 - weightedSum(d, [3, 7, 6, 1, 8, 9, 4, 5, 2]) % 11;
|
|
5948
|
+
const k1 = first === 11 ? 0 : first;
|
|
5949
|
+
const second = 11 - weightedSum(d, [5, 4, 3, 2, 7, 6, 5, 4, 3, 2]) % 11;
|
|
5950
|
+
const k2 = second === 11 ? 0 : second;
|
|
5951
|
+
return k1 === d[9] && k2 === d[10] && k1 !== 10 && k2 !== 10 ? OK : no("checksum");
|
|
5952
|
+
}
|
|
5953
|
+
function validateEestiIsikukood(value) {
|
|
5954
|
+
const s = stripSeparators(text(value, "validateEestiIsikukood"));
|
|
5955
|
+
if (!isDigits(s)) return no("characters");
|
|
5956
|
+
if (s.length !== 11) return no("length");
|
|
5957
|
+
const d = digitsOf(s);
|
|
5958
|
+
if (d[0] < 1 || d[0] > 8) return no("structure");
|
|
5959
|
+
const century = 1800 + Math.floor((d[0] - 1) / 2) * 100;
|
|
5960
|
+
if (!isCalendarDate(
|
|
5961
|
+
century + Number(s.slice(1, 3)),
|
|
5962
|
+
Number(s.slice(3, 5)),
|
|
5963
|
+
Number(s.slice(5, 7))
|
|
5964
|
+
))
|
|
5965
|
+
return no("date");
|
|
5966
|
+
let check = weightedSum(d, [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) % 11;
|
|
5967
|
+
if (check === 10) {
|
|
5968
|
+
check = weightedSum(d, [3, 4, 5, 6, 7, 8, 9, 1, 2, 3]) % 11;
|
|
5969
|
+
if (check === 10) check = 0;
|
|
5970
|
+
}
|
|
5971
|
+
return check === d[10] ? OK : no("checksum");
|
|
5972
|
+
}
|
|
5973
|
+
function validateRodneCislo(value) {
|
|
5974
|
+
const s = stripSeparators(text(value, "validateRodneCislo"));
|
|
5975
|
+
if (!isDigits(s)) return no("characters");
|
|
5976
|
+
if (s.length !== 9 && s.length !== 10) return no("length");
|
|
5977
|
+
const yy = Number(s.slice(0, 2));
|
|
5978
|
+
let month = Number(s.slice(2, 4));
|
|
5979
|
+
const day = Number(s.slice(4, 6));
|
|
5980
|
+
if (s.length === 9 && yy >= 54) return no("structure");
|
|
5981
|
+
if (month > 50) month -= 50;
|
|
5982
|
+
if (month > 20) month -= 20;
|
|
5983
|
+
const year = s.length === 9 ? 1900 + yy : yy < 54 ? 2e3 + yy : 1900 + yy;
|
|
5984
|
+
if (!isCalendarDate(year, month, day)) return no("date");
|
|
5985
|
+
if (s.length === 9) return OK;
|
|
5986
|
+
const first9 = Number(s.slice(0, 9));
|
|
5987
|
+
const check = Number(s[9]);
|
|
5988
|
+
return Number(s) % 11 === 0 || first9 % 11 === 10 && check === 0 ? OK : no("checksum");
|
|
5989
|
+
}
|
|
5990
|
+
function validateMagyarorszagTajSzam(value) {
|
|
5991
|
+
const s = stripSeparators(text(value, "validateMagyarorszagTajSzam"));
|
|
5992
|
+
if (!isDigits(s)) return no("characters");
|
|
5993
|
+
if (s.length !== 9) return no("length");
|
|
5994
|
+
const d = digitsOf(s);
|
|
5995
|
+
return weightedSum(d, [3, 7, 3, 7, 3, 7, 3, 7]) % 10 === d[8] ? OK : no("checksum");
|
|
5996
|
+
}
|
|
5997
|
+
function validateRossiyaSnils(value) {
|
|
5998
|
+
const s = stripSeparators(text(value, "validateRossiyaSnils").replace(/ /g, ""));
|
|
5999
|
+
if (!isDigits(s)) return no("characters");
|
|
6000
|
+
if (s.length !== 11) return no("length");
|
|
6001
|
+
const sum = weightedSum(digitsOf(s), [9, 8, 7, 6, 5, 4, 3, 2, 1]);
|
|
6002
|
+
const check = sum < 100 ? sum : sum % 101 === 100 ? 0 : sum % 101;
|
|
6003
|
+
return check === Number(s.slice(9)) ? OK : no("checksum");
|
|
6004
|
+
}
|
|
6005
|
+
var FINNISH_CHECK = "0123456789ABCDEFHJKLMNPRSTUVWXY";
|
|
6006
|
+
function validateSuomiHenkilotunnus(value) {
|
|
6007
|
+
const s = text(value, "validateSuomiHenkilotunnus").replace(/ /g, "");
|
|
6008
|
+
if (!/^[0-9]{6}[+\-A-FU-Y][0-9]{3}[0-9A-Z]$/.test(s))
|
|
6009
|
+
return s.length !== 11 ? no("length") : no("characters");
|
|
6010
|
+
const sign = s[6];
|
|
6011
|
+
const century = sign === "+" ? 1800 : sign >= "A" && sign <= "F" ? 2e3 : 1900;
|
|
6012
|
+
if (!isCalendarDate(
|
|
6013
|
+
century + Number(s.slice(4, 6)),
|
|
6014
|
+
Number(s.slice(2, 4)),
|
|
6015
|
+
Number(s.slice(0, 2))
|
|
6016
|
+
))
|
|
6017
|
+
return no("date");
|
|
6018
|
+
const serial = Number(s.slice(7, 10));
|
|
6019
|
+
if (serial < 2 || serial > 899) return no("structure");
|
|
6020
|
+
const n = Number(s.slice(0, 6) + s.slice(7, 10));
|
|
6021
|
+
return FINNISH_CHECK[n % 31] === s[10] ? OK : no("checksum");
|
|
6022
|
+
}
|
|
6023
|
+
var CF_ODD = {};
|
|
6024
|
+
{
|
|
6025
|
+
const odd = [
|
|
6026
|
+
1,
|
|
6027
|
+
0,
|
|
6028
|
+
5,
|
|
6029
|
+
7,
|
|
6030
|
+
9,
|
|
6031
|
+
13,
|
|
6032
|
+
15,
|
|
6033
|
+
17,
|
|
6034
|
+
19,
|
|
6035
|
+
21,
|
|
6036
|
+
2,
|
|
6037
|
+
4,
|
|
6038
|
+
18,
|
|
6039
|
+
20,
|
|
6040
|
+
11,
|
|
6041
|
+
3,
|
|
6042
|
+
6,
|
|
6043
|
+
8,
|
|
6044
|
+
12,
|
|
6045
|
+
14,
|
|
6046
|
+
16,
|
|
6047
|
+
10,
|
|
6048
|
+
22,
|
|
6049
|
+
25,
|
|
6050
|
+
24,
|
|
6051
|
+
23
|
|
6052
|
+
];
|
|
6053
|
+
for (let i = 0; i < 10; i++) CF_ODD[String(i)] = odd[i];
|
|
6054
|
+
for (let i = 0; i < 26; i++) CF_ODD[String.fromCharCode(65 + i)] = odd[i];
|
|
6055
|
+
}
|
|
6056
|
+
var CF_OMOCODIA = "LMNPQRSTUV";
|
|
6057
|
+
var CF_MONTHS = "ABCDEHLMPRST";
|
|
6058
|
+
function validateItaliaCodiceFiscale(value) {
|
|
6059
|
+
const s = text(value, "validateItaliaCodiceFiscale").replace(/ /g, "");
|
|
6060
|
+
if (!/^[0-9A-Z]+$/.test(s)) return no("characters");
|
|
6061
|
+
if (s.length !== 16) return no("length");
|
|
6062
|
+
if (!/^[A-Z]{6}[0-9LMNPQRSTUV]{2}[A-Z][0-9LMNPQRSTUV]{2}[A-Z][0-9LMNPQRSTUV]{3}[A-Z]$/.test(s))
|
|
6063
|
+
return no("structure");
|
|
6064
|
+
const digit = (c) => CF_OMOCODIA.includes(c) ? CF_OMOCODIA.indexOf(c) : Number(c);
|
|
6065
|
+
const month = CF_MONTHS.indexOf(s[8]) + 1;
|
|
6066
|
+
let day = digit(s[9]) * 10 + digit(s[10]);
|
|
6067
|
+
if (day > 40) day -= 40;
|
|
6068
|
+
if (month < 1 || day < 1 || day > maxDay(month)) return no("date");
|
|
6069
|
+
let sum = 0;
|
|
6070
|
+
for (let i = 0; i < 15; i++) {
|
|
6071
|
+
const c = s[i];
|
|
6072
|
+
sum += i % 2 === 0 ? CF_ODD[c] : /[0-9]/.test(c) ? Number(c) : c.charCodeAt(0) - 65;
|
|
6073
|
+
}
|
|
6074
|
+
return String.fromCharCode(65 + sum % 26) === s[15] ? OK : no("checksum");
|
|
6075
|
+
}
|
|
6076
|
+
function validatePortugalNumeroDeIdentificacaoFiscal(value) {
|
|
6077
|
+
const s = stripSeparators(text(value, "validatePortugalNumeroDeIdentificacaoFiscal"));
|
|
6078
|
+
if (!isDigits(s)) return no("characters");
|
|
6079
|
+
if (s.length !== 9) return no("length");
|
|
6080
|
+
const d = digitsOf(s);
|
|
6081
|
+
const check = 11 - weightedSum(d, [9, 8, 7, 6, 5, 4, 3, 2]) % 11;
|
|
6082
|
+
return (check >= 10 ? 0 : check) === d[8] ? OK : no("checksum");
|
|
6083
|
+
}
|
|
6084
|
+
function validateChileRolUnicoNacional(value) {
|
|
6085
|
+
const s = stripSeparators(text(value, "validateChileRolUnicoNacional"));
|
|
6086
|
+
if (!/^[0-9]*[0-9K]$/.test(s)) return no("characters");
|
|
6087
|
+
if (s.length < 2 || s.length > 9) return no("length");
|
|
6088
|
+
const body = digitsOf(s.slice(0, -1)).reverse();
|
|
6089
|
+
const sum = body.reduce((t, n, i) => t + n * (2 + i % 6), 0);
|
|
6090
|
+
const check = 11 - sum % 11;
|
|
6091
|
+
const expected = check === 11 ? "0" : check === 10 ? "K" : String(check);
|
|
6092
|
+
return expected === s[s.length - 1] ? OK : no("checksum");
|
|
6093
|
+
}
|
|
6094
|
+
function validateUruguayCedulaDeIdentidad(value) {
|
|
6095
|
+
const s = stripSeparators(text(value, "validateUruguayCedulaDeIdentidad"));
|
|
6096
|
+
if (!isDigits(s)) return no("characters");
|
|
6097
|
+
if (s.length !== 7 && s.length !== 8) return no("length");
|
|
6098
|
+
const body = digitsOf(s.slice(0, -1).padStart(7, "0"));
|
|
6099
|
+
const check = (10 - weightedSum(body, [2, 9, 8, 7, 6, 3, 4]) % 10) % 10;
|
|
6100
|
+
return check === Number(s[s.length - 1]) ? OK : no("checksum");
|
|
6101
|
+
}
|
|
6102
|
+
function validateEcuadorCedulaDeIdentidad(value) {
|
|
6103
|
+
const s = stripSeparators(text(value, "validateEcuadorCedulaDeIdentidad"));
|
|
6104
|
+
if (!isDigits(s)) return no("characters");
|
|
6105
|
+
if (s.length !== 10) return no("length");
|
|
6106
|
+
const d = digitsOf(s);
|
|
6107
|
+
const province = Number(s.slice(0, 2));
|
|
6108
|
+
if (!(province >= 1 && province <= 24 || province === 30) || d[2] > 5) return no("structure");
|
|
6109
|
+
const sum = d.slice(0, 9).reduce((t, n, i) => {
|
|
6110
|
+
const product = n * (i % 2 === 0 ? 2 : 1);
|
|
6111
|
+
return t + (product > 9 ? product - 9 : product);
|
|
6112
|
+
}, 0);
|
|
6113
|
+
return (10 - sum % 10) % 10 === d[9] ? OK : no("checksum");
|
|
6114
|
+
}
|
|
6115
|
+
function validateArgentinaCodigoUnicoDeIdentificacionLaboral(value) {
|
|
6116
|
+
const s = stripSeparators(text(value, "validateArgentinaCodigoUnicoDeIdentificacionLaboral"));
|
|
6117
|
+
if (!isDigits(s)) return no("characters");
|
|
6118
|
+
if (s.length !== 11) return no("length");
|
|
6119
|
+
if (!["20", "23", "24", "27", "30", "33", "34"].includes(s.slice(0, 2))) return no("structure");
|
|
6120
|
+
const d = digitsOf(s);
|
|
6121
|
+
const check = 11 - weightedSum(d, [5, 4, 3, 2, 7, 6, 5, 4, 3, 2]) % 11;
|
|
6122
|
+
const expected = check === 11 ? 0 : check;
|
|
6123
|
+
return expected !== 10 && expected === d[10] ? OK : no("checksum");
|
|
6124
|
+
}
|
|
6125
|
+
var CURP_ALPHABET = "0123456789ABCDEFGHIJKLMN\xD1OPQRSTUVWXYZ";
|
|
6126
|
+
function validateMexicoClaveUnicaDeRegistroDePoblacion(value) {
|
|
6127
|
+
const s = text(value, "validateMexicoClaveUnicaDeRegistroDePoblacion");
|
|
6128
|
+
if (!/^[0-9A-ZÑ]+$/.test(s)) return no("characters");
|
|
6129
|
+
if (s.length !== 18) return no("length");
|
|
6130
|
+
if (!/^[A-Z]{4}[0-9]{6}[HMX][A-Z]{5}[0-9A-Z][0-9]$/.test(s)) return no("structure");
|
|
6131
|
+
if (Number(s.slice(6, 8)) < 1 || Number(s.slice(6, 8)) > 12 || Number(s.slice(8, 10)) < 1 || Number(s.slice(8, 10)) > maxDay(Number(s.slice(6, 8))))
|
|
6132
|
+
return no("date");
|
|
6133
|
+
let sum = 0;
|
|
6134
|
+
for (let i = 0; i < 17; i++) sum += CURP_ALPHABET.indexOf(s[i]) * (18 - i);
|
|
6135
|
+
return (10 - sum % 10) % 10 === Number(s[17]) ? OK : no("checksum");
|
|
6136
|
+
}
|
|
6137
|
+
function validateSouthAfricaIdentityNumber(value) {
|
|
6138
|
+
const s = stripSeparators(text(value, "validateSouthAfricaIdentityNumber"));
|
|
6139
|
+
if (!isDigits(s)) return no("characters");
|
|
6140
|
+
if (s.length !== 13) return no("length");
|
|
6141
|
+
const month = Number(s.slice(2, 4));
|
|
6142
|
+
const day = Number(s.slice(4, 6));
|
|
6143
|
+
if (month < 1 || month > 12 || day < 1 || day > maxDay(month)) return no("date");
|
|
6144
|
+
if (s[10] !== "0" && s[10] !== "1") return no("structure");
|
|
6145
|
+
return luhnValid(s) ? OK : no("checksum");
|
|
6146
|
+
}
|
|
6147
|
+
function validateSingaporeNationalRegistrationIdentityCard(value) {
|
|
6148
|
+
const s = stripSeparators(text(value, "validateSingaporeNationalRegistrationIdentityCard"));
|
|
6149
|
+
if (!/^[A-Z0-9]+$/.test(s)) return no("characters");
|
|
6150
|
+
if (s.length !== 9) return no("length");
|
|
6151
|
+
if (!/^[STFG][0-9]{7}[A-Z]$/.test(s)) return no("structure");
|
|
6152
|
+
const sum = weightedSum(digitsOf(s.slice(1, 8)), [2, 7, 6, 5, 4, 3, 2]) + (s[0] === "T" || s[0] === "G" ? 4 : 0);
|
|
6153
|
+
const table = s[0] === "S" || s[0] === "T" ? "JZIHGFEDCBA" : "XWUTRQPNMLK";
|
|
6154
|
+
return table[sum % 11] === s[8] ? OK : no("checksum");
|
|
6155
|
+
}
|
|
6156
|
+
var TAIWAN_LETTERS = "ABCDEFGHJKLMNPQRSTUVXYWZIO";
|
|
6157
|
+
function validateTaiwanGuominShenfenzhengTongyiBianhao(value) {
|
|
6158
|
+
const s = stripSeparators(text(value, "validateTaiwanGuominShenfenzhengTongyiBianhao"));
|
|
6159
|
+
if (!/^[A-Z0-9]+$/.test(s)) return no("characters");
|
|
6160
|
+
if (s.length !== 10) return no("length");
|
|
6161
|
+
if (!/^[A-Z][1289][0-9]{8}$/.test(s)) return no("structure");
|
|
6162
|
+
const code = TAIWAN_LETTERS.indexOf(s[0]) + 10;
|
|
6163
|
+
const d = digitsOf(s.slice(1));
|
|
6164
|
+
const sum = Math.floor(code / 10) + code % 10 * 9 + weightedSum(d, [8, 7, 6, 5, 4, 3, 2, 1]) + d[8];
|
|
6165
|
+
return sum % 10 === 0 ? OK : no("checksum");
|
|
6166
|
+
}
|
|
6167
|
+
function validateNihonKojinBango(value) {
|
|
6168
|
+
const s = stripSeparators(text(value, "validateNihonKojinBango"));
|
|
6169
|
+
if (!isDigits(s)) return no("characters");
|
|
6170
|
+
if (s.length !== 12) return no("length");
|
|
6171
|
+
const body = digitsOf(s.slice(0, 11)).reverse();
|
|
6172
|
+
const sum = body.reduce((t, n, i) => t + n * (i < 6 ? i + 2 : i - 4), 0);
|
|
6173
|
+
const remainder = sum % 11;
|
|
6174
|
+
return (remainder <= 1 ? 0 : 11 - remainder) === Number(s[11]) ? OK : no("checksum");
|
|
6175
|
+
}
|
|
6176
|
+
function validateZhongguoJuminShenfenzhengHaoma(value) {
|
|
6177
|
+
const s = text(value, "validateZhongguoJuminShenfenzhengHaoma");
|
|
6178
|
+
if (!/^[0-9]+[0-9X]$/.test(s)) return no("characters");
|
|
6179
|
+
if (s.length !== 18) return no("length");
|
|
6180
|
+
if (!isCalendarDate(Number(s.slice(6, 10)), Number(s.slice(10, 12)), Number(s.slice(12, 14))))
|
|
6181
|
+
return no("date");
|
|
6182
|
+
const weights = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
|
|
6183
|
+
return "10X98765432"[weightedSum(digitsOf(s.slice(0, 17)), weights) % 11] === s[17] ? OK : no("checksum");
|
|
6184
|
+
}
|
|
6185
|
+
function validateLatvijaPersonasKods(value) {
|
|
6186
|
+
const s = stripSeparators(text(value, "validateLatvijaPersonasKods"));
|
|
6187
|
+
if (!isDigits(s)) return no("characters");
|
|
6188
|
+
if (s.length !== 11) return no("length");
|
|
6189
|
+
if (s.startsWith("32")) return OK;
|
|
6190
|
+
const d = digitsOf(s);
|
|
6191
|
+
if (d[6] > 2) return no("structure");
|
|
6192
|
+
const century = 1800 + d[6] * 100;
|
|
6193
|
+
if (!isCalendarDate(
|
|
6194
|
+
century + Number(s.slice(4, 6)),
|
|
6195
|
+
Number(s.slice(2, 4)),
|
|
6196
|
+
Number(s.slice(0, 2))
|
|
6197
|
+
))
|
|
6198
|
+
return no("date");
|
|
6199
|
+
const check = (1101 - weightedSum(d, [1, 6, 3, 7, 9, 10, 5, 8, 4, 2])) % 11 % 10;
|
|
6200
|
+
return check === d[10] ? OK : no("checksum");
|
|
6201
|
+
}
|
|
6202
|
+
function validateLietuvaAsmensKodas(value) {
|
|
6203
|
+
const s = stripSeparators(text(value, "validateLietuvaAsmensKodas"));
|
|
6204
|
+
if (!isDigits(s)) return no("characters");
|
|
6205
|
+
if (s.length !== 11) return no("length");
|
|
6206
|
+
const d = digitsOf(s);
|
|
6207
|
+
if (d[0] < 1 || d[0] > 6) return no("structure");
|
|
6208
|
+
if (!isCalendarDate(
|
|
6209
|
+
1800 + Math.floor((d[0] - 1) / 2) * 100 + Number(s.slice(1, 3)),
|
|
6210
|
+
Number(s.slice(3, 5)),
|
|
6211
|
+
Number(s.slice(5, 7))
|
|
6212
|
+
))
|
|
6213
|
+
return no("date");
|
|
6214
|
+
let check = weightedSum(d, [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) % 11;
|
|
6215
|
+
if (check === 10) {
|
|
6216
|
+
check = weightedSum(d, [3, 4, 5, 6, 7, 8, 9, 1, 2, 3]) % 11;
|
|
6217
|
+
if (check === 10) check = 0;
|
|
6218
|
+
}
|
|
6219
|
+
return check === d[10] ? OK : no("checksum");
|
|
6220
|
+
}
|
|
6221
|
+
function validateHrvatskaOsobniIdentifikacijskiBroj(value) {
|
|
6222
|
+
const s = stripSeparators(text(value, "validateHrvatskaOsobniIdentifikacijskiBroj"));
|
|
6223
|
+
if (!isDigits(s)) return no("characters");
|
|
6224
|
+
if (s.length !== 11) return no("length");
|
|
6225
|
+
let a = 10;
|
|
6226
|
+
for (const n of digitsOf(s.slice(0, 10))) {
|
|
6227
|
+
a = (a + n) % 10;
|
|
6228
|
+
if (a === 0) a = 10;
|
|
6229
|
+
a = a * 2 % 11;
|
|
6230
|
+
}
|
|
6231
|
+
const check = 11 - a === 10 ? 0 : 11 - a;
|
|
6232
|
+
return check === Number(s[10]) ? OK : no("checksum");
|
|
6233
|
+
}
|
|
6234
|
+
function validateSlovenijaEmso(value) {
|
|
6235
|
+
const s = stripSeparators(text(value, "validateSlovenijaEmso"));
|
|
6236
|
+
if (!isDigits(s)) return no("characters");
|
|
6237
|
+
if (s.length !== 13) return no("length");
|
|
6238
|
+
const d = digitsOf(s);
|
|
6239
|
+
const yyy = Number(s.slice(4, 7));
|
|
6240
|
+
if (!isCalendarDate(
|
|
6241
|
+
yyy < 100 ? 2e3 + yyy : 1e3 + yyy,
|
|
6242
|
+
Number(s.slice(2, 4)),
|
|
6243
|
+
Number(s.slice(0, 2))
|
|
6244
|
+
))
|
|
6245
|
+
return no("date");
|
|
6246
|
+
const check = 11 - weightedSum(d, [7, 6, 5, 4, 3, 2, 7, 6, 5, 4, 3, 2]) % 11;
|
|
6247
|
+
const expected = check === 11 ? 0 : check;
|
|
6248
|
+
return expected !== 10 && expected === d[12] ? OK : no("checksum");
|
|
6249
|
+
}
|
|
6250
|
+
function validateRomaniaCodNumericPersonal(value) {
|
|
6251
|
+
const s = stripSeparators(text(value, "validateRomaniaCodNumericPersonal"));
|
|
6252
|
+
if (!isDigits(s)) return no("characters");
|
|
6253
|
+
if (s.length !== 13) return no("length");
|
|
6254
|
+
const d = digitsOf(s);
|
|
6255
|
+
if (d[0] === 0) return no("structure");
|
|
6256
|
+
const county = Number(s.slice(7, 9));
|
|
6257
|
+
if (!(county >= 1 && county <= 46 || county === 51 || county === 52)) return no("structure");
|
|
6258
|
+
const month = Number(s.slice(3, 5));
|
|
6259
|
+
const day = Number(s.slice(5, 7));
|
|
6260
|
+
const century = [0, 1900, 1900, 1800, 1800, 2e3, 2e3][d[0]];
|
|
6261
|
+
const dateOk = century ? isCalendarDate(century + Number(s.slice(1, 3)), month, day) : month >= 1 && month <= 12 && day >= 1 && day <= maxDay(month);
|
|
6262
|
+
if (!dateOk) return no("date");
|
|
6263
|
+
const remainder = weightedSum(d, [2, 7, 9, 1, 4, 6, 3, 5, 8, 2, 7, 9]) % 11;
|
|
6264
|
+
return (remainder === 10 ? 1 : remainder) === d[12] ? OK : no("checksum");
|
|
6265
|
+
}
|
|
6266
|
+
function validateOsterreichSozialversicherungsnummer(value) {
|
|
6267
|
+
const s = stripSeparators(text(value, "validateOsterreichSozialversicherungsnummer"));
|
|
6268
|
+
if (!isDigits(s)) return no("characters");
|
|
6269
|
+
if (s.length !== 10) return no("length");
|
|
6270
|
+
const d = digitsOf(s);
|
|
6271
|
+
if (d[0] === 0) return no("structure");
|
|
6272
|
+
const day = Number(s.slice(4, 6));
|
|
6273
|
+
const month = Number(s.slice(6, 8));
|
|
6274
|
+
if (month < 1 || month > 12 || day < 1 || day > maxDay(month)) return no("date");
|
|
6275
|
+
const remainder = weightedSum(d, [3, 7, 9, 0, 5, 8, 4, 2, 1, 6]) % 11;
|
|
6276
|
+
return remainder !== 10 && remainder === d[3] ? OK : no("checksum");
|
|
6277
|
+
}
|
|
6278
|
+
function validateIslandKennitala(value) {
|
|
6279
|
+
const s = stripSeparators(text(value, "validateIslandKennitala"));
|
|
6280
|
+
if (!isDigits(s)) return no("characters");
|
|
6281
|
+
if (s.length !== 10) return no("length");
|
|
6282
|
+
const d = digitsOf(s);
|
|
6283
|
+
if (![8, 9, 0].includes(d[9])) return no("structure");
|
|
6284
|
+
let day = Number(s.slice(0, 2));
|
|
6285
|
+
if (day > 40) day -= 40;
|
|
6286
|
+
const year = (d[9] === 8 ? 1800 : d[9] === 9 ? 1900 : 2e3) + Number(s.slice(4, 6));
|
|
6287
|
+
if (!isCalendarDate(year, Number(s.slice(2, 4)), day)) return no("date");
|
|
6288
|
+
const check = 11 - weightedSum(d, [3, 2, 7, 6, 5, 4, 3, 2]) % 11;
|
|
6289
|
+
const expected = check === 11 ? 0 : check;
|
|
6290
|
+
return expected !== 10 && expected === d[8] ? OK : no("checksum");
|
|
6291
|
+
}
|
|
6292
|
+
function validateYisraelTeudatZehut(value) {
|
|
6293
|
+
const s = stripSeparators(text(value, "validateYisraelTeudatZehut"));
|
|
6294
|
+
if (!isDigits(s)) return no("characters");
|
|
6295
|
+
if (s.length !== 9) return no("length");
|
|
6296
|
+
const total = digitsOf(s).reduce((t, n, i) => {
|
|
6297
|
+
const product = n * (i % 2 === 0 ? 1 : 2);
|
|
6298
|
+
return t + (product > 9 ? product - 9 : product);
|
|
6299
|
+
}, 0);
|
|
6300
|
+
return total % 10 === 0 ? OK : no("checksum");
|
|
6301
|
+
}
|
|
6302
|
+
function validateIranKodEMelli(value) {
|
|
6303
|
+
const s = stripSeparators(text(value, "validateIranKodEMelli"));
|
|
6304
|
+
if (!isDigits(s)) return no("characters");
|
|
6305
|
+
if (s.length !== 10) return no("length");
|
|
6306
|
+
if (/^(.)\1{9}$/.test(s)) return no("structure");
|
|
6307
|
+
const d = digitsOf(s);
|
|
6308
|
+
const remainder = weightedSum(d, [10, 9, 8, 7, 6, 5, 4, 3, 2]) % 11;
|
|
6309
|
+
return (remainder < 2 ? remainder : 11 - remainder) === d[9] ? OK : no("checksum");
|
|
6310
|
+
}
|
|
6311
|
+
function validateAlImaratRaqmAlHuwiyah(value) {
|
|
6312
|
+
const s = stripSeparators(text(value, "validateAlImaratRaqmAlHuwiyah"));
|
|
6313
|
+
if (!isDigits(s)) return no("characters");
|
|
6314
|
+
if (s.length !== 15) return no("length");
|
|
6315
|
+
if (!s.startsWith("784")) return no("structure");
|
|
6316
|
+
return luhnValid(s) ? OK : no("checksum");
|
|
6317
|
+
}
|
|
6318
|
+
function validateHongKongIdentityCard(value) {
|
|
6319
|
+
const s = stripSeparators(text(value, "validateHongKongIdentityCard")).replace(/[()]/g, "");
|
|
6320
|
+
if (!/^[A-Z0-9]+$/.test(s)) return no("characters");
|
|
6321
|
+
if (!/^[A-Z]{1,2}[0-9]{6}[0-9A]$/.test(s))
|
|
6322
|
+
return s.length < 8 || s.length > 9 ? no("length") : no("structure");
|
|
6323
|
+
const letters = s.match(/^[A-Z]+/)[0];
|
|
6324
|
+
const values = [
|
|
6325
|
+
letters.length === 1 ? 36 : letters.charCodeAt(0) - 55,
|
|
6326
|
+
letters.charCodeAt(letters.length - 1) - 55,
|
|
6327
|
+
...digitsOf(s.slice(letters.length, letters.length + 6))
|
|
6328
|
+
];
|
|
6329
|
+
const sum = values.reduce((t, n, i) => t + n * (9 - i), 0);
|
|
6330
|
+
const check = 11 - sum % 11;
|
|
6331
|
+
const expected = check === 11 ? "0" : check === 10 ? "A" : String(check);
|
|
6332
|
+
return expected === s[s.length - 1] ? OK : no("checksum");
|
|
6333
|
+
}
|
|
6334
|
+
function validatePrathetThaiLekPrajamTuaPrachachon(value) {
|
|
6335
|
+
const s = stripSeparators(text(value, "validatePrathetThaiLekPrajamTuaPrachachon"));
|
|
6336
|
+
if (!isDigits(s)) return no("characters");
|
|
6337
|
+
if (s.length !== 13) return no("length");
|
|
6338
|
+
const d = digitsOf(s);
|
|
6339
|
+
const sum = d.slice(0, 12).reduce((t, n, i) => t + n * (13 - i), 0);
|
|
6340
|
+
return (11 - sum % 11) % 10 === d[12] ? OK : no("checksum");
|
|
6341
|
+
}
|
|
6342
|
+
function validateAustraliaIndividualHealthcareIdentifier(value) {
|
|
6343
|
+
const s = stripSeparators(text(value, "validateAustraliaIndividualHealthcareIdentifier"));
|
|
6344
|
+
if (!isDigits(s)) return no("characters");
|
|
6345
|
+
if (s.length !== 16) return no("length");
|
|
6346
|
+
if (!s.startsWith("800360")) return no("structure");
|
|
6347
|
+
return luhnValid(s) ? OK : no("checksum");
|
|
6348
|
+
}
|
|
6349
|
+
function validateDeutschlandKrankenversichertennummer(value) {
|
|
6350
|
+
const s = stripSeparators(text(value, "validateDeutschlandKrankenversichertennummer"));
|
|
6351
|
+
if (!/^[A-Z0-9]+$/.test(s)) return no("characters");
|
|
6352
|
+
if (s.length !== 10) return no("length");
|
|
6353
|
+
if (!/^[A-Z][0-9]{9}$/.test(s)) return no("structure");
|
|
6354
|
+
const position = s.charCodeAt(0) - 64;
|
|
6355
|
+
const digits = [Math.floor(position / 10), position % 10, ...digitsOf(s.slice(1, 9))];
|
|
6356
|
+
const sum = digits.reduce((t, n, i) => {
|
|
6357
|
+
const product = n * (i % 2 === 0 ? 1 : 2);
|
|
6358
|
+
return t + Math.floor(product / 10) + product % 10;
|
|
6359
|
+
}, 0);
|
|
6360
|
+
return sum % 10 === Number(s[9]) ? OK : no("checksum");
|
|
6361
|
+
}
|
|
6362
|
+
function validatePolskaNumerIdentyfikacjiPodatkowej(value) {
|
|
6363
|
+
const s = stripSeparators(text(value, "validatePolskaNumerIdentyfikacjiPodatkowej"));
|
|
6364
|
+
if (!isDigits(s)) return no("characters");
|
|
6365
|
+
if (s.length !== 10) return no("length");
|
|
6366
|
+
const d = digitsOf(s);
|
|
6367
|
+
const remainder = weightedSum(d, [6, 5, 7, 2, 3, 4, 5, 6, 7]) % 11;
|
|
6368
|
+
return remainder !== 10 && remainder === d[9] ? OK : no("checksum");
|
|
6369
|
+
}
|
|
6370
|
+
function validateUnitedKingdomNationalInsuranceNumber(value) {
|
|
6371
|
+
const s = stripSeparators(text(value, "validateUnitedKingdomNationalInsuranceNumber"));
|
|
6372
|
+
if (!/^[A-Z0-9]+$/.test(s)) return no("characters");
|
|
6373
|
+
if (s.length !== 9) return no("length");
|
|
6374
|
+
if (!/^[A-CEGHJ-PR-TW-Z][A-CEGHJ-NPR-TW-Z][0-9]{6}[A-D]$/.test(s)) return no("structure");
|
|
6375
|
+
return ["BG", "GB", "KN", "NK", "NT", "TN", "ZZ"].includes(s.slice(0, 2)) ? no("structure") : OK;
|
|
6376
|
+
}
|
|
6377
|
+
function validateUnitedStatesSocialSecurityNumber(value) {
|
|
6378
|
+
const s = stripSeparators(text(value, "validateUnitedStatesSocialSecurityNumber"));
|
|
6379
|
+
if (!isDigits(s)) return no("characters");
|
|
6380
|
+
if (s.length !== 9) return no("length");
|
|
6381
|
+
const area = Number(s.slice(0, 3));
|
|
6382
|
+
if (area === 0 || area === 666 || area >= 900 || s.slice(3, 5) === "00" || s.slice(5) === "0000")
|
|
6383
|
+
return no("structure");
|
|
6384
|
+
return OK;
|
|
6385
|
+
}
|
|
6386
|
+
function validateQazaqstanZhekeSaikestendiruNomiri(value) {
|
|
6387
|
+
const s = stripSeparators(text(value, "validateQazaqstanZhekeSaikestendiruNomiri"));
|
|
6388
|
+
if (!isDigits(s)) return no("characters");
|
|
6389
|
+
if (s.length !== 12) return no("length");
|
|
6390
|
+
const d = digitsOf(s);
|
|
6391
|
+
if (d[6] < 1 || d[6] > 6) return no("structure");
|
|
6392
|
+
const century = 1800 + Math.floor((d[6] - 1) / 2) * 100;
|
|
6393
|
+
if (!isCalendarDate(
|
|
6394
|
+
century + Number(s.slice(0, 2)),
|
|
6395
|
+
Number(s.slice(2, 4)),
|
|
6396
|
+
Number(s.slice(4, 6))
|
|
6397
|
+
))
|
|
6398
|
+
return no("date");
|
|
6399
|
+
let check = weightedSum(d, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) % 11;
|
|
6400
|
+
if (check === 10) check = weightedSum(d, [3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2]) % 11;
|
|
6401
|
+
return check !== 10 && check === d[11] ? OK : no("checksum");
|
|
6402
|
+
}
|
|
6403
|
+
function validateUkrayinaReyestratsiyniyNomerOblikovoyiKartkyPlatnykaPodatkiv(value) {
|
|
6404
|
+
const s = stripSeparators(
|
|
6405
|
+
text(value, "validateUkrayinaReyestratsiyniyNomerOblikovoyiKartkyPlatnykaPodatkiv")
|
|
6406
|
+
);
|
|
6407
|
+
if (!isDigits(s)) return no("characters");
|
|
6408
|
+
if (s.length !== 10) return no("length");
|
|
6409
|
+
const d = digitsOf(s);
|
|
6410
|
+
const sum = weightedSum(d, [-1, 5, 7, 9, 4, 6, 10, 5, 7]);
|
|
6411
|
+
return (sum % 11 + 11) % 11 % 10 === d[9] ? OK : no("checksum");
|
|
6412
|
+
}
|
|
6413
|
+
function validateAsSaudiyahRaqmAlHuwiyahAlWataniyah(value) {
|
|
6414
|
+
const s = stripSeparators(text(value, "validateAsSaudiyahRaqmAlHuwiyahAlWataniyah"));
|
|
6415
|
+
if (!isDigits(s)) return no("characters");
|
|
6416
|
+
if (s.length !== 10) return no("length");
|
|
6417
|
+
if (s[0] !== "1" && s[0] !== "2") return no("structure");
|
|
6418
|
+
return luhnValid(s) ? OK : no("checksum");
|
|
6419
|
+
}
|
|
6420
|
+
function validateEspanaCodigoDeIdentificacionFiscal(value) {
|
|
6421
|
+
const s = stripSeparators(text(value, "validateEspanaCodigoDeIdentificacionFiscal"));
|
|
6422
|
+
if (!/^[A-Z0-9]+$/.test(s)) return no("characters");
|
|
6423
|
+
if (s.length !== 9) return no("length");
|
|
6424
|
+
if (!/^[0-9]{8}[A-Z]$/.test(s)) return no("structure");
|
|
6425
|
+
return "TRWAGMYFPDXBNJZSQVHLCKE"[Number(s.slice(0, 8)) % 23] === s[8] ? OK : no("checksum");
|
|
6426
|
+
}
|
|
6427
|
+
function validateDanmarkPersonnummer(value) {
|
|
6428
|
+
const s = stripSeparators(text(value, "validateDanmarkPersonnummer"));
|
|
6429
|
+
if (!isDigits(s)) return no("characters");
|
|
6430
|
+
if (s.length !== 10) return no("length");
|
|
6431
|
+
const yy = Number(s.slice(4, 6));
|
|
6432
|
+
const d7 = Number(s[6]);
|
|
6433
|
+
const century = d7 <= 3 ? 1900 : d7 === 4 || d7 === 9 ? yy <= 36 ? 2e3 : 1900 : yy <= 57 ? 2e3 : 1800;
|
|
6434
|
+
return isCalendarDate(century + yy, Number(s.slice(2, 4)), Number(s.slice(0, 2))) ? OK : no("date");
|
|
6435
|
+
}
|
|
6436
|
+
function validateMalaysiaKadPengenalan(value) {
|
|
6437
|
+
const s = stripSeparators(text(value, "validateMalaysiaKadPengenalan"));
|
|
6438
|
+
if (!isDigits(s)) return no("characters");
|
|
6439
|
+
if (s.length !== 12) return no("length");
|
|
6440
|
+
const month = Number(s.slice(2, 4));
|
|
6441
|
+
const day = Number(s.slice(4, 6));
|
|
6442
|
+
return month >= 1 && month <= 12 && day >= 1 && day <= maxDay(month) ? OK : no("date");
|
|
6443
|
+
}
|
|
6444
|
+
function validateIndonesiaNomorIndukKependudukan(value) {
|
|
6445
|
+
const s = stripSeparators(text(value, "validateIndonesiaNomorIndukKependudukan"));
|
|
6446
|
+
if (!isDigits(s)) return no("characters");
|
|
6447
|
+
if (s.length !== 16) return no("length");
|
|
6448
|
+
if (s.startsWith("00")) return no("structure");
|
|
6449
|
+
let day = Number(s.slice(6, 8));
|
|
6450
|
+
if (day > 40) day -= 40;
|
|
6451
|
+
const month = Number(s.slice(8, 10));
|
|
6452
|
+
return month >= 1 && month <= 12 && day >= 1 && day <= maxDay(month) ? OK : no("date");
|
|
6453
|
+
}
|
|
6454
|
+
|
|
5723
6455
|
// index.ts
|
|
5724
6456
|
if (!customElements.get("lily-al-imarat-raqm-al-huwiyah-input")) customElements.define("lily-al-imarat-raqm-al-huwiyah-input", AlImaratRaqmAlHuwiyahInput);
|
|
5725
6457
|
if (!customElements.get("lily-al-imarat-raqm-al-huwiyah-view")) customElements.define("lily-al-imarat-raqm-al-huwiyah-view", AlImaratRaqmAlHuwiyahView);
|
|
@@ -6097,5 +6829,64 @@ export {
|
|
|
6097
6829
|
YisraelTeudatZehutInput,
|
|
6098
6830
|
YisraelTeudatZehutView,
|
|
6099
6831
|
ZhongguoJuminShenfenzhengHaomaInput,
|
|
6100
|
-
ZhongguoJuminShenfenzhengHaomaView
|
|
6832
|
+
ZhongguoJuminShenfenzhengHaomaView,
|
|
6833
|
+
isCalendarDate,
|
|
6834
|
+
luhnValid,
|
|
6835
|
+
stripSeparators,
|
|
6836
|
+
validateAlImaratRaqmAlHuwiyah,
|
|
6837
|
+
validateArgentinaCodigoUnicoDeIdentificacionLaboral,
|
|
6838
|
+
validateAsSaudiyahRaqmAlHuwiyahAlWataniyah,
|
|
6839
|
+
validateAustraliaIndividualHealthcareIdentifier,
|
|
6840
|
+
validateAustraliaTaxFileNumber,
|
|
6841
|
+
validateBelgiqueRegistreNational,
|
|
6842
|
+
validateBharatAadhaar,
|
|
6843
|
+
validateBulgariaEdinenGrazhdanskiNomer,
|
|
6844
|
+
validateCanadaSocialInsuranceNumber,
|
|
6845
|
+
validateChileRolUnicoNacional,
|
|
6846
|
+
validateDanmarkPersonnummer,
|
|
6847
|
+
validateDeutschlandKrankenversichertennummer,
|
|
6848
|
+
validateEcuadorCedulaDeIdentidad,
|
|
6849
|
+
validateEestiIsikukood,
|
|
6850
|
+
validateEspanaCodigoDeIdentificacionFiscal,
|
|
6851
|
+
validateFranceNir,
|
|
6852
|
+
validateHongKongIdentityCard,
|
|
6853
|
+
validateHrvatskaOsobniIdentifikacijskiBroj,
|
|
6854
|
+
validateIndonesiaNomorIndukKependudukan,
|
|
6855
|
+
validateIranKodEMelli,
|
|
6856
|
+
validateIslandKennitala,
|
|
6857
|
+
validateItaliaCodiceFiscale,
|
|
6858
|
+
validateLatvijaPersonasKods,
|
|
6859
|
+
validateLietuvaAsmensKodas,
|
|
6860
|
+
validateMagyarorszagTajSzam,
|
|
6861
|
+
validateMalaysiaKadPengenalan,
|
|
6862
|
+
validateMexicoClaveUnicaDeRegistroDePoblacion,
|
|
6863
|
+
validateNederlandBurgerservicenummer,
|
|
6864
|
+
validateNhsNumber,
|
|
6865
|
+
validateNihonKojinBango,
|
|
6866
|
+
validateNorgeFodselsnummer,
|
|
6867
|
+
validateOsterreichSozialversicherungsnummer,
|
|
6868
|
+
validatePolskaNumerIdentyfikacjiPodatkowej,
|
|
6869
|
+
validatePolskaPesel,
|
|
6870
|
+
validatePortugalNumeroDeIdentificacaoFiscal,
|
|
6871
|
+
validatePrathetThaiLekPrajamTuaPrachachon,
|
|
6872
|
+
validateQazaqstanZhekeSaikestendiruNomiri,
|
|
6873
|
+
validateRodneCislo,
|
|
6874
|
+
validateRomaniaCodNumericPersonal,
|
|
6875
|
+
validateRossiyaSnils,
|
|
6876
|
+
validateSchweizAhvNummer,
|
|
6877
|
+
validateSingaporeNationalRegistrationIdentityCard,
|
|
6878
|
+
validateSlovenijaEmso,
|
|
6879
|
+
validateSouthAfricaIdentityNumber,
|
|
6880
|
+
validateSuomiHenkilotunnus,
|
|
6881
|
+
validateSverigePersonnummer,
|
|
6882
|
+
validateTaiwanGuominShenfenzhengTongyiBianhao,
|
|
6883
|
+
validateTurkiyeTcKimlikNumarasi,
|
|
6884
|
+
validateUkrayinaReyestratsiyniyNomerOblikovoyiKartkyPlatnykaPodatkiv,
|
|
6885
|
+
validateUnitedKingdomNationalInsuranceNumber,
|
|
6886
|
+
validateUnitedStatesSocialSecurityNumber,
|
|
6887
|
+
validateUruguayCedulaDeIdentidad,
|
|
6888
|
+
validateYisraelTeudatZehut,
|
|
6889
|
+
validateZhongguoJuminShenfenzhengHaoma,
|
|
6890
|
+
verhoeffValid,
|
|
6891
|
+
weightedSum
|
|
6101
6892
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lilydesignsystem/web-components-headless-identifiers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=26"
|
|
6
6
|
},
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"healthcare"
|
|
62
62
|
],
|
|
63
63
|
"author": "Joel Parker Henderson <joel@joelparkerhenderson.com>",
|
|
64
|
-
"license": "MIT OR Apache-2.0 OR GPL-2.0-only OR GPL-3.0-only OR BSD-3-Clause",
|
|
64
|
+
"license": "MIT OR Apache-2.0 OR GPL-2.0-only OR GPL-3.0-only OR BSD-3-Clause OR OGL-UK-3.0 OR CC-BY-NC-SA-4.0",
|
|
65
65
|
"repository": {
|
|
66
66
|
"type": "git",
|
|
67
67
|
"url": "git+https://github.com/LilyDesignSystem/lily-design-system.git",
|