-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: overhaul generics section of readme to include more details on …
…z.ZodTypeAny usage (#3321) * feat: overhaul generics section of readme to inclue more details on z.ZodTypeAny usage * FMC --------- Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
- Loading branch information
1 parent
8910033
commit d63bde4
Showing
3 changed files
with
79 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,3 @@ | ||
|
||
import { z } from "./src"; | ||
|
||
z; | ||
|
||
// const enumErrorMap = { | ||
// errorMap: () => ({ invalid_type_error: "Error Message" }), | ||
// }; | ||
|
||
|
||
// const TestEnum = z.enum(['value1', 'value2'], | ||
const TestEnum = z.nativeEnum({"value1":1, "value2":2}, | ||
{ | ||
invalid_type_error: "Invalid type", | ||
required_error: "Required value", | ||
// errorMap: () => ({ message: "Custom error message" }), | ||
|
||
} | ||
); | ||
|
||
console.log(TestEnum.safeParse('3').error);; // Custom error message | ||
console.log(TestEnum.safeParse(undefined).error);; | ||
|