Documentation ¶
Index ¶
- func Choice[T any](valid []T) any
- func Configure(config Config) error
- func Max(max any) any
- func Min(min any) any
- func Range(min any, max any) any
- type AnyFunc
- type AnyRule
- type AnyValidator
- type ArrayMax
- type ArrayMin
- type ArrayRange
- type ArrayRule
- type ArrayValidator
- func (v *ArrayValidator) Default(value []typed.Typed) *ArrayValidator
- func (v *ArrayValidator) Max(max int) *ArrayValidator
- func (v *ArrayValidator) Min(min int) *ArrayValidator
- func (v *ArrayValidator) Range(min int, max int) *ArrayValidator
- func (v *ArrayValidator) Required() *ArrayValidator
- func (v *ArrayValidator) Validator(validator *ObjectValidator) *ArrayValidator
- type BoolFunc
- type BoolRule
- type BoolValidator
- type Config
- type DataChoice
- type DataMax
- type DataMin
- type DataRange
- type Field
- type FloatFunc
- type FloatMax
- type FloatMin
- type FloatRange
- type FloatRule
- type FloatValidator
- func (v *FloatValidator) Default(value float64) *FloatValidator
- func (v *FloatValidator) Func(...) *FloatValidator
- func (v *FloatValidator) Max(max float64) *FloatValidator
- func (v *FloatValidator) Min(min float64) *FloatValidator
- func (v *FloatValidator) Range(min float64, max float64) *FloatValidator
- func (v *FloatValidator) Required() *FloatValidator
- type InputValidator
- type IntFunc
- type IntMax
- type IntMin
- type IntRange
- type IntRule
- type IntValidator
- func (v *IntValidator) Default(value int) *IntValidator
- func (v *IntValidator) Func(...) *IntValidator
- func (v *IntValidator) Max(max int) *IntValidator
- func (v *IntValidator) Min(min int) *IntValidator
- func (v *IntValidator) Range(min int, max int) *IntValidator
- func (v *IntValidator) Required() *IntValidator
- type Invalid
- func InvalidArrayMaxLength(max int) Invalid
- func InvalidArrayMinLength(min int) Invalid
- func InvalidArrayRangeLength(min int, max int) Invalid
- func InvalidArrayStringType() Invalid
- func InvalidArrayType() Invalid
- func InvalidBoolType() Invalid
- func InvalidFloatMax(max float64) Invalid
- func InvalidFloatMin(min float64) Invalid
- func InvalidFloatRange(min float64, max float64) Invalid
- func InvalidFloatType() Invalid
- func InvalidIntMax(max int) Invalid
- func InvalidIntMin(min int) Invalid
- func InvalidIntRange(min int, max int) Invalid
- func InvalidIntType() Invalid
- func InvalidStringChoice(choices []string) Invalid
- func InvalidStringLength(min int, max int) Invalid
- func InvalidStringPattern(errorMessage ...string) Invalid
- func InvalidStringType() Invalid
- func InvalidUUIDType() Invalid
- func Required() Invalid
- type InvalidField
- type ObjectValidator
- type Pool
- type Result
- func (r *Result) AddInvalid(invalid Invalid)
- func (r *Result) AddInvalidField(field Field, invalid Invalid)
- func (r *Result) ArrayIndex(i int)
- func (r *Result) BeginArray()
- func (r *Result) EndArray()
- func (r Result) Errors() []any
- func (r Result) IsValid() bool
- func (r Result) Len() uint64
- func (r *Result) Release()
- type StringChoice
- type StringConverter
- type StringFunc
- type StringFuncValidator
- type StringLen
- type StringPattern
- type StringRule
- type StringValidator
- func (v *StringValidator) Choice(valid ...string) *StringValidator
- func (v *StringValidator) Convert(fn StringConverter) *StringValidator
- func (v *StringValidator) Default(value string) *StringValidator
- func (v *StringValidator) Func(fn StringFuncValidator) *StringValidator
- func (v *StringValidator) Length(min int, max int) *StringValidator
- func (v *StringValidator) Pattern(pattern string, errorMessage ...string) *StringValidator
- func (v *StringValidator) Required() *StringValidator
- type UUIDValidator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AnyValidator ¶ added in v0.0.5
type AnyValidator struct {
// contains filtered or unexported fields
}
func Any ¶ added in v0.0.5
func Any() *AnyValidator
func (*AnyValidator) Default ¶ added in v0.0.5
func (v *AnyValidator) Default(value any) *AnyValidator
func (*AnyValidator) Func ¶ added in v0.0.5
func (v *AnyValidator) Func(fn func(field Field, value any, object typed.Typed, input typed.Typed, res *Result) any) *AnyValidator
func (*AnyValidator) Required ¶ added in v0.0.5
func (v *AnyValidator) Required() *AnyValidator
type ArrayRange ¶ added in v0.0.5
type ArrayRange struct {
// contains filtered or unexported fields
}
type ArrayValidator ¶ added in v0.0.5
type ArrayValidator struct {
// contains filtered or unexported fields
}
func Array ¶ added in v0.0.5
func Array() *ArrayValidator
func (*ArrayValidator) Default ¶ added in v0.0.5
func (v *ArrayValidator) Default(value []typed.Typed) *ArrayValidator
func (*ArrayValidator) Max ¶ added in v0.0.5
func (v *ArrayValidator) Max(max int) *ArrayValidator
func (*ArrayValidator) Min ¶ added in v0.0.5
func (v *ArrayValidator) Min(min int) *ArrayValidator
func (*ArrayValidator) Range ¶ added in v0.0.5
func (v *ArrayValidator) Range(min int, max int) *ArrayValidator
func (*ArrayValidator) Required ¶ added in v0.0.5
func (v *ArrayValidator) Required() *ArrayValidator
func (*ArrayValidator) Validator ¶ added in v0.0.5
func (v *ArrayValidator) Validator(validator *ObjectValidator) *ArrayValidator
type BoolValidator ¶
type BoolValidator struct {
// contains filtered or unexported fields
}
func Bool ¶
func Bool() *BoolValidator
func (*BoolValidator) Default ¶ added in v0.0.5
func (v *BoolValidator) Default(value bool) *BoolValidator
func (*BoolValidator) Func ¶ added in v0.0.5
func (v *BoolValidator) Func(fn func(field Field, value bool, object typed.Typed, input typed.Typed, res *Result) bool) *BoolValidator
func (*BoolValidator) Required ¶ added in v0.0.5
func (v *BoolValidator) Required() *BoolValidator
type DataChoice ¶ added in v0.0.5
type DataChoice[T any] struct { Valid []T `json:"valid"` }
type Field ¶ added in v0.0.5
type Field struct { // The name of the actual field that we need to look up. This is // always equal to the last element in Path Name string // strings.Join(Path, ".") Flat string // The full path of the field. // Could be a single value, like: ["name"], // Could be nested, like ["user", "name"], // Could contain placeholders for array indexex, like: ["users", "", name] Path []string }
func NewIndexedField ¶ added in v0.0.5
type FloatFunc ¶ added in v0.0.5
type FloatFunc struct {
// contains filtered or unexported fields
}
type FloatRange ¶ added in v0.0.5
type FloatRange struct {
// contains filtered or unexported fields
}
type FloatValidator ¶ added in v0.0.5
type FloatValidator struct {
// contains filtered or unexported fields
}
func Float ¶ added in v0.0.5
func Float() *FloatValidator
func (*FloatValidator) Default ¶ added in v0.0.5
func (v *FloatValidator) Default(value float64) *FloatValidator
func (*FloatValidator) Func ¶ added in v0.0.5
func (v *FloatValidator) Func(fn func(field Field, value float64, object typed.Typed, input typed.Typed, res *Result) float64) *FloatValidator
func (*FloatValidator) Max ¶ added in v0.0.5
func (v *FloatValidator) Max(max float64) *FloatValidator
func (*FloatValidator) Min ¶ added in v0.0.5
func (v *FloatValidator) Min(min float64) *FloatValidator
func (*FloatValidator) Range ¶ added in v0.0.5
func (v *FloatValidator) Range(min float64, max float64) *FloatValidator
func (*FloatValidator) Required ¶ added in v0.0.5
func (v *FloatValidator) Required() *FloatValidator
type InputValidator ¶
type InputValidator interface {
// contains filtered or unexported methods
}
type IntValidator ¶
type IntValidator struct {
// contains filtered or unexported fields
}
func Int ¶
func Int() *IntValidator
func (*IntValidator) Default ¶ added in v0.0.5
func (v *IntValidator) Default(value int) *IntValidator
func (*IntValidator) Func ¶ added in v0.0.5
func (v *IntValidator) Func(fn func(field Field, value int, object typed.Typed, input typed.Typed, res *Result) int) *IntValidator
func (*IntValidator) Max ¶ added in v0.0.5
func (v *IntValidator) Max(max int) *IntValidator
func (*IntValidator) Min ¶ added in v0.0.5
func (v *IntValidator) Min(min int) *IntValidator
func (*IntValidator) Range ¶ added in v0.0.5
func (v *IntValidator) Range(min int, max int) *IntValidator
func (*IntValidator) Required ¶ added in v0.0.5
func (v *IntValidator) Required() *IntValidator
type Invalid ¶
type Invalid struct { Code uint32 `json:"code"` Error string `json:"error"` Data any `json:"data"` //TODO: add omitempty https://github.com/goccy/go-json/issues/391 }
func InvalidArrayMaxLength ¶ added in v0.0.5
func InvalidArrayMinLength ¶ added in v0.0.5
func InvalidArrayRangeLength ¶ added in v0.0.5
func InvalidArrayStringType ¶ added in v0.0.5
func InvalidArrayStringType() Invalid
Not used by this library (yet), but is used by callers of this library. We put it here because (a) we expect to use this eventually here and (b) we want this to be consistent across all users of this library
func InvalidArrayType ¶ added in v0.0.5
func InvalidArrayType() Invalid
func InvalidBoolType ¶
func InvalidBoolType() Invalid
func InvalidFloatMax ¶ added in v0.0.5
func InvalidFloatMin ¶ added in v0.0.5
func InvalidFloatRange ¶ added in v0.0.5
func InvalidFloatType ¶ added in v0.0.5
func InvalidFloatType() Invalid
func InvalidIntMax ¶
func InvalidIntMin ¶
func InvalidIntRange ¶
func InvalidIntType ¶
func InvalidIntType() Invalid
func InvalidStringChoice ¶ added in v0.0.5
func InvalidStringLength ¶
func InvalidStringPattern ¶
func InvalidStringType ¶
func InvalidStringType() Invalid
func InvalidUUIDType ¶ added in v0.0.5
func InvalidUUIDType() Invalid
type InvalidField ¶
type ObjectValidator ¶ added in v0.0.5
type ObjectValidator struct {
// contains filtered or unexported fields
}
func Object ¶ added in v0.0.5
func Object() *ObjectValidator
func (*ObjectValidator) Field ¶ added in v0.0.5
func (o *ObjectValidator) Field(fieldName string, validator InputValidator) *ObjectValidator
func (*ObjectValidator) Validate ¶ added in v0.0.5
func (o *ObjectValidator) Validate(input typed.Typed, res *Result) bool
object validation called on the root
func (*ObjectValidator) ValidateArgs ¶ added in v0.0.5
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
func (*Result) AddInvalid ¶ added in v0.0.5
func (*Result) AddInvalidField ¶ added in v0.0.5
func (*Result) ArrayIndex ¶ added in v0.0.5
func (*Result) BeginArray ¶ added in v0.0.5
func (r *Result) BeginArray()
type StringChoice ¶ added in v0.0.5
type StringChoice struct {
// contains filtered or unexported fields
}
type StringConverter ¶
type StringFunc ¶
type StringFunc struct {
// contains filtered or unexported fields
}
type StringFuncValidator ¶
type StringPattern ¶
type StringPattern struct {
// contains filtered or unexported fields
}
type StringRule ¶ added in v0.0.5
type StringValidator ¶
type StringValidator struct {
// contains filtered or unexported fields
}
func String ¶
func String() *StringValidator
func (*StringValidator) Choice ¶ added in v0.0.5
func (v *StringValidator) Choice(valid ...string) *StringValidator
func (*StringValidator) Convert ¶ added in v0.0.5
func (v *StringValidator) Convert(fn StringConverter) *StringValidator
func (*StringValidator) Default ¶ added in v0.0.5
func (v *StringValidator) Default(value string) *StringValidator
func (*StringValidator) Func ¶ added in v0.0.5
func (v *StringValidator) Func(fn StringFuncValidator) *StringValidator
func (*StringValidator) Length ¶ added in v0.0.5
func (v *StringValidator) Length(min int, max int) *StringValidator
func (*StringValidator) Pattern ¶ added in v0.0.5
func (v *StringValidator) Pattern(pattern string, errorMessage ...string) *StringValidator
func (*StringValidator) Required ¶ added in v0.0.5
func (v *StringValidator) Required() *StringValidator
type UUIDValidator ¶ added in v0.0.5
type UUIDValidator struct {
// contains filtered or unexported fields
}
func UUID ¶ added in v0.0.5
func UUID() *UUIDValidator
func (*UUIDValidator) Default ¶ added in v0.0.5
func (v *UUIDValidator) Default(value string) *UUIDValidator
func (*UUIDValidator) Required ¶ added in v0.0.5
func (v *UUIDValidator) Required() *UUIDValidator
Click to show internal directories.
Click to hide internal directories.