File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { RequestHandler } from "express" ;
22import createHttpError from "http-errors" ;
3+ import { expectTypeOf } from "vitest" ;
34import {
45 EndpointsFactory ,
56 Middleware ,
@@ -81,6 +82,28 @@ describe("EndpointsFactory", () => {
8182 >
8283 > ( ) ;
8384 } ) ;
85+
86+ test ( "Issue #2760: should strip excessive props by default" , ( ) => {
87+ defaultEndpointsFactory . build ( {
88+ input : z . object ( { foo : z . string ( ) } ) ,
89+ output : z . object ( { foo : z . string ( ) } ) ,
90+ handler : async ( { input } ) => {
91+ expectTypeOf ( input ) . not . toHaveProperty ( "bar" ) ;
92+ return input ;
93+ } ,
94+ } ) ;
95+ } ) ;
96+
97+ test ( "Issue #2760: should allow excessive props when using loose object schema" , ( ) => {
98+ defaultEndpointsFactory . build ( {
99+ input : z . looseObject ( { foo : z . string ( ) } ) ,
100+ output : z . object ( { foo : z . string ( ) } ) ,
101+ handler : async ( { input } ) => {
102+ expectTypeOf ( input ) . toHaveProperty ( "bar" ) . toEqualTypeOf < unknown > ( ) ;
103+ return input ;
104+ } ,
105+ } ) ;
106+ } ) ;
84107 } ) ;
85108
86109 describe ( ".addOptions()" , ( ) => {
You can’t perform that action at this time.
0 commit comments