Skip to content

Commit

Permalink
✨ Add command name validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Androz2091 committed Feb 19, 2021
1 parent be7c27c commit db6b79d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/CreateSlashCommand.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 2 additions & 0 deletions src/components/CreateSubCommand.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 2 additions & 0 deletions src/components/CreateSubGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 2 additions & 0 deletions src/components/SlashCommandOptionForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit db6b79d

Please # to comment.