saudi-utils 0.1.0 → 0.2.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.
@@ -0,0 +1,81 @@
1
+ import { normalizeShortAddressInput } from "./address.js";
2
+ import { normalizeIbanInput } from "./banking.js";
3
+ import { validateLandlineNumberDetailed, validateMobileNumberDetailed, validateSaudiIbanDetailed, validateShortAddressDetailed, validateTollFreeNumberDetailed, } from "./detailed.js";
4
+ import { normalizePhoneNumberInput } from "./telecom.js";
5
+ function unsupportedInput(value, label) {
6
+ let code;
7
+ let reason;
8
+ if (value === undefined || value === null || value === "") {
9
+ code = "REQUIRED";
10
+ reason = "is required.";
11
+ }
12
+ else if (typeof value !== "string") {
13
+ code = "INVALID_TYPE";
14
+ reason = "has an invalid type.";
15
+ }
16
+ else {
17
+ code = "INVALID_FORMAT";
18
+ reason = "uses an unsupported representation.";
19
+ }
20
+ return { valid: false, code, message: `${label} ${reason}` };
21
+ }
22
+ function withCandidate(result, candidate) {
23
+ if (result.valid) {
24
+ return result;
25
+ }
26
+ return candidate.length > 0 && candidate.length <= 64
27
+ ? { ...result, normalizedValue: candidate }
28
+ : result;
29
+ }
30
+ /**
31
+ * Normalizes and validates a Saudi IBAN using the same rules as normalizeIban and validateSaudiIbanDetailed.
32
+ * @param value - Primitive string; ASCII spaces are removed and ASCII letters are uppercased.
33
+ * @returns The validated uppercase IBAN, or a code and message. A safe candidate is included on validation failure.
34
+ * @example
35
+ * normalizeAndValidateIban("sa03 8000 0000 6080 1016 7519"); // { valid: true, value: "SA0380000000608010167519" }
36
+ */
37
+ export function normalizeAndValidateIban(value) {
38
+ const candidate = normalizeIbanInput(value);
39
+ return candidate === null
40
+ ? unsupportedInput(value, "Saudi IBAN")
41
+ : withCandidate(validateSaudiIbanDetailed(candidate), candidate);
42
+ }
43
+ /**
44
+ * Normalizes and validates a Saudi Short Address using the same rules as normalizeShortAddress and validateShortAddressDetailed.
45
+ * @param value - Primitive string with four ASCII letters, optional one ASCII space, then ASCII digits.
46
+ * @returns The validated uppercase eight-character address, or a code and message with a safe candidate when available.
47
+ */
48
+ export function normalizeAndValidateShortAddress(value) {
49
+ const candidate = normalizeShortAddressInput(value);
50
+ return candidate === null
51
+ ? unsupportedInput(value, "Short Address")
52
+ : withCandidate(validateShortAddressDetailed(candidate), candidate);
53
+ }
54
+ /**
55
+ * Normalizes and validates a Saudi mobile, landline, or toll-free number.
56
+ * @param value - Primitive string in a supported unseparated national or country-code form.
57
+ * @returns A kind-tagged canonical phone value, or a code and message with a safe candidate when available.
58
+ * Mobile and landline values use +966 form; toll-free values use national 800 form.
59
+ */
60
+ export function normalizeAndValidatePhoneNumber(value) {
61
+ const candidate = normalizePhoneNumberInput(value);
62
+ if (candidate === null) {
63
+ return unsupportedInput(value, "Phone number");
64
+ }
65
+ if (candidate.startsWith("800")) {
66
+ const result = validateTollFreeNumberDetailed(candidate);
67
+ return result.valid
68
+ ? { valid: true, value: { kind: "toll-free", value: `800${result.value.slice(3)}` } }
69
+ : withCandidate(result, candidate);
70
+ }
71
+ const result = candidate.startsWith("+9661")
72
+ ? validateLandlineNumberDetailed(candidate)
73
+ : validateMobileNumberDetailed(candidate);
74
+ if (!result.valid) {
75
+ return withCandidate(result, candidate);
76
+ }
77
+ return candidate.startsWith("+9661")
78
+ ? { valid: true, value: { kind: "landline", value: `+966${result.value.slice(4)}` } }
79
+ : { valid: true, value: { kind: "mobile", value: `+966${result.value.slice(4)}` } };
80
+ }
81
+ //# sourceMappingURL=combined.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"combined.js","sourceRoot":"","sources":["../src/combined.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EACL,8BAA8B,EAC9B,4BAA4B,EAC5B,yBAAyB,EACzB,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,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AAC,OAAO,CAAC;QAClC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE;QACrF,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC;AACxF,CAAC"}
@@ -0,0 +1,104 @@
1
+ import type { DetailedValidationResult, NationalAddress } from "./types.js";
2
+ /**
3
+ * Validates a national ID and explains the first failure without changing the canonical input.
4
+ * @param value - Input to check; only the documented canonical representation is accepted.
5
+ * @returns The unchanged validated value, or a code and message for the first failure.
6
+ */
7
+ export declare function validateNationalIdDetailed(value: unknown): DetailedValidationResult<string>;
8
+ /**
9
+ * Validates an Iqama and explains the first failure without changing the canonical input.
10
+ * @param value - Input to check; only the documented canonical representation is accepted.
11
+ * @returns The unchanged validated value, or a code and message for the first failure.
12
+ */
13
+ export declare function validateIqamaDetailed(value: unknown): DetailedValidationResult<string>;
14
+ /**
15
+ * Validates a Saudi person ID and explains the first failure without changing the canonical input.
16
+ * @param value - Input to check; only the documented canonical representation is accepted.
17
+ * @returns The unchanged validated value, or a code and message for the first failure.
18
+ */
19
+ export declare function validateSaudiIdDetailed(value: unknown): DetailedValidationResult<string>;
20
+ /**
21
+ * Validates a Border ID and explains the first failure without changing the canonical input.
22
+ * @param value - Input to check; only the documented canonical representation is accepted.
23
+ * @returns The unchanged validated value, or a code and message for the first failure.
24
+ */
25
+ export declare function validateBorderIdDetailed(value: unknown): DetailedValidationResult<string>;
26
+ /**
27
+ * Validates a Saudi IBAN and explains the first failure without changing the canonical input.
28
+ * @param value - Input to check; only the documented canonical representation is accepted.
29
+ * @returns The unchanged validated value, or a code and message for the first failure.
30
+ */
31
+ export declare function validateSaudiIbanDetailed(value: unknown): DetailedValidationResult<string>;
32
+ /**
33
+ * Validates a VAT number and explains the first failure without changing the canonical input.
34
+ * @param value - Input to check; only the documented canonical representation is accepted.
35
+ * @returns The unchanged validated value, or a code and message for the first failure.
36
+ */
37
+ export declare function validateVatNumberDetailed(value: unknown): DetailedValidationResult<string>;
38
+ /**
39
+ * Validates a TIN and explains the first failure without changing the canonical input.
40
+ * @param value - Input to check; only the documented canonical representation is accepted.
41
+ * @returns The unchanged validated value, or a code and message for the first failure.
42
+ */
43
+ export declare function validateTinDetailed(value: unknown): DetailedValidationResult<string>;
44
+ /**
45
+ * Validates a Unified National Number and explains the first failure without changing the canonical input.
46
+ * @param value - Input to check; only the documented canonical representation is accepted.
47
+ * @returns The unchanged validated value, or a code and message for the first failure.
48
+ */
49
+ export declare function validateUnifiedNationalNumberDetailed(value: unknown): DetailedValidationResult<string>;
50
+ /**
51
+ * Validates a legacy Commercial Registration number and explains the first failure without changing the canonical input.
52
+ * @param value - Input to check; only the documented canonical representation is accepted.
53
+ * @returns The unchanged validated value, or a code and message for the first failure.
54
+ */
55
+ export declare function validateCommercialRegistrationDetailed(value: unknown): DetailedValidationResult<string>;
56
+ /**
57
+ * Validates a mobile number and explains the first failure without changing the canonical input.
58
+ * @param value - Input to check; only the documented canonical representation is accepted.
59
+ * @returns The unchanged validated value, or a code and message for the first failure.
60
+ */
61
+ export declare function validateMobileNumberDetailed(value: unknown): DetailedValidationResult<string>;
62
+ /**
63
+ * Validates a landline number and explains the first failure without changing the canonical input.
64
+ * @param value - Input to check; only the documented canonical representation is accepted.
65
+ * @returns The unchanged validated value, or a code and message for the first failure.
66
+ */
67
+ export declare function validateLandlineNumberDetailed(value: unknown): DetailedValidationResult<string>;
68
+ /**
69
+ * Validates a toll-free number and explains the first failure without changing the canonical input.
70
+ * @param value - Input to check; only the documented canonical representation is accepted.
71
+ * @returns The unchanged validated value, or a code and message for the first failure.
72
+ */
73
+ export declare function validateTollFreeNumberDetailed(value: unknown): DetailedValidationResult<string>;
74
+ /**
75
+ * Validates a postal code and explains the first failure without changing the canonical input.
76
+ * @param value - Input to check; only the documented canonical representation is accepted.
77
+ * @returns The unchanged validated value, or a code and message for the first failure.
78
+ */
79
+ export declare function validatePostalCodeDetailed(value: unknown): DetailedValidationResult<string>;
80
+ /**
81
+ * Validates a building number and explains the first failure without changing the canonical input.
82
+ * @param value - Input to check; only the documented canonical representation is accepted.
83
+ * @returns The unchanged validated value, or a code and message for the first failure.
84
+ */
85
+ export declare function validateBuildingNumberDetailed(value: unknown): DetailedValidationResult<string>;
86
+ /**
87
+ * Validates an additional number and explains the first failure without changing the canonical input.
88
+ * @param value - Input to check; only the documented canonical representation is accepted.
89
+ * @returns The unchanged validated value, or a code and message for the first failure.
90
+ */
91
+ export declare function validateAdditionalNumberDetailed(value: unknown): DetailedValidationResult<string>;
92
+ /**
93
+ * Validates a Short Address and explains the first failure without changing the canonical input.
94
+ * @param value - Input to check; only the documented canonical representation is accepted.
95
+ * @returns The unchanged validated value, or a code and message for the first failure.
96
+ */
97
+ export declare function validateShortAddressDetailed(value: unknown): DetailedValidationResult<string>;
98
+ /**
99
+ * Validates a National Address and explains the first failure without changing the canonical input.
100
+ * @param value - Input to check; only the documented canonical representation is accepted.
101
+ * @returns The unchanged validated value, or a code and message for the first failure.
102
+ */
103
+ export declare function validateNationalAddressDetailed(value: unknown): DetailedValidationResult<NationalAddress>;
104
+ //# sourceMappingURL=detailed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detailed.d.ts","sourceRoot":"","sources":["../src/detailed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,eAAe,EAAuB,MAAM,YAAY,CAAC;AA0CjG;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,wBAAwB,CAAC,MAAM,CAAC,CAE3F;AAED;;;;GAIG;AACH,wBAAgB,qBAA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B,CAAC,MAAM,CAAC,CAE/F;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,OAAO,GAAG,wBAAwB,CAAC,MAAM,CAAC,CAEjG;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,wBAAwB,CAAC,MAAM,CAAC,CAE7F;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,OAAO,GACb,wBAAwB,CAAC,eAAe,CAAC,CAE3C"}
@@ -0,0 +1,156 @@
1
+ import { validateNationalId, validateIqama, validateSaudiId, validateBorderId, } from "./identity.js";
2
+ import { validateSaudiIban } from "./banking.js";
3
+ import { validateVatNumber, validateTin, validateUnifiedNationalNumber, validateCommercialRegistration, } from "./business.js";
4
+ import { validateMobileNumber, validateLandlineNumber, validateTollFreeNumber } from "./telecom.js";
5
+ import { validatePostalCode, validateBuildingNumber, validateAdditionalNumber, validateShortAddress, validateNationalAddress, } from "./address.js";
6
+ const REASONS = {
7
+ REQUIRED: "is required.",
8
+ INVALID_TYPE: "has an invalid type.",
9
+ INVALID_LENGTH: "has an invalid length.",
10
+ INVALID_FORMAT: "has an invalid format.",
11
+ INVALID_PREFIX: "has an invalid prefix.",
12
+ INVALID_CHECKSUM: "has an invalid checksum.",
13
+ };
14
+ function explain(result, label) {
15
+ if (result.valid) {
16
+ return { valid: true, value: result.value };
17
+ }
18
+ return { valid: false, code: result.code, message: `${label} ${REASONS[result.code]}` };
19
+ }
20
+ /**
21
+ * Validates a national ID and explains the first failure without changing the canonical input.
22
+ * @param value - Input to check; only the documented canonical representation is accepted.
23
+ * @returns The unchanged validated value, or a code and message for the first failure.
24
+ */
25
+ export function validateNationalIdDetailed(value) {
26
+ return explain(validateNationalId(value), "National ID");
27
+ }
28
+ /**
29
+ * Validates an Iqama and explains the first failure without changing the canonical input.
30
+ * @param value - Input to check; only the documented canonical representation is accepted.
31
+ * @returns The unchanged validated value, or a code and message for the first failure.
32
+ */
33
+ export function validateIqamaDetailed(value) {
34
+ return explain(validateIqama(value), "Iqama");
35
+ }
36
+ /**
37
+ * Validates a Saudi person ID and explains the first failure without changing the canonical input.
38
+ * @param value - Input to check; only the documented canonical representation is accepted.
39
+ * @returns The unchanged validated value, or a code and message for the first failure.
40
+ */
41
+ export function validateSaudiIdDetailed(value) {
42
+ return explain(validateSaudiId(value), "Saudi person ID");
43
+ }
44
+ /**
45
+ * Validates a Border ID and explains the first failure without changing the canonical input.
46
+ * @param value - Input to check; only the documented canonical representation is accepted.
47
+ * @returns The unchanged validated value, or a code and message for the first failure.
48
+ */
49
+ export function validateBorderIdDetailed(value) {
50
+ return explain(validateBorderId(value), "Border ID");
51
+ }
52
+ /**
53
+ * Validates a Saudi IBAN and explains the first failure without changing the canonical input.
54
+ * @param value - Input to check; only the documented canonical representation is accepted.
55
+ * @returns The unchanged validated value, or a code and message for the first failure.
56
+ */
57
+ export function validateSaudiIbanDetailed(value) {
58
+ return explain(validateSaudiIban(value), "Saudi IBAN");
59
+ }
60
+ /**
61
+ * Validates a VAT number and explains the first failure without changing the canonical input.
62
+ * @param value - Input to check; only the documented canonical representation is accepted.
63
+ * @returns The unchanged validated value, or a code and message for the first failure.
64
+ */
65
+ export function validateVatNumberDetailed(value) {
66
+ return explain(validateVatNumber(value), "VAT number");
67
+ }
68
+ /**
69
+ * Validates a TIN and explains the first failure without changing the canonical input.
70
+ * @param value - Input to check; only the documented canonical representation is accepted.
71
+ * @returns The unchanged validated value, or a code and message for the first failure.
72
+ */
73
+ export function validateTinDetailed(value) {
74
+ return explain(validateTin(value), "TIN");
75
+ }
76
+ /**
77
+ * Validates a Unified National Number and explains the first failure without changing the canonical input.
78
+ * @param value - Input to check; only the documented canonical representation is accepted.
79
+ * @returns The unchanged validated value, or a code and message for the first failure.
80
+ */
81
+ export function validateUnifiedNationalNumberDetailed(value) {
82
+ return explain(validateUnifiedNationalNumber(value), "Unified National Number");
83
+ }
84
+ /**
85
+ * Validates a legacy Commercial Registration number and explains the first failure without changing the canonical input.
86
+ * @param value - Input to check; only the documented canonical representation is accepted.
87
+ * @returns The unchanged validated value, or a code and message for the first failure.
88
+ */
89
+ export function validateCommercialRegistrationDetailed(value) {
90
+ return explain(validateCommercialRegistration(value), "Legacy Commercial Registration number");
91
+ }
92
+ /**
93
+ * Validates a mobile number and explains the first failure without changing the canonical input.
94
+ * @param value - Input to check; only the documented canonical representation is accepted.
95
+ * @returns The unchanged validated value, or a code and message for the first failure.
96
+ */
97
+ export function validateMobileNumberDetailed(value) {
98
+ return explain(validateMobileNumber(value), "Mobile number");
99
+ }
100
+ /**
101
+ * Validates a landline number and explains the first failure without changing the canonical input.
102
+ * @param value - Input to check; only the documented canonical representation is accepted.
103
+ * @returns The unchanged validated value, or a code and message for the first failure.
104
+ */
105
+ export function validateLandlineNumberDetailed(value) {
106
+ return explain(validateLandlineNumber(value), "Landline number");
107
+ }
108
+ /**
109
+ * Validates a toll-free number and explains the first failure without changing the canonical input.
110
+ * @param value - Input to check; only the documented canonical representation is accepted.
111
+ * @returns The unchanged validated value, or a code and message for the first failure.
112
+ */
113
+ export function validateTollFreeNumberDetailed(value) {
114
+ return explain(validateTollFreeNumber(value), "Toll-free number");
115
+ }
116
+ /**
117
+ * Validates a postal code and explains the first failure without changing the canonical input.
118
+ * @param value - Input to check; only the documented canonical representation is accepted.
119
+ * @returns The unchanged validated value, or a code and message for the first failure.
120
+ */
121
+ export function validatePostalCodeDetailed(value) {
122
+ return explain(validatePostalCode(value), "Postal code");
123
+ }
124
+ /**
125
+ * Validates a building number and explains the first failure without changing the canonical input.
126
+ * @param value - Input to check; only the documented canonical representation is accepted.
127
+ * @returns The unchanged validated value, or a code and message for the first failure.
128
+ */
129
+ export function validateBuildingNumberDetailed(value) {
130
+ return explain(validateBuildingNumber(value), "Building number");
131
+ }
132
+ /**
133
+ * Validates an additional number and explains the first failure without changing the canonical input.
134
+ * @param value - Input to check; only the documented canonical representation is accepted.
135
+ * @returns The unchanged validated value, or a code and message for the first failure.
136
+ */
137
+ export function validateAdditionalNumberDetailed(value) {
138
+ return explain(validateAdditionalNumber(value), "Additional number");
139
+ }
140
+ /**
141
+ * Validates a Short Address and explains the first failure without changing the canonical input.
142
+ * @param value - Input to check; only the documented canonical representation is accepted.
143
+ * @returns The unchanged validated value, or a code and message for the first failure.
144
+ */
145
+ export function validateShortAddressDetailed(value) {
146
+ return explain(validateShortAddress(value), "Short Address");
147
+ }
148
+ /**
149
+ * Validates a National Address and explains the first failure without changing the canonical input.
150
+ * @param value - Input to check; only the documented canonical representation is accepted.
151
+ * @returns The unchanged validated value, or a code and message for the first failure.
152
+ */
153
+ export function validateNationalAddressDetailed(value) {
154
+ return explain(validateNationalAddress(value), "National Address");
155
+ }
156
+ //# sourceMappingURL=detailed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detailed.js","sourceRoot":"","sources":["../src/detailed.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,6BAA6B,EAC7B,8BAA8B,GAC/B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACpG,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AAEtB,MAAM,OAAO,GAAwC;IACnD,QAAQ,EAAE,cAAc;IACxB,YAAY,EAAE,sBAAsB;IACpC,cAAc,EAAE,wBAAwB;IACxC,cAAc,EAAE,wBAAwB;IACxC,cAAc,EAAE,wBAAwB;IACxC,gBAAgB,EAAE,0BAA0B;CAC7C,CAAC;AAEF,SAAS,OAAO,CACd,MAA+E,EAC/E,KAAa;I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D,OAAO,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC,CAAC;AAC/D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,+BAA+B,CAC7C,KAAc;IAEd,OAAO,OAAO,CAAC,uBAAuB,CAAC,KAAK,CAAC,EAAE,kBAAkB,CAAC,CAAC;AACrE,CAAC"}
@@ -1,11 +1,73 @@
1
1
  import type { ValidationResult } from "./types.js";
2
+ /**
3
+ * Validates a Saudi national ID: 10 ASCII digits starting with 1 and a valid check digit.
4
+ *
5
+ * Does not establish issuance, holder identity, or current status.
6
+ *
7
+ * @param value - Unknown input; only a primitive string in the stated canonical format is accepted.
8
+ * @returns A result containing the unchanged string when valid, or the first applicable error code.
9
+ */
2
10
  export declare function validateNationalId(value: unknown): ValidationResult;
11
+ /**
12
+ * Checks a Saudi national ID using the same structural and checksum rules as validateNationalId.
13
+ *
14
+ * @param value - Unknown input; only a primitive string in the stated canonical format is accepted.
15
+ * @returns True when the input satisfies the stated offline rules; false otherwise.
16
+ */
3
17
  export declare function isNationalId(value: unknown): boolean;
18
+ /**
19
+ * Validates an Iqama: 10 ASCII digits starting with 2 and a valid check digit.
20
+ *
21
+ * Does not establish issuance, residency, or current status.
22
+ *
23
+ * @param value - Unknown input; only a primitive string in the stated canonical format is accepted.
24
+ * @returns A result containing the unchanged string when valid, or the first applicable error code.
25
+ */
4
26
  export declare function validateIqama(value: unknown): ValidationResult;
