validator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2022 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