Documentation ¶
Index ¶
- Variables
- func AddDataElement(d DataElement) error
- func AddDomainType(domainType DomainType) error
- func GetDefaultErrorMsg(code int) string
- func GetErrorMsg(code int) string
- func InputByDataType(name string, v interface{}) interface{}
- func LoadConfig(cf string)
- func RegisterConvertorFactory(name string, c ConvertorFactory)
- func SetDictMeta(dm DictMeta)
- func SetErrorMsg(code int, msg string)
- func Validate(obj interface{}) []error
- func ValidateByDataType(name string, v interface{}, dt string) error
- type Convertor
- type ConvertorFactory
- type DataElement
- type DictCatalog
- type DictCatalogItem
- type DictMeta
- type DomainType
- type Type
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultErorrFormat = "The %s field validate failed by '%s'"
Functions ¶
func AddDataElement ¶
func AddDataElement(d DataElement) error
func AddDomainType ¶
func AddDomainType(domainType DomainType) error
func GetDefaultErrorMsg ¶
func GetErrorMsg ¶
func InputByDataType ¶
func InputByDataType(name string, v interface{}) interface{}
func RegisterConvertorFactory ¶
func RegisterConvertorFactory(name string, c ConvertorFactory)
func SetDictMeta ¶
func SetDictMeta(dm DictMeta)
func SetErrorMsg ¶
func ValidateByDataType ¶
使用指定的数据元素对值进行校验
Types ¶
type Convertor ¶
type Convertor interface { //输入转换 Input(v interface{}) interface{} //输出转换 Output(v interface{}) interface{} }
转换器
type DataElement ¶
type DataElement struct { Code string Label string DataType string //所属的域元素 Validater validatefunction //校验器 ValidateExpr string //校验表达式 Convertor string //转换器 ConvertorExpr string // contains filtered or unexported fields }
数据元素
func (*DataElement) Input ¶
func (this *DataElement) Input(v interface{}) interface{}
func (*DataElement) Output ¶
func (this *DataElement) Output(v interface{}) interface{}
func (*DataElement) Validate ¶
func (this *DataElement) Validate(v interface{}) (bool, int)
type DictCatalog ¶
type DictCatalog struct { Code string Label string Tip string Items []DictCatalogItem }
词条
func GetDict ¶
func GetDict(d string) *DictCatalog
type DictCatalogItem ¶
type DictCatalogItem struct { Code string //值 Label string //显示值 Tip string //提示 Virtual bool //是否虚拟,表示存在有同名的词条 Ord int //显示次序 Extends map[string]string //扩展属性 }
词条的选择项
type DictMeta ¶
type DictMeta func(code string) *DictCatalog
---------------------------字典------------------------//
type DomainType ¶
type DomainType struct { Code string Label string DataType Type `yaml:"type"` //数据元素 Length int //最大长度 NullEnabled bool `yaml:"null"` //是否允许为空 Validater validatefunction //校验器 ValidateExpr string `yaml:"expr"` //校验表达式 }
func (*DomainType) Validate ¶
func (this *DomainType) Validate(v interface{}) (bool, int)
返回,是否校验通过及对应的错误码
Source Files ¶
Click to show internal directories.
Click to hide internal directories.