Documentation
¶
Index ¶
- Constants
- func IsMemberOf(claim string, claims ...string) bool
- func NotEmpty(claims ...string) bool
- type Assertion
- type Validatable
- type Validator
- func (v *Validator) AddError(txt string)
- func (v *Validator) AddWarning(txt string)
- func (v *Validator) AsError() error
- func (v *Validator) Error() string
- func (v *Validator) ISO639(src string)
- func (v *Validator) IsClean() bool
- func (v *Validator) IsValid() bool
- func (v *Validator) MapContains(src map[string]string, key, name string)
- func (v *Validator) MapNotEmpty(src map[string]string, name string)
- func (v *Validator) NErrors() int
- func (v *Validator) NWarnings() int
- func (v *Validator) NonZero(src int, name string)
- func (v *Validator) NotNil(src interface{})
- func (v *Validator) RFC1123Z(src string)
- func (v *Validator) Report() string
- func (v *Validator) StringEquals(src, expected string)
- func (v *Validator) StringNotEmpty(src, name string)
- func (v *Validator) Timestamp(src string)
- func (v *Validator) Validate(src Validatable) *Validator
Constants ¶
View Source
const ( // AssertionWarning indicates a potential issue AssertionWarning = 0 // AssertionError indicates an error in the validation AssertionError = 1 MsgStringMismatch = "expected '%s', found '%s'" MsgNonEmptyString = "expected non empty string '%s'" MsgNotNil = "expected not-nil attribute, got '%s'" MsgNonZero = "expected non-zero value '%s'" MsgInvalidLanguageCode = "invalid language code '%s'" MsgInvalidTimestamp = "invalid timestamp '%d'" MsgNonEmptyMap = "expected none empty map '%s'" MsgExpectedKey = "expected key '%s' in map '%s'" MsgEmptyReport = "validation '%s' has zero errors/warnings" )
Variables ¶
This section is empty.
Functions ¶
func IsMemberOf ¶ added in v2.7.0
IsMemberOf returns true if claim is part of the list of claims
Types ¶
type Assertion ¶ added in v2.7.0
type Assertion struct { Type int // 0 == warning, 1 == error Txt string // description of the problem Err error }
Assertion is used to collect validation information
type Validatable ¶ added in v2.7.0
Validatable is the interface that maust be implemented to support recursive validations of strucs
type Validator ¶ added in v2.7.0
Validator collects assertions
func (*Validator) AddWarning ¶ added in v2.7.1
AddWarning adds an warning assertion
func (*Validator) IsValid ¶ added in v2.7.0
IsValid returns true if NError == 0. Warnings are ignored
func (*Validator) MapContains ¶ added in v2.7.1
MapContains verifies that a map contains key
func (*Validator) MapNotEmpty ¶ added in v2.7.1
MapNotEmpty verifies that a map is not empty
func (*Validator) NotNil ¶ added in v2.7.1
func (v *Validator) NotNil(src interface{})
NotNil verifies that an attribute is not nil
func (*Validator) StringEquals ¶ added in v2.7.1
StringEquals verifies a string
func (*Validator) StringNotEmpty ¶ added in v2.7.1
StringNotEmpty verifies a string is not empty
func (*Validator) Timestamp ¶ added in v2.7.1
Timestamp validates that src is a valid UNIX timestamp
func (*Validator) Validate ¶ added in v2.7.0
func (v *Validator) Validate(src Validatable) *Validator
Validate starts the chain of validations
Click to show internal directories.
Click to hide internal directories.