refactor(validation): restucture api input and output validation

This commit is contained in:
Dominik 2025-06-18 21:36:30 +02:00 committed by Micha
parent 8207230886
commit b8ad6891e3
6 changed files with 14 additions and 359 deletions

View file

@ -37,7 +37,7 @@ const providers: Provider[] = [
if (process.env.DISABLE_PASSWORD_LOGIN) return null;
try {
const { email, password } = await loginClientSchema.parseAsync(c);
const { email, password } = await loginSchema.parseAsync(c);
const user = await prisma.user.findFirst({
where: { OR: [{ email }, { name: email }] },

View file

@ -18,7 +18,7 @@ function LoginFormElement({
formRef?: React.RefObject<HTMLFormElement | null>;
}) {
const { handleSubmit, formState, register, setError } =
useZodForm(loginClientSchema);
useZodForm(loginSchema);
const router = useRouter();
const onSubmit = handleSubmit(async (data) => {
@ -95,7 +95,7 @@ function RegisterFormElement({
formRef?: React.RefObject<HTMLFormElement | null>;
}) {
const { handleSubmit, formState, register, setError } =
useZodForm(registerClientSchema);
useZodForm(registerSchema);
const onSubmit = handleSubmit(async (data) => {
try {

View file

@ -4,7 +4,7 @@ import { z } from 'zod/v4';
import { loginSchema } from './validation';
import { signIn } from '@/auth';
export async function loginAction(data: z.infer<typeof loginClientSchema>) {
export async function loginAction(data: z.infer<typeof loginSchema>) {
try {
await signIn('credentials', {
...data,