zValidator middleware custom hook

Hi! Iam trying to create a custom error message for my validator, I am using "query"
works fine, the data is there but the data isn't being passed to the next function in the chain, resulting in errors because q becomes undefined. Hope someone can help me
const errorHandler: Hook<Record<string, unknown>, Env, string, {}> = async (result, c) =>{
    if (!result.success) {  
        return c.text(result.error.issues[0].message, 400);
    }
    console.log({result}); // works fine, the data is there but the data isn't being passed to the next function in the chain
};

export const usernameValidator = zValidator("query", z.object({q: usernameSchema}),errorHandler);
Was this page helpful?