zod 3.24.0 → 3.24.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/lib/types.js CHANGED
@@ -84,40 +84,6 @@ function processCreateParams(params) {
84
84
  return { errorMap: customMap, description };
85
85
  }
86
86
  class ZodType {
87
- constructor(def) {
88
- /** Alias of safeParseAsync */
89
- this.spa = this.safeParseAsync;
90
- this._def = def;
91
- this.parse = this.parse.bind(this);
92
- this.safeParse = this.safeParse.bind(this);
93
- this.parseAsync = this.parseAsync.bind(this);
94
- this.safeParseAsync = this.safeParseAsync.bind(this);
95
- this.spa = this.spa.bind(this);
96
- this.refine = this.refine.bind(this);
97
- this.refinement = this.refinement.bind(this);
98
- this.superRefine = this.superRefine.bind(this);
99
- this.optional = this.optional.bind(this);
100
- this.nullable = this.nullable.bind(this);
101
- this.nullish = this.nullish.bind(this);
102
- this.array = this.array.bind(this);
103
- this.promise = this.promise.bind(this);
104
- this.or = this.or.bind(this);
105
- this.and = this.and.bind(this);
106
- this.transform = this.transform.bind(this);
107
- this.brand = this.brand.bind(this);
108
- this.default = this.default.bind(this);
109
- this.catch = this.catch.bind(this);
110
- this.describe = this.describe.bind(this);
111
- this.pipe = this.pipe.bind(this);
112
- this.readonly = this.readonly.bind(this);
113
- this.isNullable = this.isNullable.bind(this);
114
- this.isOptional = this.isOptional.bind(this);
115
- this["~standard"] = {
116
- version: 1,
117
- vendor: "zod",
118
- validate: (data) => this["~validate"](data),
119
- };
120
- }
121
87
  get description() {
122
88
  return this._def.description;
123
89
  }
@@ -182,7 +148,7 @@ class ZodType {
182
148
  return handleResult(ctx, result);
183
149
  }
184
150
  "~validate"(data) {
185
- var _a, _b, _c;
151
+ var _a, _b;
186
152
  const ctx = {
187
153
  common: {
188
154
  issues: [],
@@ -206,7 +172,7 @@ class ZodType {
206
172
  };
207
173
  }
208
174
  catch (err) {
209
- if ((_c = (_b = (_a = err) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === null || _c === void 0 ? void 0 : _c.includes("encountered")) {
175
+ if ((_b = (_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes("encountered")) {
210
176
  this["~standard"].async = true;
211
177
  }
212
178
  ctx.common = {
@@ -309,6 +275,40 @@ class ZodType {
309
275
  superRefine(refinement) {
310
276
  return this._refinement(refinement);
311
277
  }
278
+ constructor(def) {
279
+ /** Alias of safeParseAsync */
280
+ this.spa = this.safeParseAsync;
281
+ this._def = def;
282
+ this.parse = this.parse.bind(this);
283
+ this.safeParse = this.safeParse.bind(this);
284
+ this.parseAsync = this.parseAsync.bind(this);
285
+ this.safeParseAsync = this.safeParseAsync.bind(this);
286
+ this.spa = this.spa.bind(this);
287
+ this.refine = this.refine.bind(this);
288
+ this.refinement = this.refinement.bind(this);
289
+ this.superRefine = this.superRefine.bind(this);
290
+ this.optional = this.optional.bind(this);
291
+ this.nullable = this.nullable.bind(this);
292
+ this.nullish = this.nullish.bind(this);
293
+ this.array = this.array.bind(this);
294
+ this.promise = this.promise.bind(this);
295
+ this.or = this.or.bind(this);
296
+ this.and = this.and.bind(this);
297
+ this.transform = this.transform.bind(this);
298
+ this.brand = this.brand.bind(this);
299
+ this.default = this.default.bind(this);
300
+ this.catch = this.catch.bind(this);
301
+ this.describe = this.describe.bind(this);
302
+ this.pipe = this.pipe.bind(this);
303
+ this.readonly = this.readonly.bind(this);
304
+ this.isNullable = this.isNullable.bind(this);
305
+ this.isOptional = this.isOptional.bind(this);
306
+ this["~standard"] = {
307
+ version: 1,
308
+ vendor: "zod",
309
+ validate: (data) => this["~validate"](data),
310
+ };
311
+ }
312
312
  optional() {
313
313
  return ZodOptional.create(this, this._def);
314
314
  }
@@ -870,7 +870,10 @@ class ZodString extends ZodType {
870
870
  }
871
871
  base64url(message) {
872
872
  // base64url encoding is a modification of base64 that can safely be used in URLs and filenames
873
- return this._addCheck({ kind: "base64url", ...errorUtil_1.errorUtil.errToObj(message) });
873
+ return this._addCheck({
874
+ kind: "base64url",
875
+ ...errorUtil_1.errorUtil.errToObj(message),
876
+ });
874
877
  }
875
878
  jwt(options) {
876
879
  return this._addCheck({ kind: "jwt", ...errorUtil_1.errorUtil.errToObj(options) });
@@ -971,8 +974,7 @@ class ZodString extends ZodType {
971
974
  });
972
975
  }
973
976
  /**
974
- * @deprecated Use z.string().min(1) instead.
975
- * @see {@link ZodString.min}
977
+ * Equivalent to `.min(1)`
976
978
  */
977
979
  nonempty(message) {
978
980
  return this.min(1, errorUtil_1.errorUtil.errToObj(message));
@@ -3722,7 +3724,7 @@ var ZodFirstPartyTypeKind;
3722
3724
  ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
3723
3725
  ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
3724
3726
  ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly";
3725
- })(ZodFirstPartyTypeKind = exports.ZodFirstPartyTypeKind || (exports.ZodFirstPartyTypeKind = {}));
3727
+ })(ZodFirstPartyTypeKind || (exports.ZodFirstPartyTypeKind = ZodFirstPartyTypeKind = {}));
3726
3728
  // requires TS 4.4+
3727
3729
  class Class {
3728
3730
  constructor(..._) { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod",
3
- "version": "3.24.0",
3
+ "version": "3.24.1",
4
4
  "author": "Colin McDonnell <colin@colinhacks.com>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -44,7 +44,7 @@
44
44
  "ts-node": "^10.9.1",
45
45
  "tslib": "^2.3.1",
46
46
  "tsx": "^3.8.0",
47
- "typescript": "~4.5.5",
47
+ "typescript": "^5.0.0",
48
48
  "vitest": "^0.32.2"
49
49
  },
50
50
  "exports": {