mirror of
https://github.com/wasp-lang/open-saas.git
synced 2025-11-24 04:17:03 +01:00
format write
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
import { HttpError } from 'wasp/server';
|
||||
import * as z from 'zod';
|
||||
import { HttpError } from "wasp/server";
|
||||
import * as z from "zod";
|
||||
|
||||
export function ensureArgsSchemaOrThrowHttpError<Schema extends z.ZodType>(
|
||||
schema: Schema,
|
||||
rawArgs: unknown
|
||||
rawArgs: unknown,
|
||||
): z.infer<Schema> {
|
||||
const parseResult = schema.safeParse(rawArgs);
|
||||
if (!parseResult.success) {
|
||||
console.error(parseResult.error);
|
||||
throw new HttpError(400, 'Operation arguments validation failed', { errors: parseResult.error.errors });
|
||||
throw new HttpError(400, "Operation arguments validation failed", {
|
||||
errors: parseResult.error.errors,
|
||||
});
|
||||
} else {
|
||||
return parseResult.data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user