hmn/src/models/tag.go

26 lines
352 B
Go
Raw Permalink Normal View History

2021-11-11 19:00:46 +00:00
package models
import "regexp"
2021-11-11 19:00:46 +00:00
type Tag struct {
ID int `db:"id"`
Text string `db:"text"`
}
var REValidTag = regexp.MustCompile(`^[a-z0-9]+(-[a-z0-9]+)*$`)
func ValidateTagText(text string) bool {
if text == "" {
return true
}
if len(text) > 20 {
return false
}
if !REValidTag.MatchString(text) {
return false
}
return true
}