validate

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2020 License: GPL-3.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Float64Positive = GreaterThan.Float64(0.0)
View Source
var IntNatural = GreaterOrEqual.Int(0)
View Source
var IntPositive = GreaterThan.Int(0)

Functions

func FromJson

func FromJson(v Validator, b []byte) (err error)

func IntFromJson added in v0.3.0

func IntFromJson(iv IntValidator, b []byte) (ii int, err error)

Types

type Float64Limit

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

func (Float64Limit) Exceeded

func (f Float64Limit) Exceeded(val float64) (fe Float64LimitExceeded)

func (Float64Limit) InLimit

func (f Float64Limit) InLimit(val float64) (b bool)

func (Float64Limit) Validate

func (f Float64Limit) Validate(val float64) (err error)

type Float64LimitExceeded

type Float64LimitExceeded struct {
	Float64Limit
	// contains filtered or unexported fields
}

func (Float64LimitExceeded) Error

func (f Float64LimitExceeded) Error() (s string)

type Float64Range

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

func NewFloat64Range

func NewFloat64Range(min, max float64) (f Float64Range)

func (Float64Range) Validate

func (f Float64Range) Validate(val float64) (err error)

type Float64Validator

type Float64Validator interface {
	Validate(float64) error
}

type Float64Validators

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

func (Float64Validators) Validate

func (f Float64Validators) Validate(value float64) (err error)

type IntLimit added in v0.3.0

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

func (IntLimit) Exceeded added in v0.3.0

func (i IntLimit) Exceeded(val int) (ie IntLimitExceeded)

func (IntLimit) InLimit added in v0.3.0

func (i IntLimit) InLimit(val int) (b bool)

func (IntLimit) Validate added in v0.3.0

func (i IntLimit) Validate(val int) (err error)

type IntLimitExceeded added in v0.3.0

type IntLimitExceeded struct {
	IntLimit
	// contains filtered or unexported fields
}

func (IntLimitExceeded) Error added in v0.3.0

func (f IntLimitExceeded) Error() (s string)

type IntValidator added in v0.3.0

type IntValidator interface {
	Validate(int) error
}

type NaturalInt added in v0.3.0

type NaturalInt int

func (*NaturalInt) UnmarshalJSON added in v0.3.0

func (n *NaturalInt) UnmarshalJSON(b []byte) (err error)

type Op

type Op int
const (
	GreaterThan Op = iota
	GreaterOrEqual
	LessThan
	LessOrEqual
)

func (Op) Explain

func (op Op) Explain() (s string)

func (Op) Float64

func (op Op) Float64(limit float64) (f Float64Limit)

func (Op) Int added in v0.3.0

func (op Op) Int(limit int) (i IntLimit)

type PositiveInt added in v0.3.0

type PositiveInt int

func (*PositiveInt) UnmarshalJSON added in v0.3.0

func (p *PositiveInt) UnmarshalJSON(b []byte) (err error)

type Validator

type Validator interface {
	Validate() error
}

Jump to

Keyboard shortcuts

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