Skip to content

Commit e7d350e

Browse files
committed
Ref: shortening getFinalEndpointInputSchema() implementation.
1 parent 396e75d commit e7d350e

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

express-zod-api/src/io-schema.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ export const getFinalEndpointInputSchema = <
2020
>(
2121
middlewares: AbstractMiddleware[],
2222
input: IN,
23-
): z.ZodIntersection<MIN, IN> => {
24-
const allSchemas: IOSchema[] = R.pluck("schema", middlewares);
25-
allSchemas.push(input);
26-
return allSchemas.reduce((acc, schema) =>
27-
acc.and(schema),
28-
) as z.ZodIntersection<MIN, IN>;
29-
};
23+
) =>
24+
R.pluck("schema", middlewares)
25+
.concat(input)
26+
.reduce((acc, schema) => acc.and(schema)) as z.ZodIntersection<MIN, IN>;

0 commit comments

Comments
 (0)