github.com/isyscore/isc-gobase@v1.5.3-0.20231218061332-cbc7451899e9/validate/matcher/matcher.go (about)

     1  package matcher
     2  
     3  import (
     4  	"github.com/antonmedv/expr/vm"
     5  	"reflect"
     6  )
     7  
     8  type Matcher interface {
     9  	//Match(object any, field reflect.StructField, fieldValue any) bool
    10  	Match(parameterMap map[string]interface{}, object interface{}, field reflect.StructField, fieldValue interface{}) bool
    11  	IsEmpty() bool
    12  	GetWhitMsg() string
    13  	GetBlackMsg() string
    14  }
    15  
    16  type FieldMatcher struct {
    17  
    18  	// 属性名
    19  	FieldName string
    20  	// 异常信息编译后的处理
    21  	ErrMsgProgram *vm.Program
    22  	// 是否接受:true,则表示白名单,false,则表示黑名单
    23  	Accept bool
    24  	// 是否禁用
    25  	Disable bool
    26  	// 匹配器列表
    27  	Matchers []*Matcher
    28  }
    29  
    30  // MatchMap key:类全名,value:key:属性名
    31  var MatchMap = make(map[string]map[string]*FieldMatcher)