mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 03:53:29 +01:00
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:
@@ -16,8 +16,8 @@ describe('Context Menu Commands', () => {
|
|||||||
// Too short of a name
|
// Too short of a name
|
||||||
expect(() => ContextMenuCommandAssertions.validateName('')).toThrowError();
|
expect(() => ContextMenuCommandAssertions.validateName('')).toThrowError();
|
||||||
|
|
||||||
// Invalid characters used
|
// This should be fine, even with trailing and leading spaces (API trims it).
|
||||||
expect(() => ContextMenuCommandAssertions.validateName('ABC123$%^&')).toThrowError();
|
expect(() => ContextMenuCommandAssertions.validateName(' 🩵 ABC 123 $%^& ')).not.toThrowError();
|
||||||
|
|
||||||
// Too long of a name
|
// Too long of a name
|
||||||
expect(() =>
|
expect(() =>
|
||||||
@@ -60,8 +60,6 @@ describe('Context Menu Commands', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('GIVEN invalid name THEN throw error', () => {
|
test('GIVEN invalid name THEN throw error', () => {
|
||||||
expect(() => getBuilder().setName('$$$')).toThrowError();
|
|
||||||
|
|
||||||
expect(() => getBuilder().setName(' ')).toThrowError();
|
expect(() => getBuilder().setName(' ')).toThrowError();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ const namePredicate = s
|
|||||||
.string()
|
.string()
|
||||||
.lengthGreaterThanOrEqual(1)
|
.lengthGreaterThanOrEqual(1)
|
||||||
.lengthLessThanOrEqual(32)
|
.lengthLessThanOrEqual(32)
|
||||||
// eslint-disable-next-line prefer-named-capture-group
|
.regex(/\S/)
|
||||||
.regex(/^( *[\p{P}\p{L}\p{N}\p{sc=Devanagari}\p{sc=Thai}]+ *)+$/u)
|
|
||||||
.setValidationEnabled(isValidationEnabled);
|
.setValidationEnabled(isValidationEnabled);
|
||||||
const typePredicate = s
|
const typePredicate = s
|
||||||
.union([s.literal(ApplicationCommandType.User), s.literal(ApplicationCommandType.Message)])
|
.union([s.literal(ApplicationCommandType.User), s.literal(ApplicationCommandType.Message)])
|
||||||
|
|||||||
Reference in New Issue
Block a user