Documentation ¶
Index ¶
- Constants
- Variables
- func Alias(check string) []string
- func NewChoice() func(field *Field, check *Check) (IsValid, error)
- func NewGt() func(field *Field, check *Check) (IsValid, error)
- func NewGte() func(field *Field, check *Check) (IsValid, error)
- func NewLt() func(field *Field, check *Check) (IsValid, error)
- func NewLte() func(field *Field, check *Check) (IsValid, error)
- func NewNotRegExprCheck(expr *regexp.Regexp) func(field *Field, check *Check) (IsValid, error)
- func NewRegExprCheck(expr *regexp.Regexp) func(field *Field, check *Check) (IsValid, error)
- func NewRegExprCheckWithMinLength(expr *regexp.Regexp, minLen int) func(field *Field, check *Check) (IsValid, error)
- func NewRepeatedRegExprCheck(expr *regexp.Regexp, separator string) func(field *Field, check *Check) (IsValid, error)
- func Register(check string, fn NewIsValid)
- func RegisterAlias(check string, checks ...string)
- func SessionContext(ctx context.Context, session *Session) context.Context
- type CanUseMarkerProvider
- type Check
- type Checks
- type Choice
- type Field
- type FieldCheck
- type IsValid
- type NewIsValid
- type Numeric
- type Option
- type Options
- type Path
- type PathKind
- type RegExprCheck
- type Service
- type Session
- type Tag
- type Validation
- type Violation
- type Zeroable
Constants ¶
View Source
const ( //PathKindRoot defines root path kind PathKindRoot = PathKind(iota) //PathKinField defines field path kind PathKinField //PathKindKey defines key path kind PathKindKey //PathKindIndex defines index path kind PathKindIndex )
Variables ¶
View Source
var SessionKey string
SessionKey represents a session key
Functions ¶
func NewNotRegExprCheck ¶
func NewRegExprCheck ¶
NewRegExprCheck creates a regexpr based validation check
func NewRegExprCheckWithMinLength ¶
func NewRegExprCheckWithMinLength(expr *regexp.Regexp, minLen int) func(field *Field, check *Check) (IsValid, error)
NewRegExprCheckWithMinLength creates a regexpr based validation check with min Length
func NewRepeatedRegExprCheck ¶
func RegisterAlias ¶
RegisterAlias register tag alias
Types ¶
type CanUseMarkerProvider ¶ added in v0.3.0
type CanUseMarkerProvider func(v interface{}) bool
type Checks ¶
type Checks struct { Type reflect.Type Fields []*FieldCheck Slices []*Field Structs []*Field SimpleSlices []*Field // contains filtered or unexported fields }
Checks represents struct checks
type FieldCheck ¶
FieldCheckPos represents field checks
type NewIsValid ¶
NewIsValid function to create IsValid
type Option ¶
type Option func(c *Options)
func WithCanUseMarkerProvider ¶ added in v0.3.0
func WithCanUseMarkerProvider(provider CanUseMarkerProvider) Option
WithCanUseMarkerProvider creates with marker provider option
func WithPreservePointer ¶ added in v0.2.3
WithPreservePointer creates with preserve pointer option
func WithSetMarker ¶ added in v0.2.1
func WithSetMarker() Option
WithSetMarker creates with marker option
type Options ¶
type Options struct { UseMarker bool PreservePointer bool Shallow bool Path *Path CanUseMarkerProvider CanUseMarkerProvider // contains filtered or unexported fields }
type Path ¶
type Path struct { Kind PathKind `json:",omitempty"` Path *Path `json:",omitempty"` Name string `json:",omitempty"` Index int `json:",omitempty"` Key interface{} `json:",omitempty"` }
Path represents an arbitrary data structure path
type RegExprCheck ¶
type RegExprCheck struct {
// contains filtered or unexported fields
}
func (*RegExprCheck) IsValidString ¶
func (r *RegExprCheck) IsValidString(ctx context.Context, value interface{}) (bool, error)
func (*RegExprCheck) IsValidStringPtr ¶
func (r *RegExprCheck) IsValidStringPtr(ctx context.Context, value interface{}) (bool, error)
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service represents a service
type Validation ¶
func (*Validation) AddViolation ¶ added in v0.1.3
func (v *Validation) AddViolation(field string, value interface{}, check string, msg string)
func (*Validation) Append ¶
func (v *Validation) Append(path *Path, field string, value interface{}, check string, msg string)
func (*Validation) Error ¶
func (e *Validation) Error() string
func (*Validation) String ¶
func (e *Validation) String() string
Click to show internal directories.
Click to hide internal directories.