mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 02:10:40 +00:00
there is a validation module
This commit is contained in:
parent
a10a9141f8
commit
6fef54ed1c
1 changed files with 8 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
||||||
package validation
|
package validation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -134,3 +135,10 @@ func IsValidUsername(name string) bool {
|
||||||
|
|
||||||
return validUsernamePatternWithoutDots.MatchString(name) && !invalidUsernamePattern.MatchString(name)
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue