validation

package
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2023 License: MIT Imports: 5 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 any) error

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

Types

type Error added in v0.4.4

type Error struct {
	Message string
	Source  error
}

func (Error) Error added in v0.4.4

func (e Error) Error() string

func (Error) UserError added in v0.4.4

func (e Error) UserError() string

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 any) *Errors

Add appends the field and msg to the current list of errors. Add will initialize the Errors object if it is not initialized. If msg is `error` it is added directly, otherwise the value is converted to a string and added.

func (*Errors) Error

func (ee *Errors) Error() string

Error returns the error string of Errors.

func (*Errors) Fields added in v0.4.4

func (ee *Errors) Fields() map[string][]string

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

type Messages

type Messages []error //nolint: errname

Messages are the validation failures for a given field.

func (Messages) Error

func (mm Messages) Error() string

type UserError added in v0.4.4

type UserError interface {
	error
	UserError() string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