validator

package
v1.26.0-data-model.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2018 License: BSD-2-Clause Imports: 8 Imported by: 13

Documentation

Index

Constants

View Source
const (
	ErrorCodeValueNotExists   = "value-not-exists"
	ErrorCodeValueExists      = "value-exists"
	ErrorCodeValueNotEmpty    = "value-not-empty"
	ErrorCodeValueEmpty       = "value-empty"
	ErrorCodeValueDuplicate   = "value-duplicate"
	ErrorCodeValueNotTrue     = "value-not-true"
	ErrorCodeValueNotFalse    = "value-not-false"
	ErrorCodeValueOutOfRange  = "value-out-of-range"
	ErrorCodeValueDisallowed  = "value-disallowed"
	ErrorCodeValueNotAllowed  = "value-not-allowed"
	ErrorCodeValueMatches     = "value-matches"
	ErrorCodeValueNotMatches  = "value-not-matches"
	ErrorCodeValueNotAfter    = "value-not-after"
	ErrorCodeValueNotBefore   = "value-not-before"
	ErrorCodeValueNotValid    = "value-not-valid"
	ErrorCodeLengthOutOfRange = "length-out-of-range"
)

Variables

This section is empty.

Functions

func ErrorLengthEqualTo

func ErrorLengthEqualTo(length int, limit int) error

func ErrorLengthNotEqualTo

func ErrorLengthNotEqualTo(length int, limit int) error

func ErrorLengthNotGreaterThan

func ErrorLengthNotGreaterThan(length int, limit int) error

func ErrorLengthNotGreaterThanOrEqualTo

func ErrorLengthNotGreaterThanOrEqualTo(length int, limit int) error

func ErrorLengthNotInRange

func ErrorLengthNotInRange(length int, lowerLimit int, upperLimit int) error

func ErrorLengthNotLessThan

func ErrorLengthNotLessThan(length int, limit int) error

func ErrorLengthNotLessThanOrEqualTo

func ErrorLengthNotLessThanOrEqualTo(length int, limit int) error

func ErrorValueBooleanNotFalse added in v1.26.0

func ErrorValueBooleanNotFalse() error

func ErrorValueBooleanNotTrue added in v1.26.0

func ErrorValueBooleanNotTrue() error

func ErrorValueDuplicate added in v1.26.0

func ErrorValueDuplicate() error

func ErrorValueEmpty

func ErrorValueEmpty() error

func ErrorValueEqualTo

func ErrorValueEqualTo(value interface{}, limit interface{}) error

func ErrorValueExists

func ErrorValueExists() error

func ErrorValueFloat64NotOneOf

func ErrorValueFloat64NotOneOf(value float64, allowedValues []float64) error

func ErrorValueFloat64OneOf

func ErrorValueFloat64OneOf(value float64, disallowedValues []float64) error

func ErrorValueIntNotOneOf

func ErrorValueIntNotOneOf(value int, allowedValues []int) error

func ErrorValueIntOneOf

func ErrorValueIntOneOf(value int, disallowedValues []int) error

func ErrorValueNotEmpty

func ErrorValueNotEmpty() error

func ErrorValueNotEqualTo

func ErrorValueNotEqualTo(value interface{}, limit interface{}) error

func ErrorValueNotExists

func ErrorValueNotExists() error

func ErrorValueNotGreaterThan

func ErrorValueNotGreaterThan(value interface{}, limit interface{}) error

func ErrorValueNotGreaterThanOrEqualTo

func ErrorValueNotGreaterThanOrEqualTo(value interface{}, limit interface{}) error

func ErrorValueNotInRange

func ErrorValueNotInRange(value interface{}, lowerLimit interface{}, upperLimit interface{}) error

func ErrorValueNotLessThan

func ErrorValueNotLessThan(value interface{}, limit interface{}) error

func ErrorValueNotLessThanOrEqualTo

func ErrorValueNotLessThanOrEqualTo(value interface{}, limit interface{}) error

func ErrorValueStringAsTimeNotValid added in v1.24.0

func ErrorValueStringAsTimeNotValid(value string, layout string) error

func ErrorValueStringMatches

func ErrorValueStringMatches(value string, expression *regexp.Regexp) error

func ErrorValueStringNotMatches

func ErrorValueStringNotMatches(value string, expression *regexp.Regexp) error

func ErrorValueStringNotOneOf

func ErrorValueStringNotOneOf(value string, allowedValues []string) error

func ErrorValueStringOneOf

func ErrorValueStringOneOf(value string, disallowedValues []string) error

func ErrorValueTimeNotAfter

