boredgame/src/lib/dtos/signup-username-email.dto.ts
2024-08-08 12:38:17 -07:00

18 lines
No EOL
739 B
TypeScript

import { z } from "zod";
import { refinePasswords } from "$lib/validations/account";
export const signupUsernameEmailDto = z.object({
firstName: z.string().trim().optional(),
lastName: z.string().trim().optional(),
email: z.string().trim().max(64, {message: 'Email must be less than 64 characters'}).optional(),
username: z
.string()
.trim()
.min(3, {message: 'Must be at least 3 characters'})
.max(50, {message: 'Must be less than 50 characters'}),
password: z.string({required_error: 'Password is required'}).trim(),
confirm_password: z.string({required_error: 'Confirm Password is required'}).trim()
})
.superRefine(({ confirm_password, password }, ctx) => {
refinePasswords(confirm_password, password, ctx);
});