valider

package module
v0.0.0-...-5f68a80 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeRequired   = "required"
	CodeNotMatched = "not_matched"
	CodeNotEqual   = "not_equal"
	CodeEqual      = "equal"
	CodeOutRange   = "out_range"
	CodeIn         = "in"
	CodeLen        = "length"
	CodeDate       = "not_date"
	CodeNotFound   = "not_found"
	CodeExists     = "exists"

	CodeUnsupported  = "unsopported_type"
	CodeBadParameter = "bad_parameter"
)
View Source
const (
	PatternEmail = "" /* 135-byte string literal not displayed */
	PatternURL   = `` /* 301-byte string literal not displayed */
)

Variables

View Source
var (
	ErrRequired   = errors.New("is required")
	ErrNotMatched = errors.New("not matched")
	ErrNotEqual   = errors.New("is not equal to value passed")
	ErrEqual      = errors.New("is equal to value passed")
	ErrOutRange   = errors.New("is out of range")
	ErrIn         = errors.New("is not in the values passed")
	ErrLen        = errors.New("is more length than value passed")
	ErrDate       = errors.New("is not a valid datetime")
	ErrNotFound   = errors.New("not found the value")
	ErrExists     = errors.New("the value exists")

	ErrUnsupported  = errors.New("unsopported type")
	ErrBadParameter = errors.New("bad parameter")
)

Functions

This section is empty.

Types

type Bool

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

func (*Bool) Equal

func (b *Bool) Equal(v bool) *Bool

func (*Bool) Valid

func (b *Bool) Valid() bool

type Bytes

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

func (*Bytes) In

func (f *Bytes) In(values ...[]byte) *Bytes

func (*Bytes) Len

func (f *Bytes) Len(num int) *Bytes

func (*Bytes) Range

func (f *Bytes) Range(min, max int) *Bytes

func (*Bytes) Required

func (f *Bytes) Required() *Bytes

type Error

type Error struct {
	Error    error
	Code     string
	ShouldBe interface{}
}

type Errors

type Errors map[string][]Error

func (Errors) Add

func (f Errors) Add(name string, err error, code string)

func (Errors) String

func (f Errors) String() string

type Float

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

func (*Float) Equal

func (f *Float) Equal(eq float64) *Float

func (*Float) Len

func (f *Float) Len(num int) *Float

func (*Float) Range

func (f *Float) Range(min, max float64) *Float

func (*Float) Required

func (f *Float) Required() *Float

type Int

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

func (*Int) Equal

func (it *Int) Equal(eq int) *Int

func (*Int) Len

func (it *Int) Len(num int) *Int

func (*Int) Range

func (it *Int) Range(min, max int) *Int

func (*Int) Required

func (it *Int) Required() *Int

type Map

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

func (*Map) Date

func (ma *Map) Date(layout string) *Map

func (*Map) InKeys

func (ma *Map) InKeys(keys ...string) *Map

func (*Map) InValues

func (ma *Map) InValues(values ...interface{}) *Map

func (*Map) Keys

func (ma *Map) Keys(keys ...string) *Map

func (*Map) Range

func (ma *Map) Range(min, max int) *Map

func (*Map) Required

func (ma *Map) Required() *Map

func (*Map) Values

func (ma *Map) Values(values ...interface{}) *Map

type Slice

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

func (*Slice) In

func (sl *Slice) In(values interface{}) *Slice

func (*Slice) Len

func (sl *Slice) Len(le int) *Slice

func (*Slice) Range

func (sl *Slice) Range(min, max int) *Slice

func (*Slice) Required

func (sl *Slice) Required() *Slice

type Str

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

func (*Str) Date

func (str *Str) Date(layout string) *Str

func (*Str) Email

func (str *Str) Email() *Str

func (*Str) Equal

func (str *Str) Equal(eq string) *Str

func (*Str) In

func (str *Str) In(values ...string) *Str

func (*Str) Len

func (str *Str) Len(num int) *Str

func (*Str) NotEqual

func (str *Str) NotEqual(eq string) *Str

func (*Str) Range

func (str *Str) Range(min, max int) *Str

func (*Str) RegExp

func (str *Str) RegExp(pattern string) *Str

func (*Str) Required

func (str *Str) Required() *Str

func (*Str) URL

func (str *Str) URL() *Str

type Validator

type Validator struct {
	Errors Errors
}

func New

func New(errs Errors) *Validator

func (*Validator) Bool

func (v *Validator) Bool(value bool, field string) *Bool

func (*Validator) Bytes

func (v *Validator) Bytes(value []byte, field string) *Bytes

func (*Validator) Float

func (v *Validator) Float(value float64, field string) *Float

func (*Validator) Int

func (v *Validator) Int(value int, field string) *Int

func (*Validator) Map

func (v *Validator) Map(value interface{}, field string) *Map

func (*Validator) Slice

func (v *Validator) Slice(value interface{}, field string) *Slice

func (*Validator) Str

func (v *Validator) Str(value, field string) *Str

Jump to

Keyboard shortcuts

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