rules

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func After

func After[T any](f form.TimeField[T], t time.Time) form.Rule[T]

func AfterWithCode

func AfterWithCode[T any](f form.TimeField[T], t time.Time, code form.Code) form.Rule[T]

func Alpha

func Alpha[T any](f form.StringField[T]) form.Rule[T]

func AlphaDash

func AlphaDash[T any](f form.StringField[T]) form.Rule[T]

func AlphaDashWithCode

func AlphaDashWithCode[T any](f form.StringField[T], code form.Code) form.Rule[T]

func AlphaNum

func AlphaNum[T any](f form.StringField[T]) form.Rule[T]

func AlphaNumWithCode

func AlphaNumWithCode[T any](f form.StringField[T], code form.Code) form.Rule[T]

func AlphaWithCode

func AlphaWithCode[T any](f form.StringField[T], code form.Code) form.Rule[T]

func Before

func Before[T any](f form.TimeField[T], t time.Time) form.Rule[T]

func BeforeWithCode

func BeforeWithCode[T any](f form.TimeField[T], t time.Time, code form.Code) form.Rule[T]

func BetweenFloat64

func BetweenFloat64[T any](f form.Float64Field[T], min, max float64) form.Rule[T]

func BetweenFloat64WithCode

func BetweenFloat64WithCode[T any](f form.Float64Field[T], min, max float64, code form.Code) form.Rule[T]

func BetweenInt

func BetweenInt[T any](f form.IntField[T], min, max int) form.Rule[T]

func BetweenIntWithCode

func BetweenIntWithCode[T any](f form.IntField[T], min, max int, code form.Code) form.Rule[T]

func BetweenTime

func BetweenTime[T any](f form.TimeField[T], min, max time.Time) form.Rule[T]

func BetweenTimeWithCode

func BetweenTimeWithCode[T any](f form.TimeField[T], min, max time.Time, code form.Code) form.Rule[T]

func BoolEquals

func BoolEquals[T any](f form.BoolField[T], expected bool) form.Rule[T]

func BoolEqualsWithCode

func BoolEqualsWithCode[T any](f form.BoolField[T], expected bool, code form.Code) form.Rule[T]

func Compare

func Compare[T any, V Ordered](aF form.Field[T, V], bF form.Field[T, V], op CompareOp) form.Rule[T]

func CompareWithCode

func CompareWithCode[T any, V Ordered](aF form.Field[T, V], bF form.Field[T, V], op CompareOp, code form.Code) form.Rule[T]

func Contains

func Contains[T any](f form.StringField[T], needle string) form.Rule[T]

func ContainsWithCode

func ContainsWithCode[T any](f form.StringField[T], needle string, code form.Code) form.Rule[T]

func DistinctStr

func DistinctStr[T any](f form.SliceStringField[T]) form.Rule[T]

func DistinctStrWithCode

func DistinctStrWithCode[T any](f form.SliceStringField[T], code form.Code) form.Rule[T]

func EachStr

func EachStr[T any](f form.SliceStringField[T], rules ...StrValueRule) form.Rule[T]

func Email

func Email[T any](f form.StringField[T]) form.Rule[T]

func EmailWithCode

func EmailWithCode[T any](f form.StringField[T], code form.Code) form.Rule[T]

func EndsWith

func EndsWith[T any](f form.StringField[T], suffix string) form.Rule[T]

func EndsWithWithCode

func EndsWithWithCode[T any](f form.StringField[T], suffix string, code form.Code) form.Rule[T]

func IP

func IP[T any](f form.StringField[T]) form.Rule[T]

func IPWithCode

func IPWithCode[T any](f form.StringField[T], code form.Code) form.Rule[T]

func IsBool

func IsBool[T any](f form.BoolField[T]) form.Rule[T]

IsBool is kept for API symmetry. For Go-typed inputs it is a no-op. (Type mismatches are typically caught during JSON decoding.)

func IsFalse

func IsFalse[T any](f form.BoolField[T]) form.Rule[T]

func IsFalseWithCode

func IsFalseWithCode[T any](f form.BoolField[T], code form.Code) form.Rule[T]

func IsTrue

func IsTrue[T any](f form.BoolField[T]) form.Rule[T]

