@@ -1411,4 +1411,41 @@ describe('Zod schema factory test', () => {
14111411 } ) ;
14121412
14131413 // #endregion
1414+
1415+ // #region makeProcedureParamSchema
1416+
1417+ describe ( 'makeProcedureParamSchema' , ( ) => {
1418+ it ( 'works with scalar types' , ( ) => {
1419+ const s = client . $zod . makeProcedureParamSchema ( { type : 'String' } ) ;
1420+ expect ( s . safeParse ( 'hello' ) . success ) . toBe ( true ) ;
1421+ expect ( s . safeParse ( 42 ) . success ) . toBe ( false ) ;
1422+ } ) ;
1423+
1424+ it ( 'works with array types' , ( ) => {
1425+ const s = client . $zod . makeProcedureParamSchema ( { type : 'String' , array : true } ) ;
1426+ expect ( s . safeParse ( [ 'a' , 'b' , 'c' ] ) . success ) . toBe ( true ) ;
1427+ expect ( s . safeParse ( 'a' ) . success ) . toBe ( false ) ;
1428+ expect ( s . safeParse ( [ 1 , 2 , 3 ] ) . success ) . toBe ( false ) ;
1429+ } ) ;
1430+
1431+ it ( 'works with optional types' , ( ) => {
1432+ const s = client . $zod . makeProcedureParamSchema ( { type : 'String' , optional : true } ) ;
1433+ expect ( s . safeParse ( 'hello' ) . success ) . toBe ( true ) ;
1434+ expect ( s . safeParse ( undefined ) . success ) . toBe ( true ) ;
1435+ expect ( s . safeParse ( 42 ) . success ) . toBe ( false ) ;
1436+ } ) ;
1437+
1438+ it ( 'works with array and optional types combined' , ( ) => {
1439+ const s = client . $zod . makeProcedureParamSchema ( { type : 'Int' , array : true , optional : true } ) ;
1440+ expect ( s . safeParse ( [ 1 , 2 , 3 ] ) . success ) . toBe ( true ) ;
1441+ expect ( s . safeParse ( undefined ) . success ) . toBe ( true ) ;
1442+ expect ( s . safeParse ( 1 ) . success ) . toBe ( false ) ;
1443+ } ) ;
1444+
1445+ it ( 'throws for unsupported type' , ( ) => {
1446+ expect ( ( ) => client . $zod . makeProcedureParamSchema ( { type : 'NotAType' } ) ) . toThrow ( ) ;
1447+ } ) ;
1448+ } ) ;
1449+
1450+ // #endregion
14141451} ) ;
0 commit comments