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 +}