We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alpha validator cannot have space. I think we need it.
hasPass := regexp.MustCompile(`^[a-zA-Z ]+$`).MatchString(reqData.Name)
The text was updated successfully, but these errors were encountered:
I custom validator @shamir92
var regexAlphaNumSpace = regexp.MustCompile("^[ \\p{L}\\p{N}]+$") var Ins *validator.Validate func init() { Ins = validator.New() Ins.RegisterValidation("alphanumspace", ValidateAlphaNumSpace) } func ValidateAlphaNumSpace(fl validator.FieldLevel) bool { return regexAlphaNumSpace.MatchString(fl.Field().String()) }
Use:
type Request struct { Name string `json:"name" validate:"required,alphanumspace"` }
Sorry, something went wrong.
Changing the current validator would be a breaking change.
But I can see benefit for such a validator so feel free to open a PR for that
Hi @zemzale. Can I add a new validation for alpha spaces?
Would love this but I think the regex should be modified so only whitespace isn't valid?
No branches or pull requests
Package version eg. v9, v10: v10
Issue, Question or Enhancement:
Alpha validator cannot have space. I think we need it.
Code sample, to showcase or reproduce:
The text was updated successfully, but these errors were encountered: