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

31 lines
684 B
TypeScript
Raw Normal View History

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