validation

package
v0.0.0-...-0fadc07 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrIDFailedValidation      = errors.ID("failed-validation")
	StatusCodeFailedValidation = errors.StatusBadRequest
)

Exported error IDs.

Variables

This section is empty.

Functions

func FieldsFromValidationErrors

func FieldsFromValidationErrors(errs validator.ValidationErrors) map[string]interface{}

FieldsFromValidationErrors converts ValidationErrors to fields.

func MustRegisterValidator

func MustRegisterValidator(tag string, validator validator.Func)

MustRegisterValidator registers a validator.

func RegexpValidatorFactory

func RegexpValidatorFactory(regexp *regexp.Regexp) validator.Func

RegexpValidatorFactory creates a validator that matches a regexp.

func Validate

func Validate(v interface{}) error

Validate calls Valid and/or Validate if the given value implements SimpleValidator or Validator.

func ValidateStruct

func ValidateStruct(v interface{}) error

ValidateStruct validates a struct.

func WrapError

func WrapError(err error, fields map[string]interface{}, options ...errors.Option) error

WrapError wraps an error as failed validation error.

Types

type SimpleValidator

type SimpleValidator interface {
	Valid() bool
}

SimpleValidator describes a type that can validate itself, returning only a "valid" bool.

type Validator

type Validator interface {
	Validate() error
}

Validator describes a type that can validate itself.

Directories

Path Synopsis
internal
validationmocks
Package validationmocks is a generated GoMock package.
Package validationmocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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