validation

package
v0.0.0-...-86833b7 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Email = NewRegexValidator("^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\\])$")

Functions

func IsZero

func IsZero(v reflect.Value) bool

func NewRegexValidator

func NewRegexValidator(pattern string) func(msg string) func(*Context)

Types

type At

type At func(fieldName string, vs ...Validator) *Context

type Context

type Context struct {
	Name  string
	Value reflect.Value
	// contains filtered or unexported fields
}

func New

func New(target interface{}) *Context

func (*Context) Done

func (cc *Context) Done() Result

func (*Context) Err

func (cc *Context) Err(msg string)

func (*Context) Field

func (cc *Context) Field(name string) reflect.Value

func (*Context) Test

func (cc *Context) Test(fieldName string, vs ...Validator) *Context

type Error

type Error struct {
	Field, Description string
}

type Provider

type Provider func(i string) reflect.Value

func NewRouterValueProvider

func NewRouterValueProvider(vl router.Parameter) Provider

func NewURLValueProvider

func NewURLValueProvider(vl url.Values) Provider

type Result

type Result []Error

func Run

func Run(target interface{}, aa func(At)) Result

func RunStop

func RunStop(target interface{}, aa func(At)) Result

func (Result) CanContinue

func (result Result) CanContinue() bool

func (Result) Get

func (result Result) Get(fieldName string) (err *Error)

func (Result) HasErrors

func (result Result) HasErrors() bool

func (Result) Lookup

func (result Result) Lookup(fieldName string) (err *Error, has bool)

type Validator

type Validator func(c *Context)

func AfterNow

func AfterNow(msg string) Validator

func BeforeNow

func BeforeNow(msg string) Validator

func Empty

func Empty(msg string) Validator

func MaxFloat

func MaxFloat(msg string, i float64) Validator

func MaxInt

func MaxInt(msg string, i int64) Validator

func MaxLength

func MaxLength(msg string, length int) Validator

func MaxUint

func MaxUint(msg string, i uint64) Validator

func MinFloat

func MinFloat(msg string, i float64) Validator

func MinInt

func MinInt(msg string, i int64) Validator

func MinLength

func MinLength(msg string, length int) Validator

func MinUint

func MinUint(msg string, i uint64) Validator

func NoEmpty

func NoEmpty(msg string) Validator

func OneOf

func OneOf(msg string, list ...interface{}) Validator

func SameAs

func SameAs(msg string, FieldName string) Validator

func SliceContains

func SliceContains(msg string, item interface{}) Validator

func StringContains

func StringContains(msg string, item string) Validator

func Sub

func Sub(runner func(At)) Validator

Jump to

Keyboard shortcuts

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