Z
Zod17mo ago
Gludek

hey I m getting this error which is

hey, I'm getting this error which is confusing to me.
ZodError: [
{

"code": "invalid_intersection_types",

"path": [],

"message": "Intersection results could not be merged"

}

]
ZodError: [
{

"code": "invalid_intersection_types",

"path": [],

"message": "Intersection results could not be merged"

}

]
I'm using safeParse on this
const AdditonalInfo = z
.discriminatedUnion("priorPsychologicalAssistance", [
z.object({
priorPsychologicalAssistance: z.literal("tak").transform((arg) => true),
priorPsychologicalAssistanceDesc: z.string(),
priorPsychologicalAssistanceWhen: z.string()
}),
z.object({
priorPsychologicalAssistance: z.literal("nie").transform((arg) => false),
priorPsychologicalAssistanceDesc: z.string().nullish(),
priorPsychologicalAssistanceWhen: z.string().nullish()
})
])
.and(
z.discriminatedUnion("faith", [
z.object({
faith: z.literal("tak").transform((arg) => true),
faithInfluence: radio(),
faithDesc: z.string()
}),
z.object({
faith: z.literal("nie").transform((arg) => false),
faithInfluence: radio(["tak", "nie", undefined]),
faithDesc: z.string().nullish()
})
])
)
.and(
z.discriminatedUnion("difficulties", [
z.object({
difficulties: z.literal("tak").transform((arg) => true),
difficultiesRelated: radio()
}),
z.object({
difficulties: z.literal("nie").transform((arg) => false),
difficultiesRelated: radio(["tak", "nie", undefined]).nullish()
})
])
)
.and(
z.object({
drugs: drug.array(),
familiRelation: radio(["good", "bad"]),
lifeSituationSatisfaction: radio(),
hobby: radio(),
difficulties: radio(),
emotionalDamage: radio(),
stressCopeMechanism: z.number()
})
);
const AdditonalInfo = z
.discriminatedUnion("priorPsychologicalAssistance", [
z.object({
priorPsychologicalAssistance: z.literal("tak").transform((arg) => true),
priorPsychologicalAssistanceDesc: z.string(),
priorPsychologicalAssistanceWhen: z.string()
}),
z.object({
priorPsychologicalAssistance: z.literal("nie").transform((arg) => false),
priorPsychologicalAssistanceDesc: z.string().nullish(),
priorPsychologicalAssistanceWhen: z.string().nullish()
})
])
.and(
z.discriminatedUnion("faith", [
z.object({
faith: z.literal("tak").transform((arg) => true),
faithInfluence: radio(),
faithDesc: z.string()
}),
z.object({
faith: z.literal("nie").transform((arg) => false),
faithInfluence: radio(["tak", "nie", undefined]),
faithDesc: z.string().nullish()
})
])
)
.and(
z.discriminatedUnion("difficulties", [
z.object({
difficulties: z.literal("tak").transform((arg) => true),
difficultiesRelated: radio()
}),
z.object({
difficulties: z.literal("nie").transform((arg) => false),
difficultiesRelated: radio(["tak", "nie", undefined]).nullish()
})
])
)
.and(
z.object({
drugs: drug.array(),
familiRelation: radio(["good", "bad"]),
lifeSituationSatisfaction: radio(),
hobby: radio(),
difficulties: radio(),
emotionalDamage: radio(),
stressCopeMechanism: z.number()
})
);
1 Reply
Gludek
GludekOP17mo ago
it seems that if I remove this part
.and(
z.discriminatedUnion("difficulties", [
z.object({
difficulties: z.literal("tak").transform((arg) => true),
difficultiesRelated: radio()
}),
z.object({
difficulties: z.literal("nie").transform((arg) => false),
difficultiesRelated: radio(["tak", "nie", undefined]).nullish()
})
])
)
.and(
z.discriminatedUnion("difficulties", [
z.object({
difficulties: z.literal("tak").transform((arg) => true),
difficultiesRelated: radio()
}),
z.object({
difficulties: z.literal("nie").transform((arg) => false),
difficultiesRelated: radio(["tak", "nie", undefined]).nullish()
})
])
)
it works nvm, I found it. stupid mistake of having "difficulties" twice
Want results from more Discord servers?
Add your server