From db6b79daabf0432a5362f232b772b5965cb7b92f Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Fri, 19 Feb 2021 19:03:39 +0100 Subject: [PATCH] :sparkles: Add command name validation --- src/components/CreateSlashCommand.vue | 2 ++ src/components/CreateSubCommand.vue | 2 ++ src/components/CreateSubGroup.vue | 2 ++ src/components/SlashCommandOptionForm.vue | 2 ++ 4 files changed, 8 insertions(+) diff --git a/src/components/CreateSlashCommand.vue b/src/components/CreateSlashCommand.vue index ae822c3..6b86e88 100644 --- a/src/components/CreateSlashCommand.vue +++ b/src/components/CreateSlashCommand.vue @@ -100,6 +100,8 @@ export default { if (commandNameMinLength) return 'Name can not be shorter than 3 characters.'; const commandNameMaxLength = this.name.length > 32; if (commandNameMaxLength) return 'Name can not be longer than 32 characters.'; + const invalidCharacters = !(/^[0-9a-zA-Z_]{3,32}$/.test(this.name)); + if (invalidCharacters) return 'Name contains invalid characters.'; return null; }, commandDescriptionInputError () { diff --git a/src/components/CreateSubCommand.vue b/src/components/CreateSubCommand.vue index eb77760..712967f 100644 --- a/src/components/CreateSubCommand.vue +++ b/src/components/CreateSubCommand.vue @@ -97,6 +97,8 @@ export default { if (nameMinLength) return 'The sub command name can not be shorter than 3 characters!'; const nameMaxLength = this.name.length > 32; if (nameMaxLength) return 'The sub command name can not be longer than 32 characters!'; + const invalidCharacters = !(/^[0-9a-zA-Z_]{3,32}$/.test(this.name)); + if (invalidCharacters) return 'Name contains invalid characters.'; return null; }, descriptionInputError () { diff --git a/src/components/CreateSubGroup.vue b/src/components/CreateSubGroup.vue index a19d359..39f6fcb 100644 --- a/src/components/CreateSubGroup.vue +++ b/src/components/CreateSubGroup.vue @@ -97,6 +97,8 @@ export default { if (nameMinLength) return 'The group name can not be shorter than 3 characters!'; const nameMaxLength = this.name.length > 32; if (nameMaxLength) return 'The group name can not be longer than 32 characters!'; + const invalidCharacters = !(/^[0-9a-zA-Z_]{3,32}$/.test(this.name)); + if (invalidCharacters) return 'Name contains invalid characters.'; return null; }, descriptionInputError () { diff --git a/src/components/SlashCommandOptionForm.vue b/src/components/SlashCommandOptionForm.vue index a1b81e9..5b3a300 100644 --- a/src/components/SlashCommandOptionForm.vue +++ b/src/components/SlashCommandOptionForm.vue @@ -203,6 +203,8 @@ export default { if (nameMinLength) return 'The option name can not be shorter than 3 characters!'; const nameMaxLength = this.name.length > 32; if (nameMaxLength) return 'The option name can not be longer than 32 characters!'; + const invalidCharacters = !(/^[0-9a-zA-Z_]{3,32}$/.test(this.name)); + if (invalidCharacters) return 'Name contains invalid characters.'; return null; }, descriptionInputError () {