I have set authclient with: export const client = createAuthClient({ plugins: [ usernameClient(), ...]}) export const { signUp, signIn, signOut, useSession, organization, useListOrganizations, useActiveOrganization, } = client;
In zod schema: import { client } from '~/src/lib/auth-client';
userName: z .string() .min(5, 'User name must be over 5 characters long') .regex(/^[a-zA-Z0-9_\.]+$/), .superRefine(async ({ email, userName }, ctx) => { console.log(
superRefine ${email} userName ${userName}
superRefine ${email} userName ${userName}
); if (email) { const emailEnique = await uniqueEmail(email); if (!emailEnique) { ctx.addIssue({ code: 'custom', message: 'The email already exists', path: ['email'], }); } } if (userName) { console.log(
start userName check with value ${JSON.stringify(userName)}
start userName check with value ${JSON.stringify(userName)}
Please let me know how to get isUserNameAvailable working within the zod validation route. Better-auth makes the call POST /api/auth/is-user-name-available