Validators

type Email

type Email struct {
    Match
}

func VaildEmail

func VaildEmail() Email

func (Email) DefaultMessage

func (e Email) DefaultMessage() string

type Length

type Length struct {
    N int
}

Requires an array or string to be exactly a given length.

func ValidLength

func ValidLength(n int) Length

func (Length) DefaultMessage

func (s Length) DefaultMessage() string

func (Length) IsSatisfied

func (s Length) IsSatisfied(obj interface{}) bool

type Match

type Match struct {
    Regexp *regexp.Regexp
}

Requires a string to match a given regex.

func ValidMatch

func ValidMatch(regex *regexp.Regexp) Match

func (Match) DefaultMessage

func (m Match) DefaultMessage() string

func (Match) IsSatisfied

func (m Match) IsSatisfied(obj interface{}) bool

type Max

type Max struct {
    Max int
}

func ValidMax

func ValidMax(max int) Max

func (Max) DefaultMessage

func (m Max) DefaultMessage() string

func (Max) IsSatisfied

func (m Max) IsSatisfied(obj interface{}) bool

type MaxSize

type MaxSize struct {
    Max int
}

Requires an array or string to be at most a given length.

func ValidMaxSize

func ValidMaxSize(max int) MaxSize

func (MaxSize) DefaultMessage

func (m MaxSize) DefaultMessage() string

func (MaxSize) IsSatisfied

func (m MaxSize) IsSatisfied(obj interface{}) bool

type Min

type Min struct {
    Min int
}

func ValidMin

func ValidMin(min int) Min

func (Min) DefaultMessage

func (m Min) DefaultMessage() string

func (Min) IsSatisfied

func (m Min) IsSatisfied(obj interface{}) bool

type MinSize

type MinSize struct {
    Min int
}

Requires an array or string to be at least a given length.

func ValidMinSize

func ValidMinSize(min int) MinSize

func (MinSize) DefaultMessage

func (m MinSize) DefaultMessage() string

func (MinSize) IsSatisfied

func (m MinSize) IsSatisfied(obj interface{}) bool

type Range

type Range struct {
    Min
    Max
}

Requires an integer to be within Min, Max inclusive.

func ValidRange

func ValidRange(min, max int) Range

func (Range) DefaultMessage

func (r Range) DefaultMessage() string

func (Range) IsSatisfied

func (r Range) IsSatisfied(obj interface{}) bool

type Required

type Required struct{}

func ValidRequired

func ValidRequired() Required

func (Required) DefaultMessage

func (r Required) DefaultMessage() string

func (Required) IsSatisfied

func (r Required) IsSatisfied(obj interface{}) bool

type Validator

type Validator interface {
    IsSatisfied(interface{}) bool
    DefaultMessage() string
}