-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from TEDx-SJEC/bug_fix
fix
- Loading branch information
Showing
2 changed files
with
37 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,52 @@ | ||
import { z } from "zod"; | ||
|
||
export const RegistrationFormSchema = z.object({ | ||
name: z.string().min(1, "Name is required"), | ||
usn: z.string().optional(), | ||
email: z.string().email("Invalid email format"), | ||
contact: z.string().length(10, "Contact must be exactly 10 digits"), | ||
designation: z | ||
.string() | ||
.refine((value) => ["Student", "Faculty", "Employee"].includes(value), { | ||
message: "Invalid designation", | ||
name: z.string().min(1, "Name is required"), | ||
usn: z.string().optional(), | ||
email: z.string().email("Invalid email format"), | ||
contact: z.string().length(10, "Contact must be exactly 10 digits"), | ||
designation: z.string().refine((value) => ["Student", "Faculty", "Employee"].includes(value), { | ||
message: "Invalid designation", | ||
}), | ||
photo: z.string().optional(), | ||
collegeIdCard: z.string().optional(), | ||
entityName: z.string().min(1, "Entity name is required"), | ||
referralUsed: z.string().optional(), | ||
createdById: z.string(), | ||
photo: z.string().optional(), | ||
collegeIdCard: z.string().optional(), | ||
entityName: z.string().min(1, "Entity name is required"), | ||
referralUsed: z.string().optional(), | ||
createdById: z.string(), | ||
}); | ||
|
||
export type TRegistrationForm = z.infer<typeof RegistrationFormSchema>; | ||
|
||
export const emailSchema = z.object({ | ||
email: z.string().email(), | ||
name: z.string().min(1), | ||
email: z.string().email(), | ||
name: z.string().min(1), | ||
}); | ||
|
||
export const baseSchema = z.object({ | ||
designation: z.enum(["student", "faculty", "external"]), | ||
name: z.string().min(2, { message: "Name must be at least 2 characters." }), | ||
email: z.string().email({ message: "Invalid email address." }), | ||
phone: z | ||
.string() | ||
.regex(/^\d{10}$/, { message: "Phone number must be 10 digits." }), | ||
photo: z.string(), | ||
entityName: z.string().optional(), | ||
couponCode: z.string().optional(), | ||
foodPreference: z.enum(["veg", "non-veg"]), | ||
designation: z.enum(["student", "faculty", "external"]), | ||
name: z.string().min(2, { message: "Name must be at least 2 characters." }), | ||
email: z.string().email({ message: "Invalid email address." }), | ||
phone: z.string().regex(/^\d{10}$/, { message: "Phone number must be 10 digits." }), | ||
photo: z.string(), | ||
entityName: z.string().optional(), | ||
couponCode: z.string().optional(), | ||
foodPreference: z.enum(["veg", "non-veg"]), | ||
}); | ||
|
||
export const studentSchema = baseSchema.extend({ | ||
usn: z.string().min(1, { message: "USN is required for students." }), | ||
idCard: z.string().min(1, { message: "ID Card is required for students." }), | ||
usn: z.string().min(1, { message: "USN is required for students." }), | ||
idCard: z.string().min(1, { message: "ID Card is required for students." }), | ||
}); | ||
|
||
export const studentFormSchema = z.object({ | ||
name: z.string().min(2, { message: "Name must be at least 2 characters." }), | ||
email: z.string().email({ message: "Invalid email address." }), | ||
phone: z | ||
.string() | ||
.regex(/^\d{10}$/, { message: "Phone number must be 10 digits." }), | ||
usn: z.string().min(1, { message: "USN is required for students." }), | ||
idCard: z.string().min(1, { message: "ID Card is required for students." }), | ||
photo: z.string().min(1, { message: "Photo is required." }), | ||
name: z.string().min(2, { message: "Name must be at least 2 characters." }), | ||
email: z.string().email({ message: "Invalid email address." }), | ||
phone: z.string().regex(/^\d{10}$/, { message: "Phone number must be 10 digits." }), | ||
usn: z | ||
.string() | ||
.min(10, { message: "USN is required for students." }) | ||
.max(10, { message: "USN must be exactly 10 characters long." }) | ||
.regex(/^[A-Z0-9]+$/, { message: "USN must be in uppercase." }), | ||
idCard: z.string().min(1, { message: "ID Card is required for students." }), | ||
photo: z.string().min(1, { message: "Photo is required." }), | ||
}); |