35 lines
842 B
TypeScript
35 lines
842 B
TypeScript
import { z } from 'zod'
|
|
|
|
export const SignupFormSchema = z.object({
|
|
name: z
|
|
.string()
|
|
.min(2, { message: '至少应该超过两个字符' })
|
|
.trim(),
|
|
account: z.string(),
|
|
password: z
|
|
.string()
|
|
.min(8, { message: '密码过于简单' })
|
|
.regex(/[a-zA-Z]/, { message: 'Contain at least one letter.' })
|
|
.regex(/[0-9]/, { message: 'Contain at least one number.' })
|
|
.regex(/[^a-zA-Z0-9]/, {
|
|
message: 'Contain at least one special character.',
|
|
})
|
|
.trim(),
|
|
})
|
|
export const LoginFormSchema = z.object({
|
|
account: z.string().min(1, "账号必填").trim(),
|
|
password: z.string().trim(),
|
|
})
|
|
export type FormState =
|
|
{
|
|
errors?: {
|
|
account?: string[]
|
|
password?: string[]
|
|
}
|
|
message?: string
|
|
}
|
|
| undefined
|
|
export type SessionPayload = {
|
|
userId: string;
|
|
expiresAt: Date;
|
|
} |