sarlink-portal/lib/schemas.ts
i701 4e78ff2de9 Update user schema and forms to include address and consent fields
- Replaced 'house_name' with 'address' in user schema and related files.
- Added new fields for terms and privacy policy acceptance in the signup form schema.
- Updated package.json and package-lock.json to include @radix-ui/react-checkbox for checkbox functionality.
- Modified seed script to reflect changes in the user model.
2024-11-30 23:37:35 +05:00

30 lines
1.0 KiB
TypeScript

import { z } from "zod";
export const signUpFormSchema = z.object({
name: z.string().min(2, { message: "Name is required." }),
id_card: z
.string()
.min(2, { message: "ID Card is required" })
.regex(/^[A][0-9]{6}$/, "Please enter a valid ID Card number."),
atoll_id: z.string().min(2, { message: "Atoll is required." }),
island_id: z
.string({ required_error: "Island is required." })
.min(2, { message: "Island is required." }),
address: z.string().min(2, { message: "address is required." }),
dob: z.coerce.date({ message: "Date of birth is required." }),
phone_number: z
.string()
.min(7, { message: "Phone number is required." })
.regex(/^[79][0-9]{2}[0-9]{4}$/, "Please enter a valid phone number")
.transform((val) => val.replace(/\D/g, "")),
terms: z
.string({
required_error: "You must accept the terms and conditions",
})
.transform((val) => val === "on"),
policy: z
.string({
required_error: "You must accept the privacy policy",
})
.transform((val) => val === "on"),
});