Versions in this module Expand all Collapse all v1 v1.22.0 Apr 25, 2024 Changes in this version + const TagDefault + const TagErrMsg + const TagValidate + var TargetDecimalDigitsOfFloatValue = "decimal digits of float value" + var TargetFloatValue = "float value" + var TargetIntValue = "int value" + var TargetMapLength = "map length" + var TargetSliceLength = "slice length" + var TargetStringLength = "string length" + var TargetTotalDigitsOfFloatValue = "total digits of float value" + var TargetUintValue = "uint value" + var ValidatorMgrDefault = NewValidatorFactory() + func ContextWithNamedTagKey(ctx context.Context, namedTagKey string) context.Context + func ContextWithValidatorMgr(c context.Context, validatorMgr ValidatorMgr) context.Context + func MaxInt(bitSize uint) int64 + func MaxUint(bitSize uint) uint64 + func MinInt(bitSize uint) int64 + func NamedKeyFromContext(ctx context.Context) string + func RangeFromUint(min uint64, max *uint64) []*rules.RuleLit + func ToMarshalledText(v interface{}) string + func UintRange(typ string, bitSize uint, ranges ...*rules.RuleLit) (uint64, *uint64, error) + type ErrorSet struct + func NewErrorSet(paths ...interface{}) *ErrorSet + func (es *ErrorSet) AddErr(err error, keyPathNodes ...interface{}) + func (es *ErrorSet) Each(cb func(fieldErr *FieldError)) + func (es *ErrorSet) Err() error + func (es *ErrorSet) Error() string + func (es *ErrorSet) Flatten() *ErrorSet + func (es *ErrorSet) Len() int + func (es *ErrorSet) ToErrorFields() statuserror.ErrorFields + type FieldError struct + Error error + Path KeyPath + type FloatValidator struct + DecimalDigits *uint + Enums []float64 + ExclusiveMaximum bool + ExclusiveMinimum bool + MaxDigits uint + Maximum *float64 + Minimum *float64 + MultipleOf float64 + func (FloatValidator) Names() []string + func (FloatValidator) New(ctx context.Context, rule *Rule) (Validator, error) + func (validator *FloatValidator) SetDefaults() + func (validator *FloatValidator) String() string + func (validator *FloatValidator) TypeCheck(rule *Rule) error + func (validator *FloatValidator) Validate(v interface{}) error + type IntValidator struct + BitSize uint + Enums []int64 + ExclusiveMaximum bool + ExclusiveMinimum bool + Maximum *int64 + Minimum *int64 + MultipleOf int64 + func (IntValidator) Names() []string + func (IntValidator) New(ctx context.Context, rule *Rule) (Validator, error) + func (validator *IntValidator) SetDefaults() + func (validator *IntValidator) String() string + func (validator *IntValidator) TypeCheck(rule *Rule) error + func (validator *IntValidator) Validate(v interface{}) error + type KeyPath []interface + func (keyPath KeyPath) String() string + type Location string + type MapValidator struct + ElemValidator Validator + KeyValidator Validator + MaxProperties *uint64 + MinProperties uint64 + func (MapValidator) Names() []string + func (validator *MapValidator) New(ctx context.Context, rule *Rule) (Validator, error) + func (validator *MapValidator) String() string + func (validator *MapValidator) Validate(v interface{}) error + func (validator *MapValidator) ValidateReflectValue(rv reflect.Value) error + type MissingRequired struct + func (MissingRequired) Error() string + type MultipleOfError struct + Current interface{} + MultipleOf interface{} + Target string + func (e *MultipleOfError) Error() string + type NotInEnumError struct + Current interface{} + Enums []interface{} + Target string + func (e *NotInEnumError) Error() string + type NotMatchError struct + Current interface{} + Pattern string + Target string + func (err *NotMatchError) Error() string + type OutOfRangeError struct + Current interface{} + ExclusiveMaximum bool + ExclusiveMinimum bool + Maximum interface{} + Minimum interface{} + Target string + func (e *OutOfRangeError) Error() string + type PreprocessStage int + const PreprocessPtr + const PreprocessSkip + const PreprocessString + type Rule struct + ErrMsg []byte + Type typesutil.Type + func MustParseRuleStringWithType(ruleStr string, typ typesutil.Type) *Rule + func ParseRuleWithType(ruleBytes []byte, typ typesutil.Type) (*Rule, error) + func (r *Rule) SetDefaultValue(defaultValue []byte) + func (r *Rule) SetErrMsg(errMsg []byte) + func (r *Rule) SetOptional(optional bool) + func (r *Rule) String() string + type RuleModifier interface + SetDefaultValue func(defaultValue []byte) + SetErrMsg func(errMsg []byte) + SetOptional func(optional bool) + type RuleProcessor = func(rule RuleModifier) + type SliceValidator struct + ElemValidator Validator + MaxItems *uint64 + MinItems uint64 + func (SliceValidator) Names() []string + func (SliceValidator) New(ctx context.Context, rule *Rule) (Validator, error) + func (validator *SliceValidator) String() string + func (validator *SliceValidator) Validate(v interface{}) error + func (validator *SliceValidator) ValidateReflectValue(rv reflect.Value) error + type StrLenMode string + const StrLenModeLength + const StrLenModeRuneCount + type StrfmtValidator struct + func NewRegexpStrfmtValidator(regexpStr string, name string, aliases ...string) *StrfmtValidator + func NewStrfmtValidator(validate func(v interface{}) error, name string, aliases ...string) *StrfmtValidator + func (validator *StrfmtValidator) Names() []string + func (validator *StrfmtValidator) String() string + func (validator *StrfmtValidator) TypeCheck(rule *Rule) error + func (validator *StrfmtValidator) Validate(v interface{}) error + func (validator StrfmtValidator) New(ctx context.Context, rule *Rule) (Validator, error) + type StringValidator struct + Enums []string + LenMode StrLenMode + MaxLength *uint64 + MinLength uint64 + Pattern string + func (StringValidator) Names() []string + func (StringValidator) New(ctx context.Context, rule *Rule) (Validator, error) + func (validator *StringValidator) String() string + func (validator *StringValidator) TypeCheck(rule *Rule) error + func (validator *StringValidator) Validate(v interface{}) error + type StructValidator struct + func NewStructValidator(namedTagKey string) *StructValidator + func (StructValidator) Names() []string + func (validator *StructValidator) New(ctx context.Context, rule *Rule) (Validator, error) + func (validator *StructValidator) String() string + func (validator *StructValidator) Validate(v interface{}) error + func (validator *StructValidator) ValidateReflectValue(rv reflect.Value) error + type UintValidator struct + BitSize uint + Enums []uint64 + ExclusiveMaximum bool + ExclusiveMinimum bool + Maximum uint64 + Minimum uint64 + MultipleOf uint64 + func (UintValidator) Names() []string + func (UintValidator) New(ctx context.Context, rule *Rule) (Validator, error) + func (validator *UintValidator) SetDefaults() + func (validator *UintValidator) String() string + func (validator *UintValidator) TypeCheck(rule *Rule) error + func (validator *UintValidator) Validate(v interface{}) error + type UnsupportedTypeError struct + func NewUnsupportedTypeError(typ string, rule string, msgs ...string) *UnsupportedTypeError + func (e *UnsupportedTypeError) Error() string + type Validator interface + String func() string + Validate func(v interface{}) error + type ValidatorCreator interface + Names func() []string + New func(context.Context, *Rule) (Validator, error) + type ValidatorFactory struct + func NewValidatorFactory() *ValidatorFactory + func (f *ValidatorFactory) Compile(ctx context.Context, ruleBytes []byte, typ typesutil.Type, ...) (validator Validator, err error) + func (f *ValidatorFactory) MustCompile(ctx context.Context, rule []byte, typ typesutil.Type, ...) Validator + func (f *ValidatorFactory) Register(validators ...ValidatorCreator) + type ValidatorLoader struct + DefaultValue []byte + ErrMsg []byte + Optional bool + ValidatorCreator ValidatorCreator + func NewValidatorLoader(validatorCreator ValidatorCreator) *ValidatorLoader + func (loader *ValidatorLoader) New(ctx context.Context, rule *Rule) (Validator, error) + func (loader *ValidatorLoader) String() string + func (loader *ValidatorLoader) Validate(v interface{}) error + type ValidatorMgr interface + Compile func(context.Context, []byte, typesutil.Type, ...RuleProcessor) (Validator, error) + func ValidatorMgrFromContext(c context.Context) ValidatorMgr