Documentation ¶
Index ¶
- Variables
- func Contains(actual, expect interface{}) (bool, error)
- func Endwith(actual, expect interface{}) (bool, error)
- func Eq(actual, expect interface{}) (bool, error)
- func Exist(actual, expect interface{}) (bool, error)
- func Gt(actual, expect interface{}) (bool, error)
- func Gte(actual, expect interface{}) (bool, error)
- func JsonDecoder(bts []byte, m *map[string]interface{}) error
- func JsonPathPluck(props map[string]interface{}, path string, decoder DataDecoder) (interface{}, error)
- func Lt(actual, expect interface{}) (bool, error)
- func Lte(actual, expect interface{}) (bool, error)
- func Ncontains(actual, expect interface{}) (bool, error)
- func Nendwith(actual, expect interface{}) (bool, error)
- func Neq(actual, expect interface{}) (bool, error)
- func Nexist(actual, expect interface{}) (bool, error)
- func NoneOf(actual, expect interface{}) (bool, error)
- func Nregex(actual, expect interface{}) (bool, error)
- func Nstartwith(actual, expect interface{}) (bool, error)
- func OneOf(actual, expect interface{}) (bool, error)
- func PathPluck(props map[string]interface{}, path string, decoder DataDecoder) (interface{}, error)
- func Regex(actual, expect interface{}) (bool, error)
- func Startwith(actual, expect interface{}) (bool, error)
- func XmlDecoder(bts []byte, m *map[string]interface{}) error
- func YamlDecoder(bts []byte, m *map[string]interface{}) error
- type Comparator
- type DataDecoder
- type Group
- type Pluck
- type Result
- type Rule
- type Ruler
Constants ¶
This section is empty.
Variables ¶
View Source
var ( TypeMismatchErr = errors.New("type mismatch error") TypeNotSupportErr = errors.New("type not support error") )
View Source
var (
TypeMisMatch = errors.New("ruler type mismatch")
)
Functions ¶
func JsonDecoder ¶
func JsonPathPluck ¶
func JsonPathPluck(props map[string]interface{}, path string, decoder DataDecoder) (interface{}, error)
JsonPathPluck 根据路径基于jsonpath解析map值
func Nstartwith ¶
Nstartwith actual不以expect开头
func PathPluck ¶
func PathPluck(props map[string]interface{}, path string, decoder DataDecoder) (interface{}, error)
PathPluck 根据路径解析map值
func XmlDecoder ¶
func YamlDecoder ¶
Types ¶
type Comparator ¶
Comparator 是比较器 目前实现了一些基本的比较器 可以根据需求来实现相应的比较器函数传入Rule
type DataDecoder ¶
DataDecoder 数据解析
type Pluck ¶
type Pluck func(props map[string]interface{}, path string, decoder DataDecoder) (interface{}, error)
Pluck 根据路径嵌套解析map值
type Rule ¶
type Rule struct {
// contains filtered or unexported fields
}
Rule 规则 comparator 是比较器, 用于比较两个值是否相等 path 基于Map的取值路径 value 期待值 pluck 取值方式
func NewRuleByOptions ¶
func NewRuleByOptions(path string, value interface{}, comparator Comparator, pluck Pluck) *Rule
NewRuleByOptions 自定义Rule
func (*Rule) CompareReturnResult ¶
CompareReturnResult 比较结果, 并返回error
type Ruler ¶
type Ruler interface { AddRule(rule *Rule) Ruler Validate(msg map[string]interface{}) bool ValidateWithResult(msg map[string]interface{}) (map[string]*Result, bool) }
Ruler 这个接口用来规定一组RuleSet以哪种规则匹配
func NewDefaultRuler ¶
func NewDefaultRuler(rules []*Rule, t string, decoder DataDecoder) (Ruler, error)
NewDefaultRuler 创建基础Ruler
Click to show internal directories.
Click to hide internal directories.