flowstate/lib/schemas/auth.schema.ts
Chneemann a60851ac07
All checks were successful
Deploy Flowstate to VPS / deploy (push) Successful in 1m27s
refactor(lib): consolidate services, types, utils, and actions into lib folder and update import paths
2026-08-23 16:44:18 +02:00

48 lines
1.3 KiB
TypeScript

/**
* @file app/lib/schemas/auth.schema.ts
* @description Zod validation schemas for authentication forms, including login and user registration data constraints.
*/
import { z } from "zod";
/**
* Zod validation schema for user login credentials.
*/
export const loginSchema = z.object({
email: z
.string()
.max(255, "Email is too long")
.pipe(z.email("Please provide a valid email address")),
password: z
.string()
.min(1, "Password is required")
.max(72, "Password is too long"),
});
/**
* Zod validation schema for new user registration payloads, including password confirmation matching.
*/
export const registerSchema = z
.object({
firstName: z
.string()
.min(1, "First name is required")
.max(50, "First name is too long"),
lastName: z
.string()
.min(1, "Last name is required")
.max(50, "Last name is too long"),
email: z
.string()
.max(255, "Email is too long")
.pipe(z.email("Please provide a valid email address")),
password: z
.string()
.min(8, "Password must be at least 8 characters long")
.max(72, "Password is too long (max 72 characters)"),
confirmPassword: z.string(),
})
.refine((data) => data.password === data.confirmPassword, {
message: "Passwords do not match",
path: ["confirmPassword"],
});