File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,9 @@ describe("Validate", () => {
9292 it ( "Invalid" , async ( ) => {
9393 const res = await request . post ( "/zod" ) . send ( { invalid : true } ) ;
9494 expect ( res . status ) . toEqual ( 400 ) ;
95- expect ( res . body . data ?. issues ?. [ 0 ] ?. code ) . toEqual ( "invalid_type" ) ;
95+ // TODO: zod5 error message is stringified
96+ const payload = JSON . parse ( res . body . data . message ) ;
97+ expect ( payload [ 0 ] . code ) . toEqual ( "invalid_type" ) ;
9698 } ) ;
9799 } ) ;
98100 } ) ;
@@ -110,7 +112,13 @@ describe("Validate", () => {
110112 app . use (
111113 "/zod" ,
112114 eventHandler ( async ( event ) => {
113- const data = await getValidatedQuery ( event , zodValidate ) ;
115+ const data = await getValidatedQuery ( event , ( data ) => {
116+ try {
117+ return zodValidate ( data ) ;
118+ } catch ( error ) {
119+ console . log ( error . toJSON ( ) ) ;
120+ }
121+ } ) ;
114122 return data ;
115123 } ) ,
116124 ) ;
You can’t perform that action at this time.
0 commit comments