You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would it be possible to access string literals somehow? I want to define a property in my validation object which only accept an OR union of string literals.
export const schema = parseZodSchema(z.object({
size: z.union([
z.literal('S'),
z.literal('M'),
z.literal('L'),
z.literal('XL'),
]),
})
// this is equivalent to this type:
type Size = 'S' | 'M' | 'L' | 'XL'
I'm hoping to have something like this:
schema.keys.size.S // => "S"
But I'm not sure if this possible with how Typescript works.
The text was updated successfully, but these errors were encountered:
Thank you, I would really appreciate this feature!
Another consideration could be creating a new property on schema next to keys, could be called options or literals or something. It could be the place where all literal values and other values could go and could look like this:
Would it be possible to access string literals somehow? I want to define a property in my validation object which only accept an OR union of string literals.
I'm hoping to have something like this:
But I'm not sure if this possible with how Typescript works.
The text was updated successfully, but these errors were encountered: