@oxog/vld 2.1.0 → 2.2.5

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.
Files changed (220) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +1296 -1235
  3. package/dist/chunks/errors-core-Cqi4-9ew.js +1 -0
  4. package/dist/chunks/index-CkbfQQ4n.js +1 -0
  5. package/dist/chunks/index-yjpbvFgw.js +1 -0
  6. package/dist/chunks/ip-validation-g5LWgy9t.js +1 -0
  7. package/dist/chunks/security-Dy24T8N7.js +1 -0
  8. package/dist/cjs/chunks/errors-core-DKPohm9I.cjs +1 -0
  9. package/dist/cjs/chunks/index-BEV9nG0N.cjs +1 -0
  10. package/dist/cjs/chunks/index-ZjHAxYdA.cjs +1 -0
  11. package/dist/cjs/chunks/ip-validation-BZqPamPC.cjs +1 -0
  12. package/dist/cjs/chunks/security-aXZVI7qW.cjs +1 -0
  13. package/dist/cjs/cli/bin.cjs +1 -505
  14. package/dist/cjs/cli/index.cjs +1 -209
  15. package/dist/cjs/codecs/index.cjs +1 -45
  16. package/dist/cjs/coercion/index.cjs +1 -588
  17. package/dist/cjs/compat/emitter.cjs +1 -184
  18. package/dist/cjs/compat/result.cjs +1 -189
  19. package/dist/cjs/errors.cjs +1 -180
  20. package/dist/cjs/index.cjs +1 -1894
  21. package/dist/cjs/kernel.cjs +1 -415
  22. package/dist/cjs/locales/af.cjs +1 -108
  23. package/dist/cjs/locales/ar.cjs +1 -108
  24. package/dist/cjs/locales/bn.cjs +1 -108
  25. package/dist/cjs/locales/da.cjs +1 -108
  26. package/dist/cjs/locales/de.cjs +1 -108
  27. package/dist/cjs/locales/en.cjs +1 -108
  28. package/dist/cjs/locales/es-MX.cjs +1 -107
  29. package/dist/cjs/locales/es.cjs +1 -96
  30. package/dist/cjs/locales/fi.cjs +1 -108
  31. package/dist/cjs/locales/fr.cjs +1 -96
  32. package/dist/cjs/locales/hi.cjs +1 -108
  33. package/dist/cjs/locales/id.cjs +1 -108
  34. package/dist/cjs/locales/index.cjs +1 -43
  35. package/dist/cjs/locales/it.cjs +1 -108
  36. package/dist/cjs/locales/ja.cjs +1 -108
  37. package/dist/cjs/locales/ko.cjs +1 -108
  38. package/dist/cjs/locales/lazy.cjs +1 -188
  39. package/dist/cjs/locales/nl.cjs +1 -108
  40. package/dist/cjs/locales/no.cjs +1 -108
  41. package/dist/cjs/locales/pl.cjs +1 -108
  42. package/dist/cjs/locales/pt-BR.cjs +1 -108
  43. package/dist/cjs/locales/pt.cjs +1 -108
  44. package/dist/cjs/locales/ru.cjs +1 -108
  45. package/dist/cjs/locales/runtime.cjs +1 -51
  46. package/dist/cjs/locales/sv.cjs +1 -108
  47. package/dist/cjs/locales/sw.cjs +1 -108
  48. package/dist/cjs/locales/th.cjs +1 -108
  49. package/dist/cjs/locales/tr.cjs +1 -108
  50. package/dist/cjs/locales/vi.cjs +1 -108
  51. package/dist/cjs/locales/zh.cjs +1 -108
  52. package/dist/cjs/mini.cjs +1 -242
  53. package/dist/cjs/pigment.cjs +1 -207
  54. package/dist/cjs/plugins/index.cjs +1 -12
  55. package/dist/cjs/registry.cjs +1 -37
  56. package/dist/cjs/v3/index.cjs +1 -425
  57. package/dist/cjs/v4/core/index.cjs +1 -894
  58. package/dist/cjs/v4/index.cjs +1 -425
  59. package/dist/cjs/v4/locales/index.cjs +1 -130
  60. package/dist/cjs/v4/mini/index.cjs +1 -509
  61. package/dist/cjs/v4-mini/index.cjs +1 -532
  62. package/dist/cjs/validators/any.cjs +1 -40
  63. package/dist/cjs/validators/array.cjs +1 -283
  64. package/dist/cjs/validators/base.cjs +1 -887
  65. package/dist/cjs/validators/base64.cjs +1 -73
  66. package/dist/cjs/validators/bigint.cjs +1 -232
  67. package/dist/cjs/validators/boolean.cjs +1 -146
  68. package/dist/cjs/validators/codec.cjs +1 -205
  69. package/dist/cjs/validators/custom.cjs +1 -71
  70. package/dist/cjs/validators/date.cjs +1 -278
  71. package/dist/cjs/validators/discriminated-union.cjs +1 -130
  72. package/dist/cjs/validators/enum.cjs +1 -154
  73. package/dist/cjs/validators/file.cjs +1 -130
  74. package/dist/cjs/validators/function.cjs +1 -63
  75. package/dist/cjs/validators/hex.cjs +1 -70
  76. package/dist/cjs/validators/index.cjs +1 -123
  77. package/dist/cjs/validators/intersection.cjs +1 -120
  78. package/dist/cjs/validators/json.cjs +1 -70
  79. package/dist/cjs/validators/lazy.cjs +1 -53
  80. package/dist/cjs/validators/literal.cjs +1 -64
  81. package/dist/cjs/validators/map.cjs +1 -218
  82. package/dist/cjs/validators/nan.cjs +1 -41
  83. package/dist/cjs/validators/never.cjs +1 -36
  84. package/dist/cjs/validators/null.cjs +1 -43
  85. package/dist/cjs/validators/number.cjs +1 -427
  86. package/dist/cjs/validators/object.cjs +1 -868
  87. package/dist/cjs/validators/promise.cjs +1 -115
  88. package/dist/cjs/validators/record.cjs +1 -262
  89. package/dist/cjs/validators/set.cjs +1 -203
  90. package/dist/cjs/validators/string-bool.cjs +1 -124
  91. package/dist/cjs/validators/string-formats.cjs +1 -168
  92. package/dist/cjs/validators/string.cjs +1 -12
  93. package/dist/cjs/validators/symbol.cjs +1 -62
  94. package/dist/cjs/validators/template-literal.cjs +1 -108
  95. package/dist/cjs/validators/tuple.cjs +1 -187
  96. package/dist/cjs/validators/uint8array.cjs +1 -106
  97. package/dist/cjs/validators/undefined.cjs +1 -43
  98. package/dist/cjs/validators/union.cjs +1 -191
  99. package/dist/cjs/validators/unknown.cjs +1 -40
  100. package/dist/cjs/validators/void.cjs +1 -48
  101. package/dist/cjs/validators/xor.cjs +1 -69
  102. package/dist/cli/bin.js +1 -406
  103. package/dist/cli/index.js +1 -205
  104. package/dist/codecs/index.js +1 -11
  105. package/dist/coercion/index.js +1 -579
  106. package/dist/compat/emitter.js +1 -180
  107. package/dist/compat/result.js +1 -170
  108. package/dist/errors-core.d.ts +20 -1
  109. package/dist/errors.js +1 -171
  110. package/dist/index.d.ts +248 -357
  111. package/dist/index.js +1 -1534
  112. package/dist/kernel.js +1 -409
  113. package/dist/locales/af.js +1 -106
  114. package/dist/locales/ar.js +1 -106
  115. package/dist/locales/bn.js +1 -106
  116. package/dist/locales/da.js +1 -106
  117. package/dist/locales/de.js +1 -106
  118. package/dist/locales/en.js +1 -106
  119. package/dist/locales/es-MX.js +1 -105
  120. package/dist/locales/es.js +1 -94
  121. package/dist/locales/fi.js +1 -106
  122. package/dist/locales/fr.js +1 -94
  123. package/dist/locales/hi.js +1 -106
  124. package/dist/locales/id.js +1 -106
  125. package/dist/locales/index.js +1 -29
  126. package/dist/locales/it.js +1 -106
  127. package/dist/locales/ja.js +1 -106
  128. package/dist/locales/ko.js +1 -106
  129. package/dist/locales/lazy.js +1 -177
  130. package/dist/locales/nl.js +1 -106
  131. package/dist/locales/no.js +1 -106
  132. package/dist/locales/pl.js +1 -106
  133. package/dist/locales/pt-BR.js +1 -106
  134. package/dist/locales/pt.js +1 -106
  135. package/dist/locales/ru.js +1 -106
  136. package/dist/locales/runtime.js +1 -41
  137. package/dist/locales/sv.js +1 -106
  138. package/dist/locales/sw.js +1 -106
  139. package/dist/locales/th.js +1 -106
  140. package/dist/locales/tr.js +1 -106
  141. package/dist/locales/vi.js +1 -106
  142. package/dist/locales/zh.js +1 -106
  143. package/dist/mini.d.ts +3 -3
  144. package/dist/mini.js +1 -156
  145. package/dist/pigment.js +1 -180
  146. package/dist/plugins/index.js +1 -1
  147. package/dist/registry.js +1 -34
  148. package/dist/utils/json-schema.d.ts +10 -1
  149. package/dist/v3/index.js +1 -46
  150. package/dist/v4/core/index.d.ts +28 -16
  151. package/dist/v4/core/index.js +1 -277
  152. package/dist/v4/index.js +1 -50
  153. package/dist/v4/locales/index.d.ts +4 -0
  154. package/dist/v4/locales/index.js +1 -77
  155. package/dist/v4/mini/index.js +1 -47
  156. package/dist/v4-mini/index.d.ts +1 -1
  157. package/dist/v4-mini/index.js +1 -75
  158. package/dist/validators/any.js +1 -37
  159. package/dist/validators/array.d.ts +7 -0
  160. package/dist/validators/array.js +1 -279
  161. package/dist/validators/base.d.ts +63 -8
  162. package/dist/validators/base.js +1 -868
  163. package/dist/validators/base64.js +1 -68
  164. package/dist/validators/bigint.js +1 -228
  165. package/dist/validators/boolean.js +1 -142
  166. package/dist/validators/codec.js +1 -200
  167. package/dist/validators/custom.js +1 -67
  168. package/dist/validators/date.js +1 -274
  169. package/dist/validators/discriminated-union.d.ts +2 -2
  170. package/dist/validators/discriminated-union.js +1 -123
  171. package/dist/validators/enum.js +1 -150
  172. package/dist/validators/file.js +1 -125
  173. package/dist/validators/function.js +1 -58
  174. package/dist/validators/hex.js +1 -65
  175. package/dist/validators/index.d.ts +1 -1
  176. package/dist/validators/index.js +1 -35
  177. package/dist/validators/intersection.js +1 -116
  178. package/dist/validators/json.js +1 -66
  179. package/dist/validators/lazy.js +1 -50
  180. package/dist/validators/literal.d.ts +7 -3
  181. package/dist/validators/literal.js +1 -60
  182. package/dist/validators/map.js +1 -214
  183. package/dist/validators/nan.js +1 -38
  184. package/dist/validators/never.js +1 -32
  185. package/dist/validators/null.js +1 -40
  186. package/dist/validators/number.d.ts +20 -1
  187. package/dist/validators/number.js +1 -423
  188. package/dist/validators/object.d.ts +12 -2
  189. package/dist/validators/object.js +1 -864
  190. package/dist/validators/promise.js +1 -111
  191. package/dist/validators/record.d.ts +11 -8
  192. package/dist/validators/record.js +1 -258
  193. package/dist/validators/set.js +1 -199
  194. package/dist/validators/string-bool.js +1 -120
  195. package/dist/validators/string-formats.d.ts +58 -62
  196. package/dist/validators/string-formats.js +1 -135
  197. package/dist/validators/string.d.ts +47 -10
  198. package/dist/validators/string.js +1 -4
  199. package/dist/validators/symbol.js +1 -58
  200. package/dist/validators/template-literal.js +1 -103
  201. package/dist/validators/tuple.d.ts +17 -13
  202. package/dist/validators/tuple.js +1 -183
  203. package/dist/validators/uint8array.js +1 -101
  204. package/dist/validators/undefined.js +1 -40
  205. package/dist/validators/union.js +1 -187
  206. package/dist/validators/unknown.js +1 -37
  207. package/dist/validators/void.js +1 -44
  208. package/dist/validators/xor.d.ts +2 -2
  209. package/dist/validators/xor.js +1 -66
  210. package/package.json +239 -238
  211. package/dist/chunks/errors-core-BeiFUtZM.js +0 -81
  212. package/dist/chunks/index-0R2ntSud.js +0 -508
  213. package/dist/chunks/index-BvH403Yy.js +0 -88
  214. package/dist/chunks/security-B0Pd_vSY.js +0 -35
  215. package/dist/chunks/string-BJRQod3t.js +0 -530
  216. package/dist/cjs/chunks/errors-core-DWxLFs2f.cjs +0 -83
  217. package/dist/cjs/chunks/index-BkI37108.cjs +0 -538
  218. package/dist/cjs/chunks/index-Cc3bjUMX.cjs +0 -91
  219. package/dist/cjs/chunks/security-Dc3Jh13T.cjs +0 -37
  220. package/dist/cjs/chunks/string-BKZrc4hs.cjs +0 -533
