From 0df7cab4fb0c84444ceb4c9b5f28f410a38025f5 Mon Sep 17 00:00:00 2001 From: Lanre Adelowo Date: Tue, 7 Aug 2018 18:15:41 +0100 Subject: prevent empty review comment (#4632) * prevent empty review comment This would only require a comment for rejection and comment * add tests * add comment --- modules/auth/repo_form.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'modules/auth/repo_form.go') diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go index d205a6fd53..3c7940afce 100644 --- a/modules/auth/repo_form.go +++ b/modules/auth/repo_form.go @@ -402,6 +402,14 @@ func (f SubmitReviewForm) ReviewType() models.ReviewType { } } +// HasEmptyContent checks if the content of the review form is empty. +func (f SubmitReviewForm) HasEmptyContent() bool { + reviewType := f.ReviewType() + + return (reviewType == models.ReviewTypeComment || reviewType == models.ReviewTypeReject) && + len(strings.TrimSpace(f.Content)) == 0 +} + // __________ .__ // \______ \ ____ | | ____ _____ ______ ____ // | _// __ \| | _/ __ \\__ \ / ___// __ \ -- cgit v1.2.3