validate

package
v0.0.0-...-2e936b0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(val any) error

Check validate the provided model against it's declared tags.

func IsFieldErrors

func IsFieldErrors(err error) bool

IsFieldErrors checks if error of type FieldErrors exists.

func NewFieldsError

func NewFieldsError(field string, err error) error

NewFieldsError creates a field error.

Types

type FieldError

type FieldError struct {
	Field string `json:"field"`
	Error string `json:"error"`
}

FieldError is used to indicate an error with a specific request field.

type FieldErrors

type FieldErrors []FieldError

FieldErrors represents a collection of field errors.

func GetFieldErrors

func GetFieldErrors(err error) FieldErrors

GetFieldErrors returns a copy of the FieldErrors pointer.

func (FieldErrors) Error

func (fe FieldErrors) Error() string

Error implements the error interface.

func (FieldErrors) Fields

func (fe FieldErrors) Fields() map[string]string

Fields returns the fields that failed validation.

Jump to

Keyboard shortcuts

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