validate

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEmail

func IsEmail(email string) bool

IsEmail 是否为电子邮箱

func IsMobile

func IsMobile(mobileNum string) bool

IsMobile 验证是否为手机号

func SetErrMsgTag

func SetErrMsgTag(tagName string)

SetErrMsgTag 设置错误标签名称

func SetRuleTag

func SetRuleTag(tagName string)

SetRuleTag 设置数据验证规则的tag名称

func ValidStruct

func ValidStruct(data any) error

ValidStruct 验证数据的有效性

func ValidStructWithTag

func ValidStructWithTag(data any, tagName string) error

func ValidVar

func ValidVar(data any, tag string) error

Types

type ValidErrors

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

func NewValidErrors

func NewValidErrors(errs ...error) *ValidErrors

func (*ValidErrors) Add

func (ve *ValidErrors) Add(err error)

func (*ValidErrors) Clear

func (ve *ValidErrors) Clear()

func (*ValidErrors) Error

func (ve *ValidErrors) Error() string

func (*ValidErrors) Errors

func (ve *ValidErrors) Errors() []error

func (*ValidErrors) IsError

func (ve *ValidErrors) IsError() bool

func (*ValidErrors) MarshalJSON

func (ve *ValidErrors) MarshalJSON() ([]byte, error)

type ValidFieldError

type ValidFieldError struct {
	Field      string `json:"field"`
	FieldError string `json:"error"`
}

func NewFieldError

func NewFieldError(fieldName string, error string) *ValidFieldError

func (*ValidFieldError) Error

func (vf *ValidFieldError) Error() string

Jump to

Keyboard shortcuts

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