go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

I am planning to implement Auto Validation

Open Linde7777 opened this issue 2 weeks ago • 14 comments

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

Linde7777 avatar Jun 20 '24 08:06 Linde7777