Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (25 sloc) 616 Bytes
package validators
import (
// RegexMatch specifies the properties needed by the validation.
type RegexMatch struct {
Name string
Field string
Expr string
Message string
// IsValid performs the validation based on the regexp match.
func (v *RegexMatch) IsValid(errors *validate.Errors) {
r := regexp.MustCompile(v.Expr)
if r.Match([]byte(v.Field)) {
if len(v.Message) > 0 {
errors.Add(GenerateKey(v.Name), v.Message)
errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s does not match the expected format.", v.Name))
You can’t perform that action at this time.