validator

package
v0.0.51 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ValidatorParamsCheckFailCode int    = -400300
	ValidatorParamsCheckFailMsg  string = "参数校验失败"

	// 表单参数验证器未通过时的错误
	ErrorsValidatorNotExists      string = "不存在的验证器"
	ErrorsValidatorTransInitFail  string = "validator的翻译器初始化错误"
	ErrorNotAllParamsIsBlank      string = "该接口不允许所有参数都为空,请按照接口要求提交必填参数"
	ErrorsValidatorBindParamsFail string = "验证器绑定参数失败"
)

Variables

Trans 定义一个全局翻译器T

Functions

func ErrorParam

func ErrorParam(c *gin.Context, wrongParam interface{})

参数校验错误

func InitTrans

func InitTrans(locale string) (err error)

InitTrans 初始化表单参数验证器的翻译器

func RemoveTopStruct

func RemoveTopStruct(fields map[string]string) map[string]string

RemoveTopStruct 将返回的结构体名去除掉,只留下需要的字段名

func ValidatorError

func ValidatorError(c *gin.Context, err error)

ValidatorError 翻译表单参数验证器出现的校验错误

Types

This section is empty.

Jump to

Keyboard shortcuts

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