Files
no-copy-frontend/src/app/lib/definitions.ts
T

38 lines
878 B
TypeScript
Raw Normal View History

2025-11-27 21:33:53 +07:00
import * as z from 'zod'
2025-11-28 12:38:14 +07:00
export const SignupFormSchema = z
.object({
full_name: z
.string()
.min(3, { error: 'Name must be at least 3 characters long.' })
.trim(),
email: z.email({ error: 'Please enter a valid email.' }).trim(),
password: z
.string()
.min(6, { error: 'Be at least 6 characters long' })
.regex(/[a-zA-Z]/, { error: 'Contain at least one letter.' })
.regex(/[0-9]/, { error: 'Contain at least one number.' })
.trim(),
confirm_password: z
.string()
})
.refine((data) => data.password === data.confirm_password, {
message: 'passwordMismatchErrorMessage',
path: ['confirm_password'],
});
2025-11-27 21:33:53 +07:00
export type FormState =
| {
errors?: {
name?: string[]
email?: string[]
password?: string[]
}
message?: string
}
| undefined
export type FormAction = (
state: FormState,
formData: FormData
) => Promise<FormState>