zod 3.25.23 → 3.25.24-beta.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.
- package/dist/cjs/v4/core/core.js +39 -31
- package/dist/esm/v4/core/core.js +39 -31
- package/package.json +1 -1
package/dist/cjs/v4/core/core.js
CHANGED
|
@@ -4,42 +4,50 @@ exports.globalConfig = exports.$ZodAsyncError = exports.$brand = void 0;
|
|
|
4
4
|
exports.$constructor = $constructor;
|
|
5
5
|
exports.config = config;
|
|
6
6
|
function $constructor(name, initializer, params) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
function init(inst, def) {
|
|
8
|
+
var _a;
|
|
9
|
+
Object.defineProperty(inst, "_zod", {
|
|
10
|
+
value: inst._zod ?? {},
|
|
11
|
+
enumerable: false,
|
|
12
|
+
});
|
|
13
|
+
// inst._zod ??= {} as any;a
|
|
14
|
+
(_a = inst._zod).traits ?? (_a.traits = new Set());
|
|
15
|
+
// const seen = inst._zod.traits.has(name);
|
|
16
|
+
inst._zod.traits.add(name);
|
|
17
|
+
initializer(inst, def);
|
|
18
|
+
// support prototype modifications
|
|
19
|
+
for (const k in _.prototype) {
|
|
20
|
+
Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
|
|
18
21
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
inst._zod.traits.add(name);
|
|
29
|
-
initializer(inst, def);
|
|
30
|
-
// support prototype modifications
|
|
31
|
-
for (const k in _.prototype) {
|
|
32
|
-
Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
|
|
33
|
-
}
|
|
34
|
-
inst._zod.constr = _;
|
|
35
|
-
inst._zod.def = def;
|
|
22
|
+
inst._zod.constr = _;
|
|
23
|
+
inst._zod.def = def;
|
|
24
|
+
}
|
|
25
|
+
function construct(instance, def) {
|
|
26
|
+
var _a;
|
|
27
|
+
init(instance, def);
|
|
28
|
+
(_a = instance._zod).deferred ?? (_a.deferred = []);
|
|
29
|
+
for (const fn of instance._zod.deferred) {
|
|
30
|
+
fn();
|
|
36
31
|
}
|
|
37
|
-
|
|
32
|
+
return instance;
|
|
33
|
+
}
|
|
34
|
+
const Parent = params?.Parent ?? Object;
|
|
35
|
+
class Definition extends Parent {
|
|
36
|
+
}
|
|
37
|
+
function _(def) {
|
|
38
|
+
if (params?.Parent) {
|
|
39
|
+
return construct(new Definition(), def);
|
|
40
|
+
}
|
|
41
|
+
return construct(this, def);
|
|
42
|
+
}
|
|
43
|
+
Object.defineProperty(_, "init", { value: init });
|
|
44
|
+
Object.defineProperty(_, Symbol.hasInstance, {
|
|
45
|
+
value: (inst) => {
|
|
38
46
|
if (params?.Parent && inst instanceof params.Parent)
|
|
39
47
|
return true;
|
|
40
48
|
return inst?._zod?.traits?.has(name);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
49
|
+
},
|
|
50
|
+
});
|
|
43
51
|
Object.defineProperty(_, "name", { value: name });
|
|
44
52
|
return _;
|
|
45
53
|
}
|
package/dist/esm/v4/core/core.js
CHANGED
|
@@ -1,40 +1,48 @@
|
|
|
1
1
|
export /*@__NO_SIDE_EFFECTS__*/ function $constructor(name, initializer, params) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
function init(inst, def) {
|
|
3
|
+
var _a;
|
|
4
|
+
Object.defineProperty(inst, "_zod", {
|
|
5
|
+
value: inst._zod ?? {},
|
|
6
|
+
enumerable: false,
|
|
7
|
+
});
|
|
8
|
+
// inst._zod ??= {} as any;a
|
|
9
|
+
(_a = inst._zod).traits ?? (_a.traits = new Set());
|
|
10
|
+
// const seen = inst._zod.traits.has(name);
|
|
11
|
+
inst._zod.traits.add(name);
|
|
12
|
+
initializer(inst, def);
|
|
13
|
+
// support prototype modifications
|
|
14
|
+
for (const k in _.prototype) {
|
|
15
|
+
Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
|
|
13
16
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
inst._zod.traits.add(name);
|
|
24
|
-
initializer(inst, def);
|
|
25
|
-
// support prototype modifications
|
|
26
|
-
for (const k in _.prototype) {
|
|
27
|
-
Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
|
|
28
|
-
}
|
|
29
|
-
inst._zod.constr = _;
|
|
30
|
-
inst._zod.def = def;
|
|
17
|
+
inst._zod.constr = _;
|
|
18
|
+
inst._zod.def = def;
|
|
19
|
+
}
|
|
20
|
+
function construct(instance, def) {
|
|
21
|
+
var _a;
|
|
22
|
+
init(instance, def);
|
|
23
|
+
(_a = instance._zod).deferred ?? (_a.deferred = []);
|
|
24
|
+
for (const fn of instance._zod.deferred) {
|
|
25
|
+
fn();
|
|
31
26
|
}
|
|
32
|
-
|
|
27
|
+
return instance;
|
|
28
|
+
}
|
|
29
|
+
const Parent = params?.Parent ?? Object;
|
|
30
|
+
class Definition extends Parent {
|
|
31
|
+
}
|
|
32
|
+
function _(def) {
|
|
33
|
+
if (params?.Parent) {
|
|
34
|
+
return construct(new Definition(), def);
|
|
35
|
+
}
|
|
36
|
+
return construct(this, def);
|
|
37
|
+
}
|
|
38
|
+
Object.defineProperty(_, "init", { value: init });
|
|
39
|
+
Object.defineProperty(_, Symbol.hasInstance, {
|
|
40
|
+
value: (inst) => {
|
|
33
41
|
if (params?.Parent && inst instanceof params.Parent)
|
|
34
42
|
return true;
|
|
35
43
|
return inst?._zod?.traits?.has(name);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
44
|
+
},
|
|
45
|
+
});
|
|
38
46
|
Object.defineProperty(_, "name", { value: name });
|
|
39
47
|
return _;
|
|
40
48
|
}
|
package/package.json
CHANGED