Documentation
¶
Overview ¶
Package validation provides utilities for parsing and working with validation tags in go-bricks applications. It offers helpers for extracting validation metadata from struct types that can be used for both runtime validation and documentation generation.
Index ¶
- type TagInfo
- func (t *TagInfo) AllConstraints() map[string]string
- func (t *TagInfo) Enum() ([]string, bool)
- func (t *TagInfo) HasFormat(format string) bool
- func (t *TagInfo) IsEmail() bool
- func (t *TagInfo) IsRequired() bool
- func (t *TagInfo) IsURL() bool
- func (t *TagInfo) IsUUID() bool
- func (t *TagInfo) Max() (int, bool)
- func (t *TagInfo) MaxLength() (int, bool)
- func (t *TagInfo) Min() (int, bool)
- func (t *TagInfo) MinLength() (int, bool)
- func (t *TagInfo) Pattern() (string, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TagInfo ¶
type TagInfo struct {
Name string // Go field name
JSONName string // JSON field name (from json tag)
ParamType string // Parameter type: path, query, header, form, body
ParamName string // Parameter name for path/query/header params
Required bool // Whether field is required
Constraints map[string]string // Validation constraints from validate tag
Description string // Documentation from doc tag
Example string // Example value from example tag
Tags map[string]string // All struct tags for reference
}
TagInfo represents parsed validation tag information from a struct field
func ParseValidationTags ¶
ParseValidationTags extracts validation metadata from a struct type This function analyzes struct fields and their tags to build TagInfo objects that contain all validation and documentation metadata.
func (*TagInfo) AllConstraints ¶ added in v0.19.0
AllConstraints returns all validation constraints
func (*TagInfo) IsRequired ¶
IsRequired returns true if the field has a required constraint
func (*TagInfo) MaxLength ¶ added in v0.19.0
MaxLength returns the maximum length constraint if present