Documentation ¶
Index ¶
- Constants
- Variables
- type ElasticLike
- type LenValidator
- type OptionLike
- type StateValidator
- type UndLike
- type UndOpt
- func (o UndOpt) Describe() string
- func (u UndOpt) Len() option.Option[LenValidator]
- func (u UndOpt) States() option.Option[StateValidator]
- func (o UndOpt) ValidElastic(e ElasticLike) bool
- func (o UndOpt) ValidOpt(opt OptionLike) bool
- func (o UndOpt) ValidUnd(u UndLike) bool
- func (u UndOpt) Values() option.Option[ValuesValidator]
- type UndOptExport
- type ValuesValidator
Constants ¶
View Source
const ( // "und" struct tag tells tools like ../validate or github.com/ngicks/go-codegen how fields should be treated. // // example: // type Sample struct { // Foo string `und:"def,und"` // } TagName = "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). // // example: // type Sample struct { // Foo string `und:"required"` // } UndTagValueRequired = "required" // The field must be nullish(None, Null, Undefined). // mutually exclusive to required, def, null, und. // UndTagValueNullish can be combined with len. // // example: // type Sample struct { // Foo string `und:"nullish"` // } UndTagValueNullish = "nullish" // The field is allowed to be Some or Defined. // can be combined with null, und or len. // // example: // type Sample struct { // Foo string `und:"def"` // } UndTagValueDef = "def" // The field is allowed to be None or Null. // can be combined with def, und or len. // // example: // type Sample struct { // Foo string `und:"null"` // } UndTagValueNull = "null" // The field is allowed to be None or Undefined. // can be combined with def, null or len. // // example: // type Sample struct { // Foo string `und:"und"` // } 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. // // example: // type Sample struct { // Foo string `und:"len==3"` // } UndTagValueLen = "len" // Only for elastic types. // // The value must be formatted as values:nonnull. // // nonnull value means its internal value must not have null. // // example: // type Sample struct { // Foo string `und:"values:nonnull"` // } UndTagValueValues = "values" )
View Source
const ( LenOpEqEq = lenOp(iota + 1) // == LenOpGr // > LenOpGrEq // >= LenOpLe // < LenOpLeEq // <= )
Variables ¶
View Source
var ( // ErrEmptyOption would be returned by [ParseOption] // if input's `und` struct tag have no option specified. ErrEmptyOption = errors.New("empty option") // ErrMultipleOption would be returned by UndValidate and UndCheck // 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 UndValidate and UndCheck // if an input has unknown options in `und` struct tag. ErrUnknownOption = errors.New("unknown option") // ErrMalformedLen is an error which will be returned by UndValidate and UndCheck // 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 UndValidate and UndCheck // 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) Describe ¶
func (v LenValidator) Describe() string
func (LenValidator) Valid ¶
func (v LenValidator) Valid(e ElasticLike) bool
type OptionLike ¶
type StateValidator ¶
type StateValidator struct { Def bool Null bool Und bool // contains filtered or unexported fields }
func (StateValidator) Describe ¶
func (s StateValidator) Describe() string
func (StateValidator) Valid ¶
func (s StateValidator) Valid(u UndLike) bool
type UndOpt ¶
type UndOpt struct {
// contains filtered or unexported fields
}
func ParseOption ¶
func (UndOpt) ValidElastic ¶
func (o UndOpt) ValidElastic(e ElasticLike) bool
func (UndOpt) ValidOpt ¶
func (o UndOpt) ValidOpt(opt OptionLike) bool
type UndOptExport ¶
type UndOptExport struct { States *StateValidator Len *LenValidator Values *ValuesValidator }
func (UndOptExport) Into ¶
func (o UndOptExport) Into() UndOpt
type ValuesValidator ¶
type ValuesValidator struct {
Nonnull bool
}
func ParseValues ¶
func ParseValues(s string) (ValuesValidator, error)
func (ValuesValidator) Describe ¶
func (v ValuesValidator) Describe() string
func (ValuesValidator) Valid ¶
func (v ValuesValidator) Valid(e ElasticLike) bool
Click to show internal directories.
Click to hide internal directories.