validators

package
v2.0.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CustomKeys = map[string]string{}

Functions

func GenerateKey

func GenerateKey(s string) string

Types

type BytesArePresent

type BytesArePresent struct {
	Name    string
	Field   []byte
	Message string
}

func (*BytesArePresent) IsValid

func (v *BytesArePresent) IsValid(errors *validate.Errors)

IsValid adds an error if the field is not empty.

type EmailIsPresent

type EmailIsPresent struct {
	Name    string
	Field   string
	Message string
}

func (*EmailIsPresent) IsValid

func (v *EmailIsPresent) IsValid(errors *validate.Errors)

IsValid performs the validation based on the email regexp match.

type EmailLike

type EmailLike struct {
	Name    string
	Field   string
	Message string
}

EmailLike checks that email has two parts (username and domain separated by @) Also it check that domain have domain zone (don`t check that zone is valid)

func (*EmailLike) IsValid

func (v *EmailLike) IsValid(errors *validate.Errors)

IsValid performs the validation based on email struct (username@domain)

type FuncValidator

type FuncValidator struct {
	Fn      func() bool
	Field   string
	Name    string
	Message string
}

func (*FuncValidator) IsValid

func (f *FuncValidator) IsValid(verrs *validate.Errors)

type IntArrayIsPresent

type IntArrayIsPresent struct {
	Name    string
	Field   []int
	Message string
}

func (*IntArrayIsPresent) IsValid

func (v *IntArrayIsPresent) IsValid(errors *validate.Errors)

IsValid adds an error if the field is an empty array.

type IntIsGreaterThan

type IntIsGreaterThan struct {
	Name     string
	Field    int
	Compared int
	Message  string
}

func (*IntIsGreaterThan) IsValid

func (v *IntIsGreaterThan) IsValid(errors *validate.Errors)

IsValid adds an error if the field is not greater than the compared value.

type IntIsLessThan

type IntIsLessThan struct {
	Name     string
	Field    int
	Compared int
	Message  string
}

func (*IntIsLessThan) IsValid

func (v *IntIsLessThan) IsValid(errors *validate.Errors)

IsValid adds an error if the field is not less than the compared value.

type IntIsPresent

type IntIsPresent struct {
	Name    string
	Field   int
	Message string
}

func (*IntIsPresent) IsValid

func (v *IntIsPresent) IsValid(errors *validate.Errors)

IsValid adds an error if the field equals 0.

type RegexMatch

type RegexMatch struct {
	Name    string
	Field   string
	Expr    string
	Message string
}

RegexMatch specifies the properties needed by the validation.

func (*RegexMatch) IsValid

func (v *RegexMatch) IsValid(errors *validate.Errors)

IsValid performs the validation based on the regexp match.

type StringInclusion

type StringInclusion struct {
	Name    string
	Field   string
	List    []string
	Message string
}

func (*StringInclusion) IsValid

func (v *StringInclusion) IsValid(errors *validate.Errors)

IsValid adds an error if the field is not one of the allowed values.

type StringIsPresent

type StringIsPresent struct {
	Name    string
	Field   string
	Message string
}

func (*StringIsPresent) IsValid

func (v *StringIsPresent) IsValid(errors *validate.Errors)

IsValid adds an error if the field is empty.

type StringLengthInRange

type StringLengthInRange struct {
	Name    string
	Field   string
	Min     int
	Max     int
	Message string
}

func (*StringLengthInRange) IsValid

func (v *StringLengthInRange) IsValid(errors *validate.Errors)

IsValid checks that string in range of min:max if max not present or it equal to 0 it will be equal to string length

type StringsMatch

type StringsMatch struct {
	Name    string
	Field   string
	Field2  string
	Message string
}

func (*StringsMatch) IsValid

func (v *StringsMatch) IsValid(errors *validate.Errors)

IsValid performs the validation equality of two strings.

type TimeAfterTime

type TimeAfterTime struct {
	FirstName  string
	FirstTime  time.Time
	SecondName string
	SecondTime time.Time
	Message    string
}

func (*TimeAfterTime) IsValid

func (v *TimeAfterTime) IsValid(errors *validate.Errors)

IsValid adds an error if the FirstTime is not after the SecondTime.

type TimeIsBeforeTime

type TimeIsBeforeTime struct {
	FirstName  string
	FirstTime  time.Time
	SecondName string
	SecondTime time.Time
	Message    string
}

func (*TimeIsBeforeTime) IsValid

func (v *TimeIsBeforeTime) IsValid(errors *validate.Errors)

IsValid adds an error if the FirstTime is after the SecondTime.

type TimeIsPresent

type TimeIsPresent struct {
	Name    string
	Field   time.Time
	Message string
}

func (*TimeIsPresent) IsValid

func (v *TimeIsPresent) IsValid(errors *validate.Errors)

IsValid adds an error if the field is not a valid time.

type URLIsPresent

type URLIsPresent struct {
	Name    string
	Field   string
	Message string
}

func (*URLIsPresent) IsValid

func (v *URLIsPresent) IsValid(errors *validate.Errors)

IsValid performs the validation to check if URL is formatted correctly uses net/url ParseRequestURI to check validity

type UUIDIsPresent

type UUIDIsPresent struct {
	Name    string
	Field   uuid.UUID
	Message string
}

func (*UUIDIsPresent) IsValid

func (v *UUIDIsPresent) IsValid(errors *validate.Errors)

IsValid adds an error if the field is not a valid uuid.

Jump to

Keyboard shortcuts

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