fix(contextMenuCommands): Remove regular expression validation (#10996)

* fix: remove name check for context menu commands

* fix: simpler regex

Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com>

---------

Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com>
This commit is contained in:
Jiralite
2025-07-17 10:07:18 +01:00
committed by GitHub
parent ba5ccab919
commit 4906aaea4c
2 changed files with 3 additions and 6 deletions

View File

@@ -16,8 +16,8 @@ describe('Context Menu Commands', () => {
// Too short of a name
expect(() => ContextMenuCommandAssertions.validateName('')).toThrowError();
// Invalid characters used
expect(() => ContextMenuCommandAssertions.validateName('ABC123$%^&')).toThrowError();
// This should be fine, even with trailing and leading spaces (API trims it).
expect(() => ContextMenuCommandAssertions.validateName(' 🩵 ABC 123 $%^& ')).not.toThrowError();
// Too long of a name
expect(() =>
@@ -60,8 +60,6 @@ describe('Context Menu Commands', () => {
});
test('GIVEN invalid name THEN throw error', () => {
expect(() => getBuilder().setName('$$$')).toThrowError();
expect(() => getBuilder().setName(' ')).toThrowError();
});

View File

@@ -7,8 +7,7 @@ const namePredicate = s
.string()
.lengthGreaterThanOrEqual(1)
.lengthLessThanOrEqual(32)
// eslint-disable-next-line prefer-named-capture-group
.regex(/^( *[\p{P}\p{L}\p{N}\p{sc=Devanagari}\p{sc=Thai}]+ *)+$/u)
.regex(/\S/)
.setValidationEnabled(isValidationEnabled);
const typePredicate = s
.union([s.literal(ApplicationCommandType.User), s.literal(ApplicationCommandType.Message)])