add registration and session logic

This commit is contained in:
smanylov
2025-11-27 21:33:53 +07:00
parent 5c6a235ece
commit 39dee22b89
12 changed files with 191 additions and 45 deletions
+31
View File
@@ -0,0 +1,31 @@
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>