fix(stringOption): zod validation (#11532)

fix: zod validation

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Denis-Adrian Cristea
2026-05-21 18:46:49 +03:00
committed by GitHub
parent 1e88dcdc05
commit e490a230a3
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);