fix: zod validation

This commit is contained in:
didinele
2026-05-14 11:34:35 +03:00
parent 40ce0791a8
commit 3c4a75cd39
2 changed files with 11 additions and 2 deletions

View File

@@ -188,10 +188,19 @@ describe('Application Command toJSON() results', () => {
type: ApplicationCommandOptionType.String,
required: true,
autocomplete: true,
// TODO
choices: [],
});
// Starting with zod 4.4.0 (potentially lower), this usecase was broken prior to #11532
// (i.e. choices not present at all with autocomplete: true)
expect(getStringOption().setAutocomplete(true).toJSON()).toEqual<APIApplicationCommandStringOption>({
name: 'owo',
description: 'Testing 123',
type: ApplicationCommandOptionType.String,
required: true,
autocomplete: true,
});
expect(
getStringOption().addChoices({ name: 'uwu', value: '1' }).toJSON(),
).toEqual<APIApplicationCommandStringOption>({

View File

@@ -39,7 +39,7 @@ const channelMixinOptionPredicate = z.object({
const autocompleteMixinOptionPredicate = z.object({
autocomplete: z.literal(true),
choices: z.union([z.never(), z.never().array(), z.undefined()]),
choices: z.array(z.any()).length(0).optional(),
});
const choiceValueStringPredicate = z.string().min(1).max(100);