#how to create tuples in convex

1 messages · Page 1 of 1 (latest)

sick night
#

export const weekDayValidator = v.array(
v.literal(WeekDay.SUNDAY),
v.literal(WeekDay.MONDAY),
v.literal(WeekDay.TUESDAY),
v.literal(WeekDay.WEDNESDAY),
v.literal(WeekDay.THURSDAY),
v.literal(WeekDay.FRIDAY),
v.literal(WeekDay.SATURDAY),
);
i want to achieve this , but v.array only accepts 1 argument

granite burrowBOT
#

Thanks for posting in #1088161997662724167.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.

    - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
    - Use [search.convex.dev](https://search.convex.dev) to search Docs, Stack, and Discord all at once.
    - Additionally, you can post your questions in the Convex Community's #1228095053885476985 channel to receive a response from AI.
    - Avoid tagging staff unless specifically instructed.

    Thank you!
desert karma
#

Although looking at your type, I'm not sure why you would want a tuple made entirely of literals. Do you perhaps want a v.union ?

small rain
#

const v1 = v.union(v.literal("sunday"), v.literal("monday"), ...) would match values like "monday" and "wednesday".

const v2 = v.array(v.union(v.literal("sunday"), v.literal("monday"), ...)) would match values like ["monday"] and ["saturday", "sunday"] and ["monday", "monday", "tuesday"] (but not "monday" since it's not an array, or ["monday", "foo"] since "foo is not in the union)