validhelper

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2024 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const CUSTOM_RULE = "CUSTOM_RULE:"
View Source
const EQ = "EQ"
View Source
const GE = "GE"
View Source
const GT = "GT"
View Source
const LE = "LE"
View Source
const LT = "LT"
View Source
const NE = "NE"
View Source
const NOT_EMPTY = "notEmpty"
View Source
const REGEXP = "regexp"

Variables

View Source
var ErrIsEmpty = errors.New("is empty")
View Source
var ErrLenNotValid = errors.New("len is not valid")
View Source
var ErrRegexp = errors.New("regexp fail")

Functions

func Eq

func Eq(mark string) string

func Ge

func Ge(mark string) string

func Gt

func Gt(mark string) string

func Le

func Le(mark string) string

func Lt

func Lt(mark string) string

func Ne

func Ne(mark string) string

func NotEmpty

func NotEmpty() string

func RegexpMatch

func RegexpMatch(rule string) string

Types

type Comparable

type Comparable interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr |
		~float32 | ~float64
}

type Rules

type Rules map[string][]string

type Validator

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

func NewValidator

func NewValidator(t func(fieldName string, field reflect.Value, err error, rule string) error) Validator

func (*Validator) AddCustomRule

func (a *Validator) AddCustomRule(customRule map[string]func(st interface{}, targetField reflect.Value, rule string) (err error)) Validator

customRule key format must be <NAME>=<VALUE> e.x: IS_FLOAT_FORCE_DECIMAL=2

func (*Validator) RemoveCustomRule

func (a *Validator) RemoveCustomRule(customRules []string) Validator

func (*Validator) Verify

func (a *Validator) Verify(st interface{}, ruleMap Rules) (err error)

Jump to

Keyboard shortcuts

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