From 1dfc511e4fbce7b2a70e724ec680444685c5d01c Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Wed, 16 Jul 2025 16:47:29 +0100 Subject: [PATCH] fix(contextMenu): Remove regular expression validation (#10994) * fix: remove regex validation * test: remove incorrect test This is fine to create. * fix: guard against whitespace --- .../__tests__/interactions/ContextMenuCommands.test.ts | 2 -- .../src/interactions/commands/contextMenu/Assertions.ts | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/builders/__tests__/interactions/ContextMenuCommands.test.ts b/packages/builders/__tests__/interactions/ContextMenuCommands.test.ts index 4d5da2922..36b569af1 100644 --- a/packages/builders/__tests__/interactions/ContextMenuCommands.test.ts +++ b/packages/builders/__tests__/interactions/ContextMenuCommands.test.ts @@ -12,8 +12,6 @@ describe('Context Menu Commands', () => { }); test('GIVEN invalid name THEN throw error', () => { - expect(() => getBuilder().setName('$$$').toJSON()).toThrowError(); - expect(() => getBuilder().setName(' ').toJSON()).toThrowError(); }); diff --git a/packages/builders/src/interactions/commands/contextMenu/Assertions.ts b/packages/builders/src/interactions/commands/contextMenu/Assertions.ts index 0dc0f4bdd..ea06b63c9 100644 --- a/packages/builders/src/interactions/commands/contextMenu/Assertions.ts +++ b/packages/builders/src/interactions/commands/contextMenu/Assertions.ts @@ -6,7 +6,9 @@ const namePredicate = z .string() .min(1) .max(32) - .regex(/^(?:(?: *[\p{P}\p{L}\p{N}\p{sc=Devanagari}\p{sc=Thai}\p{Extended_Pictographic}\p{Emoji_Component}]) *)+$/u); + .refine((val) => val.trim().length > 0, { + error: 'Must not consist of only whitespace.', + }); const contextsPredicate = z.array(z.enum(InteractionContextType)); const integrationTypesPredicate = z.array(z.enum(ApplicationIntegrationType));