validator

package
v0.0.0-...-106859a Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNonStructPayload = errors.New("validation payload is not a struct")

Functions

This section is empty.

Types

type ErrUnsupportedValidationTag

type ErrUnsupportedValidationTag struct {
	Tag string
}

func (ErrUnsupportedValidationTag) Error

type Error

type Error struct {
	Type    string                 `json:"type"`
	Field   string                 `json:"field"`
	Value   interface{}            `json:"value,omitempty"`
	Details map[string]interface{} `json:"details,omitempty"`
}

func (Error) Error

func (e Error) Error() string

type Option

type Option func(*Validator)

func ErrorFieldFromJSONTag

func ErrorFieldFromJSONTag() Option

type Result

type Result struct {
	Errors []Error `json:"validation_errors"`
}

func (Result) Invalid

func (r Result) Invalid() bool

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

func New

func New(options ...Option) Validator

func (Validator) Validate

func (v Validator) Validate(payload interface{}) (Result, error)

Jump to

Keyboard shortcuts

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