27
+ /**
28
+ * Checks an Iqama using the same structural and checksum rules as validateIqama.
29
+ *
30
+ * @param value - Unknown input; only a primitive string in the stated canonical format is accepted.
31
+ * @returns True when the input satisfies the stated offline rules; false otherwise.
32
+ */
5
33
  export declare function isIqama(value: unknown): boolean;
34
+ /**
35
+ * Validates either a Saudi national ID or Iqama, including its check digit.
36
+ *
37
+ * Accepts only 10 ASCII digits starting with 1 or 2.
38
+ *
39
+ * @param value - Unknown input; only a primitive string in the stated canonical format is accepted.
40
+ * @returns A result containing the unchanged string when valid, or the first applicable error code.
41
+ */
6
42
  export declare function validateSaudiId(value: unknown): ValidationResult;
43
+ /**
44
+ * Checks whether a value is a valid national ID or Iqama.
45
+ *
46
+ * @param value - Unknown input; only a primitive string in the stated canonical format is accepted.
47
+ * @returns True when the input satisfies the stated offline rules; false otherwise.
48
+ */
7
49
  export declare function isSaudiId(value: unknown): boolean;
50
+ /**
51
+ * Identifies a valid Saudi national ID or Iqama.
52
+ *
53
+ * @param value - Unknown input; only a primitive string in the stated canonical format is accepted.
54
+ * @returns "national-id" or "iqama" for a valid value; null otherwise.
55
+ */
8
56
  export declare function getSaudiIdType(value: unknown): "national-id" | "iqama" | null;
