Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Validator ¶
func Validator(validators ...ValidatorFunc) middleware.Middleware
Validator returns a middleware that performs validation on requests. It validates requests that implement Validate and any custom validators. Example usage:
buf validate(https://github.com/bufbuild/protovalidate): import "buf.build/go/protovalidate" import "google.golang.org/protobuf/proto"
Validator(func(v any) error {
if msg, ok := v.(proto.Message); ok {
return protovalidate.Validate(msg)
}
return nil
})
Google AIP field behavior validate(https://google.aip.dev/203): import "go.einride.tech/aip/fieldbehavior" import "google.golang.org/protobuf/proto"
Validator(func(v any) error {
if msg, ok := v.(proto.Message); ok {
return fieldbehavior.ValidateRequiredFields(msg)
}
return nil
})
Types ¶
type ValidatorFunc ¶
ValidatorFunc defines a validation function type.
Click to show internal directories.
Click to hide internal directories.