validation

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Join added in v0.4.0

func Join(elems []error, sep string) string

func New

func New(field string, msg string) error

New returns a single validation error for the field with msg.

func NewError added in v0.4.0

func NewError(field string, msg error) error

NewError returns a single validation error for the field with the embedded error.

Types

type Errors

type Errors map[string]Messages //nolint: errname

Errors maps fields to the list of validation failures.

func (*Errors) Add

func (ee *Errors) Add(field string, msg error) *Errors

Add appends the field and msg to the current list of errors. Add will initialize the Errors object if it is not initialized.

func (Errors) Error

func (ee Errors) Error() string

Error returns the error string of Errors.

func (*Errors) GetErr

func (ee *Errors) GetErr() error

GetErr allows you to use a nil Errors object and return directly. If there are no validation errors it returns nil.

func (Errors) Keys added in v0.0.9

func (ee Errors) Keys() []string

func (*Errors) MarshalJSON added in v0.4.0

func (ee *Errors) MarshalJSON() ([]byte, error)

type Messages

type Messages []error //nolint: errname

Messages are the validation failures for a given field.

func (Messages) Error

func (mm Messages) Error() string

Jump to

Keyboard shortcuts

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