validators

package
v0.0.1-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2017 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

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

Error describes error occured during validation.

func NewError

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

NewError initializes new Error instance.

type MaxLengthValidator

type MaxLengthValidator struct {
	Length int
}

MaxLengthValidator controls minimum length.

func MaxLength

func MaxLength(length int) *MaxLengthValidator

MaxLength initializes MaxLengthValidator instance.

func (MaxLengthValidator) Validate

func (validator MaxLengthValidator) Validate(v interface{}) (interface{}, *Error)

Validate do validation.

type MaxValueValidator

type MaxValueValidator struct {
	Value float64
}

MaxValueValidator controls maximum value.

func MaxValue

func MaxValue(value float64) *MaxValueValidator

MaxValue initializes MaxValueValidator instance.

func (MaxValueValidator) Validate

func (validator MaxValueValidator) Validate(v interface{}) (interface{}, *Error)

Validate do validation.

type MinLengthValidator

type MinLengthValidator struct {
	Length int
}

MinLengthValidator controls minimum length.

func MinLength

func MinLength(length int) *MinLengthValidator

MinLength initializes MinLengthValidator instance.

func (MinLengthValidator) Validate

func (validator MinLengthValidator) Validate(v interface{}) (interface{}, *Error)

Validate do validation.

type MinValueValidator

type MinValueValidator struct {
	Value float64
}

MinValueValidator controls minimum value.

func MinValue

func MinValue(value float64) *MinValueValidator

MinValue initializes MinValueValidator instance.

func (MinValueValidator) Validate

func (validator MinValueValidator) Validate(v interface{}) (interface{}, *Error)

Validate do validation.

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