go-zero
go-zero copied to clipboard
I am planning to implement Auto Validation
Related issue(but stale): #3167
I am planning to implement such feature.
Is your feature request related to a problem? Please describe. Current auto validation rules is not enough.
Describe the solution you'd like
Imitating Gin's validator implementation.
There is a tag "binding", once you add that tag to the struct, when you call Bind()
-like function(in go-zero, it is httpx.Parse()
), it will automatically validate the struct's fields.
Gin underlying using the go-playground's validator, it has many validation rules, and also support custom validation rule.
Describe alternatives you've considered Currently I have no alternatives for auto validation
Additional context
In Gin's implementation, the validation's interface has such function: Validate(obj any) error
, and in go-zero, the validation interface's function is Validate() error
, I not sure which I should use