Skip to content

error hook #24

@directormac

Description

@directormac

Please look here for example implementation #23

const signup = new OpenAPIHono<{ Variables: ContextVars }>({
	defaultHook: (result, c) => {
		if (!result.success) {
			const response = processZodError<SignupSchema>('Invalid form', result.error);
			return c.json(response, 422);
		}
	}
}).openapi(signupSpec,....)

We can do this for every validation we want the bad part would only be the query default that we impose for example

export const queryParamsSchema = object({
	q: string().default(''),
	page: number().default(0),
	limit: number().default(10)
});

Where we have to put the logic always on the routes that uses it.

@gestanestle please read thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions