rules

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRule

func AddRule(key string, rule ValidationRule)

func AddStringRule

func AddStringRule(key string, cb func(value string, args []string) bool)

func AddTypeRule

func AddTypeRule(key string, rule *TypeRule)

Types

type TypeRule

type TypeRule struct {
	ArgCount int
	Int      func(value int64, arguments TypeRuleArguments) bool
	Uint     func(value uint64, arguments TypeRuleArguments) bool
	Float    func(value float64, arguments TypeRuleArguments) bool
	String   func(value string, arguments TypeRuleArguments) bool
	Bool     func(value bool, arguments TypeRuleArguments) bool
	Time     func(value time.Time, arguments TypeRuleArguments) bool
}

type TypeRuleArguments

type TypeRuleArguments []string

func (TypeRuleArguments) GetBoolean

func (a TypeRuleArguments) GetBoolean(i int) bool

func (TypeRuleArguments) GetFloat

func (a TypeRuleArguments) GetFloat(i int) float64

func (TypeRuleArguments) GetInt

func (a TypeRuleArguments) GetInt(i int) int64

func (TypeRuleArguments) GetString

func (a TypeRuleArguments) GetString(i int) string

func (TypeRuleArguments) GetTime

func (a TypeRuleArguments) GetTime(i int) time.Time

func (TypeRuleArguments) GetUint

func (a TypeRuleArguments) GetUint(i int) uint64

type ValidationOptions

type ValidationOptions struct {
	Value     any
	Arguments []string
	Request   *http.Request
	Name      string
}

type ValidationRule

type ValidationRule func(options *ValidationOptions) bool

func GetRule

func GetRule(key string) (ValidationRule, bool)

Jump to

Keyboard shortcuts

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