Documentation
¶
Overview ¶
Package validate provides a connect.Interceptor that validates messages against constraints specified in their Protobuf schemas. Because the interceptor is powered by protovalidate, validation is flexible, efficient, and consistent across languages - without additional code generation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interceptor ¶
type Interceptor struct {
// contains filtered or unexported fields
}
Interceptor is a connect.Interceptor that ensures that RPC request messages match the constraints expressed in their Protobuf schemas. It does not validate response messages.
By default, Interceptors use a validator that lazily compiles constraints and works with any Protobuf message. This is a simple, widely-applicable configuration: after compiling and caching the constraints for a Protobuf message type once, validation is very efficient. To customize the validator, use WithValidator and protovalidate.ValidatorOption.
RPCs with invalid request messages short-circuit with an error. The error always uses connect.CodeInvalidArgument and has a detailed representation of the error attached as a connect.ErrorDetail.
This interceptor is primarily intended for use on handlers. Client-side use is possible, but discouraged unless the client always has an up-to-date schema.
func NewInterceptor ¶
func NewInterceptor(opts ...Option) (*Interceptor, error)
NewInterceptor builds an Interceptor. The default configuration is appropriate for most use cases.
func (*Interceptor) WrapStreamingClient ¶
func (i *Interceptor) WrapStreamingClient(next connect.StreamingClientFunc) connect.StreamingClientFunc
WrapStreamingClient implements connect.Interceptor.
func (*Interceptor) WrapStreamingHandler ¶
func (i *Interceptor) WrapStreamingHandler(next connect.StreamingHandlerFunc) connect.StreamingHandlerFunc
WrapStreamingHandler implements connect.Interceptor.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
An Option configures an Interceptor.
func WithValidator ¶
func WithValidator(validator protovalidate.Validator) Option
WithValidator configures the Interceptor to use a customized protovalidate.Validator. See protovalidate.ValidatorOption for the range of available customizations.