File tree Expand file tree Collapse file tree 2 files changed +9
-25
lines changed Expand file tree Collapse file tree 2 files changed +9
-25
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " zod" ,
3
- "version" : " 3.25.60 " ,
3
+ "version" : " 3.25.61 " ,
4
4
"type" : " module" ,
5
5
"author" :
" Colin McDonnell <[email protected] >" ,
6
6
"description" : " TypeScript-first schema declaration and validation library with static type inference" ,
Original file line number Diff line number Diff line change 1
1
import { z } from "zod/v4" ;
2
2
3
- const enumSchema = z . enum ( [ "a" , "b" , "c" ] ) ;
4
- const nativeEnumSchema = z . nativeEnum ( enumSchema . enum ) ;
5
-
6
- console . dir ( nativeEnumSchema . safeParse ( "a" ) , { depth : null } ) ; // Valid
7
- console . dir ( nativeEnumSchema . safeParse ( "d" ) , { depth : null } ) ; // Throws ZodError
8
-
9
- z . file ( ) . mime ( [ "" ] ) ;
10
-
11
- // function makeZodObj<const T extends string>(key: T) {
12
- // const a: string = "a";
13
- // const b: string = "b";
14
- // return z.looseObject({
15
- // [a]: z.string(),
16
- // [b]: z.number(),
17
- // });
18
- // }
19
-
20
- function makeZodObj < K extends string > ( key : K ) {
21
- return z . record ( z . literal ( key ) , z . string ( ) ) ;
22
- }
23
-
24
- const schema = makeZodObj ( "foo" ) ;
25
- type schema = z . infer < typeof schema > ;
26
- // { foo: string; }
3
+ const A = z . string ( ) . describe ( "name" ) ;
4
+ const B = A . superRefine ( ( val , ctx ) => {
5
+ ctx . addIssue ( {
6
+ message : `Invalid ${ A . description } ` ,
7
+ } ) ;
8
+ } ) ;
9
+
10
+ B . parse ( "test" ) ; // Should pass
You can’t perform that action at this time.
0 commit comments