func ErrorValueTimeNotAfter(value time.Time, limit time.Time) error

func ErrorValueTimeNotAfterNow

func ErrorValueTimeNotAfterNow(value time.Time) error

func ErrorValueTimeNotBefore

func ErrorValueTimeNotBefore(value time.Time, limit time.Time) error

func ErrorValueTimeNotBeforeNow

func ErrorValueTimeNotBeforeNow(value time.Time) error

Types

type Array added in v1.24.0

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

func NewArray added in v1.24.0

func NewArray(base *structureBase.Base, value *[]interface{}) *Array

func (*Array) Empty added in v1.24.0

func (a *Array) Empty() structure.Array

func (*Array) Exists added in v1.24.0

func (a *Array) Exists() structure.Array

func (*Array) NotEmpty added in v1.24.0

func (a *Array) NotEmpty() structure.Array

func (*Array) NotExists added in v1.24.0

func (a *Array) NotExists() structure.Array

func (*Array) Using added in v1.24.0

func (a *Array) Using(usingFunc structure.ArrayUsingFunc) structure.Array

type Bool

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

func NewBool

func NewBool(base *structureBase.Base, value *bool) *Bool

func (*Bool) Exists

func (b *Bool) Exists() structure.Bool

func (*Bool) False

func (b *Bool) False() structure.Bool

func (*Bool) NotExists

func (b *Bool) NotExists() structure.Bool

func (*Bool) True

func (b *Bool) True() structure.Bool

func (*Bool) Using added in v1.24.0

func (b *Bool) Using(usingFunc structure.BoolUsingFunc) structure.Bool

type Float64

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

func NewFloat64

func NewFloat64(base *structureBase.Base, value *float64) *Float64

func (*Float64) EqualTo

func (f *Float64) EqualTo(value float64) structure.Float64

func (*Float64) Exists

func (f *Float64) Exists() structure.Float64

func (*Float64) GreaterThan

func (f *Float64) GreaterThan(limit float64) structure.Float64

func (*Float64) GreaterThanOrEqualTo

func (f *Float64) GreaterThanOrEqualTo(limit float64) structure.Float64

func (*Float64) InRange

func (f *Float64) InRange(lowerLimit float64, upperLimit float64) structure.Float64

func (*Float64) LessThan

func (f *Float64) LessThan(limit float64) structure.Float64

func (*Float64) LessThanOrEqualTo

func (f *Float64) LessThanOrEqualTo(limit float64) structure.Float64

func (*Float64) NotEqualTo

func (f *Float64) NotEqualTo(value float64) structure.Float64

func (*Float64) NotExists

func (f *Float64) NotExists() structure.Float64

func (*Float64) NotOneOf

func (f *Float64) NotOneOf(disallowedValues ...float64) structure.Float64

func (*Float64) OneOf

func (f *Float64) OneOf(allowedValues ...float64) structure.Float64

func (*Float64) Using added in v1.24.0

func (f *Float64) Using(usingFunc structure.Float64UsingFunc) structure.Float64

type Int

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

func NewInt

func NewInt(base *structureBase.Base, value *int) *Int

func (*Int) EqualTo

func (i *Int) EqualTo(value int) structure.Int

func (*Int) Exists

func (i *Int) Exists() structure.Int

func (*Int) GreaterThan

func (i *Int) GreaterThan(limit int) structure.Int

func (*Int) GreaterThanOrEqualTo

func (i *Int) GreaterThanOrEqualTo(limit int) structure.Int

func (*Int) InRange

func (i *Int) InRange(lowerLimit int, upperLimit int) structure.Int

func (*Int) LessThan

func (i *Int) LessThan(limit int) structure.Int

func (*Int) LessThanOrEqualTo

func (i *Int) LessThanOrEqualTo(limit int) structure.Int

func (*Int) NotEqualTo

func (i *Int) NotEqualTo(value int) structure.Int

func (*Int) NotExists

func (i *Int) NotExists() structure.Int

func (*Int) NotOneOf

func (i *Int) NotOneOf(disallowedValues ...int) structure.Int

func (*Int) OneOf

func (i *Int) OneOf(allowedValues ...int) structure.Int

func (*Int) Using added in v1.24.0

func (i *Int) Using(usingFunc structure.IntUsingFunc) structure.Int

type Object added in v1.24.0

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

func NewObject added in v1.24.0

func NewObject(base *structureBase.Base, value *map[string]interface{}) *Object

func (*Object) Empty added in v1.24.0

func (o *Object) Empty() structure.Object

func (*Object) Exists added in v1.24.0

