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

Will go-zero support auto validation in api types.go?

Open zhyblack opened this issue 2 years ago • 2 comments
trafficstars

现在生成的 types.go 并没有实现自动校验的功能, 但是浏览代码的时候发现预留了接口和执行逻辑,

if valid, ok := v.(validation.Validator); ok {
    return valid.Validate()
} else if val := validator.Load(); val != nil {
    return val.(Validator).Validate(r, v)
}

如果自己在types.go中实现 validation.Validator 参数发生改变的时候重新生成就会被覆盖,

zhyblack avatar Apr 24 '23 09:04 zhyblack

You can implement the interface in a different file like types_validation.go

kevwan avatar Apr 30 '23 03:04 kevwan

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar May 05 '24 01:05 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Aug 08 '24 01:08 github-actions[bot]