(
target: Target,
schema: T,
)
| 8 | } from "../http/validation-error.ts"; |
| 9 | |
| 10 | export const validator = < |
| 11 | T extends z.ZodType, |
| 12 | Target extends keyof ValidationTargets, |
| 13 | >( |
| 14 | target: Target, |
| 15 | schema: T, |
| 16 | ) => |
| 17 | zValidator(target, schema, (result, _c) => { |
| 18 | if (!result.success) { |
| 19 | throw new ValidationError( |
| 20 | new ZodError(result.error as $ZodIssue[]), |
| 21 | target as ValidationTarget, |
| 22 | ); |
| 23 | } |
| 24 | }); |
no outgoing calls