validator

package
v0.0.0-...-c264b96 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(err error) string

Error 获取并翻译错误信息

func SetErrSeparator

func SetErrSeparator(s string)

SetErrSeparator 设置错误分割符,当showAllErrors为true时,将以此符号分割

func ShowFullError

func ShowFullError(b bool)

ShowFullError 当有多个错误时,是否全部显示,默认只显示一个错误

func Translate

func Translate(err error) string

Translate 翻译错误消息

func UseTranslator

func UseTranslator(et ErrorTranslator)

UseTranslator 注册一个自定义的错误解释器,主要用于非汉语环境

Types

type ErrorTranslator

type ErrorTranslator interface {
	RegisterTranslations(v *validator.Validate) (ut.Translator, error)
}

ErrorTranslator 错误解释器,用于多语言环境的错误处理

Jump to

Keyboard shortcuts

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