func IsTrueWithCode

func IsTrueWithCode[T any](f form.BoolField[T], code form.Code) form.Rule[T]

func JSON

func JSON[T any](f form.StringField[T]) form.Rule[T]

func JSONWithCode

func JSONWithCode[T any](f form.StringField[T], code form.Code) form.Rule[T]

func Len

func Len[T any](f form.StringField[T], n int) form.Rule[T]

func LenWithCode

func LenWithCode[T any](f form.StringField[T], n int, code form.Code) form.Rule[T]

func Lowercase

func Lowercase[T any](f form.StringField[T]) form.Rule[T]

func LowercaseWithCode

func LowercaseWithCode[T any](f form.StringField[T], code form.Code) form.Rule[T]

func Max

func Max[T any](f form.IntField[T], n int) form.Rule[T]

func MaxFloat64

func MaxFloat64[T any](f form.Float64Field[T], n float64) form.Rule[T]

func MaxFloat64WithCode

func MaxFloat64WithCode[T any](f form.Float64Field[T], n float64, code form.Code) form.Rule[T]

func MaxItemsStr

func MaxItemsStr[T any](f form.SliceStringField[T], n int) form.Rule[T]

func MaxItemsStrWithCode

func MaxItemsStrWithCode[T any](f form.SliceStringField[T], n int, code form.Code) form.Rule[T]

func MaxLen

func MaxLen[T any](f form.StringField[T], n int) form.Rule[T]

func MaxLenWithCode

func MaxLenWithCode[T any](f form.StringField[T], n int, code form.Code) form.Rule[T]

func MaxWithCode

func MaxWithCode[T any](f form.IntField[T], n int, code form.Code) form.Rule[T]

func Min

func Min[T any](f form.IntField[T], n int) form.Rule[T]

func MinFloat64

func MinFloat64[T any](f form.Float64Field[T], n float64) form.Rule[T]

func MinFloat64WithCode

func MinFloat64WithCode[T any](f form.Float64Field[T], n float64, code form.Code) form.Rule[T]

func MinItemsStr

func MinItemsStr[T any](f form.SliceStringField[T], n int) form.Rule[T]

func MinItemsStrWithCode

func MinItemsStrWithCode[T any](f form.SliceStringField[T], n int, code form.Code) form.Rule[T]

func MinLen

func MinLen[T any](f form.StringField[T], n int) form.Rule[T]

func MinLenWithCode

func MinLenWithCode[T any](f form.StringField[T], n int, code form.Code) form.Rule[T]

func MinWithCode

func MinWithCode[T any](f form.IntField[T], n int, code form.Code) form.Rule[T]

func NotNil

func NotNil[T any, V any](f form.Field[T, *V]) form.Rule[T]

func NotNilWithCode

func NotNilWithCode[T any, V any](f form.Field[T, *V], code form.Code) form.Rule[T]

func NotRegex

func NotRegex[T any](f form.StringField[T], re *regexp.Regexp) form.Rule[T]

func NotRegexWithCode

func NotRegexWithCode[T any](f form.StringField[T], re *regexp.Regexp, code form.Code) form.Rule[T]

func OneOf

func OneOf[T any, V comparable](f form.Field[T, V], allowed ...V) form.Rule[T]

func OneOfWithCode

func OneOfWithCode[T any, V comparable](f form.Field[T, V], code form.Code, allowed ...V) form.Rule[T]

func Regex

func Regex[T any](f form.StringField[T], re *regexp.Regexp) form.Rule[T]

func RegexWithCode

func RegexWithCode[T any](f form.StringField[T], re *regexp.Regexp, code form.Code) form.Rule[T]

func Required

func Required[T any](f form.StringField[T]) form.Rule[T]

func RequiredBool

func RequiredBool[T any](f form.BoolField[T]) form.Rule[T]

func RequiredBoolWithCode

func RequiredBoolWithCode[T any](f form.BoolField[T], code form.Code) form.Rule[T]

func RequiredField

func RequiredField[T any, V any](f form.Field[T, V]) form.Rule[T]

func RequiredFieldWithCode

func RequiredFieldWithCode[T any, V any](f form.Field[T, V], code form.Code) form.Rule[T]