func (o *Object) Exists() structure.Object

func (*Object) NotEmpty added in v1.24.0

func (o *Object) NotEmpty() structure.Object

func (*Object) NotExists added in v1.24.0

func (o *Object) NotExists() structure.Object

func (*Object) Using added in v1.24.0

func (o *Object) Using(usingFunc structure.ObjectUsingFunc) structure.Object

type String

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

func NewString

func NewString(base *structureBase.Base, value *string) *String

func (*String) AsTime added in v1.24.0

func (s *String) AsTime(layout string) structure.Time

func (*String) Empty

func (s *String) Empty() structure.String

func (*String) EqualTo

func (s *String) EqualTo(value string) structure.String

func (*String) Exists

func (s *String) Exists() structure.String

func (*String) LengthEqualTo

func (s *String) LengthEqualTo(limit int) structure.String

func (*String) LengthGreaterThan

func (s *String) LengthGreaterThan(limit int) structure.String

func (*String) LengthGreaterThanOrEqualTo

func (s *String) LengthGreaterThanOrEqualTo(limit int) structure.String

func (*String) LengthInRange

func (s *String) LengthInRange(lowerLimit int, upperLimit int) structure.String

func (*String) LengthLessThan

func (s *String) LengthLessThan(limit int) structure.String

func (*String) LengthLessThanOrEqualTo

func (s *String) LengthLessThanOrEqualTo(limit int) structure.String

func (*String) LengthNotEqualTo

func (s *String) LengthNotEqualTo(limit int) structure.String

func (*String) Matches

func (s *String) Matches(expression *regexp.Regexp) structure.String

func (*String) NotEmpty

func (s *String) NotEmpty() structure.String

func (*String) NotEqualTo

func (s *String) NotEqualTo(value string) structure.String

func (*String) NotExists

func (s *String) NotExists() structure.String

func (*String) NotMatches

func (s *String) NotMatches(expression *regexp.Regexp) structure.String

func (*String) NotOneOf

func (s *String) NotOneOf(disallowedValues ...string) structure.String

func (*String) OneOf

func (s *String) OneOf(allowedValues ...string) structure.String

func (*String) Using added in v1.24.0

func (s *String) Using(usingFunc structure.StringUsingFunc) structure.String

type StringArray

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

func NewStringArray

func NewStringArray(base *structureBase.Base, value *[]string) *StringArray

func (*StringArray) Each added in v1.26.0

func (*StringArray) EachMatches

func (s *StringArray) EachMatches(expression *regexp.Regexp) structure.StringArray

func (*StringArray) EachNotEmpty added in v1.24.0

func (s *StringArray) EachNotEmpty() structure.StringArray

func (*StringArray) EachNotMatches

func (s *StringArray) EachNotMatches(expression *regexp.Regexp) structure.StringArray

func (*StringArray) EachNotOneOf

func (s *StringArray) EachNotOneOf(disallowedValues ...string) structure.StringArray

func (*StringArray) EachOneOf

func (s *StringArray) EachOneOf(allowedValues ...string) structure.StringArray

func (*StringArray) EachUnique added in v1.26.0

func (s *StringArray) EachUnique() structure.StringArray

func (*StringArray) Empty

func (s *StringArray) Empty() structure.StringArray

func (*StringArray) Exists

func (s *StringArray) Exists() structure.StringArray

func (*StringArray) LengthEqualTo

func (s *StringArray) LengthEqualTo(limit int) structure.StringArray

func (*StringArray) LengthGreaterThan

func (s *StringArray) LengthGreaterThan(limit int) structure.StringArray

func (*StringArray) LengthGreaterThanOrEqualTo

func (s *StringArray) LengthGreaterThanOrEqualTo(limit int) structure.StringArray

func (*StringArray) LengthInRange

func (s *StringArray) LengthInRange(lowerLimit int, upperLimit int) structure.StringArray

func (*StringArray) LengthLessThan

func (s *StringArray) LengthLessThan(limit int) structure.StringArray

func (*StringArray) LengthLessThanOrEqualTo

func (s *StringArray) LengthLessThanOrEqualTo(limit int) structure.StringArray

func (*StringArray) LengthNotEqualTo

func (s *StringArray) LengthNotEqualTo(limit int) structure.StringArray

func (*StringArray) NotEmpty

func (s *StringArray) NotEmpty() structure.StringArray

func (*StringArray) NotExists

func (s *StringArray) NotExists() structure.StringArray

func (*StringArray) Using added in v1.24.0

type Time

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

func NewTime

