zod 3.12.1 → 3.13.0
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 +5 -5
- package/lib/ZodError.d.ts +0 -1
- package/lib/ZodError.js +0 -1
- package/lib/benchmarks/discriminatedUnion.d.ts +0 -1
- package/lib/benchmarks/discriminatedUnion.js +0 -1
- package/lib/benchmarks/index.d.ts +0 -1
- package/lib/benchmarks/index.js +0 -1
- package/lib/benchmarks/object.d.ts +0 -1
- package/lib/benchmarks/object.js +0 -1
- package/lib/benchmarks/string.d.ts +0 -1
- package/lib/benchmarks/string.js +0 -1
- package/lib/benchmarks/union.d.ts +0 -1
- package/lib/benchmarks/union.js +0 -1
- package/lib/external.d.ts +0 -1
- package/lib/external.js +0 -1
- package/lib/helpers/errorUtil.d.ts +0 -1
- package/lib/helpers/errorUtil.js +0 -1
- package/lib/helpers/parseUtil.d.ts +0 -1
- package/lib/helpers/parseUtil.js +0 -1
- package/lib/helpers/partialUtil.d.ts +0 -1
- package/lib/helpers/partialUtil.js +0 -1
- package/lib/helpers/typeAliases.d.ts +0 -1
- package/lib/helpers/typeAliases.js +0 -1
- package/lib/helpers/util.d.ts +0 -1
- package/lib/helpers/util.js +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/index.mjs +3390 -2
- package/lib/types.d.ts +6 -4
- package/lib/types.js +9 -4
- package/package.json +1 -1
- package/lib/ZodError.d.ts.map +0 -1
- package/lib/ZodError.js.map +0 -1
- package/lib/benchmarks/discriminatedUnion.d.ts.map +0 -1
- package/lib/benchmarks/discriminatedUnion.js.map +0 -1
- package/lib/benchmarks/index.d.ts.map +0 -1
- package/lib/benchmarks/index.js.map +0 -1
- package/lib/benchmarks/object.d.ts.map +0 -1
- package/lib/benchmarks/object.js.map +0 -1
- package/lib/benchmarks/string.d.ts.map +0 -1
- package/lib/benchmarks/string.js.map +0 -1
- package/lib/benchmarks/union.d.ts.map +0 -1
- package/lib/benchmarks/union.js.map +0 -1
- package/lib/external.d.ts.map +0 -1
- package/lib/external.js.map +0 -1
- package/lib/helpers/errorUtil.d.ts.map +0 -1
- package/lib/helpers/errorUtil.js.map +0 -1
- package/lib/helpers/parseUtil.d.ts.map +0 -1
- package/lib/helpers/parseUtil.js.map +0 -1
- package/lib/helpers/partialUtil.d.ts.map +0 -1
- package/lib/helpers/partialUtil.js.map +0 -1
- package/lib/helpers/typeAliases.d.ts.map +0 -1
- package/lib/helpers/typeAliases.js.map +0 -1
- package/lib/helpers/util.d.ts.map +0 -1
- package/lib/helpers/util.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/index.mjs.map +0 -1
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js.map +0 -1
package/README.md
CHANGED
|
@@ -244,7 +244,7 @@ There are a growing number of tools that are built atop or support Zod natively!
|
|
|
244
244
|
### Form integrations
|
|
245
245
|
|
|
246
246
|
- [`react-hook-form`](https://github.com/react-hook-form/resolvers#zod): A first-party Zod resolver for React Hook Form
|
|
247
|
-
- [`formik`](https://github.com/robertLichtnow/zod-formik-adapter): A community-maintained Formik adapter for Zod
|
|
247
|
+
- [`zod-formik-adapter`](https://github.com/robertLichtnow/zod-formik-adapter): A community-maintained Formik adapter for Zod
|
|
248
248
|
|
|
249
249
|
# Basic usage
|
|
250
250
|
|
|
@@ -1066,8 +1066,8 @@ interface Category {
|
|
|
1066
1066
|
subcategories: Category[];
|
|
1067
1067
|
}
|
|
1068
1068
|
|
|
1069
|
-
// cast to z.
|
|
1070
|
-
const Category: z.
|
|
1069
|
+
// cast to z.ZodType<Category>
|
|
1070
|
+
const Category: z.ZodType<Category> = z.lazy(() =>
|
|
1071
1071
|
z.object({
|
|
1072
1072
|
name: z.string(),
|
|
1073
1073
|
subcategories: z.array(Category),
|
|
@@ -1104,7 +1104,7 @@ interface Category extends z.infer<typeof BaseCategory> {
|
|
|
1104
1104
|
|
|
1105
1105
|
// merge the base schema with
|
|
1106
1106
|
// a new Zod schema containing relations
|
|
1107
|
-
const Category: z.
|
|
1107
|
+
const Category: z.ZodType<Category> = BaseCategory.merge(
|
|
1108
1108
|
z.object({
|
|
1109
1109
|
subcategories: z.lazy(() => z.array(Category)),
|
|
1110
1110
|
})
|
|
@@ -1119,7 +1119,7 @@ If you want to validate any JSON value, you can use the snippet below.
|
|
|
1119
1119
|
type Literal = boolean | null | number | string;
|
|
1120
1120
|
type Json = Literal | { [key: string]: Json } | Json[];
|
|
1121
1121
|
const literalSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]);
|
|
1122
|
-
const jsonSchema: z.
|
|
1122
|
+
const jsonSchema: z.ZodType<Json> = z.lazy(() =>
|
|
1123
1123
|
z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)])
|
|
1124
1124
|
);
|
|
1125
1125
|
|
package/lib/ZodError.d.ts
CHANGED
package/lib/ZodError.js
CHANGED
package/lib/benchmarks/index.js
CHANGED
package/lib/benchmarks/object.js
CHANGED
package/lib/benchmarks/string.js
CHANGED
package/lib/benchmarks/union.js
CHANGED
package/lib/external.d.ts
CHANGED
package/lib/external.js
CHANGED
package/lib/helpers/errorUtil.js
CHANGED
|
@@ -98,4 +98,3 @@ export declare const isAborted: (x: ParseReturnType<any>) => x is INVALID;
|
|
|
98
98
|
export declare const isDirty: <T>(x: ParseReturnType<T>) => x is OK<T> | DIRTY<T>;
|
|
99
99
|
export declare const isValid: <T>(x: ParseReturnType<T>) => x is OK<T> | DIRTY<T>;
|
|
100
100
|
export declare const isAsync: <T>(x: ParseReturnType<T>) => x is AsyncParseReturnType<T>;
|
|
101
|
-
//# sourceMappingURL=parseUtil.d.ts.map
|
package/lib/helpers/parseUtil.js
CHANGED
package/lib/helpers/util.d.ts
CHANGED
package/lib/helpers/util.js
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED