Documentation ¶
Index ¶
- Constants
- Variables
- func NewArray(inner TypeDef) *typeArray
- func NewBool() *typeBool
- func NewByte() *typeByte
- func NewChan() *typeChan
- func NewCustom(fieldName string, typeExpr ast.Expr) *typeCustom
- func NewExternalCustom(typeName string, typeExpr ast.Expr) *typeCustom
- func NewFunc() *typeFunc
- func NewInterface() *typeInterface
- func NewMap(key, value TypeDef) *typeMap
- func NewNumber(typeName string) *typeNumber
- func NewString() *typeString
- func ParseTags(astTag *ast.BasicLit, logCtx string) ([]ValidatableTag, FieldTagsNames)
- type FieldTagsNames
- type GenConfig
- type Name
- func NewIndexedKeyName(labelName, indexVar, validateVar, tagName string) Name
- func NewIndexedValueName(labelName, indexVar, validateVar, tagName string) Name
- func NewName(pointerPrefix, structVar, labelName, fieldName, tagName string) Name
- func NewSimpleNameWithAliasType(fieldName, aliasType string) Name
- type ScopeTag
- type SimpleTag
- type TypeDef
- type TypePointer
- func (t *TypePointer) Expr() ast.Expr
- func (t *TypePointer) Generate(w io.Writer, cfg GenConfig, name Name)
- func (t TypePointer) NeedGenerate() bool
- func (t *TypePointer) SetInnerType(newType TypeDef) *TypePointer
- func (t *TypePointer) SetValidateTag(tag ValidatableTag) error
- func (t *TypePointer) Type() string
- func (t *TypePointer) Validate() error
- type ValidatableTag
- type ValidatableTags
Constants ¶
View Source
const ( ValidateTag = "validate" StringMinLenKey string = "min_len" StringMaxLenKey string = "max_len" NumberMinKey string = "min" NumberMaxKey string = "max" ArrayMinItemsKey string = "min_items" ArrayMaxItemsKey string = "max_items" ArrayItemKey string = "item" PointerNullableKey string = "nullable" PointerNotNullKey string = "not_null" InterfaceFuncKey string = "func" StructFuncKey string = "func" MapMinItemsKey string = "min_items" MapMaxItemsKey string = "max_items" MapKeyKey string = "key" MapValueKey string = "value" )
View Source
const Array string = "array"
View Source
const Bool string = "bool"
View Source
const Byte string = "byte"
View Source
const FieldNameFromStructDefinition = ""
View Source
const Map string = "map"
View Source
const String string = "string"
Variables ¶
View Source
var ErrUnusedTag = errors.New("unused tag")
Functions ¶
func NewExternalCustom ¶
func NewInterface ¶
func NewInterface() *typeInterface
func ParseTags ¶
func ParseTags(astTag *ast.BasicLit, logCtx string) ([]ValidatableTag, FieldTagsNames)
Types ¶
type FieldTagsNames ¶
contains {"json": "provider_id", "xml": "provider_id"} for `json:"provider_id,omitempty" "xml":"provider_id" validate:"min_len=1"
func (FieldTagsNames) Get ¶
func (n FieldTagsNames) Get(name string) string
func (FieldTagsNames) GetFromStructDefinition ¶
func (n FieldTagsNames) GetFromStructDefinition() string
type Name ¶
type Name struct {
// contains filtered or unexported fields
}
func NewIndexedKeyName ¶
func NewIndexedValueName ¶
func (Name) WithPointer ¶
func (Name) WithoutPointer ¶
type ScopeTag ¶
type ScopeTag struct { Name string InnerTags []ValidatableTag }
type TypePointer ¶
type TypePointer struct {
// contains filtered or unexported fields
}
func NewPointer ¶
func NewPointer(inner TypeDef) *TypePointer
func (*TypePointer) Expr ¶
func (t *TypePointer) Expr() ast.Expr
func (*TypePointer) Generate ¶
func (t *TypePointer) Generate(w io.Writer, cfg GenConfig, name Name)
func (TypePointer) NeedGenerate ¶
func (t TypePointer) NeedGenerate() bool
func (*TypePointer) SetInnerType ¶
func (t *TypePointer) SetInnerType(newType TypeDef) *TypePointer
func (*TypePointer) SetValidateTag ¶
func (t *TypePointer) SetValidateTag(tag ValidatableTag) error
func (*TypePointer) Type ¶
func (t *TypePointer) Type() string
func (*TypePointer) Validate ¶
func (t *TypePointer) Validate() error
type ValidatableTag ¶
type ValidatableTag interface { // Key returns a tag title Key() string }
ValidatableTag represents a tag that uses for validating
type ValidatableTags ¶
type ValidatableTags []ValidatableTag
ValidatableTags represents a set of ValidatableTag
func (ValidatableTags) ContainsTag ¶
func (ts ValidatableTags) ContainsTag(t ValidatableTag) bool
ContainsTag checks whether ValidatableTags contains a ValidatableTag
func (ValidatableTags) Empty ¶
func (ts ValidatableTags) Empty() bool
Empty check whether ValidatableTags is empty
Click to show internal directories.
Click to hide internal directories.