-
Notifications
You must be signed in to change notification settings - Fork 1.4k
How can I add regex=? (regular expression) into the struct tagname and customer the validate function. #561
New issue
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
Comments
Hey @celcbratelife You could create your own regex validation, but I'd recommend against it and create a custom validation with the regex precompiled. I won't be adding a regex to the built-in ones, please see the documentation for the reasons:
|
This is workaround: I couldnt make comma's to work:
|
Hi @deankarn Mabye this issue could help to implement: |
Hi @kfirfer Thanks for the interest in adding a regex tag. I still however maintain that adding one would:
Adding a tag with a pre-compiled regex only takes a minute and then is re-usable on many structs if desired. |
One scenario when this generic The OpenAPI specification is based on the JSON Scheme that defines the pattern field that is based on the ECMA 262 regular expression dialect. The It is handy, because you can use this Hint: for someone who still want to use the go-playground/validator with the OpenAPI
|
Example:
type Test struct{
Name string
validate:"regexp=??"
}
The text was updated successfully, but these errors were encountered: