Documentation
¶
Index ¶
Constants ¶
View Source
const ( UndTag = "und" // The field must be required(Some or Defined). // mutually exclusive to nullish, def, null, und. // UndTagValueRequired can be combined with len (there's no point though). UndTagValueRequired = "required" // The field must be nullish(None, Null, Undefined). // mutually exclusive to required, def, null, und. // UndTagValueNullish can be combined with len. UndTagValueNullish = "nullish" // The field is allowed to be Some or Defined. // can be combined with null, und or len. UndTagValueDef = "def" // The field is allowed to be None or Null. // can be combined with def, und or len. UndTagValueNull = "null" // The field is allowed to be None or Undefined. // can be combined with def, null or len. UndTagValueUnd = "und" // Only for elastic types. // // The value must be formatted as len==n, len>n, len>=n, len<n or len<=n, // where n is unsigned integer. // The field's length will be evaluated as (length) (comparison operator) (n), // e.g. if tag is len>12, field.Len() > 12 must return true. // // can be combined with other options. UndTagValueLen = "len" // Only for elastic types. // // The value must be formatted as values:nonnull. // // nonnull value means its internal value must not have null. UndTagValueValues = "values" )
Variables ¶
View Source
var ( // ErrNotStruct would be returned by ValidateUnd and CheckUnd // if input is not a struct nor a pointer to a struct. ErrNotStruct = errors.New("not struct") // ErrMultipleOption would be returned by ValidateUnd and CheckUnd // if input's `und` struct tags have multiple mutually exclusive options. ErrMultipleOption = errors.New("multiple option") // ErrUnknownOption is an error value which will be returned by ValidateUnd and CheckUnd // if an input has unknown options in `und` struct tag. ErrUnknownOption = errors.New("unknown option") // ErrMalformedLen is an error which will be returned by ValidateUnd and CheckUnd // if an input has malformed len option in `und` struct tag. ErrMalformedLen = errors.New("malformed len") // ErrMalformedLen is an error which will be returned by ValidateUnd and CheckUnd // if an input has malformed values option in `und` struct tag. ErrMalformedValues = errors.New("malformed values") )
Functions ¶
This section is empty.
Types ¶
type ElasticLike ¶
type LenValidator ¶
type LenValidator struct {
Len int
Op lenOp
}
func ParseLen ¶
func ParseLen(s string) (LenValidator, error)
func (LenValidator) String ¶
func (v LenValidator) String() string
func (LenValidator) Valid ¶
func (v LenValidator) Valid(e ElasticLike) bool
type OptionLike ¶
type UndOpt ¶
type UndOpt struct {
States option.Option[States]
Len option.Option[LenValidator]
Values option.Option[ValuesValidator]
}
func ParseOption ¶
func (UndOpt) ValidElastic ¶
func (o UndOpt) ValidElastic(e ElasticLike) bool
func (UndOpt) ValidOpt ¶
func (o UndOpt) ValidOpt(opt OptionLike) bool
type ValuesValidator ¶
type ValuesValidator struct {
Nonnull bool
}
func ParseValues ¶
func ParseValues(s string) (ValuesValidator, error)
func (ValuesValidator) String ¶
func (v ValuesValidator) String() string
func (ValuesValidator) Valid ¶
func (v ValuesValidator) Valid(e ElasticLike) bool
Click to show internal directories.
Click to hide internal directories.