model_validater

package
v0.0.0-...-9a50b96 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataValidater

type DataValidater struct {
	Validater interface{}
}

数据验证器对象,里面封装了具体的验证器

func (DataValidater) Validate

func (validater DataValidater) Validate(dataMap map[string]interface{}, ai sql_interface.SqlActionInterface, primaryKey string, operationType int) (string, bool)

验证器的验证方法

type ExistValidater

type ExistValidater struct {
	TargetModel    string          //目标模型
	ConditionField string          //条件字段
	ConditionValue string          //条件值
	FieldArray     []ValidateField //验证的字段数组
	Message        string          //错误消息
	OperateType    int             //支持的数据库操作类型
	IsNot          bool            //是否为不存在验证
}

存在验证器

type LengthValidater

type LengthValidater struct {
	FieldName   string //字段名
	MinLength   int    //最小长度
	MaxLength   int    //最大长度
	Message     string //错误消息
	OperateType int    //支持的数据库操作类型
}

长度验证器

type NilValidater

type NilValidater struct {
	FieldName   string //字段名
	Message     string //错误消息
	OperateType int    //支持的数据库操作类型
}

空验证器

type RegexValidater

type RegexValidater struct {
	FieldName   string //字段名
	Regex       string //正则表达式
	Message     string //错误消息
	OperateType int    //支持的数据库操作类型
}

正则表达式验证器

type ValidateField

type ValidateField struct {
	Name        string //字段名
	TargetField string //目标字段名
}

验证字段

type ValidaterInterface

type ValidaterInterface interface {
	//验证方法
	Validate(dataMap map[string]interface{}, ai sql_interface.SqlActionInterface, primaryKey string, operationType int) (string, bool)
}

验证器接口

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL