This commit is contained in:
lbenedar
2026-03-06 12:35:10 +03:00
parent 91f5a63366
commit 2824e51c29
7 changed files with 113 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
package validator
import (
"regexp"
"strings"
"unicode/utf8"
)
@@ -44,3 +45,13 @@ func PermittedInt(value int, permittedValues ...int) bool {
}
return false
}
var EmailRX = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
func MinChars(value string, n int) bool {
return utf8.RuneCountInString(value) >= n
}
func Matches(value string, rx *regexp.Regexp) bool {
return rx.MatchString(value)
}