Documentation
¶
Index ¶
- func Alpha3Currency(context *FieldValidationContext) (string, bool)
- type Children
- type ErrorBag
- func (v *ErrorBag) AddError(path string, description string)
- func (v *ErrorBag) CountErrors() int
- func (v *ErrorBag) Error() string
- func (v *ErrorBag) GetErrorsForKey(key string) []string
- func (v *ErrorBag) HasFailedKeyAndRule(key string, rule string) bool
- func (v *ErrorBag) IsInvalid() bool
- func (v *ErrorBag) IsValid() bool
- type FieldCache
- type FieldValidationContext
- type JsonContext
- type JsonTag
- type Rule
- type RuleContext
- type RuleFunction
- type Rulebook
- func (rulebook Rulebook) GetComposite(ruleDefinition string) string
- func (rulebook Rulebook) GetRule(ruleDefinition string) *RuleContext
- func (rulebook Rulebook) IsComposite(ruleDefinition string) bool
- func (rulebook Rulebook) RegisterAlias(alias string, name string) Rulebook
- func (rulebook Rulebook) RegisterComposite(name string, rules string) Rulebook
- func (rulebook Rulebook) RegisterRule(rule Rule) Rulebook
- type StructCache
- type ValidationContext
- type ValidationTag
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Alpha3Currency ¶
func Alpha3Currency(context *FieldValidationContext) (string, bool)
Types ¶
type Children ¶ added in v1.3.10
type Children struct {
// contains filtered or unexported fields
}
func (*Children) All ¶ added in v1.3.10
func (children *Children) All() []*FieldCache
func (*Children) Append ¶ added in v1.3.10
func (children *Children) Append(field ...*FieldCache)
type ErrorBag ¶
func (*ErrorBag) CountErrors ¶
func (*ErrorBag) GetErrorsForKey ¶
func (*ErrorBag) HasFailedKeyAndRule ¶
HasFailedKeyAndRule Is used for testing. So performance is not critical.
type FieldCache ¶
type FieldCache struct { Parent *FieldCache Children *Children Reflection reflect.Type JsonKey string StructKey string ValidationTag *ValidationTag IsStruct bool IsSlice bool IsMap bool }
func (*FieldCache) GetChildByName ¶
func (fieldCache *FieldCache) GetChildByName(name string) *FieldCache
type FieldValidationContext ¶
type FieldValidationContext struct { Validation *ValidationContext Params []string RuleName string }
func (*FieldValidationContext) GetFloatParam ¶
func (context *FieldValidationContext) GetFloatParam(index int) float64
func (*FieldValidationContext) GetIntParam ¶
func (context *FieldValidationContext) GetIntParam(index int) int
func (*FieldValidationContext) GetParam ¶
func (context *FieldValidationContext) GetParam(index int) string
type JsonContext ¶
type JsonContext struct { Path string // The JSON path to the key under validation KeyPresent bool // True if the key was present in the json EmptyValue bool // True if the value is either null, 0, "", {}, [], or false IsNull bool // True if the value is null Value any // The raw json parsed value for the key. Will be nil if KeyPresent=false }
type Rule ¶
type Rule struct { Name string IsPresenceRule bool IsNullableRule bool Function RuleFunction }
type RuleContext ¶
func (*RuleContext) GetFloatParam ¶
func (context *RuleContext) GetFloatParam(index int) float64
func (*RuleContext) GetIntParam ¶
func (context *RuleContext) GetIntParam(index int) int
func (*RuleContext) GetStringParam ¶
func (context *RuleContext) GetStringParam(index int) string
type RuleFunction ¶
type RuleFunction func(*FieldValidationContext) (string, bool)
type Rulebook ¶
type Rulebook struct {
// contains filtered or unexported fields
}
func (Rulebook) GetComposite ¶ added in v1.3.9
func (Rulebook) GetRule ¶
func (rulebook Rulebook) GetRule(ruleDefinition string) *RuleContext
func (Rulebook) IsComposite ¶ added in v1.3.9
func (Rulebook) RegisterAlias ¶
func (Rulebook) RegisterComposite ¶ added in v1.3.9
func (Rulebook) RegisterRule ¶
type StructCache ¶
type StructCache struct { Cache map[reflect.Type]*FieldCache // contains filtered or unexported fields }
func (*StructCache) Analyze ¶
func (structCache *StructCache) Analyze(rulebook *Rulebook, targetType reflect.Type) (*FieldCache, error)
type ValidationContext ¶
type ValidationContext struct { Json *JsonContext RootContext *ValidationContext ParentContext *ValidationContext Field *FieldCache FieldName string StructFieldName string ValidationTag *ValidationTag Validator *Validator }
func (*ValidationContext) GetNeighborField ¶
func (context *ValidationContext) GetNeighborField(name string) (*ValidationContext, bool)
func (*ValidationContext) IsRoot ¶
func (context *ValidationContext) IsRoot() bool
type ValidationTag ¶
type ValidationTag struct { Rules []*RuleContext PresenceRules []*RuleContext ExplicitlyNullable bool }
func (*ValidationTag) GetRules ¶
func (tag *ValidationTag) GetRules(name string) []*RuleContext
Click to show internal directories.
Click to hide internal directories.