File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
packages/zod/src/v4/classic/tests Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -240,7 +240,7 @@ test("readonly and the get method", () => {
240
240
expect ( readonlyBigInt . parse ( bigIntVal ) ) . toEqual ( bigIntVal ) ;
241
241
expect ( readonlyBoolean . parse ( true ) ) . toEqual ( true ) ;
242
242
const dateVal = new Date ( ) ;
243
- expect ( readonlyDate . parse ( new Date ( ) ) ) . toEqual ( dateVal ) ;
243
+ expect ( readonlyDate . parse ( dateVal ) ) . toEqual ( dateVal ) ;
244
244
expect ( readonlyUndefined . parse ( undefined ) ) . toEqual ( undefined ) ;
245
245
expect ( readonlyNull . parse ( null ) ) . toEqual ( null ) ;
246
246
expect ( readonlyAny . parse ( "whatever" ) ) . toEqual ( "whatever" ) ;
Original file line number Diff line number Diff line change 1
1
import { z } from "zod/v4" ;
2
2
3
- z . string ( ) . regex ( / a s d f / ) ;
3
+ // import { z } from "zod/v4" ;
4
4
5
- z . literal ;
5
+ export const elementInputSchema = z
6
+ . discriminatedUnion ( "type" , [
7
+ z . object ( {
8
+ type : z . literal ( "CONTAINER" ) ,
9
+ } ) ,
10
+ z . object ( {
11
+ type : z . literal ( "SCREEN" ) ,
12
+ config : z . object ( { x : z . number ( ) , y : z . number ( ) } ) ,
13
+ } ) ,
14
+ ] )
15
+ . and (
16
+ z . object ( {
17
+ get children ( ) : z . ZodOptional < z . ZodArray < typeof elementInputSchema > > {
18
+ return z . array ( elementInputSchema ) . optional ( ) ;
19
+ } ,
20
+ } )
21
+ ) ;
22
+
23
+ export type ElementInput = z . infer < typeof elementInputSchema > ;
You can’t perform that action at this time.
0 commit comments