validate

package
v0.0.0-...-13f918f Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2016 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chain

func Chain(validator *Validator) func(v reflect.Value) error

func City

func City(v reflect.Value) error

func CityId

func CityId(v reflect.Value) error

func CurrencyCode

func CurrencyCode(v reflect.Value) error

func Hob

func Hob(v reflect.Value) error

func HobId

func HobId(v reflect.Value) error

func Latitude

func Latitude(v reflect.Value) error

func Longitude

func Longitude(v reflect.Value) error

func NotEmpty

func NotEmpty(v reflect.Value) error

func Regexp

func Regexp(re *regexp.Regexp) func(v reflect.Value) error

Types

type Rule

type Rule func(v reflect.Value) error

func NotOneOf

func NotOneOf(disallowed ...interface{}) Rule

func OneOf

func OneOf(allowed ...interface{}) Rule

func StringLength

func StringLength(min, max int) Rule

StringLength validates that a value is a string between min/max length (rune count)

type Validator

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

func New

func New() *Validator

func (*Validator) CheckField

func (v *Validator) CheckField(field string, rules ...Rule) *Validator

CheckField adds a check to this validator to look at struct field `field` and test this for every rule in `rules`

func (*Validator) CheckMethod

func (v *Validator) CheckMethod(method string, rules ...Rule) *Validator

CheckMethod adds a check to this validator to look at an expected method named `method`, and then test the return value from this method against every rule in `rules`

func (*Validator) Validate

func (v *Validator) Validate(s interface{}) *multierror.MultiError

Validate tests all defined checks within this validator against some value `s`

Jump to

Keyboard shortcuts

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