@zudojs/types 1.1.0 → 1.1.1
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.
|
@@ -52,9 +52,8 @@ export declare const MAX_EMAIL_LENGTH = 254;
|
|
|
52
52
|
* This is the monorepo's reference email check. `ValidationPattern.EMAIL`
|
|
53
53
|
* in `@zudojs/constants` (and therefore `createEmailAddress` and the schema
|
|
54
54
|
* `email` format) encodes the same acceptance set, including the 254
|
|
55
|
-
* character bound
|
|
56
|
-
*
|
|
57
|
-
* here, an address over 254 characters passes that constraint only.
|
|
55
|
+
* character bound, and `@zudojs/validation`'s `email` constraint uses that
|
|
56
|
+
* pattern, so all three accept exactly the same addresses.
|
|
58
57
|
*/
|
|
59
58
|
export declare function isEmail(value: unknown): value is string;
|
|
60
59
|
/**
|
|
@@ -86,6 +85,10 @@ export declare function isIsoDateString(value: unknown): value is string;
|
|
|
86
85
|
export declare function isIsoDateTimeString(value: unknown): value is string;
|
|
87
86
|
/**
|
|
88
87
|
* Check if a value is an array of a specific element type.
|
|
88
|
+
*
|
|
89
|
+
* Every index in `0..length-1` is read, so a hole is tested as `undefined`
|
|
90
|
+
* rather than skipped. `Array.prototype.every` skips holes, which made
|
|
91
|
+
* `new Array(3)` satisfy every guard and narrow three holes to `T[]`.
|
|
89
92
|
*/
|
|
90
93
|
export declare function isArrayOfType<T>(value: unknown, guard: (item: unknown) => item is T): value is T[];
|
|
91
94
|
/**
|
|
@@ -79,9 +79,8 @@ export const MAX_EMAIL_LENGTH = 254;
|
|
|
79
79
|
* This is the monorepo's reference email check. `ValidationPattern.EMAIL`
|
|
80
80
|
* in `@zudojs/constants` (and therefore `createEmailAddress` and the schema
|
|
81
81
|
* `email` format) encodes the same acceptance set, including the 254
|
|
82
|
-
* character bound
|
|
83
|
-
*
|
|
84
|
-
* here, an address over 254 characters passes that constraint only.
|
|
82
|
+
* character bound, and `@zudojs/validation`'s `email` constraint uses that
|
|
83
|
+
* pattern, so all three accept exactly the same addresses.
|
|
85
84
|
*/
|
|
86
85
|
export function isEmail(value) {
|
|
87
86
|
if (typeof value !== "string")
|
|
@@ -170,11 +169,19 @@ export function isIsoDateTimeString(value) {
|
|
|
170
169
|
}
|
|
171
170
|
/**
|
|
172
171
|
* Check if a value is an array of a specific element type.
|
|
172
|
+
*
|
|
173
|
+
* Every index in `0..length-1` is read, so a hole is tested as `undefined`
|
|
174
|
+
* rather than skipped. `Array.prototype.every` skips holes, which made
|
|
175
|
+
* `new Array(3)` satisfy every guard and narrow three holes to `T[]`.
|
|
173
176
|
*/
|
|
174
177
|
export function isArrayOfType(value, guard) {
|
|
175
178
|
if (!Array.isArray(value))
|
|
176
179
|
return false;
|
|
177
|
-
|
|
180
|
+
for (let index = 0; index < value.length; index++) {
|
|
181
|
+
if (!guard(value[index]))
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
return true;
|
|
178
185
|
}
|
|
179
186
|
/**
|
|
180
187
|
* Check if a value is defined (not null or undefined).
|