validator

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: Apache-2.0 Imports: 11 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

This section is empty.

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, msgs ...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, msgs ...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, msgs ...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) Panic

func (*ValidateError) Panic() myError.IMyError

func (*ValidateError) Wrap

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

type Validator

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

Validator 验证器 验证规则 -> [required] [email|datetime|date|time] [min<|min<=] [max>|max=] [range=]

func New

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

New 实例化:验证器

func NewValidator

func NewValidator[T any](data T, prefixNames ...string) *Validator[T]

NewValidator 实例化:验证器

func (*Validator[T]) DateFormat

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

DateFormat 设置日期默认规则

func (*Validator[T]) DatetimeFormat

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

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

func (*Validator[T]) EmailFormat

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

EmailFormat 设置email默认规则

func (*Validator[T]) TimeFormat

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

TimeFormat 设置时间默认规则

func (*Validator[T]) Validate

func (my *Validator[T]) Validate(exChecks ...func(item T) error) error

Validate 执行验证

Jump to

Keyboard shortcuts

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