Skip to content

Commit 2a64914

Browse files
committed
revert: revert deletion of validation.ts
- Restore original file content - Partial reversion of 721fd6f.
1 parent 2b3195c commit 2a64914

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { HttpError } from 'wasp/server';
2+
import * as z from 'zod';
3+
4+
export function ensureArgsSchemaOrThrowHttpError<Schema extends z.ZodType>(
5+
schema: Schema,
6+
rawArgs: unknown
7+
): z.infer<Schema> {
8+
const parseResult = schema.safeParse(rawArgs);
9+
if (!parseResult.success) {
10+
console.error(parseResult.error);
11+
throw new HttpError(400, 'Operation arguments validation failed', { errors: parseResult.error.errors });
12+
} else {
13+
return parseResult.data;
14+
}
15+
}

0 commit comments

Comments
 (0)