validation

package
v0.0.0-...-81145fb Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrMatch

func ErrMatch[T strings](val T, fieldName string, pattern string) error

func ErrMax

func ErrMax(fieldName string, maxValue any) error

func ErrMaxLength

func ErrMaxLength(fieldName string, maxLength int) error

func ErrMin

func ErrMin(fieldName string, minValue any) error

func ErrMinLength

func ErrMinLength(fieldName string, minLength int) error

func ErrRequired

func ErrRequired(fieldName string) error

func Field

func Field[T any](f T, name string) *field[T]

func RuleSet

func RuleSet(fields ...ruleField) *ruleSet

func VArray

func VArray[T any](arr []T) hasLength

func VMap

func VMap[T comparable, K any](m map[T]K) hasLength

func VString

func VString(str string) hasLength

Types

type ErrMatchFn

type ErrMatchFn[T strings] func(val T, fieldName string, pattern string) error

type ErrMinMaxFn

type ErrMinMaxFn func(string, any) error

type ErrMinMaxLengthFn

type ErrMinMaxLengthFn func(fieldName string, val int) error

type ErrRequiredFn

type ErrRequiredFn func(fieldName string) error

type RuleFn

type RuleFn[T any] func(*field[T]) ValidationRule

func Match

func Match[T strings](pattern T) RuleFn[T]

func Max

func Max[T numeric](max T) RuleFn[T]

func MaxLength

func MaxLength(maxLength int) RuleFn[hasLength]

func Min

func Min[T numeric](min T) RuleFn[T]

func MinLength

func MinLength(minLength int) RuleFn[hasLength]

type ValidationRule

type ValidationRule interface {
	Validate() (bool, error)
}

func Required

func Required[T any](f *field[T]) ValidationRule

Jump to

Keyboard shortcuts

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