Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derived params #8

Open
lukemorales opened this issue Feb 4, 2024 Discussed in #3 · 0 comments
Open

Derived params #8

lukemorales opened this issue Feb 4, 2024 Discussed in #3 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@lukemorales
Copy link
Owner

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?

@lukemorales lukemorales added the enhancement New feature or request label Feb 4, 2024
@lukemorales lukemorales self-assigned this Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant