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.
@@ -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
- const Parent = params?.Parent ?? Object;
8
- class _ extends Parent {
9
- constructor(def) {
10
- var _a;
11
- super();
12
- const th = this;
13
- _.init(th, def);
14
- (_a = th._zod).deferred ?? (_a.deferred = []);
15
- for (const fn of th._zod.deferred) {
16
- fn();
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
- static init(inst, def) {
20
- var _a;
21
- Object.defineProperty(inst, "_zod", {
22
- value: inst._zod ?? {},
23
- enumerable: false,
24
- });
25
- // inst._zod ??= {} as any;
26
- (_a = inst._zod).traits ?? (_a.traits = new Set());
27
- // const seen = inst._zod.traits.has(name);
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
- static [Symbol.hasInstance](inst) {
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
  }
@@ -1,40 +1,48 @@
1
1
  export /*@__NO_SIDE_EFFECTS__*/ function $constructor(name, initializer, params) {
2
- const Parent = params?.Parent ?? Object;
3
- class _ extends Parent {
4
- constructor(def) {
5
- var _a;
6
- super();
7
- const th = this;
8
- _.init(th, def);
9
- (_a = th._zod).deferred ?? (_a.deferred = []);
10
- for (const fn of th._zod.deferred) {
11
- fn();
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
- static init(inst, def) {
15
- var _a;
16
- Object.defineProperty(inst, "_zod", {
17
- value: inst._zod ?? {},
18
- enumerable: false,
19
- });
20
- // inst._zod ??= {} as any;
21
- (_a = inst._zod).traits ?? (_a.traits = new Set());
22
- // const seen = inst._zod.traits.has(name);
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
- static [Symbol.hasInstance](inst) {
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod",
3
- "version": "3.25.23",
3
+ "version": "3.25.24-beta.1",
4
4
  "type": "module",
5
5
  "author": "Colin McDonnell <zod@colinhacks.com>",
6
6
  "description": "TypeScript-first schema declaration and validation library with static type inference",