1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-24 08:57:03 -05:00

there is a validation module

This commit is contained in:
Michael Jerger 2023-12-08 18:08:16 +01:00
parent a10a9141f8
commit 6fef54ed1c

View file

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