-
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.
register page design and validation completed
- Loading branch information
Showing
6 changed files
with
176 additions
and
18 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
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"use client" | ||
|
||
import * as React from "react" | ||
import * as CheckboxPrimitive from "@radix-ui/react-checkbox" | ||
import { Check } from "lucide-react" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const Checkbox = React.forwardRef< | ||
React.ElementRef<typeof CheckboxPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> | ||
>(({ className, ...props }, ref) => ( | ||
<CheckboxPrimitive.Root | ||
ref={ref} | ||
className={cn( | ||
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground", | ||
className | ||
)} | ||
{...props} | ||
> | ||
<CheckboxPrimitive.Indicator | ||
className={cn("flex items-center justify-center text-current")} | ||
> | ||
<Check className="h-4 w-4" /> | ||
</CheckboxPrimitive.Indicator> | ||
</CheckboxPrimitive.Root> | ||
)) | ||
Checkbox.displayName = CheckboxPrimitive.Root.displayName | ||
|
||
export { Checkbox } |
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,13 +1,63 @@ | ||
import { BloodTypes, GenderOptions } from "@/constants"; | ||
import { z } from "zod"; | ||
|
||
export const loginFormValidation = z.object({ | ||
phone: z.string().refine(phone => /^\+?[1-9]\d{1,14}$/.test(phone), "Invalid phone number"), | ||
password: z.string().min(4, "Password must be at least 6 characters long"), | ||
// password: z.string() | ||
// .min(8, "Password must be at least 8 characters long") | ||
// .regex(/[A-Z]/, "Password must contain at least one uppercase letter") | ||
// .regex(/[a-z]/, "Password must contain at least one lowercase letter") | ||
// .regex(/[0-9]/, "Password must contain at least one number") | ||
// .regex(/[@$!%*?&#]/, "Password must contain at least one special character"), | ||
phone: z | ||
.string() | ||
.refine( | ||
(phone) => /^\+?[1-9]\d{1,14}$/.test(phone), | ||
"Invalid phone number" | ||
), | ||
password: z.string().min(4, "Password must be at least 4 characters long"), | ||
}); | ||
|
||
export const registerFormValidation = z | ||
.object({ | ||
name: z | ||
.string() | ||
.min(1, "Full Name is required") | ||
.nonempty("Full Name cannot be empty"), | ||
email: z | ||
.string() | ||
.email("Invalid email address") | ||
.min(1, "Email address is required"), | ||
phone: z | ||
.string() | ||
.min(10, "Phone number must be at least 10 digits") | ||
.max(15, "Phone number must be at most 15 digits"), | ||
birthDate: z.string().min(1, "Date of birth is required"), | ||
gender: z.enum(["Male", "Female", "Other"]), | ||
bloodType: z.enum(["A+", "A-", "B+", "B-", "O+", "O-", "AB+", "AB-"]), | ||
disease: z.string().min(1, "Primary Disease is required"), | ||
password: z.string().min(4, "Password must be at least 4 characters long"), | ||
// password: z.string() | ||
// .min(8, "Password must be at least 8 characters long") | ||
// .regex(/[A-Z]/, "Password must contain at least one uppercase letter") | ||
// .regex(/[a-z]/, "Password must contain at least one lowercase letter") | ||
// .regex(/[0-9]/, "Password must contain at least one number") | ||
// .regex(/[@$!%*?&#]/, "Password must contain at least one special character"), | ||
confirmPassword: z | ||
.string() | ||
.min(4, "Password must be at least 4 characters long"), | ||
privacyPolicy: z | ||
.boolean() | ||
.refine( | ||
(val) => val === true, | ||
"You must agree to the Privacy Policy" | ||
), | ||
concent: z | ||
.boolean() | ||
.refine((val) => val === true, "You must Consent to Treatment"), | ||
disclosureConsent: z | ||
.boolean() | ||
.refine((val) => val === true, "You must Consent to Privacy Policy"), | ||
}) | ||
.superRefine(({ confirmPassword, password }, ctx) => { | ||
if (confirmPassword !== password) { | ||
ctx.addIssue({ | ||
code: "custom", | ||
message: "The Password did not match", | ||
path: ["confirmPassword"], | ||
}); | ||
} | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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