Documentation
¶
Index ¶
- Constants
- 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 (t *Function) Tokens() []token32
- func (t *Function) Trim(length uint32)
- func (p *Function) WriteSyntaxTree(w io.Writer)
- type Parser
- type Rule
- type RuleFactory
- type ToolFunction
- type TypedValidationValue
- type Validation
- type ValidationType
- type ValidationValue
- type ValueType
Constants ¶
View Source
const (
NotNil = "not_nil"
)
Variables ¶
View Source
var ( NumericAnnotation = struct { Const string LessThan string LessEqual string GreatThan string GreatEqual string In string NotIn string NotNil string }{ Const: "const", LessThan: "lt", LessEqual: "le", GreatThan: "gt", GreatEqual: "ge", In: "in", NotIn: "not_in", NotNil: NotNil, } BinaryAnnotation = struct { Const string MinLen string MaxLen string Pattern string Prefix string Suffix string Contains string NotContains string In string NotIn string NotNil string }{ Const: "const", MinLen: "min_size", MaxLen: "max_size", Pattern: "pattern", Prefix: "prefix", Suffix: "suffix", Contains: "contains", NotContains: "not_contains", In: "in", NotIn: "not_in", NotNil: NotNil, } BoolAnnotation = struct { Const string NotNil string }{ Const: "const", NotNil: NotNil, } EnumAnnotation = struct { Const string DefinedOnly string NotNil string }{ Const: "const", DefinedOnly: "defined_only", NotNil: NotNil, } ListAnnotation = struct { MinLen string MaxLen string Elem string }{ MinLen: "min_size", MaxLen: "max_size", Elem: "elem", } MapAnnotation = struct { MinPairs string MaxPairs string NoSparse string Key string Value string }{ MinPairs: "min_size", MaxPairs: "max_size", NoSparse: "no_sparse", Key: "key", Value: "value", } StructLikeAnnotation = struct { Skip string NotNil string }{ Skip: "skip", NotNil: NotNil, } )
Functions ¶
Types ¶
type Function ¶
func (*Function) PrettyPrintSyntaxTree ¶
func (t *Function) PrettyPrintSyntaxTree(buffer string)
func (*Function) PrintSyntaxTree ¶
func (p *Function) PrintSyntaxTree()
func (*Function) WriteSyntaxTree ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) Parse ¶
func (p *Parser) Parse(st *tp.StructLike) (map[*tp.Field]*Validation, error)
type Rule ¶
type Rule struct {
Annotation string
Specified *ValidationValue
Range []*ValidationValue
Inner *Validation
}
type RuleFactory ¶
type RuleFactory struct {
// contains filtered or unexported fields
}
func NewRuleFactory ¶
func NewRuleFactory(specifiedKeys, rangeKeys []string) *RuleFactory
func (*RuleFactory) NewRule ¶
func (v *RuleFactory) NewRule(key string, value *ValidationValue) (bool, *Rule)
type ToolFunction ¶
type ToolFunction struct {
Name string
Arguments []ValidationValue
}
type TypedValidationValue ¶
type Validation ¶
type Validation struct {
ValidationType ValidationType
Rules []*Rule
}
type ValidationType ¶
type ValidationType int
const ( NumericValidation ValidationType = iota BinaryValidation BoolValidation EnumValidation ListValidation MapValidation StructLikeValidation )
type ValidationValue ¶
type ValidationValue struct {
ValueType ValueType
TypedValue TypedValidationValue
}
Click to show internal directories.
Click to hide internal directories.