validate

package
v1.0.1002 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2023 License: Apache-2.0 Imports: 8 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddValidations added in v1.0.1002

func AddValidations(v ...Validation)

添加验证器

func New

func New() (cv *validate, err error)

初始化一个验证器

func SetTrans added in v1.0.1002

func SetTrans(trans string)

设置默认翻译

func Validate added in v1.0.1002

func Validate(s any, message map[string]string) (bool, map[string]string)

*

  • 验证器
  • 返回验证器验证结果错误消息 和 bool (是否验证成功)

func ValidateError added in v1.0.1002

func ValidateError(s any, message map[string]string) (bool, string)

*

  • 验证器
  • 返回验证器验证结果错误消息 和 bool (是否验证成功)

func ValidateMap added in v1.0.1002

func ValidateMap(data map[string]any, rules map[string]any, message map[string]string) (bool, map[string]string)

*

  • map 验证器

func ValidateMapError added in v1.0.1002

func ValidateMapError(data map[string]any, rules map[string]any, message map[string]string) (bool, string)

*

  • map 验证器

func Var added in v1.0.1002

func Var(data string, rule string) (bool, error)

*

  • Var 验证器

Types

type Validation

type Validation struct {
	// contains filtered or unexported fields
}

表示 validator.Validate 和 ut.Translator 的组合. 包含验证标签, 方式, 翻译器等基本要素 其中, tag 为必要字段

当存在 translation 时, 其他均为可选, 表示重写一个 tag 的翻译器

Jump to

Keyboard shortcuts

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