You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when i use - plugin: buf.build/bufbuild/validate-go to generate validation, a *.pb.validate.go is generated, but no validation rule in function Validate or ValidateAll. if i want to use validate, i need to new a protovalidateor to validate the struct. is it excessive?
// Validate checks the field values on Task with the rules defined in the proto// definition for this message. If any rules are violated, the first error// encountered is returned, or nil if there are no violations.func (m*Task) Validate() error {
returnm.validate(false)
}
// ValidateAll checks the field values on Task with the rules defined in the// proto definition for this message. If any rules are violated, the result is// a list of violation errors wrapped in TaskMultiError, or nil if none found.func (m*Task) ValidateAll() error {
returnm.validate(true)
}
func (m*Task) validate(allbool) error {
ifm==nil {
returnnil
}
varerrors []error// no validation rules for Id// no validation rules for Name// no validation rules for Descriptioniflen(errors) >0 {
returnTaskMultiError(errors)
}
returnnil
}
Expected Behavior
i can use task.Validate() or task.ValidateAll() to validate fields
Hi @Panlq! We covered the impetus for moving to a non-codegen approach in our blog post announcing the protovalidate project. If you have further questions, please don't hesitate to open a new issue. We're more than happy to provide further clarification.
bufbuild
locked as resolved and limited conversation to collaborators
Feb 22, 2024
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Description
when i use - plugin: buf.build/bufbuild/validate-go to generate validation, a *.pb.validate.go is generated, but no validation rule in function Validate or ValidateAll. if i want to use validate, i need to new a protovalidateor to validate the struct. is it excessive?
Steps to Reproduce
buf.gen.yaml
task.pb.validate.go
Expected Behavior
i can use task.Validate() or task.ValidateAll() to validate fields
Actual Behavior
all pass directly
Screenshots/Logs
Environment
Possible Solution
Additional Context
The text was updated successfully, but these errors were encountered: