yo-next-auth/schemas/index.ts

26 lines
752 B
TypeScript

import { MIN_PASSWORD_LENGTH } from '@/config/validation'
import { object, string } from 'zod'
const passwordMessage = JSON.stringify(
['schema.message.password_min', { min: MIN_PASSWORD_LENGTH }])
export const LoginSchema = object({
email: string().
trim().
email({ message: 'schema.message.email_required' }).
toLowerCase(),
password: string().
trim().
min(1, { message: 'schema.message.password_required' }),
})
export const RegisterSchema = object({
email: string().
email({ message: 'schema.message.email_required' }).
toLowerCase(),
password: string().
trim().
min(MIN_PASSWORD_LENGTH, { message: passwordMessage }),
name: string().trim().min(1, { message: 'schema.message.name_required' }),
})