@@ -173,6 +173,29 @@ describe("App", () => {
173173 ) ;
174174 } ) ;
175175
176+ describe ( "path parameters parsing" , ( ) => {
177+ it ( "should coerce path parameters when using z.coerce.number()" , async ( ) => {
178+ let actual : any ;
179+ const app = createApp ( ) . get (
180+ "/test/:id" ,
181+ {
182+ params : z . object ( {
183+ id : z . coerce . number ( ) ,
184+ } ) ,
185+ } ,
186+ ( { params } ) => void ( actual = params ) ,
187+ ) ;
188+ const client = createTestAppClient ( app ) ;
189+
190+ await client . fetch ( "GET" , "/test/:id" , {
191+ params : { id : "123" } ,
192+ } ) ;
193+
194+ expect ( actual ) . toEqual ( { id : 123 } ) ;
195+ expect ( typeof actual . id ) . toBe ( "number" ) ;
196+ } ) ;
197+ } ) ;
198+
176199 describe ( "query parameters parsing" , ( ) => {
177200 it . each < {
178201 input : Record < string , string > ;
@@ -213,6 +236,27 @@ describe("App", () => {
213236 expect ( actual ) . toEqual ( expected ) ;
214237 } ,
215238 ) ;
239+
240+ it ( "should coerce query parameters when using z.coerce.number()" , async ( ) => {
241+ let actual : any ;
242+ const app = createApp ( ) . get (
243+ "/test" ,
244+ {
245+ query : z . object ( {
246+ limit : z . coerce . number ( ) ,
247+ } ) ,
248+ } ,
249+ ( { query } ) => void ( actual = query ) ,
250+ ) ;
251+ const client = createTestAppClient ( app ) ;
252+
253+ await client . fetch ( "GET" , "/test" , {
254+ query : { limit : "50" } ,
255+ } ) ;
256+
257+ expect ( actual ) . toEqual ( { limit : 50 } ) ;
258+ expect ( typeof actual . limit ) . toBe ( "number" ) ;
259+ } ) ;
216260 } ) ;
217261
218262 describe ( "any" , ( ) => {
0 commit comments