validator

package
v1.7.7 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Validator

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

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

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(rules ...func(item T) error) error

Validate 执行验证

Jump to

Keyboard shortcuts

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