Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
iesreza committed Mar 27, 2024
1 parent 4ea286a commit b846db8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/validation/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
var Validators = map[*regexp.Regexp]func(match []string, value *generic.Value) error{
regexp.MustCompile("^text$"): textValidator,
regexp.MustCompile("^alpha$"): alphaValidator,
regexp.MustCompile("^name$"): nameValidator,
regexp.MustCompile("^digit$"): digitValidator,
regexp.MustCompile("^alphanumeric$"): alphaNumericValidator,
regexp.MustCompile("^required$"): requiredValidator,
Expand Down Expand Up @@ -264,6 +265,15 @@ func lenValidator(match []string, value *generic.Value) error {
return nil
}

func nameValidator(match []string, value *generic.Value) error {
var v = value.String()
if !regexp.MustCompile(`^[a-zA-Z]+(?:[\s-][a-zA-Z]+)*$`).MatchString(v) {
return fmt.Errorf("is not valid name")
}

return nil
}

func alphaValidator(match []string, value *generic.Value) error {
var v = value.String()
for _, r := range v {
Expand Down

0 comments on commit b846db8

Please sign in to comment.