validation

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlphaNumRule

type AlphaNumRule struct{}

AlphaNumRule 字母数字规则

func (*AlphaNumRule) Message

func (r *AlphaNumRule) Message() string

func (*AlphaNumRule) Validate

func (r *AlphaNumRule) Validate(field string, value interface{}, data map[string]interface{}) error

type AlphaRule

type AlphaRule struct{}

AlphaRule 字母规则

func (*AlphaRule) Message

func (r *AlphaRule) Message() string

func (*AlphaRule) Validate

func (r *AlphaRule) Validate(field string, value interface{}, data map[string]interface{}) error

type ConfirmedRule

type ConfirmedRule struct{}

ConfirmedRule 确认规则

func (*ConfirmedRule) Message

func (r *ConfirmedRule) Message() string

func (*ConfirmedRule) Validate

func (r *ConfirmedRule) Validate(field string, value interface{}, data map[string]interface{}) error

type EmailRule

type EmailRule struct{}

EmailRule 邮箱规则

func (*EmailRule) Message

func (r *EmailRule) Message() string

func (*EmailRule) Validate

func (r *EmailRule) Validate(field string, value interface{}, data map[string]interface{}) error

type InRule

type InRule struct {
	Values []string
}

InRule 在指定值中规则

func (*InRule) Message

func (r *InRule) Message() string

func (*InRule) Validate

func (r *InRule) Validate(field string, value interface{}, data map[string]interface{}) error

type MaxRule

type MaxRule struct {
	Max int
}

MaxRule 最大长度规则

func (*MaxRule) Message

func (r *MaxRule) Message() string

func (*MaxRule) Validate

func (r *MaxRule) Validate(field string, value interface{}, data map[string]interface{}) error

type MinRule

type MinRule struct {
	Min int
}

MinRule 最小长度规则

func (*MinRule) Message

func (r *MinRule) Message() string

func (*MinRule) Validate

func (r *MinRule) Validate(field string, value interface{}, data map[string]interface{}) error

type NumericRule

type NumericRule struct{}

NumericRule 数字规则

func (*NumericRule) Message

func (r *NumericRule) Message() string

func (*NumericRule) Validate

func (r *NumericRule) Validate(field string, value interface{}, data map[string]interface{}) error

type RequiredRule

type RequiredRule struct{}

RequiredRule 必填规则

func (*RequiredRule) Message

func (r *RequiredRule) Message() string

func (*RequiredRule) Validate

func (r *RequiredRule) Validate(field string, value interface{}, data map[string]interface{}) error

type Rule

type Rule interface {
	Validate(field string, value interface{}, data map[string]interface{}) error
	Message() string
}

Rule 验证规则接口

func ParseRules

func ParseRules(ruleStr string) []Rule

ParseRules 解析规则字符串

type URLRule

type URLRule struct{}

URLRule URL 规则

func (*URLRule) Message

func (r *URLRule) Message() string

func (*URLRule) Validate

func (r *URLRule) Validate(field string, value interface{}, data map[string]interface{}) error

type Validator

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

Validator Laravel 风格的验证器

func Make

func Make(data map[string]interface{}, rules map[string]string) *Validator

Make 快速创建验证器

func New

func New(data map[string]interface{}, rules map[string][]Rule) *Validator

New 创建新的验证器

func (*Validator) Errors

func (v *Validator) Errors() map[string][]string

Errors 获取所有错误

func (*Validator) First

func (v *Validator) First(field ...string) string

First 获取第一个错误

func (*Validator) Has

func (v *Validator) Has(field string) bool

Has 检查字段是否有错误

func (*Validator) Validate

func (v *Validator) Validate() bool

Validate 执行验证

Jump to

Keyboard shortcuts

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