@@ -1,130 +1 @@
1
- 'use strict';
2
-
3
- var validators_base = require('./base.cjs');
4
- var locales_runtime = require('../locales/runtime.cjs');
5
- var errorsCore = require('../chunks/errors-core-DWxLFs2f.cjs');
6
- require('../registry.cjs');
7
- require('../locales/en.cjs');
8
-
9
- function createFileError(message) {
10
- return new errorsCore.VldError([{ code: 'invalid_type', path: [], message }]);
11
- }
12
- /**
13
- * Immutable file validator for file uploads
14
- * Supports size and MIME type validation
15
- */
16
- class VldFile extends validators_base.VldBase {
17
- constructor(checks = []) {
18
- super(validators_base.VLD_VALIDATOR_TYPES.FILE);
19
- this.checks = checks;
20
- }
21
- /**
22
- * Create a new file validator
23
- */
24
- static create() {
25
- return new VldFile();
26
- }
27
- isFileLike(value) {
28
- if (typeof value !== 'object' || value === null) {
29
- return false;
30
- }
31
- if (typeof File !== 'undefined' && value instanceof File) {
32
- return true;
33
- }
34
- return 'size' in value && 'type' in value;
35
- }
36
- /**
37
- * Parse and validate a file value
38
- */
39
- parse(value) {
40
- if (this.isFileLike(value)) {
41
- return this.parseKnownFile(value);
42
- }
43
- if (typeof File === 'undefined') {
44
- throw new Error(locales_runtime.getMessages().fileNotSupported || 'File API not supported in this environment');
45
- }
46
- throw new Error(locales_runtime.getMessages().invalidFile || 'Expected a File object');
47
- }
48
- /**
49
- * Parse a value that has already passed the file-like type guard.
50
- * @internal Used by object validators to avoid duplicate hot-path checks.
51
- */
52
- parseKnownFile(value) {
53
- return this.runChecks(value);
54
- }
55
- /**
56
- * Run all validation checks on the file
57
- */
58
- runChecks(file) {
59
- const msgs = locales_runtime.getMessages();
60
- for (const check of this.checks) {
61
- switch (check.type) {
62
- case 'min':
63
- if (file.size < check.value) {
64
- throw new Error(check.message ||
65
- (msgs.fileMinSize?.(check.value) || `File size must be at least ${check.value} bytes`));
66
- }
67
- break;
68
- case 'max':
69
- if (file.size > check.value) {
70
- throw new Error(check.message ||
71
- (msgs.fileMaxSize?.(check.value) || `File size must not exceed ${check.value} bytes`));
72
- }
73
- break;
74
- case 'mime':
75
- if (!check.value.includes(file.type)) {
76
- throw new Error(check.message ||
77
- (msgs.fileMimeType?.(check.value) || `Invalid file type. Expected: ${check.value.join(', ')}`));
78
- }
79
- break;
80
- }
81
- }
82
- return file;
83
- }
84
- /**
85
- * Safely parse and validate a file value
86
- */
87
- safeParse(value) {
88
- try {
89
- return { success: true, data: this.parse(value) };
90
- }
91
- catch (error) {
92
- return { success: false, error: createFileError(error.message) };
93
- }
94
- }
95
- /**
96
- * Set minimum file size in bytes
97
- */
98
- min(bytes, message) {
99
- return new VldFile([...this.checks, { type: 'min', value: bytes, message }]);
100
- }
101
- /**
102
- * Set maximum file size in bytes
103
- */
104
- max(bytes, message) {
105
- return new VldFile([...this.checks, { type: 'max', value: bytes, message }]);
106
- }
107
- /**
108
- * Set allowed MIME types
109
- */
110
- mime(types, message) {
111
- const typeArray = Array.isArray(types) ? types : [types];
112
- return new VldFile([...this.checks, { type: 'mime', value: typeArray, message }]);
113
- }
114
- /**
115
- * Set both minimum and maximum file size
116
- */
117
- size(min, max, message) {
118
- return this.min(min, message).max(max, message);
119
- }
120
- }
121
- /**
122
- * Helper function to create file validators
123
- * Usage: v.file().min(1024).max(10485760).mime(['image/jpeg', 'image/png'])
124
- */
125
- function file() {
126
- return VldFile.create();
127
- }
128
-
129
- exports.VldFile = VldFile;
130
- exports.file = file;
1
+ "use strict";var e=require("./base.cjs"),s=require("../locales/runtime.cjs"),r=require("../chunks/errors-core-DKPohm9I.cjs");require("../registry.cjs"),require("../locales/en.cjs");class VldFile extends e.VldBase{constructor(s=[]){super(e.VLD_VALIDATOR_TYPES.FILE),this.checks=s}static create(){return new VldFile}isFileLike(e){return"object"==typeof e&&null!==e&&("undefined"!=typeof File&&e instanceof File||"size"in e&&"type"in e)}parse(e){if(this.isFileLike(e))return this.parseKnownFile(e);if("undefined"==typeof File)throw new Error(s.getMessages().fileNotSupported||"File API not supported in this environment");throw new Error(s.getMessages().invalidFile||"Expected a File object")}parseKnownFile(e){return this.runChecks(e)}runChecks(e){const r=s.getMessages();for(const s of this.checks)switch(s.type){case"min":if(e.size<s.value)throw new Error(s.message||r.fileMinSize?.(s.value)||`File size must be at least ${s.value} bytes`);break;case"max":if(e.size>s.value)throw new Error(s.message||r.fileMaxSize?.(s.value)||`File size must not exceed ${s.value} bytes`);break;case"mime":if(!s.value.includes(e.type))throw new Error(s.message||r.fileMimeType?.(s.value)||`Invalid file type. Expected: ${s.value.join(", ")}`)}return e}safeParse(e){try{return{success:!0,data:this.parse(e)}}catch(e){return{success:!1,error:(s=e.message,new r.VldError([{code:"invalid_type",path:[],message:s}]))}}var s}min(e,s){return new VldFile([...this.checks,{type:"min",value:e,message:s}])}max(e,s){return new VldFile([...this.checks,{type:"max",value:e,message:s}])}mime(e,s){const r=Array.isArray(e)?e:[e];return new VldFile([...this.checks,{type:"mime",value:r,message:s}])}size(e,s,r){return this.min(e,r).max(s,r)}}exports.VldFile=VldFile,exports.file=function(){return VldFile.create()};
@@ -1,63 +1 @@
1
- 'use strict';
2
-
3
- var validators_base = require('./base.cjs');
4
- var locales_runtime = require('../locales/runtime.cjs');
5
- var errorsCore = require('../chunks/errors-core-DWxLFs2f.cjs');
6
- require('../registry.cjs');
7
- require('../locales/en.cjs');
8
-
9
- function createFunctionError(message) {
10
- return new errorsCore.VldError([{ code: 'invalid_type', path: [], message }]);
11
- }
12
- /**
13
- * Immutable function validator
14
- * Validates that a value is a function
15
- */
16
- class VldFunction extends validators_base.VldBase {
17
- constructor() {
18
- super(validators_base.VLD_VALIDATOR_TYPES.FUNCTION);
19
- }
20
- /**
21
- * Create a new function validator
22
- */
23
- static create() {
24
- return new VldFunction();
25
- }
26
- /**
27
- * Parse and validate a function value
28
- */
29
- parse(value) {
30
- if (typeof value !== 'function') {
31
- throw new Error(locales_runtime.getMessages().invalidFunction || 'Expected a function');
32
- }
33
- return value;
34
- }
35
- /**
36
- * Parse a value that has already passed the function type guard.
37
- * @internal Used by object validators to avoid duplicate hot-path checks.
38
- */
39
- parseKnownFunction(value) {
40
- return value;
41
- }
42
- /**
43
- * Safely parse and validate a function value
44
- */
45
- safeParse(value) {
46
- try {
47
- return { success: true, data: this.parse(value) };
48
- }
49
- catch (error) {
50
- return { success: false, error: createFunctionError(error.message) };
51
- }
52
- }
53
- }
54
- /**
55
- * Helper function to create function validators
56
- * Usage: v.function()
57
- */
58
- function functionValidator() {
59
- return VldFunction.create();
60
- }
61
-
62
- exports.VldFunction = VldFunction;
63
- exports.functionValidator = functionValidator;
1
+ "use strict";var e=require("./base.cjs"),r=require("../locales/runtime.cjs"),s=require("../chunks/errors-core-DKPohm9I.cjs");require("../registry.cjs"),require("../locales/en.cjs");class VldFunction extends e.VldBase{constructor(){super(e.VLD_VALIDATOR_TYPES.FUNCTION)}static create(){return new VldFunction}parse(e){if("function"!=typeof e)throw new Error(r.getMessages().invalidFunction||"Expected a function");return e}parseKnownFunction(e){return e}safeParse(e){try{return{success:!0,data:this.parse(e)}}catch(e){return{success:!1,error:(r=e.message,new s.VldError([{code:"invalid_type",path:[],message:r}]))}}var r}}exports.VldFunction=VldFunction,exports.functionValidator=function(){return VldFunction.create()};
@@ -1,70 +1 @@
1
- 'use strict';
2
-
3
- var validators_base = require('./base.cjs');
4
- var errors = require('../errors.cjs');
5
- var locales_runtime = require('../locales/runtime.cjs');
6
- var errorsCore = require('../chunks/errors-core-DWxLFs2f.cjs');
7
- require('../registry.cjs');
8
- require('../pigment.cjs');
9
- require('../locales/en.cjs');
10
-
11
- /**
12
- * Hexadecimal string validator
13
- */
14
- class VldHex extends validators_base.VldBase {
15
- constructor(lowercase = false) {
16
- super(validators_base.VLD_VALIDATOR_TYPES.HEX);
17
- this.lowercase = lowercase;
18
- }
19
- parse(value) {
20
- const result = this.safeParse(value);
21
- if (!result.success) {
22
- throw result.error;
23
- }
24
- return result.data;
25
- }
26
- safeParse(value) {
27
- if (typeof value !== 'string') {
28
- return {
29
- success: false,
30
- error: new errorsCore.VldError([
31
- errors.createIssue('invalid_type', [], locales_runtime.getMessages().expectedString)
32
- ])
33
- };
34
- }
35
- // Check if it's a valid hex string
36
- if (!VldHex.HEX_REGEX.test(value)) {
37
- return {
38
- success: false,
39
- error: new errorsCore.VldError([
40
- errors.createIssue('custom', [], locales_runtime.getMessages().invalidHex)
41
- ])
42
- };
43
- }
44
- // Check if even length (full bytes)
45
- if (value.length % 2 !== 0) {
46
- return {
47
- success: false,
48
- error: new errorsCore.VldError([
49
- errors.createIssue('custom', [], locales_runtime.getMessages().invalidHex)
50
- ])
51
- };
52
- }
53
- // Normalize case if required
54
- const normalizedValue = this.lowercase ? value.toLowerCase() : value;
55
- return { success: true, data: normalizedValue };
56
- }
57
- /**
58
- * Require lowercase hex characters
59
- */
60
- lowercaseMode() {
61
- return new VldHex(true);
62
- }
63
- static create(lowercase = false) {
64
- return new VldHex(lowercase);
65
- }
66
- }
67
- // BUG-008 FIX: Use * instead of + to allow empty hex strings (consistent with base64 validator)
68
- VldHex.HEX_REGEX = /^[0-9a-fA-F]*$/;
69
-
70
- exports.VldHex = VldHex;
1
+ "use strict";var e=require("./base.cjs"),r=require("../errors.cjs"),s=require("../locales/runtime.cjs"),t=require("../chunks/errors-core-DKPohm9I.cjs");require("../registry.cjs"),require("../pigment.cjs"),require("../locales/en.cjs");class VldHex extends e.VldBase{constructor(r=!1){super(e.VLD_VALIDATOR_TYPES.HEX),this.lowercase=r}parse(e){const r=this.safeParse(e);if(!r.success)throw r.error;return r.data}safeParse(e){if("string"!=typeof e)return{success:!1,error:new t.VldError([r.createIssue("invalid_type",[],s.getMessages().expectedString)])};if(!VldHex.HEX_REGEX.test(e))return{success:!1,error:new t.VldError([r.createIssue("custom",[],s.getMessages().invalidHex)])};if(e.length%2!=0)return{success:!1,error:new t.VldError([r.createIssue("custom",[],s.getMessages().invalidHex)])};return{success:!0,data:this.lowercase?e.toLowerCase():e}}lowercaseMode(){return new VldHex(!0)}static create(e=!1){return new VldHex(e)}}VldHex.HEX_REGEX=/^[0-9a-fA-F]*$/,exports.VldHex=VldHex;
@@ -1,123 +1 @@
1
- 'use strict';
2
-
3
- var validators_base = require('./base.cjs');
4
- var validators_string = require('../chunks/string-BKZrc4hs.cjs');
5
- var validators_number = require('./number.cjs');
6
- var validators_boolean = require('./boolean.cjs');
7
- var validators_date = require('./date.cjs');
8
- var validators_stringBool = require('./string-bool.cjs');
9
- var validators_array = require('./array.cjs');
10
- var validators_object = require('./object.cjs');
11
- var validators_union = require('./union.cjs');
12
- var validators_intersection = require('./intersection.cjs');
13
- var validators_literal = require('./literal.cjs');
14
- var validators_enum = require('./enum.cjs');
15
- var validators_tuple = require('./tuple.cjs');
16
- var validators_record = require('./record.cjs');
17
- var validators_set = require('./set.cjs');
18
- var validators_map = require('./map.cjs');
19
- var validators_bigint = require('./bigint.cjs');
20
- var validators_symbol = require('./symbol.cjs');
21
- var validators_any = require('./any.cjs');
22
- var validators_unknown = require('./unknown.cjs');
23
- var validators_void = require('./void.cjs');
24
- var validators_never = require('./never.cjs');
25
- var validators_null = require('./null.cjs');
26
- var validators_undefined = require('./undefined.cjs');
27
- var validators_nan = require('./nan.cjs');
28
- var validators_lazy = require('./lazy.cjs');
29
- var validators_discriminatedUnion = require('./discriminated-union.cjs');
30
- var validators_xor = require('./xor.cjs');
31
- var validators_json = require('./json.cjs');
32
- var validators_templateLiteral = require('./template-literal.cjs');
33
- var validators_custom = require('./custom.cjs');
34
- var validators_file = require('./file.cjs');
35
- var validators_function = require('./function.cjs');
36
- var validators_promise = require('./promise.cjs');
37
- var validators_stringFormats = require('./string-formats.cjs');
38
- require('../registry.cjs');
39
- require('../locales/runtime.cjs');
40
- require('../locales/en.cjs');
41
- require('../chunks/errors-core-DWxLFs2f.cjs');
42
- require('../chunks/security-Dc3Jh13T.cjs');
43
-
44
-
45
-
46
- exports.VldBase = validators_base.VldBase;
47
- exports.VldBrand = validators_base.VldBrand;
48
- exports.VldCatch = validators_base.VldCatch;
49
- exports.VldDefault = validators_base.VldDefault;
50
- exports.VldExactOptional = validators_base.VldExactOptional;
51
- exports.VldNullable = validators_base.VldNullable;
52
- exports.VldNullish = validators_base.VldNullish;
53
- exports.VldOptional = validators_base.VldOptional;
54
- exports.VldPipe = validators_base.VldPipe;
55
- exports.VldPreprocess = validators_base.VldPreprocess;
56
- exports.VldReadonly = validators_base.VldReadonly;
57
- exports.VldRefine = validators_base.VldRefine;
58
- exports.VldSuperRefine = validators_base.VldSuperRefine;
59
- exports.VldTransform = validators_base.VldTransform;
60
- exports.VldString = validators_string.VldString;
61
- exports.VldNumber = validators_number.VldNumber;
62
- exports.VldBoolean = validators_boolean.VldBoolean;
63
- exports.VldDate = validators_date.VldDate;
64
- exports.VldStringBool = validators_stringBool.VldStringBool;
65
- exports.VldArray = validators_array.VldArray;
66
- exports.VldObject = validators_object.VldObject;
67
- exports.VldUnion = validators_union.VldUnion;
68
- exports.VldIntersection = validators_intersection.VldIntersection;
69
- exports.VldLiteral = validators_literal.VldLiteral;
70
- exports.VldEnum = validators_enum.VldEnum;
71
- exports.VldTuple = validators_tuple.VldTuple;
72
- exports.VldRecord = validators_record.VldRecord;
73
- exports.VldSet = validators_set.VldSet;
74
- exports.VldMap = validators_map.VldMap;
75
- exports.VldBigInt = validators_bigint.VldBigInt;
76
- exports.VldSymbol = validators_symbol.VldSymbol;
77
- exports.VldAny = validators_any.VldAny;
78
- exports.VldUnknown = validators_unknown.VldUnknown;
79
- exports.VldVoid = validators_void.VldVoid;
80
- exports.VldNever = validators_never.VldNever;
81
- exports.VldNull = validators_null.VldNull;
82
- exports.VldUndefined = validators_undefined.VldUndefined;
83
- exports.VldNan = validators_nan.VldNan;
84
- exports.VldLazy = validators_lazy.VldLazy;
85
- exports.VldDiscriminatedUnion = validators_discriminatedUnion.VldDiscriminatedUnion;
86
- exports.VldXor = validators_xor.VldXor;
87
- exports.VldJson = validators_json.VldJson;
88
- exports.VldTemplateLiteral = validators_templateLiteral.VldTemplateLiteral;
89
- exports.templateLiteral = validators_templateLiteral.templateLiteral;
90
- exports.VldCustom = validators_custom.VldCustom;
91
- exports.custom = validators_custom.custom;
92
- exports.VldFile = validators_file.VldFile;
93
- exports.file = validators_file.file;
94
- exports.VldFunction = validators_function.VldFunction;
95
- exports.functionValidator = validators_function.functionValidator;
96
- exports.VldPromise = validators_promise.VldPromise;
97
- exports.promise = validators_promise.promise;
98
- exports.base64 = validators_stringFormats.base64;
99
- exports.base64url = validators_stringFormats.base64url;
100
- exports.cidrv4 = validators_stringFormats.cidrv4;
101
- exports.cidrv6 = validators_stringFormats.cidrv6;
102
- exports.cuid = validators_stringFormats.cuid;
103
- exports.cuid2 = validators_stringFormats.cuid2;
104
- exports.e164 = validators_stringFormats.e164;
105
- exports.email = validators_stringFormats.email;
106
- exports.emoji = validators_stringFormats.emoji;
107
- exports.guid = validators_stringFormats.guid;
108
- exports.hash = validators_stringFormats.hash;
109
- exports.hex = validators_stringFormats.hex;
110
- exports.hostname = validators_stringFormats.hostname;
111
- exports.httpUrl = validators_stringFormats.httpUrl;
112
- exports.ipv4 = validators_stringFormats.ipv4;
113
- exports.ipv6 = validators_stringFormats.ipv6;
114
- exports.iso = validators_stringFormats.iso;
115
- exports.jwt = validators_stringFormats.jwt;
116
- exports.mac = validators_stringFormats.mac;
117
- exports.nanoid = validators_stringFormats.nanoid;
118
- exports.regexes = validators_stringFormats.regexes;
119
- exports.stringFormat = validators_stringFormats.stringFormat;
120
- exports.ulid = validators_stringFormats.ulid;
121
- exports.uuid = validators_stringFormats.uuid;
122
- exports.uuidv4 = validators_stringFormats.uuidv4;
123
- exports.xid = validators_stringFormats.xid;
1
+ "use strict";var e=require("./base.cjs"),r=require("./string.cjs"),s=require("./number.cjs"),l=require("./boolean.cjs"),t=require("./date.cjs"),o=require("./string-bool.cjs"),i=require("./array.cjs"),d=require("./object.cjs"),p=require("./union.cjs"),u=require("./intersection.cjs"),n=require("./literal.cjs"),V=require("./enum.cjs"),x=require("./tuple.cjs"),c=require("./record.cjs"),a=require("./set.cjs"),j=require("./map.cjs"),m=require("./bigint.cjs"),q=require("./symbol.cjs"),v=require("./any.cjs"),b=require("./unknown.cjs"),f=require("./void.cjs"),g=require("./never.cjs"),h=require("./null.cjs"),y=require("./undefined.cjs"),N=require("./nan.cjs"),B=require("./lazy.cjs"),S=require("./discriminated-union.cjs"),U=require("./xor.cjs"),k=require("./json.cjs"),L=require("./template-literal.cjs"),R=require("./custom.cjs"),D=require("./file.cjs"),F=require("./function.cjs"),O=require("./promise.cjs"),P=require("./string-formats.cjs");require("../registry.cjs"),require("../locales/runtime.cjs"),require("../locales/en.cjs"),require("../chunks/ip-validation-BZqPamPC.cjs"),require("../chunks/errors-core-DKPohm9I.cjs"),require("../chunks/security-aXZVI7qW.cjs"),exports.VldBase=e.VldBase,exports.VldBrand=e.VldBrand,exports.VldCatch=e.VldCatch,exports.VldDefault=e.VldDefault,exports.VldExactOptional=e.VldExactOptional,exports.VldNullable=e.VldNullable,exports.VldNullish=e.VldNullish,exports.VldOptional=e.VldOptional,exports.VldPipe=e.VldPipe,exports.VldPreprocess=e.VldPreprocess,exports.VldReadonly=e.VldReadonly,exports.VldRefine=e.VldRefine,exports.VldSuperRefine=e.VldSuperRefine,exports.VldTransform=e.VldTransform,exports.VldString=r.VldString,exports.VldNumber=s.VldNumber,exports.VldBoolean=l.VldBoolean,exports.VldDate=t.VldDate,exports.VldStringBool=o.VldStringBool,exports.VldArray=i.VldArray,exports.VldObject=d.VldObject,exports.VldUnion=p.VldUnion,exports.VldIntersection=u.VldIntersection,exports.VldLiteral=n.VldLiteral,exports.VldEnum=V.VldEnum,exports.VldTuple=x.VldTuple,exports.VldRecord=c.VldRecord,exports.VldSet=a.VldSet,exports.VldMap=j.VldMap,exports.VldBigInt=m.VldBigInt,exports.VldSymbol=q.VldSymbol,exports.VldAny=v.VldAny,exports.VldUnknown=b.VldUnknown,exports.VldVoid=f.VldVoid,exports.VldNever=g.VldNever,exports.VldNull=h.VldNull,exports.VldUndefined=y.VldUndefined,exports.VldNan=N.VldNan,exports.VldLazy=B.VldLazy,exports.VldDiscriminatedUnion=S.VldDiscriminatedUnion,exports.VldXor=U.VldXor,exports.VldJson=k.VldJson,exports.VldTemplateLiteral=L.VldTemplateLiteral,exports.templateLiteral=L.templateLiteral,exports.VldCustom=R.VldCustom,exports.custom=R.custom,exports.VldFile=D.VldFile,exports.file=D.file,exports.VldFunction=F.VldFunction,exports.functionValidator=F.functionValidator,exports.VldPromise=O.VldPromise,exports.promise=O.promise,exports.base64=P.base64,exports.base64url=P.base64url,exports.cidrv4=P.cidrv4,exports.cidrv6=P.cidrv6,exports.cuid=P.cuid,exports.cuid2=P.cuid2,exports.e164=P.e164,exports.email=P.email,exports.emoji=P.emoji,exports.guid=P.guid,exports.hash=P.hash,exports.hex=P.hex,exports.hostname=P.hostname,exports.httpUrl=P.httpUrl,exports.ipv4=P.ipv4,exports.ipv6=P.ipv6,exports.iso=P.iso,exports.jwt=P.jwt,exports.ksuid=P.ksuid,exports.mac=P.mac,exports.nanoid=P.nanoid,exports.regexes=P.regexes,exports.stringFormat=P.stringFormat,exports.ulid=P.ulid,exports.url=P.url,exports.uuid=P.uuid,exports.uuidv4=P.uuidv4,exports.uuidv6=P.uuidv6,exports.uuidv7=P.uuidv7,exports.xid=P.xid;
@@ -1,120 +1 @@
1
- 'use strict';
2
-
3
- var validators_base = require('./base.cjs');
4
- var security = require('../chunks/security-Dc3Jh13T.cjs');
5
- var locales_runtime = require('../locales/runtime.cjs');
6
- var errorsCore = require('../chunks/errors-core-DWxLFs2f.cjs');
7
- require('../registry.cjs');
8
- require('../locales/en.cjs');
9
-
10
- /**
11
- * Type guard to check if a value is a plain object
12
- */
13
- function isPlainObject(obj) {
14
- return (obj !== null &&
15
- typeof obj === 'object' &&
16
- obj.constructor === Object &&
17
- Object.prototype.toString.call(obj) === '[object Object]');
18
- }
19
- /**
20
- * Safely deep merge two objects without prototype pollution vulnerability
21
- * Optimized for performance with minimal object allocations
22
- * BUG-NEW-020 FIX: Use comprehensive dangerous key protection from shared utility
23
- * @param target The target object
24
- * @param source The source object to merge from
25
- * @returns A new merged object
26
- */
27
- function deepMerge(target, source) {
28
- // Create a new object to avoid mutations (only once)
29
- const result = { ...target };
30
- // Get source keys directly for better performance
31
- const sourceKeys = Object.keys(source);
32
- for (let i = 0; i < sourceKeys.length; i++) {
33
- const key = sourceKeys[i];
34
- // Skip dangerous keys that could lead to prototype pollution
35
- if (security.isDangerousKey(key)) {
36
- continue;
37
- }
38
- // Only process own properties (redundant with Object.keys but safe)
39
- if (!Object.prototype.hasOwnProperty.call(source, key)) {
40
- continue;
41
- }
42
- const sourceValue = source[key];
43
- const targetValue = target[key];
44
- // If both values are plain objects, merge them recursively
45
- if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {
46
- result[key] = deepMerge(targetValue, sourceValue);
47
- }
48
- else {
49
- // Otherwise, use the source value (including undefined)
50
- result[key] = sourceValue;
51
- }
52
- }
53
- return result;
54
- }
55
-
56
- function createIntersectionError(message) {
57
- return new errorsCore.VldError([{ code: 'invalid_type', path: [], message }]);
58
- }
59
- /**
60
- * Immutable intersection validator for combining validators
61
- */
62
- class VldIntersection extends validators_base.VldBase {
63
- /**
64
- * Private constructor to enforce immutability
65
- */
66
- constructor(validatorA, validatorB) {
67
- super(validators_base.VLD_VALIDATOR_TYPES.INTERSECTION);
68
- this.validatorA = validatorA;
69
- this.validatorB = validatorB;
70
- }
71
- /**
72
- * Create a new intersection validator
73
- */
74
- static create(validatorA, validatorB) {
75
- return new VldIntersection(validatorA, validatorB);
76
- }
77
- /**
78
- * Parse and validate a value against both validators
79
- */
80
- parse(value) {
81
- try {
82
- // Both validators must pass
83
- const resultA = this.validatorA.parse(value);
84
- const resultB = this.validatorB.parse(value);
85
- // BUG-NEW-015 FIX: Check type consistency before merging
86
- const aIsObject = isPlainObject(resultA);
87
- const bIsObject = isPlainObject(resultB);
88
- // Both are objects - safe to merge
89
- if (aIsObject && bIsObject) {
90
- return deepMerge(resultA, resultB);
91
- }
92
- // Neither are objects - must be identical primitives
93
- if (!aIsObject && !bIsObject) {
94
- if (resultA === resultB) {
95
- return resultA;
96
- }
97
- throw new Error('Values must be identical for intersection of primitive types');
98
- }
99
- // One is object, one is primitive - invalid intersection
100
- throw new Error('Cannot create intersection of object and primitive types. ' +
101
- 'Both validators must produce the same type category.');
102
- }
103
- catch (error) {
104
- throw new Error(locales_runtime.getMessages().intersectionError(error.message));
105
- }
106
- }
107
- /**
108
- * Safely parse and validate a value against both validators
109
- */
110
- safeParse(value) {
111
- try {
112
- return { success: true, data: this.parse(value) };
113
- }
114
- catch (error) {
115
- return { success: false, error: createIntersectionError(error.message) };
116
- }
117
- }
118
- }
119
-
120
- exports.VldIntersection = VldIntersection;
1
+ "use strict";var e=require("./base.cjs"),r=require("../chunks/security-aXZVI7qW.cjs"),t=require("../locales/runtime.cjs"),s=require("../chunks/errors-core-DKPohm9I.cjs");function c(e){return null!==e&&"object"==typeof e&&e.constructor===Object&&"[object Object]"===Object.prototype.toString.call(e)}function o(e,t){const s={...e},n=Object.keys(t);for(let i=0;i<n.length;i++){const a=n[i];if(r.isDangerousKey(a))continue;if(!Object.prototype.hasOwnProperty.call(t,a))continue;const u=t[a],l=e[a];c(u)&&c(l)?s[a]=o(l,u):s[a]=u}return s}require("../registry.cjs"),require("../locales/en.cjs");class VldIntersection extends e.VldBase{constructor(r,t){super(e.VLD_VALIDATOR_TYPES.INTERSECTION),this.validatorA=r,this.validatorB=t}static create(e,r){return new VldIntersection(e,r)}parse(e){try{const r=this.validatorA.parse(e),t=this.validatorB.parse(e),s=c(r),n=c(t);if(s&&n)return o(r,t);if(!s&&!n){if(r===t)return r;throw new Error("Values must be identical for intersection of primitive types")}throw new Error("Cannot create intersection of object and primitive types. Both validators must produce the same type category.")}catch(e){throw new Error(t.getMessages().intersectionError(e.message))}}safeParse(e){try{return{success:!0,data:this.parse(e)}}catch(e){return{success:!1,error:(r=e.message,new s.VldError([{code:"invalid_type",path:[],message:r}]))}}var r}}exports.VldIntersection=VldIntersection;
@@ -1,70 +1 @@
1
- 'use strict';
2
-
3
- var validators_base = require('./base.cjs');
4
- var locales_runtime = require('../locales/runtime.cjs');
5
- require('../registry.cjs');
6
- require('../locales/en.cjs');
7
-
8
- /**
9
- * Immutable JSON validator that validates and parses JSON strings
10
- * Accepts both strings (which are parsed) and already-parsed objects
11
- */
12
- class VldJson extends validators_base.VldBase {
13
- constructor(schema) {
14
- super(validators_base.VLD_VALIDATOR_TYPES.JSON);
15
- this.schema = schema;
16
- }
17
- /**
18
- * Create a new JSON validator
19
- */
20
- static create(schema) {
21
- return new VldJson(schema);
22
- }
23
- /**
24
- * Parse and validate a JSON value
25
- */
26
- parse(value) {
27
- let parsed;
28
- // If it's a string, try to parse it as JSON first
29
- if (typeof value === 'string') {
30
- try {
31
- parsed = JSON.parse(value);
32
- }
33
- catch {
34
- throw new Error(locales_runtime.getMessages().invalidJson);
35
- }
36
- }
37
- else {
38
- // Not a string - assume it's already parsed
39
- parsed = value;
40
- }
41
- // If we have a schema, validate against it
42
- if (this.schema) {
43
- return this.schema.parse(parsed);
44
- }
45
- // No schema - just return the parsed value
46
- return parsed;
47
- }
48
- /**
49
- * Safely parse and validate a JSON value
50
- */
51
- safeParse(value) {
52
- try {
53
- return { success: true, data: this.parse(value) };
54
- }
55
- catch (error) {
56
- return {
57
- success: false,
58
- error: error
59
- };
60
- }
61
- }
62
- /**
63
- * Create a new JSON validator with a schema for validation
64
- */
65
- withSchema(schema) {
66
- return new VldJson(schema);
67
- }
68
- }
69
-
70
- exports.VldJson = VldJson;
1
+ "use strict";var e=require("./base.cjs"),s=require("../locales/runtime.cjs");require("../registry.cjs"),require("../locales/en.cjs");class VldJson extends e.VldBase{constructor(s){super(e.VLD_VALIDATOR_TYPES.JSON),this.schema=s}static create(e){return new VldJson(e)}parse(e){let r;if("string"==typeof e)try{r=JSON.parse(e)}catch{throw new Error(s.getMessages().invalidJson)}else r=e;return this.schema?this.schema.parse(r):r}safeParse(e){try{return{success:!0,data:this.parse(e)}}catch(e){return{success:!1,error:e}}}withSchema(e){return new VldJson(e)}}exports.VldJson=VldJson;
@@ -1,53 +1 @@
1
- 'use strict';
2
-
3
- var validators_base = require('./base.cjs');
4
- require('../registry.cjs');
5
-
6
- /**
7
- * VldLazy - Lazy evaluation for recursive schemas
8
- * Part of Zod 4 API parity implementation
9
- * Allows schemas that reference themselves (e.g., tree structures, nested categories)
10
- */
11
- /**
12
- * Lazy validator - defers schema evaluation until runtime
13
- * Essential for recursive and self-referencing types
14
- *
15
- * Caches the resolved schema after first use. This keeps recursive schemas stable
16
- * and avoids re-running the schema getter on hot parse paths.
17
- */
18
- class VldLazy extends validators_base.VldBase {
19
- constructor(_schemaGetter) {
20
- super(validators_base.VLD_VALIDATOR_TYPES.LAZY);
21
- this._schemaGetter = _schemaGetter;
22
- this._cachedSchema = null;
23
- }
24
- static create(schemaGetter) {
25
- return new VldLazy(schemaGetter);
26
- }
27
- /**
28
- * Get the actual schema, caching it after first retrieval
29
- */
30
- _getSchema() {
31
- if (this._cachedSchema) {
32
- return this._cachedSchema;
33
- }
34
- const schema = this._schemaGetter();
35
- this._cachedSchema = schema;
36
- return schema;
37
- }
38
- /**
39
- * Get the inner schema (unwrap)
40
- * Returns a strong reference that will keep the schema alive
41
- */
42
- unwrap() {
43
- return this._getSchema();
44
- }
45
- parse(value) {
46
- return this._getSchema().parse(value);
47
- }
48
- safeParse(value) {
49
- return this._getSchema().safeParse(value);
50
- }
51
- }
52
-
53
- exports.VldLazy = VldLazy;
1
+ "use strict";var e=require("./base.cjs");require("../registry.cjs");class VldLazy extends e.VldBase{constructor(t){super(e.VLD_VALIDATOR_TYPES.LAZY),this._schemaGetter=t,this._cachedSchema=null}static create(e){return new VldLazy(e)}_getSchema(){if(this._cachedSchema)return this._cachedSchema;const e=this._schemaGetter();return this._cachedSchema=e,e}unwrap(){return this._getSchema()}parse(e){return this._getSchema().parse(e)}safeParse(e){return this._getSchema().safeParse(e)}}exports.VldLazy=VldLazy;