Open
Description
Discussed in #3
Originally posted by zbeyens February 3, 2024
I'm trying to derive a field from another field using .transform
to avoid using a separate hook.
skill: defineRoute('/@[username]/s/[skillTitleId]', {
// error
params: z
.object({
skillTitleId: z.string(),
username: z.string().transform((v) => v.slice(3)),
})
.transform((v) => ({
...v,
skillId: getTitleUrlId(v.skillTitleId),
})),
Using this, I'm getting
TS2740: Type
ZodEffects<ZodObject<{ skillId: ZodOptional; skillTitleId: ZodString; username: ZodEffects<ZodString, string, string>; }, "strip", ZodTypeAny, { ...; }, { ...; }>, { ...; }, { ...; }>
is missing the following properties from type
ZodObject<{ username: ZodType<any, ZodTypeDef, any>; skillTitleId: ZodType<any, ZodTypeDef, any>; }, UnknownKeysParam, ZodTypeAny, { ...; }, { ...; }>
: _cached, _getCached, shape, strict, and 14 more.
Would this be supported in some way?