Athlete filter schema
unknown
typescript
a year ago
3.7 kB
19
Indexable
export const filteredAthleteSchema = z.object({
ids: z.string().array().optional(),
associationLevelIds: z.string().array().optional(),
costOfAssociation: z
.object({
cost: z
.number()
.array()
.max(2, "Cost array can have maximum of 2 elements")
.optional(),
operationType: z.enum(OperationsTypeEnum).optional(),
})
.optional()
.refine(
(data) => {
if (data?.cost && data?.operationType === undefined) {
return false;
}
return true;
},
{
message: "operationType is required when cost is provided",
path: ["operationType"],
},
)
.refine(
(data) => {
if (data?.operationType && data?.cost === undefined) {
return false;
}
return true;
},
{
message: "cost is required when operationType is provided",
path: ["cost"],
},
),
strategyOverview: z.string().optional(),
sportIds: z.string().array().optional(),
agencyIds: z.string().array().optional(),
ageIds: z.string().array().optional(),
facebook: z.string().optional(),
instagram: z.string().optional(),
twitter: z.string().optional(),
linkedin: z.string().optional(),
youtube: z.string().optional(),
website: z.string().optional(),
subPersonalityTraitIds: z.string().array().optional(),
genderIds: z.string().array().optional(),
athleteGenderIds: z.string().array().optional(),
nccsIds: z.string().array().optional(),
primaryMarketIds: z.string().array().optional(),
secondaryMarketIds: z.string().array().optional(),
tertiaryIds: z.string().array().optional(),
stateIds: z.string().array().optional(),
nationalityIds: z.string().array().optional(),
tierIds: z.string().array().optional(),
statusIds: z.string().array().optional(),
primarySocialMediaPlatformIds: z.string().array().optional(),
secondarySocialMediaPlatformIds: z.string().array().optional(),
athleteAge: z
.object({
age: z
.number()
.array()
.max(2, "Age array can have maximum of 2 elements")
.optional(),
operationType: z.enum(OperationsTypeEnum).optional(),
})
.optional()
.refine(
(data) => {
if (data?.age && data?.operationType === undefined) {
return false;
}
return true;
},
{
message: "operationType is required when age is provided",
path: ["operationType"],
},
)
.refine(
(data) => {
if (data?.operationType && data?.age === undefined) {
return false;
}
return true;
},
{
message: "age is required when operationType is provided",
path: ["age"],
},
),
contactName: z.string().optional(),
contactDesignation: z.string().optional(),
contactEmail: z.string().optional(),
contactNumber: z.string().optional(),
contactLinkedin: z.string().optional(),
isMandatory: z.boolean({ message: "isMandatory is required" }),
});Editor is loading...
Leave a Comment