@azure-net/node-kit 0.1.1 → 0.1.2
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/VALIDATION.md
CHANGED
|
@@ -726,6 +726,7 @@ existence, ownership, authenticity, allocation, or reachability checks.
|
|
|
726
726
|
| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
727
727
|
| `email(o?)` | ASCII dot-atom local part up to 64 characters, dotted DNS domain, total up to 254; not all RFC 5322 mailboxes, no quoted local parts or deliverability check |
|
|
728
728
|
| `uuid(o?)` | RFC 9562 versions 1-8; `UuidOptions.version` restricts version; unrestricted also accepts Nil/Max UUIDs; case-insensitive |
|
|
729
|
+
| `nonEmptyUuid(o?)` | Like `uuid`, but rejects `00000000-0000-0000-0000-000000000000`; accepts `UuidOptions`, including version and custom message. |
|
|
729
730
|
| `guid(o?)` | Hyphenated `8-4-4-4-12` hex shape without UUID version/variant constraints |
|
|
730
731
|
| `url(o?)` | Absolute WHATWG URL, including non-HTTP schemes; `UrlOptions.protocol`/`hostname` RegExp filters |
|
|
731
732
|
| `httpUrl(o?)` | HTTP/HTTPS with explicit `://` and hostname; same URL filters; localhost/IPs can pass |
|
|
@@ -84,6 +84,7 @@ export const validationMessagesEn = Object.freeze({
|
|
|
84
84
|
uppercase: "Must be uppercase.",
|
|
85
85
|
email: "Must be a valid email address.",
|
|
86
86
|
uuid: "Must be a valid UUID.",
|
|
87
|
+
nonEmptyUuid: "Must be a valid non-empty UUID.",
|
|
87
88
|
guid: "Must be a valid GUID.",
|
|
88
89
|
url: "Must be a valid absolute URL.",
|
|
89
90
|
httpUrl: "Must be a valid HTTP or HTTPS URL.",
|
|
@@ -84,6 +84,7 @@ export const validationMessagesRu = Object.freeze({
|
|
|
84
84
|
uppercase: "Строка должна быть в верхнем регистре.",
|
|
85
85
|
email: "Некорректный адрес электронной почты.",
|
|
86
86
|
uuid: "Некорректный UUID.",
|
|
87
|
+
nonEmptyUuid: "Требуется корректный ненулевой UUID.",
|
|
87
88
|
guid: "Некорректный GUID.",
|
|
88
89
|
url: "Некорректный абсолютный URL.",
|
|
89
90
|
httpUrl: "Некорректный HTTP или HTTPS URL.",
|
|
@@ -30,11 +30,6 @@ export interface IsoDateTimeOptions extends IsoTimeOptions {
|
|
|
30
30
|
readonly local?: boolean;
|
|
31
31
|
}
|
|
32
32
|
export type HashAlgorithm = "md5" | "sha1" | "sha256" | "sha384" | "sha512";
|
|
33
|
-
/**
|
|
34
|
-
* Noncoercive format checks. Format scope was reviewed against Zod 4.6.7's
|
|
35
|
-
* src/v4/core/{regexes,schemas}.ts (MIT, Colin McDonnell and contributors).
|
|
36
|
-
* Implementations below are independent; no Zod runtime dependency is required.
|
|
37
|
-
*/
|
|
38
33
|
export declare const stringRules: {
|
|
39
34
|
string(options?: RuleOptions): BuiltinRule<string>;
|
|
40
35
|
/** Strings count Unicode code points by default, arrays count elements, maps/sets count entries. */
|
|
@@ -52,6 +47,8 @@ export declare const stringRules: {
|
|
|
52
47
|
email(options?: RuleOptions): BuiltinRule<string>;
|
|
53
48
|
/** RFC 9562 versions 1-8 and, without a version filter, Nil/Max UUIDs. */
|
|
54
49
|
uuid(options?: UuidOptions): BuiltinRule<string>;
|
|
50
|
+
/** A valid UUID excluding the all-zero Nil UUID. */
|
|
51
|
+
nonEmptyUuid(options?: UuidOptions): BuiltinRule<string>;
|
|
55
52
|
guid(options?: RuleOptions): BuiltinRule<string>;
|
|
56
53
|
/** Absolute WHATWG URLs, including non-HTTP schemes; not a safe-URL/security policy. */
|
|
57
54
|
url(options?: UrlOptions): BuiltinRule<string>;
|
|
@@ -174,6 +174,18 @@ let currencies;
|
|
|
174
174
|
* src/v4/core/{regexes,schemas}.ts (MIT, Colin McDonnell and contributors).
|
|
175
175
|
* Implementations below are independent; no Zod runtime dependency is required.
|
|
176
176
|
*/
|
|
177
|
+
function uuidRule(options, nonNil) {
|
|
178
|
+
checkOptions(options);
|
|
179
|
+
const version = options.version;
|
|
180
|
+
if (version !== undefined &&
|
|
181
|
+
(!Number.isInteger(version) || version < 1 || version > 8))
|
|
182
|
+
throw new RangeError("UUID version must be 1 through 8.");
|
|
183
|
+
const normal = full(`[0-9a-f]{8}-[0-9a-f]{4}-${version ?? "[1-8]"}[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}`, "i");
|
|
184
|
+
return format(nonNil ? "nonEmptyUuid" : "uuid", (value) => normal.test(value) ||
|
|
185
|
+
(version === undefined &&
|
|
186
|
+
((!nonNil && value === "00000000-0000-0000-0000-000000000000") ||
|
|
187
|
+
value.toLowerCase() === "ffffffff-ffff-ffff-ffff-ffffffffffff")), options, { version: version ?? "any" });
|
|
188
|
+
}
|
|
177
189
|
export const stringRules = {
|
|
178
190
|
string(options = {}) {
|
|
179
191
|
checkOptions(options);
|
|
@@ -241,16 +253,11 @@ export const stringRules = {
|
|
|
241
253
|
},
|
|
242
254
|
/** RFC 9562 versions 1-8 and, without a version filter, Nil/Max UUIDs. */
|
|
243
255
|
uuid(options = {}) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
const normal = full(`[0-9a-f]{8}-[0-9a-f]{4}-${version ?? "[1-8]"}[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}`, "i");
|
|
250
|
-
return format("uuid", (value) => normal.test(value) ||
|
|
251
|
-
(version === undefined &&
|
|
252
|
-
(value === "00000000-0000-0000-0000-000000000000" ||
|
|
253
|
-
value.toLowerCase() === "ffffffff-ffff-ffff-ffff-ffffffffffff")), options, { version: version ?? "any" });
|
|
256
|
+
return uuidRule(options, false);
|
|
257
|
+
},
|
|
258
|
+
/** A valid UUID excluding the all-zero Nil UUID. */
|
|
259
|
+
nonEmptyUuid(options = {}) {
|
|
260
|
+
return uuidRule(options, true);
|
|
254
261
|
},
|
|
255
262
|
guid(options = {}) {
|
|
256
263
|
return pattern("guid", "[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}", options, "i");
|
|
@@ -44,6 +44,7 @@ export declare const rules: Readonly<{
|
|
|
44
44
|
uppercase(options?: RuleOptions): BuiltinRule<string>;
|
|
45
45
|
email(options?: RuleOptions): BuiltinRule<string>;
|
|
46
46
|
uuid(options?: import("./StringRules.js").UuidOptions): BuiltinRule<string>;
|
|
47
|
+
nonEmptyUuid(options?: import("./StringRules.js").UuidOptions): BuiltinRule<string>;
|
|
47
48
|
guid(options?: RuleOptions): BuiltinRule<string>;
|
|
48
49
|
url(options?: import("./StringRules.js").UrlOptions): BuiltinRule<string>;
|
|
49
50
|
httpUrl(options?: import("./StringRules.js").UrlOptions): BuiltinRule<string>;
|