func RequiredInt

func RequiredInt[T any](f form.IntField[T]) form.Rule[T]

func RequiredIntWithCode

func RequiredIntWithCode[T any](f form.IntField[T], code form.Code) form.Rule[T]

func RequiredOptBool

func RequiredOptBool[T any](f form.OptBoolField[T]) form.Rule[T]

func RequiredOptBoolWithCode

func RequiredOptBoolWithCode[T any](f form.OptBoolField[T], code form.Code) form.Rule[T]

func RequiredOptInt

func RequiredOptInt[T any](f form.OptIntField[T]) form.Rule[T]

func RequiredOptIntWithCode

func RequiredOptIntWithCode[T any](f form.OptIntField[T], code form.Code) form.Rule[T]

func RequiredOptStr

func RequiredOptStr[T any](f form.OptStringField[T]) form.Rule[T]

func RequiredOptStrWithCode

func RequiredOptStrWithCode[T any](f form.OptStringField[T], code form.Code) form.Rule[T]

func RequiredOptTime

func RequiredOptTime[T any](f form.OptTimeField[T]) form.Rule[T]

func RequiredOptTimeWithCode

func RequiredOptTimeWithCode[T any](f form.OptTimeField[T], code form.Code) form.Rule[T]

func RequiredSliceStr

func RequiredSliceStr[T any](f form.SliceStringField[T]) form.Rule[T]

func RequiredSliceStrWithCode

func RequiredSliceStrWithCode[T any](f form.SliceStringField[T], code form.Code) form.Rule[T]

func RequiredStr

func RequiredStr[T any](f form.StringField[T]) form.Rule[T]

func RequiredStrWithCode

func RequiredStrWithCode[T any](f form.StringField[T], code form.Code) form.Rule[T]

func RequiredTime

func RequiredTime[T any](f form.TimeField[T]) form.Rule[T]

func RequiredTimeWithCode

func RequiredTimeWithCode[T any](f form.TimeField[T], code form.Code) form.Rule[T]

func RequiredWithCode

func RequiredWithCode[T any](f form.StringField[T], code form.Code) form.Rule[T]

func StartsWith

func StartsWith[T any](f form.StringField[T], prefix string) form.Rule[T]

func StartsWithWithCode

func StartsWithWithCode[T any](f form.StringField[T], prefix string, code form.Code) form.Rule[T]

func Timezone

func Timezone[T any](f form.StringField[T]) form.Rule[T]

func TimezoneWithCode

func TimezoneWithCode[T any](f form.StringField[T], code form.Code) form.Rule[T]

func URL

func URL[T any](f form.StringField[T]) form.Rule[T]

func URLWithCode

func URLWithCode[T any](f form.StringField[T], code form.Code) form.Rule[T]

func UUID

func UUID[T any](f form.StringField[T]) form.Rule[T]

func UUIDWithCode

func UUIDWithCode[T any](f form.StringField[T], code form.Code) form.Rule[T]

func Uppercase

func Uppercase[T any](f form.StringField[T]) form.Rule[T]

func UppercaseWithCode

func UppercaseWithCode[T any](f form.StringField[T], code form.Code) form.Rule[T]

Types

type CompareOp

type CompareOp string
const (
	OpEQ  CompareOp = "eq"
	OpNE  CompareOp = "ne"
	OpLT  CompareOp = "lt"
	OpLTE CompareOp = "lte"
	OpGT  CompareOp = "gt"
	OpGTE CompareOp = "gte"
)

type Ordered

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

type StrValueRule

type StrValueRule func(v string) (ok bool, code form.Code)

EachStr: validation of each element with indexing field[0], field[1]...

func VMinLen

func VMinLen(n int) StrValueRule

func VMinLenWithCode

func VMinLenWithCode(n int, code form.Code) StrValueRule

func VRegex

func VRegex(re *regexp.Regexp) StrValueRule

func VRegexWithCode

func VRegexWithCode(re *regexp.Regexp, code form.Code) StrValueRule

func VRequired

func VRequired() StrValueRule

func VRequiredWithCode

func VRequiredWithCode(code form.Code) StrValueRule

Jump to

Keyboard shortcuts

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