validationerrors

package
v0.16.8 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CondFieldEq

func CondFieldEq(theField string) errors.MapCond

CondFieldEq function returns a condition function that checks if the field matches the validation error field.

func CondReasonEq

func CondReasonEq(theReason string) errors.MapCond

CondReasonEq function returns a condition function that checks if the reason matches the validation error reason.

func CondValidation

func CondValidation() errors.MapCond

CondValidation function returns a condition function that matches standard Validation error and ensures that the error contains a field and a reason.

func DefaultMapping

func DefaultMapping() errors.MapFunc

DefaultMapping the default behavior for validation error mapping.

func GetValidationError

func GetValidationError(err error) error

GetValidationError function returns a validation error from an error.

func ToMapFunc

func ToMapFunc(f func(context.Context, ValidationError) (error, bool)) errors.MapFunc

ToMapFunc function converts mapping function for *validationerrors.Error to a conventional MapFunc from atlas-app-toolkit/errors package.

func UnaryServerInterceptor

func UnaryServerInterceptor() grpc.UnaryServerInterceptor

UnaryServerInterceptor returns a new unary server interceptor that validates incoming messages.

Invalid messages will be rejected with `InvalidArgument` before reaching any userspace handlers.

Types

type RequestValidationError added in v0.14.0

type RequestValidationError interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
}

RequestValidationError represent a validation error

type ValidationError

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

ValidationError represents the validation error that contains which field failed and the reasoning behind it.

func (ValidationError) Cause

func (e ValidationError) Cause() error

Cause function returns cause value.

func (ValidationError) Error

func (e ValidationError) Error() string

Error satisfies the builtin error interface

func (ValidationError) ErrorName added in v0.14.0

func (e ValidationError) ErrorName() string

ErrorName returns error name.

func (ValidationError) Field

func (e ValidationError) Field() string

Field function returns field value.

func (ValidationError) Key

func (e ValidationError) Key() bool

Key function returns key value.

func (ValidationError) Reason

func (e ValidationError) Reason() string

Reason function returns reason value.

Jump to

Keyboard shortcuts

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