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) Context() string
- 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, hint string)
- func (v *Validator) MapNotEmpty(src map[string]string, hint string)
- func (v *Validator) NErrors() int
- func (v *Validator) NWarnings() int
- func (v *Validator) NonZero(src int, hint string)
- func (v *Validator) NotNil(src interface{}, hint string)
- func (v *Validator) RFC1123Z(src string)
- func (v *Validator) Report() string
- func (v *Validator) RestoreContext()
- func (v *Validator) SaveContext(ctx string)
- func (v *Validator) StringEquals(src, expected string)
- func (v *Validator) StringNotEmpty(src, hint string)
- func (v *Validator) Timestamp(src string)
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 non-nil attribute '%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 = "no errors/warnings" )
Variables ¶
This section is empty.
Functions ¶
func IsMemberOf ¶
IsMemberOf returns true if claim is part of the list of claims
Types ¶
type Assertion ¶
type Assertion struct { Type int // 0 == warning, 1 == error Txt string // description of the problem Err error // contains filtered or unexported fields }
Assertion is used to collect validation information
func (*Assertion) ToStringWithIndex ¶
func (*Assertion) TypeAsString ¶
type Validatable ¶
Validatable is the interface that must be implemented to support (recursive) validations of structs
type Validator ¶
type Validator struct { Issues []*Assertion Errors int Warnings int // contains filtered or unexported fields }
Validator collects assertions
func NewValidator ¶
func NewValidator() *Validator
NewValidator initializes and returns a new Validator
func (*Validator) AddWarning ¶
AddWarning adds an warning assertion
func (*Validator) MapContains ¶
MapContains verifies that a map contains key
func (*Validator) MapNotEmpty ¶
MapNotEmpty verifies that a map is not empty
func (*Validator) RestoreContext ¶
func (v *Validator) RestoreContext()
func (*Validator) SaveContext ¶
func (*Validator) StringEquals ¶
StringEquals verifies a string
func (*Validator) StringNotEmpty ¶
StringNotEmpty verifies a string is not empty
Click to show internal directories.
Click to hide internal directories.