139 lines
3.8 KiB
TypeScript
139 lines
3.8 KiB
TypeScript
import { z } from "zod";
|
|
|
|
export const parentCompanySchema = z.object({
|
|
companyName: z.string()
|
|
.max(100, "Parent company name cannot exceed 100 characters")
|
|
.optional(),
|
|
|
|
address1: z.string()
|
|
.max(150, "Address1 cannot exceed 150 characters")
|
|
.optional(),
|
|
|
|
address2: z.string()
|
|
.max(150, "Address2 cannot exceed 150 characters")
|
|
.optional(),
|
|
|
|
cityXid: z.number().optional(),
|
|
stateXid: z.number().optional(),
|
|
countryXid: z.number().optional(),
|
|
|
|
pinCode: z.string()
|
|
.max(30, "Pincode cannot exceed 30 characters")
|
|
.optional(),
|
|
|
|
logoPath: z.string()
|
|
.max(400, "Logo path cannot exceed 400 characters")
|
|
.optional(),
|
|
|
|
registrationNumber: z.string()
|
|
.max(30, "Registration number cannot exceed 30 characters")
|
|
.optional(),
|
|
|
|
panNumber: z.string()
|
|
.max(30, "PAN number cannot exceed 30 characters")
|
|
.optional(),
|
|
|
|
gstNumber: z.string()
|
|
.max(30, "GST number cannot exceed 30 characters")
|
|
.optional(),
|
|
|
|
formationDate: z.string()
|
|
.optional()
|
|
.refine((val) => !val || !isNaN(Date.parse(val)), {
|
|
message: "Formation date must be a valid date",
|
|
}),
|
|
|
|
companyTypeXid: z.number()
|
|
.optional(),
|
|
|
|
websiteUrl: z.string().nullable().optional(),
|
|
instagramUrl: z.string().nullable().optional(),
|
|
facebookUrl: z.string().nullable().optional(),
|
|
linkedinUrl: z.string().nullable().optional(),
|
|
twitterUrl: z.string().nullable().optional(),
|
|
|
|
});
|
|
|
|
|
|
// =======================================================
|
|
// HOST COMPANY DETAILS (Main Company)
|
|
// =======================================================
|
|
|
|
export const hostCompanyDetailsSchema = z.object({
|
|
companyName: z.string()
|
|
.min(1, "Company name is required")
|
|
.max(100, "Company name cannot exceed 100 characters"),
|
|
|
|
address1: z.string()
|
|
.min(1, "Address1 is required")
|
|
.max(150, "Address1 cannot exceed 150 characters"),
|
|
|
|
address2: z.string()
|
|
.max(150, "Address2 cannot exceed 150 characters")
|
|
.optional(),
|
|
|
|
cityXid: z.number().min(1, "City is required"),
|
|
stateXid: z.number().min(1, "State is required"),
|
|
countryXid: z.number().min(1, "Country is required"),
|
|
|
|
pinCode: z.string()
|
|
.min(4, "Pincode/Zipcode is required")
|
|
.max(30, "Pincode cannot exceed 30 characters"),
|
|
|
|
logoPath: z.string()
|
|
.max(400, "Logo path cannot exceed 400 characters")
|
|
.optional(),
|
|
|
|
isSubsidairy: z.boolean(),
|
|
|
|
registrationNumber: z.string()
|
|
.max(30, "Registration number cannot exceed 30 characters")
|
|
.optional(),
|
|
|
|
panNumber: z.string()
|
|
.min(1, "PAN number is required")
|
|
.max(30, "PAN number cannot exceed 30 characters"),
|
|
|
|
gstNumber: z.string()
|
|
.max(30, "GST number cannot exceed 30 characters")
|
|
.optional(),
|
|
|
|
formationDate: z.string()
|
|
.optional()
|
|
.refine((val) => !val || !isNaN(Date.parse(val)), {
|
|
message: "Formation date must be a valid date",
|
|
}),
|
|
|
|
companyTypeXid: z.number()
|
|
.int("Company type must be a valid integer")
|
|
.min(1, "Company type is required"),
|
|
|
|
|
|
referencedBy: z.string()
|
|
.optional(),
|
|
|
|
websiteUrl: z.string().nullable().optional(),
|
|
instagramUrl: z.string().nullable().optional(),
|
|
facebookUrl: z.string().nullable().optional(),
|
|
linkedinUrl: z.string().nullable().optional(),
|
|
twitterUrl: z.string().nullable().optional(),
|
|
|
|
|
|
parentCompany: parentCompanySchema.optional(),
|
|
});
|
|
|
|
|
|
// =======================================================
|
|
// DOCUMENTS VALIDATION
|
|
// =======================================================
|
|
|
|
export const hostDocumentsSchema = z.array(
|
|
z.object({
|
|
documentTypeXid: z.number(),
|
|
documentName: z.string().max(50, "Document name cannot exceed 50 characters"), // per parent max 50 / host max 20 — safe limit 50
|
|
fieldName: z.string(),
|
|
owner: z.enum(['host', 'parent']).optional(),
|
|
isOptional: z.boolean().optional(),
|
|
})
|
|
);
|