validators

package
v1.0.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BooleanValidator

type BooleanValidator interface {
	Validate(value bool) (bool, *Error)
}

type DatetimeValidator

type DatetimeValidator interface {
	Validate(value time.Time) (time.Time, *Error)
}

type Error

type Error struct {
	Code       uint
	Parameters []interface{}
}

Error describes error occured during validation.

func NewError

func NewError(code uint, parameters ...interface{}) *Error

NewError initializes new Error instance.

type FloatMaxValueValidator

type FloatMaxValueValidator struct {
	Value float64
}

FloatMaxValueValidator controls maximum value.

func FloatMaxValue

func FloatMaxValue(value float64) *FloatMaxValueValidator

FloatMaxValue initializes FloatMaxValueValidator instance.

func (FloatMaxValueValidator) Validate

func (validator FloatMaxValueValidator) Validate(value float64) (float64, *Error)

Validate do validation.

type FloatMinValueValidator

type FloatMinValueValidator struct {
	Value float64
}

FloatMinValueValidator controls minimum value.

func FloatMinValue

func FloatMinValue(value float64) *FloatMinValueValidator

FloatMinValue initializes FloatMinValueValidator instance.

func (*FloatMinValueValidator) Validate

func (validator *FloatMinValueValidator) Validate(value float64) (float64, *Error)

Validate do validation.

type FloatValidator

type FloatValidator interface {
	Validate(value float64) (float64, *Error)
}

type IntegerMaxValueValidator

type IntegerMaxValueValidator struct {
	Value int
}

IntegerMaxValueValidator controls maximum value.

func IntegerMaxValue

func IntegerMaxValue(value int) *IntegerMaxValueValidator

IntegerMaxValue initializes IntegerMaxValueValidator instance.

func (IntegerMaxValueValidator) Validate

func (validator IntegerMaxValueValidator) Validate(value int) (int, *Error)

Validate do validation.

type IntegerMinValueValidator

type IntegerMinValueValidator struct {
	Value int
}

IntegerMinValueValidator controls minimum value.

func IntegerMinValue

func IntegerMinValue(value int) *IntegerMinValueValidator

IntegerMinValue initializes IntegerMinValueValidator instance.

func (IntegerMinValueValidator) Validate

func (validator IntegerMinValueValidator) Validate(value int) (int, *Error)

Validate do validation.

type IntegerValidator

type IntegerValidator interface {
	Validate(value int) (int, *Error)
}

type StringMaxLengthValidator

type StringMaxLengthValidator struct {
	Length int
}

StringMaxLengthValidator controls minimum length.

func StringMaxLength

func StringMaxLength(length int) *StringMaxLengthValidator

StringMaxLength initializes MaxLengthValidator instance.

func (StringMaxLengthValidator) Validate

func (validator StringMaxLengthValidator) Validate(value string) (string, *Error)

Validate do validation.

type StringMinLengthValidator

type StringMinLengthValidator struct {
	Length int
}

StringMinLengthValidator controls minimum length.

func StringMinLength

func StringMinLength(length int) *StringMinLengthValidator

StringMinLength initializes MinLengthValidator instance.

func (StringMinLengthValidator) Validate

func (validator StringMinLengthValidator) Validate(value string) (string, *Error)

Validate do validation.

type StringValidator

type StringValidator interface {
	Validate(value string) (string, *Error)
}

type Validator

type Validator interface {
	Validate(value interface{}) (interface{}, *Error)
}

Validator describes validation function. Error must contains error code as message.

Jump to

Keyboard shortcuts

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