func NewTime(base *structureBase.Base, value *time.Time) *Time

func (*Time) After

func (t *Time) After(limit time.Time) structure.Time

func (*Time) AfterNow

func (t *Time) AfterNow(threshold time.Duration) structure.Time

func (*Time) Before

func (t *Time) Before(limit time.Time) structure.Time

func (*Time) BeforeNow

func (t *Time) BeforeNow(threshold time.Duration) structure.Time

func (*Time) Exists

func (t *Time) Exists() structure.Time

func (*Time) NotExists

func (t *Time) NotExists() structure.Time

func (*Time) NotZero

func (t *Time) NotZero() structure.Time

func (*Time) Using added in v1.24.0

func (t *Time) Using(usingFunc structure.TimeUsingFunc) structure.Time

func (*Time) Zero

func (t *Time) Zero() structure.Time

type ValidatableWithInt added in v1.26.0

type ValidatableWithInt interface {
	Validate(validator structure.Validator, i *int)
}

type ValidatableWithIntAdapter added in v1.26.0

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

func NewValidatableWithIntAdapter added in v1.26.0

func NewValidatableWithIntAdapter(validatableWithInt ValidatableWithInt, i *int) *ValidatableWithIntAdapter

func (*ValidatableWithIntAdapter) Validate added in v1.26.0

func (v *ValidatableWithIntAdapter) Validate(validator structure.Validator)

type ValidatableWithString

type ValidatableWithString interface {
	Validate(validator structure.Validator, str *string)
}

type ValidatableWithStringAdapter

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

func NewValidatableWithStringAdapter

func NewValidatableWithStringAdapter(validatableWithString ValidatableWithString, str *string) *ValidatableWithStringAdapter

func (*ValidatableWithStringAdapter) Validate

func (v *ValidatableWithStringAdapter) Validate(validator structure.Validator)

type ValidatableWithStringArray

type ValidatableWithStringArray interface {
	Validate(validator structure.Validator, strArray *[]string)
}

type ValidatableWithStringArrayAdapter

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

func NewValidatableWithStringArrayAdapter

func NewValidatableWithStringArrayAdapter(validatableWithStringArray ValidatableWithStringArray, strArray *[]string) *ValidatableWithStringArrayAdapter

func (*ValidatableWithStringArrayAdapter) Validate

func (v *ValidatableWithStringArrayAdapter) Validate(validator structure.Validator)

type Validator

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

func New

func New() *Validator

func NewValidator

func NewValidator(base *structureBase.Base) *Validator

func (*Validator) Array added in v1.24.0

func (v *Validator) Array(reference string, value *[]interface{}) structure.Array

func (*Validator) Bool

func (v *Validator) Bool(reference string, value *bool) structure.Bool

func (*Validator) Error

func (v *Validator) Error() error

func (*Validator) Float64

func (v *Validator) Float64(reference string, value *float64) structure.Float64

func (*Validator) HasError added in v1.24.0

func (v *Validator) HasError() bool

func (*Validator) HasMeta added in v1.24.0

func (v *Validator) HasMeta() bool

func (*Validator) HasSource added in v1.24.0

func (v *Validator) HasSource() bool

func (*Validator) Int

func (v *Validator) Int(reference string, value *int) structure.Int

func (*Validator) Meta added in v1.24.0

func (v *Validator) Meta() interface{}

func (*Validator) Object added in v1.24.0

func (v *Validator) Object(reference string, value *map[string]interface{}) structure.Object

func (*Validator) Origin added in v1.24.0

func (v *Validator) Origin() structure.Origin

func (*Validator) ReportError added in v1.24.0

func (v *Validator) ReportError(err error)

func (*Validator) Source added in v1.24.0

func (v *Validator) Source() structure.Source

func (*Validator) String

func (v *Validator) String(reference string, value *string) structure.String

func (*Validator) StringArray

func (v *Validator) StringArray(reference string, value *[]string) structure.StringArray

func (*Validator) Time

func (v *Validator) Time(reference string, value *time.Time) structure.Time

func (*Validator) Validate

func (v *Validator) Validate(validatable structure.Validatable) error

func (*Validator) WithMeta

func (v *Validator) WithMeta(meta interface{}) structure.Validator

func (*Validator) WithOrigin added in v1.24.0

func (v *Validator) WithOrigin(origin structure.Origin) structure.Validator

func (*Validator) WithReference

func (v *Validator) WithReference(reference string) structure.Validator

func (*Validator) WithSource

func (v *Validator) WithSource(source structure.Source) structure.Validator

Jump to

Keyboard shortcuts

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