From 6fef54ed1c73d53655fb9fefd9f16d36db7c6689 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 8 Dec 2023 18:08:16 +0100 Subject: [PATCH] there is a validation module --- modules/validation/helpers.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/validation/helpers.go b/modules/validation/helpers.go index 567ad867fe..7ea02dab02 100644 --- a/modules/validation/helpers.go +++ b/modules/validation/helpers.go @@ -4,6 +4,7 @@ package validation import ( + "fmt" "net" "net/url" "regexp" @@ -134,3 +135,10 @@ func IsValidUsername(name string) bool { return validUsernamePatternWithoutDots.MatchString(name) && !invalidUsernamePattern.MatchString(name) } + +func ValidateNotEmpty(value string, fieldName string) error { + if value == "" { + return fmt.Errorf("Field %v may not be empty.", fieldName) + } + return nil +}