File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -981,6 +981,10 @@ Dog.parse({ name: "Yeller", extraKey: true });
981981
982982To define a * catchall schema* that will be used to validate any unrecognized keys:
983983
984+
985+
986+ <Tabs groupId = " lib" items = { [" Zod" , " Zod Mini" ]} >
987+ <Tab value = " Zod" >
984988``` ts z.object
985989const DogWithStrings = z .object ({
986990 name: z .string (),
@@ -990,6 +994,23 @@ const DogWithStrings = z.object({
990994DogWithStrings .parse ({ name: " Yeller" , extraKey: " extraValue" }); // ✅
991995DogWithStrings .parse ({ name: " Yeller" , extraKey: 42 }); // ❌
992996```
997+ </Tab >
998+ <Tab value = " Zod Mini" >
999+ ``` ts z.object
1000+ const DogWithStrings = z .catchall (
1001+ z .object ({
1002+ name: z .string (),
1003+ age: z .number ().optional (),
1004+ }),
1005+ z .string ()
1006+ );
1007+
1008+ DogWithStrings .parse ({ name: " Yeller" , extraKey: " extraValue" }); // ✅
1009+ DogWithStrings .parse ({ name: " Yeller" , extraKey: 42 }); // ❌
1010+ ```
1011+ </Tab >
1012+ </Tabs >
1013+
9931014
9941015### ` .shape `
9951016
Original file line number Diff line number Diff line change 11{
22 "name" : " zod" ,
3- "version" : " 3.25.64 " ,
3+ "version" : " 3.25.65 " ,
44 "type" : " module" ,
55 "author" : " Colin McDonnell <zod@colinhacks.com>" ,
66 "description" : " TypeScript-first schema declaration and validation library with static type inference" ,
You can’t perform that action at this time.
0 commit comments