mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-13 07:31:51 +00:00
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { z } from "zod";
|
|
|
|
export const authFormSchema = (type: string) =>
|
|
z
|
|
.object({
|
|
// Sign Up
|
|
company:
|
|
type === "sign-in" ? z.string().optional() : z.string().optional(),
|
|
name:
|
|
type === "sign-in"
|
|
? z.string().optional()
|
|
: z
|
|
.string()
|
|
.min(3, {
|
|
message: "The name must be at least 3 characters.",
|
|
})
|
|
.max(20),
|
|
confirmPassword:
|
|
type === "sign-in"
|
|
? z.string().optional()
|
|
: z.string().min(12, {
|
|
message: "It must contain at least 12 characters.",
|
|
}),
|
|
invitationToken:
|
|
type === "sign-in" ? z.string().optional() : z.string().optional(),
|
|
termsAndConditions:
|
|
type === "sign-in"
|
|
? z.boolean().optional()
|
|
: z.boolean().refine((value) => value === true, {
|
|
message: "You must accept the terms and conditions.",
|
|
}),
|
|
|
|
// Fields for Sign In and Sign Up
|
|
email: z.string().email(),
|
|
password: z.string().min(12, {
|
|
message: "It must contain at least 12 characters.",
|
|
}),
|
|
})
|
|
.refine(
|
|
(data) => type === "sign-in" || data.password === data.confirmPassword,
|
|
{
|
|
message: "The password must match",
|
|
path: ["confirmPassword"],
|
|
},
|
|
);
|