validation

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPrefix

func AddPrefix(fieldPrefix string, err error) error

AddPrefix will prepend a prefix to all field names within the given error.

func IsClientError added in v0.25.0

func IsClientError(err error) bool

IsClientError will determine if an error's cause is due to request/client error.

func IsValidationError

func IsValidationError(err error) bool

IsValidationError will determine if an error's cause is a field validation error.

func NewGenericError added in v0.24.0

func NewGenericError(message string) error

NewGenericError will create a new generic validation error.

func WrapError added in v0.26.0

func WrapError(err error) error

WrapError will return a new error that is reported as a ClientError.

Types

type FieldError

type FieldError interface {
	error
	Validation() bool
	Field() string
	Reason() string
}

A FieldError represents an invalid field during validation.

func NewFieldError

func NewFieldError(fieldName string, reason string) FieldError

NewFieldError will create a new FieldError for the given field and reason

func NewFieldErrorf added in v0.29.0

func NewFieldErrorf(fieldName string, reasonFormat string, args ...interface{}) FieldError

NewFieldError will create a new FieldError for the given field and reason

type MultiFieldError

type MultiFieldError interface {
	error
	Validation() bool
	FieldErrors() []FieldError
}

func NewMultiFieldError

func NewMultiFieldError(errs []FieldError) MultiFieldError

NewMultiFieldError will combine multiple FieldErrors into a MultiFieldError.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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