@plasius/schema 1.2.16 → 1.2.18
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/README.md +15 -0
- package/dist/index.cjs +55 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +55 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -339,8 +339,11 @@ declare function getComponentSchema(type: string): Schema<SchemaShape> | undefin
|
|
|
339
339
|
declare function getAllComponentSchemas(): [string, Schema<SchemaShape>][];
|
|
340
340
|
|
|
341
341
|
/**
|
|
342
|
-
* Validates
|
|
343
|
-
*
|
|
342
|
+
* Validates the package's pragmatic dot-domain mailbox subset.
|
|
343
|
+
*
|
|
344
|
+
* This intentionally does not claim full RFC 5322 mailbox support (for
|
|
345
|
+
* example, quoted local parts and address literals are outside the product
|
|
346
|
+
* contract). The legacy filename is retained for import compatibility.
|
|
344
347
|
*/
|
|
345
348
|
declare const validateEmail: (value: unknown) => boolean;
|
|
346
349
|
|
|
@@ -358,8 +361,8 @@ declare const validatePhone: (value: unknown) => boolean;
|
|
|
358
361
|
declare const validateUrl: (value: unknown) => boolean;
|
|
359
362
|
|
|
360
363
|
/**
|
|
361
|
-
* Validates
|
|
362
|
-
*
|
|
364
|
+
* Validates the RFC 9562 UUID text format, including versions 1-8 plus Nil and
|
|
365
|
+
* Max UUIDs. The legacy filename is retained for import compatibility.
|
|
363
366
|
*/
|
|
364
367
|
declare const validateUUID: (value: unknown) => boolean;
|
|
365
368
|
|
package/dist/index.d.ts
CHANGED
|
@@ -339,8 +339,11 @@ declare function getComponentSchema(type: string): Schema<SchemaShape> | undefin
|
|
|
339
339
|
declare function getAllComponentSchemas(): [string, Schema<SchemaShape>][];
|
|
340
340
|
|
|
341
341
|
/**
|
|
342
|
-
* Validates
|
|
343
|
-
*
|
|
342
|
+
* Validates the package's pragmatic dot-domain mailbox subset.
|
|
343
|
+
*
|
|
344
|
+
* This intentionally does not claim full RFC 5322 mailbox support (for
|
|
345
|
+
* example, quoted local parts and address literals are outside the product
|
|
346
|
+
* contract). The legacy filename is retained for import compatibility.
|
|
344
347
|
*/
|
|
345
348
|
declare const validateEmail: (value: unknown) => boolean;
|
|
346
349
|
|
|
@@ -358,8 +361,8 @@ declare const validatePhone: (value: unknown) => boolean;
|
|
|
358
361
|
declare const validateUrl: (value: unknown) => boolean;
|
|
359
362
|
|
|
360
363
|
/**
|
|
361
|
-
* Validates
|
|
362
|
-
*
|
|
364
|
+
* Validates the RFC 9562 UUID text format, including versions 1-8 plus Nil and
|
|
365
|
+
* Max UUIDs. The legacy filename is retained for import compatibility.
|
|
363
366
|
*/
|
|
364
367
|
declare const validateUUID: (value: unknown) => boolean;
|
|
365
368
|
|
package/dist/index.js
CHANGED
|
@@ -223,8 +223,8 @@ var validateUrl = (value) => {
|
|
|
223
223
|
// src/validation/uuid.RFC4122.ts
|
|
224
224
|
var validateUUID = (value) => {
|
|
225
225
|
if (typeof value !== "string") return false;
|
|
226
|
-
const
|
|
227
|
-
return
|
|
226
|
+
const standard = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
227
|
+
return standard.test(value) || value.toLowerCase() === "00000000-0000-0000-0000-000000000000" || value.toLowerCase() === "ffffffff-ffff-ffff-ffff-ffffffffffff";
|
|
228
228
|
};
|
|
229
229
|
|
|
230
230
|
// src/validation/dateTime.ISO8601.ts
|
|
@@ -971,10 +971,10 @@ function isIsoLanguageCode(value) {
|
|
|
971
971
|
return typeof value === "string" && ISO_LANGUAGE_SET.has(value.toLowerCase());
|
|
972
972
|
}
|
|
973
973
|
function isRegionSubtag(value) {
|
|
974
|
-
return /^[A-
|
|
974
|
+
return /^[A-Za-z]{2}$/.test(value) || /^\d{3}$/.test(value);
|
|
975
975
|
}
|
|
976
976
|
function isScriptSubtag(value) {
|
|
977
|
-
return /^[A-
|
|
977
|
+
return /^[A-Za-z]{4}$/.test(value);
|
|
978
978
|
}
|
|
979
979
|
function isVariantSubtag(value) {
|
|
980
980
|
return /^([0-9][A-Za-z0-9]{3}|[A-Za-z0-9]{5,8})$/.test(value);
|
|
@@ -994,20 +994,42 @@ function isPrivateUseSubtag(value) {
|
|
|
994
994
|
function validateLanguage(value) {
|
|
995
995
|
if (typeof value !== "string" || value.length === 0) return false;
|
|
996
996
|
const parts = value.split("-");
|
|
997
|
+
if (parts.some((part) => part.length === 0)) return false;
|
|
998
|
+
const lowerTag = value.toLowerCase();
|
|
999
|
+
if (GRANDFATHERED_TAGS.has(lowerTag)) return true;
|
|
1000
|
+
if (parts[0]?.toLowerCase() === "x") {
|
|
1001
|
+
return parts.length > 1 && parts.slice(1).every(isPrivateUseSubtag);
|
|
1002
|
+
}
|
|
997
1003
|
let i = 0;
|
|
998
1004
|
const lang = parts[i];
|
|
999
|
-
if (!lang ||
|
|
1005
|
+
if (!lang || !/^[A-Za-z]{2,3}$/.test(lang)) return false;
|
|
1006
|
+
if (lang.length === 2 && !isIsoLanguageCode(lang)) return false;
|
|
1000
1007
|
i += 1;
|
|
1008
|
+
if (lang.length <= 3) {
|
|
1009
|
+
let extlangCount = 0;
|
|
1010
|
+
while (i < parts.length && extlangCount < 3 && /^[A-Za-z]{3}$/.test(parts[i])) {
|
|
1011
|
+
i += 1;
|
|
1012
|
+
extlangCount += 1;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1001
1015
|
if (i < parts.length && isScriptSubtag(parts[i])) {
|
|
1002
1016
|
i += 1;
|
|
1003
1017
|
}
|
|
1004
1018
|
if (i < parts.length && isRegionSubtag(parts[i].toUpperCase())) {
|
|
1005
1019
|
i += 1;
|
|
1006
1020
|
}
|
|
1021
|
+
const variants = /* @__PURE__ */ new Set();
|
|
1007
1022
|
while (i < parts.length && isVariantSubtag(parts[i])) {
|
|
1023
|
+
const variant = parts[i].toLowerCase();
|
|
1024
|
+
if (variants.has(variant)) return false;
|
|
1025
|
+
variants.add(variant);
|
|
1008
1026
|
i += 1;
|
|
1009
1027
|
}
|
|
1028
|
+
const extensionSingletons = /* @__PURE__ */ new Set();
|
|
1010
1029
|
while (i < parts.length && isExtensionSingleton(parts[i])) {
|
|
1030
|
+
const singleton = parts[i].toLowerCase();
|
|
1031
|
+
if (extensionSingletons.has(singleton)) return false;
|
|
1032
|
+
extensionSingletons.add(singleton);
|
|
1011
1033
|
i += 1;
|
|
1012
1034
|
if (!(i < parts.length && isExtensionSubtag(parts[i]))) return false;
|
|
1013
1035
|
while (i < parts.length && isExtensionSubtag(parts[i])) {
|
|
@@ -1023,6 +1045,34 @@ function validateLanguage(value) {
|
|
|
1023
1045
|
}
|
|
1024
1046
|
return i === parts.length;
|
|
1025
1047
|
}
|
|
1048
|
+
var GRANDFATHERED_TAGS = /* @__PURE__ */ new Set([
|
|
1049
|
+
"art-lojban",
|
|
1050
|
+
"cel-gaulish",
|
|
1051
|
+
"en-gb-oed",
|
|
1052
|
+
"i-ami",
|
|
1053
|
+
"i-bnn",
|
|
1054
|
+
"i-default",
|
|
1055
|
+
"i-enochian",
|
|
1056
|
+
"i-hak",
|
|
1057
|
+
"i-klingon",
|
|
1058
|
+
"i-lux",
|
|
1059
|
+
"i-mingo",
|
|
1060
|
+
"i-navajo",
|
|
1061
|
+
"i-pwn",
|
|
1062
|
+
"i-tao",
|
|
1063
|
+
"i-tay",
|
|
1064
|
+
"i-tsu",
|
|
1065
|
+
"no-bok",
|
|
1066
|
+
"no-nyn",
|
|
1067
|
+
"sgn-be-fr",
|
|
1068
|
+
"sgn-be-nl",
|
|
1069
|
+
"sgn-ch-de",
|
|
1070
|
+
"zh-guoyu",
|
|
1071
|
+
"zh-hakka",
|
|
1072
|
+
"zh-min",
|
|
1073
|
+
"zh-min-nan",
|
|
1074
|
+
"zh-xiang"
|
|
1075
|
+
]);
|
|
1026
1076
|
|
|
1027
1077
|
// src/field.ts
|
|
1028
1078
|
var field = {
|