validator

package
v0.0.0-...-7571f08 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RgxEmail = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
)

Functions

func AllIn

func AllIn[T comparable](values []T, safelist ...T) bool

func Between

func Between[T constraints.Ordered](value, min, max T) bool

func In

func In[T comparable](value T, safelist ...T) bool

func IsEmail

func IsEmail(value string) bool

func IsURL

func IsURL(value string) bool

func Matches

func Matches(value string, rx *regexp.Regexp) bool

func MaxRunes

func MaxRunes(value string, n int) bool

func MinRunes

func MinRunes(value string, n int) bool

func NoDuplicates

func NoDuplicates[T comparable](values []T) bool

func NotBlank

func NotBlank(value string) bool

func NotIn

func NotIn[T comparable](value T, blocklist ...T) bool

Types

type Validator

type Validator struct {
	Errors      []string          `json:",omitempty"`
	FieldErrors map[string]string `json:",omitempty"`
}

func (*Validator) AddError

func (v *Validator) AddError(message string)

func (*Validator) AddFieldError

func (v *Validator) AddFieldError(key, message string)

func (*Validator) Check

func (v *Validator) Check(ok bool, message string)

func (*Validator) CheckField

func (v *Validator) CheckField(ok bool, key, message string)

func (Validator) HasErrors

func (v Validator) HasErrors() bool

Jump to

Keyboard shortcuts

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