From d6642550bdab893dca6721d1613b575dfbcda02f Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 26 Apr 2020 18:32:34 +0200 Subject: [PATCH] Add input length validation for team names --- src/components/teams/EditTeam.vue | 13 ++++++++++++- src/components/teams/NewTeam.vue | 20 ++++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/components/teams/EditTeam.vue b/src/components/teams/EditTeam.vue index 4818e106..4c14da2b 100644 --- a/src/components/teams/EditTeam.vue +++ b/src/components/teams/EditTeam.vue @@ -15,6 +15,9 @@ +

+ Please specify at least five characters. +

@@ -142,7 +145,7 @@ import TeamModel from '../../models/team' import TeamMemberService from '../../services/teamMember' import TeamMemberModel from '../../models/teamMember' - + export default { name: "EditTeam", data() { @@ -156,6 +159,8 @@ showUserDeleteModal: false, user: auth.user, userIsAdmin: false, + + showError: false, } }, beforeMount() { @@ -193,6 +198,12 @@ }) }, submit() { + if (this.team.name.length <= 4) { + this.showError = true + return + } + this.showError = false + this.teamService.update(this.team) .then(response => { this.team = response diff --git a/src/components/teams/NewTeam.vue b/src/components/teams/NewTeam.vue index acc25663..5b74c9f0 100644 --- a/src/components/teams/NewTeam.vue +++ b/src/components/teams/NewTeam.vue @@ -8,7 +8,12 @@

- +

+

+ Please specify at least five characters. +

@@ -35,6 +43,7 @@ return { teamService: TeamService, team: TeamModel, + showError: false, } }, beforeMount() { @@ -50,9 +59,16 @@ }, methods: { newTeam() { + + if (this.team.name.length <= 4) { + this.showError = true + return + } + this.showError = false + this.teamService.create(this.team) .then(response => { - router.push({name:'editTeam', params:{id: response.id}}) + router.push({name: 'editTeam', params: {id: response.id}}) this.success({message: 'The team was successfully created.'}, this) }) .catch(e => {