57
+ /**
58
+ * Checks the provisional Border ID structure: 10 ASCII digits starting with 3 or 4.
59
+ *
60
+ * No checksum, issuance, or status is verified.
61
+ *
62
+ * @param value - Unknown input; only a primitive string in the stated canonical format is accepted.
63
+ * @returns A result containing the unchanged string when valid, or the first applicable error code.
64
+ */
9
65
  export declare function validateBorderId(value: unknown): ValidationResult;
66
+ /**
67
+ * Checks the provisional Border ID structure without claiming issuance or status.
68
+ *
69
+ * @param value - Unknown input; only a primitive string in the stated canonical format is accepted.
70
+ * @returns True when the input satisfies the stated offline rules; false otherwise.
71
+ */
10
72
  export declare function isBorderId(value: unknown): boolean;
11
73
  //# sourceMappingURL=identity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAwBnE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEpD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAwB9D;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE/C;AAED,wBAAgB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HANGED
@@ -1,6 +1,14 @@
1
1
  import { isAsciiDigits } from "./internal/ascii.js";
2
2
  import { hasValidSaudiIdentityChecksum } from "./internal/identity-checksum.js";
3
3
  import { checkStringInput } from "./internal/input.js";
4
+ /**
5
+ * Validates a Saudi national ID: 10 ASCII digits starting with 1 and a valid check digit.
6
+ *
7
+ * Does not establish issuance, holder identity, or current status.
8
+ *
9
+ * @param value - Unknown input; only a primitive string in the stated canonical format is accepted.
10
+ * @returns A result containing the unchanged string when valid, or the first applicable error code.
11
+ */
4
12
  export function validateNationalId(value) {
5
13
  const input = checkStringInput(value);
6
14
  if (!input.valid) {
@@ -20,9 +28,23 @@ export function validateNationalId(value) {
20
28
  }
21
29
  return { valid: true, value: input.value };
22
30
  }
31
+ /**
32
+ * Checks a Saudi national ID using the same structural and checksum rules as validateNationalId.
33
+ *
34
+ * @param value - Unknown input; only a primitive string in the stated canonical format is accepted.
35
+ * @returns True when the input satisfies the stated offline rules; false otherwise.
36
+ */
23
37
  export function isNationalId(value) {
24
38
  return validateNationalId(value).valid;
25
39
  }
40
+ /**
41
+ * Validates an Iqama: 10 ASCII digits starting with 2 and a valid check digit.
42
+ *
43
+ * Does not establish issuance, residency, or current status.
44
+ *
45
+ * @param value - Unknown input; only a primitive string in the stated canonical format is accepted.
46
+ * @returns A result containing the unchanged string when valid, or the first applicable error code.
47
+ */
26
48
  export function validateIqama(value) {
27
49
  const input = checkStringInput(value);
28
50
  if (!input.valid) {
@@ -42,9 +64,23 @@ export function validateIqama(value) {
42
64
  }
43
65
  return { valid: true, value: input.value };
44
66
  }
67
+ /**
68
+ * Checks an Iqama using the same structural and checksum rules as validateIqama.
69
+ *
70
+ * @param value - Unknown input; only a primitive string in the stated canonical format is accepted.
71
+ * @returns True when the input satisfies the stated offline rules; false otherwise.
72
+ */
45
73
  export function isIqama(value) {
46
74
  return validateIqama(value).valid;
47
75
  }
76
+ /**
77
+ * Validates either a Saudi national ID or Iqama, including its check digit.
78
+ *
79
+ * Accepts only 10 ASCII digits starting with 1 or 2.
80
+ *
81
+ * @param value - Unknown input; only a primitive string in the stated canonical format is accepted.
82
+ * @returns A result containing the unchanged string when valid, or the first applicable error code.
83
+ */
48
84
  export function validateSaudiId(value) {
49
85
  const nationalId = validateNationalId(value);
50
86
  if (nationalId.valid || nationalId.code !== "INVALID_PREFIX") {
@@ -52,9 +88,21 @@ export function validateSaudiId(value) {
52
88
  }
53
89
  return validateIqama(value);
54
90
  }
91
+ /**
92
+ * Checks whether a value is a valid national ID or Iqama.
93
+ *
94
+ * @param value - Unknown input; only a primitive string in the stated canonical format is accepted.
95
+ * @returns True when the input satisfies the stated offline rules; false otherwise.
96
+ */
55
97
  export function isSaudiId(value) {
56
98
  return validateSaudiId(value).valid;
57
99
  }
100
+ /**
101
+ * Identifies a valid Saudi national ID or Iqama.
102
+ *
103
+ * @param value - Unknown input; only a primitive string in the stated canonical format is accepted.
104
+ * @returns "national-id" or "iqama" for a valid value; null otherwise.
105
+ */
58
106
  export function getSaudiIdType(value) {
59
107
  const result = validateSaudiId(value);
60
108
  if (!result.valid) {
@@ -62,6 +110,14 @@ export function getSaudiIdType(value) {
62
110
  }
63
111
  return result.value.startsWith("1") ? "national-id" : "iqama";
64
112
  }
113
+ /**
114
+ * Checks the provisional Border ID structure: 10 ASCII digits starting with 3 or 4.
115
+ *
116
+ * No checksum, issuance, or status is verified.
117
+ *
118
+ * @param value - Unknown input; only a primitive string in the stated canonical format is accepted.
119
+ * @returns A result containing the unchanged string when valid, or the first applicable error code.
120
+ */
65
121
  export function validateBorderId(value) {
66
122
  const input = checkStringInput(value);
67
123
  if (!input.valid) {
@@ -78,6 +134,12 @@ export function validateBorderId(value) {
78
134
  }
79
135
  return { valid: true, value: input.value };
80
136
  }
137
+ /**
138
+ * Checks the provisional Border ID structure without claiming issuance or status.
139
+ *
140
+ * @param value - Unknown input; only a primitive string in the stated canonical format is accepted.
141
+ * @returns True when the input satisfies the stated offline rules; false otherwise.
142
+ */
81
143
  export function isBorderId(value) {
82
144
  return validateBorderId(value).valid;
83
145
  }
@@ -1 +1 @@
1
- {"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAEtC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAC9B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;IAClD,CAAC;IAED,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;IAClD,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACjC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;IAClD,CAAC;IAED,IAAI,CAAC,6BAA6B,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QAChD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC;IACpD,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,kBAAkB,CAAC,K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AAU,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACjE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;IAClD,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;AACvC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -4,4 +4,7 @@ export { isCommercialRegistration, isTin, isUnifiedNationalNumber, isVatNumber,
4
4
  export { getSaudiIdType, isBorderId, isIqama, isNationalId, isSaudiId, validateBorderId, validateIqama, validateNationalId, validateSaudiId, } from "./identity.js";
5
5
  export { isLandlineNumber, isMobileNumber, isTollFreeNumber, normalizePhoneNumber, validateLandlineNumber, validateMobileNumber, validateTollFreeNumber, } from "./telecom.js";
6
6
  export type { NationalAddress, NationalAddressValidationResult, NormalizedSaudiPhone, ValidationErrorCode, ValidationEvidence, ValidationResult, } from "./types.js";
7
+ export { validateNationalIdDetailed, validateIqamaDetailed, validateSaudiIdDetailed, validateBorderIdDetailed, validateSaudiIbanDetailed, validateVatNumberDetailed, validateTinDetailed, validateUnifiedNationalNumberDetailed, validateCommercialRegistrationDetailed, validateMobileNumberDetailed, validateLandlineNumberDetailed, validateTollFreeNumberDetailed, validatePostalCodeDetailed, validateBuildingNumberDetailed, validateAdditionalNumberDetailed, validateShortAddressDetailed, validateNationalAddressDetailed, } from "./detailed.js";
8
+ export type { DetailedValidationResult } from "./types.js";
9
+ export { normalizeAndValidateIban, normalizeAndValidatePhoneNumber, normalizeAndValidateShortAddress, } from "./combined.js";
7
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEzF,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,wBAAwB,EACxB,KAAK,EACL,uBAAuB,EACvB,WAAW,EACX,8BAA8B,EAC9B,WAAW,EACX,6BAA6B,EAC7B,iBAAiB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,cAAc,EACd,UAAU,EACV,OAAO,EACP,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,eAAe,GAChB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,eAAe,EACf,+BAA+B,EAC/B,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEzF,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,wBAAwB,EACxB,KAAK,EACL,uBAAuB,EACvB,WAAW,EACX,8BAA8B,EAC9B,WAAW,EACX,6BAA6B,EAC7B,iBAAiB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,cAAc,EACd,UAAU,EACV,OAAO,EACP,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,eAAe,GAChB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,eAAe,EACf,+BAA+B,EAC/B,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,mBAAmB,EACnB,qCAAqC,EACrC,sCAAsC,EACtC,4BAA4B,EAC5B,8BAA8B,EAC9B,8BAA8B,EAC9B,0BAA0B,EAC1B,8BAA8B,EAC9B,gCAAgC,EAChC,4BAA4B,EAC5B,+BAA+B,GAChC,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3D,OAAO,EACL,wBAAwB,EACxB,+BAA+B,EAC/B,gCAAgC,GACjC,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -3,4 +3,6 @@ export { isAdditionalNumber, isBuildingNumber, isPostalCode, isShortAddress, nor
3
3
  export { isCommercialRegistration, isTin, isUnifiedNationalNumber, isVatNumber, validateCommercialRegistration, validateTin, validateUnifiedNationalNumber, validateVatNumber, } from "./business.js";
4
4
  export { getSaudiIdType, isBorderId, isIqama, isNationalId, isSaudiId, validateBorderId, validateIqama, validateNationalId, validateSaudiId, } from "./identity.js";
5
5
  export { isLandlineNumber, isMobileNumber, isTollFreeNumber, normalizePhoneNumber, validateLandlineNumber, validateMobileNumber, validateTollFreeNumber, } from "./telecom.js";
6
+ export { validateNationalIdDetailed, validateIqamaDetailed, validateSaudiIdDetailed, validateBorderIdDetailed, validateSaudiIbanDetailed, validateVatNumberDetailed, validateTinDetailed, validateUnifiedNationalNumberDetailed, validateCommercialRegistrationDetailed, validateMobileNumberDetailed, validateLandlineNumberDetailed, validateTollFreeNumberDetailed, validatePostalCodeDetailed, validateBuildingNumberDetailed, validateAdditionalNumberDetailed, validateShortAddressDetailed, validateNationalAddressDetailed, } from "./detailed.js";
7
+ export { normalizeAndValidateIban, normalizeAndValidatePhoneNumber, normalizeAndValidateShortAddress, } from "./combined.js";
6
8
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEzF,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,wBAAwB,EACxB,KAAK,EACL,uBAAuB,EACvB,WAAW,EACX,8BAA8B,EAC9B,WAAW,EACX,6BAA6B,EAC7B,iBAAiB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,cAAc,EACd,UAAU,EACV,OAAO,EACP,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,eAAe,GAChB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEzF,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,wBAAwB,EACxB,KAAK,EACL,uBAAuB,EACvB,WAAW,EACX,8BAA8B,EAC9B,WAAW,EACX,6BAA6B,EAC7B,iBAAiB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,cAAc,EACd,UAAU,EACV,OAAO,EACP,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,eAAe,GAChB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,cAAc,CAAC;AAWtB,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,mBAAmB,EACnB,qCAAqC,EACrC,sCAAsC,EACtC,4BAA4B,EAC5B,8BAA8B,EAC9B,8BAA8B,EAC9B,0BAA0B,EAC1B,8BAA8B,EAC9B,gCAAgC,EAChC,4BAA4B,EAC5B,+BAA+B,GAChC,MAAM,eAAe,CAAC;AAIvB,OAAO,EACL,wBAAwB,EACxB,+BAA+B,EAC/B,gCAAgC,GACjC,MAAM,eAAe,CAAC"}