validations

package
v0.0.0-...-dae8c3a Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckBankAddress

func CheckBankAddress(address string) bool

CheckBankAddress 校验银行支行

func CheckBankBranch

func CheckBankBranch(branch string) bool

CheckBankBranch 校验银行支行

func CheckBankCard

func CheckBankCard(bankCard string) bool

CheckBankCard 校验卡号

func CheckCVCode

func CheckCVCode(code string) bool

CheckCVCode 图形验证码

func CheckCVID

func CheckCVID(id string) bool

CheckCVID 图形验证码ID

func CheckDateFormat

func CheckDateFormat(date string) bool

CheckDateFormat 校验日期格式

func CheckDeviceID

func CheckDeviceID(deviceID string) bool

CheckDeviceID 设备ID

func CheckDirFormat

func CheckDirFormat(dir string) bool

CheckDirFormat 检查dir格式

func CheckEmail

func CheckEmail(email string) bool

CheckEmail 校验邮箱

func CheckHttpUrl

func CheckHttpUrl(url string) bool

CheckHttpUrl 检查url

func CheckIP

func CheckIP(ip string) bool

CheckIP 检查ip

func CheckPassword

func CheckPassword(password string) bool

CheckPassword 校验密码 6-12位字母或数字 密码md5 32位

func CheckPhoneNumber

func CheckPhoneNumber(phone string) bool

CheckPhoneNumber 校验手机号

func CheckRealName

func CheckRealName(realName string) bool

CheckRealName 校验真实姓名

func CheckUserName

func CheckUserName(userName string) bool

CheckUserName 校验用户名 4-11位字母或数字

func CheckVCode

func CheckVCode(code string) bool

CheckVCode 校验手机邮箱验证码 只允许输入4-6位字母或数字

func CheckVType

func CheckVType(vType string) bool

CheckVType 检查vtype

func FormatEmail

func FormatEmail(email string) string

FormatEmail 格式化邮件

func FormatPhoneNumber

func FormatPhoneNumber(number string) string

FormatPhoneNumber 格式化电话号码

func IsBankCard

func IsBankCard(cardNumber string) bool

IsBankCard 是否是银行账号

func IsDeviceNumber

func IsDeviceNumber(deviceNumber string) bool

IsDeviceNumber 是否是设备编号

func IsMail

func IsMail(mail string) bool

IsMail 是否是电子邮件

func IsPhoneNumber

func IsPhoneNumber(phone string) bool

IsPhoneNumber 是否是手机号码

func IsUserName

func IsUserName(userName string) bool

IsUserName 是否是用户名称

func Verify

func Verify(obj interface{}) error

Verify 执行校验

Types

type Validator

type Validator struct {
	Data      map[string]interface{} //要校验的字段
	Errors    []string               //错误信息
	FieldName string                 //当前字段
	Required  bool                   //当前字段是否允许为空
}

Validator 校验器

func New

func New(postedData map[string]interface{}) *Validator

New 生成校验器

func (*Validator) AppendError

func (ths *Validator) AppendError(message string) *Validator

AppendError 追加错误信息

func (*Validator) BankCard

func (ths *Validator) BankCard(args ...string) *Validator

BankCard 银行卡号

func (*Validator) Check

func (ths *Validator) Check(message string, callback func(interface{}) error) *Validator

Check 检测各个字段

func (*Validator) CheckReg

func (ths *Validator) CheckReg(regex string, message string) *Validator

CheckReg 检测正则表达式

func (*Validator) Date

func (ths *Validator) Date(message string) *Validator

Date 必须是日期格式

func (*Validator) DateTime

func (ths *Validator) DateTime(message string) *Validator

DateTime 必须是日期时间格式

func (*Validator) Equal

func (ths *Validator) Equal(field string, args ...string) *Validator

Equal 两个字段必须相等

func (*Validator) Field

func (ths *Validator) Field(name string) *Validator

Field 设置当前的字段名称

func (*Validator) Gender

func (ths *Validator) Gender(args ...string) *Validator

Gender 性别

func (*Validator) InIntValues

func (ths *Validator) InIntValues(values []int, message string) *Validator

InIntValues 值在区间范围之内(整形)

func (*Validator) InValues

func (ths *Validator) InValues(values []string, message string) *Validator

InValues 值在区间范围之内

func (*Validator) Int

func (ths *Validator) Int(message string) *Validator

Int 是整数

func (*Validator) Length

func (ths *Validator) Length(min int, max int, message string) *Validator

Length 字段长度必须介于二者之间

func (*Validator) Mail

func (ths *Validator) Mail(args ...string) *Validator

Mail 判断是否是电子邮件

func (*Validator) Mobile

func (ths *Validator) Mobile(args ...string) *Validator

Mobile 是手机号码

func (*Validator) Null

func (ths *Validator) Null(args ...bool) *Validator

Null 当前字段是否允许为空值

func (*Validator) Numeric

func (ths *Validator) Numeric(message string) *Validator

Numeric 是数字, 可以为整数, 负数, 小数

func (*Validator) NumericEq0

func (ths *Validator) NumericEq0(message string) *Validator

Numeric 是数字, 可以为整数,小数,大于等于0

func (*Validator) NumericGt0

func (ths *Validator) NumericGt0(message string) *Validator

Numeric 是数字, 可以为整数,小数,大于0

func (*Validator) Password

func (ths *Validator) Password(args ...string) *Validator

Password 必须是密码

func (*Validator) State

func (ths *Validator) State(args ...string) *Validator

State 必须是状态值

func (*Validator) Time

func (ths *Validator) Time(message string) *Validator

Time 必须是时间格式

func (*Validator) Uint

func (ths *Validator) Uint(message string) *Validator

Uint 正整数非零

func (*Validator) Uint0

func (ths *Validator) Uint0(message string) *Validator

Uint0 是正整数-包括零

func (*Validator) UserName

func (ths *Validator) UserName(args ...string) *Validator

UserName 用户名称

func (*Validator) Validate

func (ths *Validator) Validate() error

Validate 生成校验结果

Jump to

Keyboard shortcuts

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