validators

package
v2.3.8+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2018 License: Apache-2.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsModelNotFoundError

func IsModelNotFoundError(err error) bool

Types

type Choices

type Choices map[string]Empty

func NewChoices

func NewChoices(choices ...string) Choices

func (Choices) Has

func (cs Choices) Has(choice string) bool

func (Choices) String

func (cs Choices) String() string

type Empty

type Empty struct{}

type ErrType

type ErrType uintptr
const (
	ERR_SUCCESS ErrType = iota
	ERR_GENERAL         // uncategorized error
	ERR_MISSING_KEY
	ERR_INVALID_TYPE
	ERR_INVALID_CHOICE
	ERR_NOT_IN_RANGE
	ERR_INVALID_VALUE
	ERR_MODEL_MANAGER
	ERR_MODEL_NOT_FOUND
)

func (ErrType) String

func (errType ErrType) String() string

type IValidator

type IValidator interface {
	IValidatorBase
	Optional(bool) IValidator
	// contains filtered or unexported methods
}

type IValidatorBase

type IValidatorBase interface {
	Validate(data *jsonutils.JSONDict) error
}

type ValidateError

type ValidateError struct {
	ErrType ErrType
	Msg     string
}

func (*ValidateError) Error

func (ve *ValidateError) Error() string

type Validator

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

func (*Validator) Default

func (v *Validator) Default(defaultVal interface{}) IValidator

func (*Validator) Optional

func (v *Validator) Optional(optional bool) IValidator

func (*Validator) Validate

func (v *Validator) Validate(data *jsonutils.JSONDict) error

type ValidatorBool

type ValidatorBool struct {
	Validator
	Value bool
}

func NewBoolValidator

func NewBoolValidator(key string) *ValidatorBool

func (*ValidatorBool) Default

func (v *ValidatorBool) Default(i bool) IValidator

func (*ValidatorBool) Validate

func (v *ValidatorBool) Validate(data *jsonutils.JSONDict) error

type ValidatorCertificate

type ValidatorCertificate struct {
	ValidatorPEM
	Certificates []*x509.Certificate
}

func NewCertificateValidator

func NewCertificateValidator(key string) *ValidatorCertificate

func (*ValidatorCertificate) FingerprintSha256

func (v *ValidatorCertificate) FingerprintSha256() []byte

func (*ValidatorCertificate) FingerprintSha256String

func (v *ValidatorCertificate) FingerprintSha256String() string

func (*ValidatorCertificate) PublicKeyBitLen

func (v *ValidatorCertificate) PublicKeyBitLen() int

func (*ValidatorCertificate) Validate

func (v *ValidatorCertificate) Validate(data *jsonutils.JSONDict) error

type ValidatorDomainName

type ValidatorDomainName struct {
	ValidatorRegexp
}

func NewDomainNameValidator

func NewDomainNameValidator(key string) *ValidatorDomainName

type ValidatorFunc

type ValidatorFunc func(*jsonutils.JSONDict) error

type ValidatorIPv4Addr

type ValidatorIPv4Addr struct {
	Validator
	IP net.IP
}

func NewIPv4AddrValidator

func NewIPv4AddrValidator(key string) *ValidatorIPv4Addr

func (*ValidatorIPv4Addr) Validate

func (v *ValidatorIPv4Addr) Validate(data *jsonutils.JSONDict) error

type ValidatorModelIdOrName

type ValidatorModelIdOrName struct {
	Validator
	ModelKeyword string
	ProjectId    string
	UserId       string
	ModelManager db.IModelManager
	Model        db.IModel
	// contains filtered or unexported fields
}

func NewModelIdOrNameValidator

func NewModelIdOrNameValidator(key string, modelKeyword string, projectId string) *ValidatorModelIdOrName

func (*ValidatorModelIdOrName) GetProjectId

func (v *ValidatorModelIdOrName) GetProjectId() string

func (*ValidatorModelIdOrName) GetTenantId

func (v *ValidatorModelIdOrName) GetTenantId() string

func (*ValidatorModelIdOrName) GetUserId

func (v *ValidatorModelIdOrName) GetUserId() string

func (*ValidatorModelIdOrName) ModelIdKey

func (v *ValidatorModelIdOrName) ModelIdKey(modelIdKey string) *ValidatorModelIdOrName

func (*ValidatorModelIdOrName) QueryFilter

func (*ValidatorModelIdOrName) Validate

func (v *ValidatorModelIdOrName) Validate(data *jsonutils.JSONDict) error

type ValidatorPEM

type ValidatorPEM struct {
	Validator
	Blocks []*pem.Block
}

func NewPEMValidator

func NewPEMValidator(key string) *ValidatorPEM

func (*ValidatorPEM) Validate

func (v *ValidatorPEM) Validate(data *jsonutils.JSONDict) error

type ValidatorPrivateKey

type ValidatorPrivateKey struct {
	ValidatorPEM
	PrivateKey crypto.PrivateKey
}

func NewPrivateKeyValidator

func NewPrivateKeyValidator(key string) *ValidatorPrivateKey

func (*ValidatorPrivateKey) MatchCertificate

func (v *ValidatorPrivateKey) MatchCertificate(cert *x509.Certificate) error

func (*ValidatorPrivateKey) Validate

func (v *ValidatorPrivateKey) Validate(data *jsonutils.JSONDict) error

type ValidatorRange

type ValidatorRange struct {
	Validator
	Lower int64
	Upper int64
	Value int64
}

func NewNonNegativeValidator

func NewNonNegativeValidator(key string) *ValidatorRange

func NewPortValidator

func NewPortValidator(key string) *ValidatorRange

func NewRangeValidator

func NewRangeValidator(key string, lower int64, upper int64) *ValidatorRange

func NewVlanIdValidator

func NewVlanIdValidator(key string) *ValidatorRange

func (*ValidatorRange) Default

func (v *ValidatorRange) Default(i int64) IValidator

func (*ValidatorRange) Validate

func (v *ValidatorRange) Validate(data *jsonutils.JSONDict) error

type ValidatorRegexp

type ValidatorRegexp struct {
	Validator
	Regexp *regexp.Regexp
	Value  string
	// contains filtered or unexported fields
}

func NewRegexpValidator

func NewRegexpValidator(key string, regexp *regexp.Regexp) *ValidatorRegexp

func (*ValidatorRegexp) AllowEmpty

func (v *ValidatorRegexp) AllowEmpty(allowEmpty bool) *ValidatorRegexp

func (*ValidatorRegexp) Validate

func (v *ValidatorRegexp) Validate(data *jsonutils.JSONDict) error

type ValidatorStringChoices

type ValidatorStringChoices struct {
	Validator
	Choices Choices

	Value string
	// contains filtered or unexported fields
}

func NewStringChoicesValidator

func NewStringChoicesValidator(key string, choices Choices) *ValidatorStringChoices

func (*ValidatorStringChoices) Default

func (*ValidatorStringChoices) Validate

func (v *ValidatorStringChoices) Validate(data *jsonutils.JSONDict) error

type ValidatorStringMultiChoices

type ValidatorStringMultiChoices struct {
	Validator
	Choices Choices

	Value string
	// contains filtered or unexported fields
}

func NewStringMultiChoicesValidator

func NewStringMultiChoicesValidator(key string, choices Choices) *ValidatorStringMultiChoices

func (*ValidatorStringMultiChoices) Default

func (*ValidatorStringMultiChoices) KeepDup

func (*ValidatorStringMultiChoices) Sep

func (*ValidatorStringMultiChoices) Validate

type ValidatorStruct

type ValidatorStruct struct {
	Validator
	Value interface{}
}

func NewStructValidator

func NewStructValidator(key string, value interface{}) *ValidatorStruct

func (*ValidatorStruct) Validate

func (v *ValidatorStruct) Validate(data *jsonutils.JSONDict) error

type ValidatorURLPath

type ValidatorURLPath struct {
	ValidatorRegexp
}

func NewURLPathValidator

func NewURLPathValidator(key string) *ValidatorURLPath

Jump to

Keyboard shortcuts

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