Documentation
¶
Index ¶
- Variables
- func BoolToPointer(value bool) *bool
- func IsSet(pointer interface{}) bool
- func Validate(value interface{}, schema Schema) error
- type AnySchema
- func (s *AnySchema) Allow(values ...interface{}) *AnySchema
- func (s *AnySchema) Description(description string) *AnySchema
- func (s *AnySchema) Disallow(values ...interface{}) *AnySchema
- func (s *AnySchema) Forbidden() *AnySchema
- func (s *AnySchema) Kind() string
- func (s *AnySchema) NonZero() *AnySchema
- func (s *AnySchema) Required() *AnySchema
- func (s *AnySchema) Root() Schema
- func (s *AnySchema) Transform(stage TransformStage, f TransformFunc) *AnySchema
- func (s *AnySchema) Validate(value interface{}) error
- func (s *AnySchema) Zero() *AnySchema
- type BoolSchema
- type EmailOptions
- type Error
- type IntSchema
- func (s *IntSchema) Greater(limit int64) *IntSchema
- func (s *IntSchema) Kind() string
- func (s *IntSchema) Less(limit int64) *IntSchema
- func (s *IntSchema) Max(max int64) *IntSchema
- func (s *IntSchema) Min(min int64) *IntSchema
- func (s *IntSchema) Multiple(base int64) *IntSchema
- func (s *IntSchema) Negative() *IntSchema
- func (s *IntSchema) Positive() *IntSchema
- func (s *IntSchema) Validate(value interface{}) error
- type Schema
- type SliceSchema
- type StringSchema
- func (s *StringSchema) Base64() *StringSchema
- func (s *StringSchema) CreditCard() *StringSchema
- func (s *StringSchema) Email(options *EmailOptions) *StringSchema
- func (s *StringSchema) Hex() *StringSchema
- func (s *StringSchema) Kind() string
- func (s *StringSchema) Length(length int) *StringSchema
- func (s *StringSchema) LowerCase() *StringSchema
- func (s *StringSchema) Max(max int) *StringSchema
- func (s *StringSchema) Min(min int) *StringSchema
- func (s *StringSchema) Regex(regex string) *StringSchema
- func (s *StringSchema) UpperCase() *StringSchema
- func (s *StringSchema) Validate(value interface{}) error
- type StructKeys
- type StructSchema
- type TransformFunc
- type TransformStage
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrAnyType = NewError("interface", "Value of wrong data type") ErrAnyRequired = NewError("interface", "Value is required") ErrAnyForbidden = NewError("interface", "Value is forbidden") ErrAnyZero = NewError("interface", "Value should be zero") ErrAnyNonZero = NewError("interface", "Value should be non-zero") ErrAnyAllow = NewError("interface", "Value is not matching allowed values") ErrAnyDisallow = NewError("interface", "Value is matching disallowed values") )
AnySchema Error definitions
View Source
var ( ErrIntMin = NewError("int", "Value is smaller") ErrIntMax = NewError("int", "Value is bigger") ErrIntPositive = NewError("int", "Value is not positive") ErrIntNegative = NewError("int", "Value is not negative") ErrIntGreater = NewError("int", "Value is not greater") ErrIntLess = NewError("int", "Value is not less") ErrIntMultiple = NewError("int", "Value is not matching multiple") )
StringSchema Error definitions
View Source
var ( ErrSliceMin = NewError("slice", "Slice is smaller than min") ErrSliceMax = NewError("slice", "Slice is larger than max") ErrSliceLength = NewError("slice", "Slice is not matching length") )
SliceSchema Error definitions
View Source
var ( ErrStringMin = NewError("string", "Value is smaller") ErrStringMax = NewError("string", "Value is bigger") ErrStringLength = NewError("string", "Value is out of length") ErrStringUpperCase = NewError("string", "Value is not uppercase") ErrStringLowerCase = NewError("string", "Value is not lowercase") ErrStringRegex = NewError("string", "Value is not matching regex") ErrStringRegexCompile = NewError("string", "Could not compile regex") ErrStringCreditCard = NewError("string", "Value is not matching creditcard") ErrStringBase64 = NewError("string", "Value is not matching base64") ErrStringHex = NewError("string", "Value is not matching hex") ErrStringEmail = NewError("string", "Value is not matching email") )
StringSchema Error definitions
View Source
var (
ErrSchemaNil = errors.New("Schema cannot be nil")
)
Error definitions
Functions ¶
Types ¶
type AnySchema ¶
type AnySchema struct {
// contains filtered or unexported fields
}
AnySchema defines the struct properties
func (*AnySchema) Description ¶
Description stores a description
func (*AnySchema) Forbidden ¶
Forbidden marks a key as forbidden which will not allow any value except nil
func (*AnySchema) Transform ¶
func (s *AnySchema) Transform(stage TransformStage, f TransformFunc) *AnySchema
Transform allows to run custom tranformation functions
type IntSchema ¶
type IntSchema struct { AnySchema // contains filtered or unexported fields }
IntSchema ...
type SliceSchema ¶
type SliceSchema struct { AnySchema // contains filtered or unexported fields }
SliceSchema ...
type StringSchema ¶
type StringSchema struct { AnySchema // contains filtered or unexported fields }
StringSchema ...
func (*StringSchema) Email ¶
func (s *StringSchema) Email(options *EmailOptions) *StringSchema
Email ...
func (*StringSchema) Validate ¶
func (s *StringSchema) Validate(value interface{}) error
Validate ...
type StructSchema ¶
type StructSchema struct { AnySchema // contains filtered or unexported fields }
StructSchema ...
func (*StructSchema) Validate ¶
func (s *StructSchema) Validate(value interface{}) error
Validate ...
type TransformFunc ¶
type TransformFunc func(interface{}) (interface{}, error)
TransformFunc function template
type TransformStage ¶
type TransformStage int
TransformStage defines the stages
const ( TransformStagePRE TransformStage = 1 + iota TransformStagePOST )
TransformStageEnums
Click to show internal directories.
Click to hide internal directories.