mirror of
https://github.com/wasp-lang/open-saas.git
synced 2025-11-23 16:07:53 +01:00
Simplify code
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { HttpError } from 'wasp/server';
|
||||
import * as z from 'zod';
|
||||
|
||||
export function ensureArgsSchemaOrThrowHttpError<Schema extends z.ZodType<any, any>>(
|
||||
export function ensureArgsSchemaOrThrowHttpError<Schema extends z.ZodType>(
|
||||
schema: Schema,
|
||||
rawArgs: unknown
|
||||
): z.infer<Schema> {
|
||||
@@ -9,6 +9,7 @@ export function ensureArgsSchemaOrThrowHttpError<Schema extends z.ZodType<any, a
|
||||
if (!parseResult.success) {
|
||||
console.error(parseResult.error);
|
||||
throw new HttpError(400, 'Operation arguments validation failed', { errors: parseResult.error.errors });
|
||||
} else {
|
||||
return parseResult.data;
|
||||
}
|
||||
return parseResult.data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user