validate

package
v0.2.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package validate implements the functions, types, and interfaces for the module.

Package validate implements the functions, types, and interfaces for the module.

Package validate implements the functions, types, and interfaces for the module.

Package validate implements the functions, types, and interfaces for the module.

Package validate implements the functions, types, and interfaces for the module.

Package validate implements the functions, types, and interfaces for the module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProtoValidate

func NewProtoValidate(opts ...ProtoValidatorOption) (protovalidate.Validator, error)

NewProtoValidate creates a new ProtoValidator.

func ProtoValidate

func ProtoValidate(message proto.Message) error

ProtoValidate validates a protobuf message.

func Server added in v0.0.12

func Server(ss ...Option) (middleware.Middleware, error)

Server is a validator middleware.

Types

type CompilationError

type CompilationError = protovalidate.CompilationError

CompilationError is an error that occurs during compilation.

type OnValidationErrCallback added in v0.0.12

type OnValidationErrCallback func(ctx context.Context, err error) bool

OnValidationErrCallback is a function that will be invoked on validation error(s). It returns true if the error is handled and should be ignored, false otherwise.

type Option added in v0.1.0

type Option = func(*Options)

func WithFailFast

func WithFailFast(failFast bool) Option

WithFailFast tells v1Validator to immediately stop doing further validation after first validation error. This option is ignored if message is only supporting v1Validator.v1ValidatorLegacy interface.

func WithOnValidationErrCallback added in v0.0.12

func WithOnValidationErrCallback(onValidationErrCallback OnValidationErrCallback) Option

WithOnValidationErrCallback registers function that will be invoked on validation error(s).

func WithV2ProtoValidatorOption added in v0.2.6

func WithV2ProtoValidatorOption(opts ...ProtoValidatorOption) Option

WithV2ProtoValidatorOption registers options for Validator with version 2.

type Options added in v0.1.56

type Options struct {
	// contains filtered or unexported fields
}

type ProtoValidator

type ProtoValidator = protovalidate.Validator

ProtoValidator is a v1Validator for protobuf messages.

type ProtoValidatorOption

type ProtoValidatorOption = protovalidate.ValidatorOption

ProtoValidatorOption is an option for the ProtoValidator.

func WithAllowUnknownFields

func WithAllowUnknownFields() ProtoValidatorOption

WithAllowUnknownFields allows unknown fields.

func WithDisableLazy

func WithDisableLazy() ProtoValidatorOption

WithDisableLazy disables lazy validation.

func WithExtensionTypeResolver

func WithExtensionTypeResolver(extensionTypeResolver protoregistry.ExtensionTypeResolver) ProtoValidatorOption

WithExtensionTypeResolver sets the extension type resolver.

func WithMessages

func WithMessages(messages ...proto.Message) ProtoValidatorOption

WithMessages sets the messages to validate.

type RuntimeError

type RuntimeError = protovalidate.RuntimeError

RuntimeError is an error that occurs during runtime.

type ValidationError

type ValidationError = protovalidate.ValidationError

ValidationError is an error that occurs during validation.

type Validator

type Validator interface {
	Validate(ctx context.Context, req interface{}) error
}

func NewValidateV1 added in v0.0.12

func NewValidateV1(failFast bool, callback OnValidationErrCallback) Validator

func NewValidateV2 added in v0.0.12

func NewValidateV2(opts ...ProtoValidatorOption) (Validator, error)

NewValidateV2 creates a new v2Validator.

type Version

type Version int

Version is the version of the module.

const (
	// V1 is the first version of the module, used github.com/envoyproxy/protoc-gen-validate
	V1 Version = 1
	// V2 is the second version of the module, used buf.build/go/protovalidate
	V2 Version = 2
)

func (Version) String

func (i Version) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL