mvalid

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

README

mRegValid

  • regexp.go 手机号、用户名验证
  • valid.go 根据 validator 库实现 错误中文翻译、邮箱验证、自定义字段名称...

Documentation

Index

Constants

View Source
const (
	RegexPhone    = "^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\\d{8}$"
	RegexEmail    = "^([A-Za-z0-9_\\-\\.])+\\@([A-Za-z0-9_\\-\\.])+\\.([A-Za-z]{2,4})$"
	RegexUserName = "^([A-Za-z_])+\\w"
)

Variables

View Source
var (
	PhoneRegex    = regexp.MustCompile(RegexPhone)
	UsernameRegex = regexp.MustCompile(RegexUserName)
)

Functions

func GetTrans

func GetTrans() ut.Translator

GetTrans 获取翻译

func GetValidate

func GetValidate() *validator.Validate

GetValidate GetValidator

func RegPhone

func RegPhone(phone string) bool

检查手机号

func RegUserName

func RegUserName(username string) bool

检查用户名

func ValidEmail

func ValidEmail(email string) bool

ValidEmail 验证邮箱

Types

This section is empty.

Jump to

Keyboard shortcuts

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