Documentation ¶
Index ¶
- Variables
- func Pretty(pretty bool) func(*Function) error
- func Size(size int) func(*Function) error
- type Function
- func (t *Function) AST() *node32
- func (t *Function) Add(rule pegRule, begin, end, index uint32)
- func (p *Function) Init(options ...func(*Function) error) error
- func (p *Function) Parse(rule ...int) error
- func (t *Function) PrettyPrintSyntaxTree(buffer string)
- func (t *Function) Print()
- func (p *Function) PrintSyntaxTree()
- func (p *Function) Reset()
- func (p *Function) SprintSyntaxTree() string
- func (t *Function) Tokens() []token32
- func (t *Function) Trim(length uint32)
- func (p *Function) WriteSyntaxTree(w io.Writer)
- type Key
- type Parser
- type Rule
- type RuleFactory
- type ToolFunction
- type TypedValidationValue
- type Validation
- type ValidationType
- type ValidationValue
- type ValueType
Constants ¶
This section is empty.
Variables ¶
View Source
var ( RangeKeys = []Key{ In, NotIn, } NumericKeys = []Key{ Const, LessThan, LessEqual, GreatThan, GreatEqual, In, NotIn, NotNil, } BinaryKeys = []Key{ Const, MinSize, MaxSize, Pattern, Prefix, Suffix, Contains, NotContains, In, NotIn, NotNil, } BoolKeys = []Key{ Const, NotNil, } EnumKeys = []Key{ Const, DefinedOnly, NotNil, In, NotIn, } ListKeys = []Key{ MinSize, MaxSize, Elem, } MapKeys = []Key{ MinSize, MaxSize, NoSparse, MapKey, MapValue, } StructLikeFieldKeys = []Key{ Skip, NotNil, } StructLikeKeys = []Key{ Assert, } )
View Source
var KeyString = [...]string{ Const: "const", LessThan: "lt", LessEqual: "le", GreatThan: "gt", GreatEqual: "ge", In: "in", NotIn: "not_in", NotNil: "not_nil", MinSize: "min_size", MaxSize: "max_size", Pattern: "pattern", Prefix: "prefix", Suffix: "suffix", Contains: "contains", NotContains: "not_contains", DefinedOnly: "defined_only", Elem: "elem", MapKey: "key", MapValue: "value", NoSparse: "no_sparse", Skip: "skip", Assert: "assert", }
View Source
var ValueTypeName = [...]string{ FieldReferenceValue: "field-reference-value", DoubleValue: "double-value", IntValue: "int-value", BoolValue: "bool-value", EnumValue: "enum-value", BinaryValue: "binary-value", FunctionValue: "function-value", }
Functions ¶
Types ¶
type Function ¶
func (*Function) PrettyPrintSyntaxTree ¶
func (t *Function) PrettyPrintSyntaxTree(buffer string)
func (*Function) PrintSyntaxTree ¶
func (p *Function) PrintSyntaxTree()
func (*Function) SprintSyntaxTree ¶ added in v0.1.4
func (*Function) WriteSyntaxTree ¶
type Key ¶ added in v0.1.4
type Key int
func KeyFromString ¶ added in v0.1.4
func PickRangeKeys ¶ added in v0.1.4
func PickSpecifiedKeys ¶ added in v0.1.4
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) Parse ¶
func (p *Parser) Parse(st *tp.StructLike) (*Validation, map[*tp.Field]*Validation, error)
type Rule ¶
type Rule struct { Key Key Specified *ValidationValue Range []*ValidationValue Inner *Validation }
type RuleFactory ¶
type RuleFactory struct {
// contains filtered or unexported fields
}
func NewRuleFactory ¶
func NewRuleFactory(keys []Key) *RuleFactory
func (*RuleFactory) NewRule ¶
func (v *RuleFactory) NewRule(key Key, value *ValidationValue) (bool, *Rule)
type ToolFunction ¶
type ToolFunction struct { Name string Arguments []ValidationValue }
type TypedValidationValue ¶
type TypedValidationValue struct { FieldReference *tp.Field Double float64 Int int64 Bool bool Enum *tp.EnumValue Binary string Function *ToolFunction }
func (*TypedValidationValue) GetFieldReferenceName ¶ added in v0.2.0
func (t *TypedValidationValue) GetFieldReferenceName(ref string, st *golang.StructLike) string
type Validation ¶
type Validation struct { ValidationType ValidationType Rules []*Rule }
type ValidationType ¶
type ValidationType int
const ( NumericValidation ValidationType = iota BinaryValidation BoolValidation EnumValidation ListValidation MapValidation StructLikeFieldValidation StructLikeValidation )
type ValidationValue ¶
type ValidationValue struct { ValueType ValueType TypedValue TypedValidationValue }
Click to show internal directories.
Click to hide internal directories.