Lightweight and easily self-hostable Git forge. git.poy.ooo
git-forge selfhosting homebrew
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738package lib
import "regexp"
var HandleRegex = regexp.MustCompile("^[a-z0-9]+([-_][a-z0-9_]+)*$")
const HandleMinLength = 3const HandleMaxLength = 30
const UsernameMinLength = 2 const UsernameMaxLength = 40
// validates a handle.func ValidateHandle(s string) bool { // check if the format is correct using the regex if !HandleRegex.MatchString(s) { return false }
// length constraint? length := len(s) if length < HandleMinLength || length > HandleMaxLength { return false }
return true}
// validates a username.func ValidateUsername(s string) bool { length := len(s) if length < UsernameMinLength || length > UsernameMaxLength { return false }
return true}