inivadil

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidValidationType = errors.New("invalid validation type")
)

Functions

func Validate

func Validate(t ValidationType, rules Rules, r io.Reader) error

Types

type Rule

type Rule []RuleElement

type RuleElement

type RuleElement func(p RuleElementParameter) ValidationError

func Array

func Array() RuleElement

func Base32

func Base32() RuleElement

func Base64

func Base64() RuleElement

func Boolean

func Boolean() RuleElement

func BooleanString

func BooleanString() RuleElement

func Contains

func Contains(str string) RuleElement

func DivisibleBy

func DivisibleBy(number float64) RuleElement

func Email

func Email() RuleElement

func Empty

func Empty() RuleElement

func Equals

func Equals(value any) RuleElement

func Float

func Float() RuleElement

func FloatString

func FloatString() RuleElement

func If

func If(ruleElement RuleElement) RuleElement

func IfNot

func IfNot(ruleElement RuleElement) RuleElement

func Integer

func Integer() RuleElement

func IntegerString

func IntegerString() RuleElement

func Length

func Length(min, max int) RuleElement

func Max

func Max(maxNumber float64) RuleElement

func MaxLength

func MaxLength(max int) RuleElement

func Min

func Min(minNumber float64) RuleElement

func MinLength

func MinLength(min int) RuleElement

func Negative

func Negative() RuleElement

func NotContains

func NotContains(str string) RuleElement

func NotEmpty

func NotEmpty() RuleElement

func NotEquals

func NotEquals(value any) RuleElement

func NotNull

func NotNull() RuleElement

func OnlyASCII

func OnlyASCII() RuleElement

func OnlyAlpha

func OnlyAlpha() RuleElement

func OnlyAlphanumeric

func OnlyAlphanumeric() RuleElement

func Positive

func Positive() RuleElement

func String

func String() RuleElement

type RuleElementParameter

type RuleElementParameter struct {
	Field  string
	Value  any
	RValue reflect.Value
}

type Rules

type Rules map[string]Rule

type ValidationError

type ValidationError struct {
	Field   string
	Message string
	// contains filtered or unexported fields
}

func NewValidationError

func NewValidationError(field, message string, args ...any) ValidationError

func NilValidationError

func NilValidationError() ValidationError

func (ValidationError) Error

func (err ValidationError) Error() string

func (ValidationError) Nil

func (err ValidationError) Nil() bool

type ValidationErrors

type ValidationErrors []ValidationError

func (ValidationErrors) Error

func (err ValidationErrors) Error() string

type ValidationType

type ValidationType uint8
const (
	JSONValidation ValidationType = iota
)

Jump to

Keyboard shortcuts

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