validation

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2019 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 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.

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

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