validator

package
v1.57.1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ValidateErr ValidateError
	RequiredErr RequiredError
	EmailErr    EmailError
	TimeErr     TimeError
	LengthErr   LengthError
	RuleErr     RuleError
)

Functions

func WithFiber

func WithFiber[T any](c *fiber.Ctx, fns ...func(ins *T) (err error)) (T, error)

WithFiber 执行验证,使用fiber.Ctx(返回值)

func WithFiberPtr

func WithFiberPtr[T any](c *fiber.Ctx, fns ...func(ins *T) (err error)) (*T, error)

func WithGin

func WithGin[T any](c *gin.Context, fns ...func(ins *T) (err error)) (T, error)

WithGin 执行验证,使用gin.Context(返回值)

func WithGinPtr

func WithGinPtr[T any](c *gin.Context, fns ...func(ins *T) (err error)) (*T, error)

WithGinPtr 执行验证,使用gin.Context(返回指针)

Types

type EmailError

type EmailError struct{ myError.MyError }

func (*EmailError) Error

func (my *EmailError) Error() string

func (*EmailError) Is

func (my *EmailError) Is(target error) bool

func (*EmailError) New

func (*EmailError) New(msg string) myError.IMyError

func (*EmailError) Panic

func (*EmailError) Panic() myError.IMyError

func (*EmailError) Wrap

func (*EmailError) Wrap(err error) myError.IMyError

type LengthError

type LengthError struct{ myError.MyError }

func (*LengthError) Error

func (my *LengthError) Error() string

func (*LengthError) Is

func (my *LengthError) Is(target error) bool

func (*LengthError) New

func (*LengthError) New(msg string) myError.IMyError

func (*LengthError) NewFormat

func (my *LengthError) NewFormat(format string, messages ...any) myError.IMyError

func (*LengthError) Panic

func (*LengthError) Panic() myError.IMyError

func (*LengthError) Wrap

func (*LengthError) Wrap(err error) myError.IMyError

type RequiredError

type RequiredError struct{ myError.MyError }

func (*RequiredError) Error

func (my *RequiredError) Error() string

func (*RequiredError) Is

func (my *RequiredError) Is(target error) bool

func (*RequiredError) New

func (*RequiredError) Panic

func (*RequiredError) Panic() myError.IMyError

func (*RequiredError) Wrap

func (*RequiredError) Wrap(err error) myError.IMyError

type RuleError

type RuleError struct{ myError.MyError }

func (*RuleError) Error

func (my *RuleError) Error() string

func (*RuleError) Is

func (my *RuleError) Is(target error) bool

func (*RuleError) New

func (*RuleError) New(msg string) myError.IMyError

func (*RuleError) NewFormat

func (my *RuleError) NewFormat(format string, messages ...any) myError.IMyError

func (*RuleError) Panic

func (*RuleError) Panic() myError.IMyError

func (*RuleError) Wrap

func (*RuleError) Wrap(err error) myError.IMyError

type TimeError

type TimeError struct{ myError.MyError }

func (*TimeError) Error

func (my *TimeError) Error() string

func (*TimeError) Is

func (my *TimeError) Is(target error) bool

func (*TimeError) New

func (*TimeError) New(msg string) myError.IMyError

func (*TimeError) NewFormat

func (my *TimeError) NewFormat(format string, messages ...any) myError.IMyError

func (*TimeError) Panic

func (*TimeError) Panic() myError.IMyError

func (*TimeError) Wrap

func (*TimeError) Wrap(err error) myError.IMyError

type ValidateError

type ValidateError struct{ myError.MyError }

func (*ValidateError) Error

func (my *ValidateError) Error() string

func (*ValidateError) Is

func (my *ValidateError) Is(target error) bool

func (*ValidateError) New

func (*ValidateError) NewFormat

func (my *ValidateError) NewFormat(format string, messages ...any) myError.IMyError

func (*ValidateError) Panic

func (*ValidateError) Panic() myError.IMyError

func (*ValidateError) Wrap

func (*ValidateError) Wrap(err error) myError.IMyError

type ValidatorApp

type ValidatorApp[T any] struct {
	// contains filtered or unexported fields
}

ValidatorApp 验证器

func New

func New[T any](data T, prefixNames ...string) *ValidatorApp[T]

New 实例化:验证器

func (*ValidatorApp[T]) DateFormat

func (my *ValidatorApp[T]) DateFormat(dateFormat string) *ValidatorApp[T]

DateFormat 设置日期默认规则

func (*ValidatorApp[T]) DatetimeFormat

func (my *ValidatorApp[T]) DatetimeFormat(datetimeFormat string) *ValidatorApp[T]

DatetimeFormat 设置日期+时间默认规则

func (*ValidatorApp[T]) EmailFormat

func (my *ValidatorApp[T]) EmailFormat(emailFormat string) *ValidatorApp[T]

EmailFormat 设置email默认规则

func (*ValidatorApp[T]) TimeFormat

func (my *ValidatorApp[T]) TimeFormat(timeFormat string) *ValidatorApp[T]

TimeFormat 设置时间默认规则

func (*ValidatorApp[T]) Validate

func (my *ValidatorApp[T]) Validate(funcs ...func(ins T) (err error)) error

Validate 执行验证

type ValidatorExCheckerApp

type ValidatorExCheckerApp struct{ ExFunMap exFunMap }
var (
	ValidatorExChecker ValidatorExCheckerApp
)

func (*ValidatorExCheckerApp) Once

func (*ValidatorExCheckerApp) Once() *ValidatorExCheckerApp

Once 单利化:额外验证器

func (*ValidatorExCheckerApp) RegisterExFun

func (my *ValidatorExCheckerApp) RegisterExFun(name string, exFun exFun) *ValidatorExCheckerApp

RegisterExFun 注册额外验证函数

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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