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) GetConstraints() map[string]string
- func (t *TagInfo) GetEnum() ([]string, bool)
- func (t *TagInfo) GetMax() (int, bool)
- func (t *TagInfo) GetMaxLength() (int, bool)
- func (t *TagInfo) GetMin() (int, bool)
- func (t *TagInfo) GetMinLength() (int, bool)
- func (t *TagInfo) GetPattern() (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
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) GetConstraints ¶
GetConstraints returns all validation constraints
func (*TagInfo) GetMaxLength ¶
GetMaxLength returns the maximum length constraint if present
func (*TagInfo) GetMinLength ¶
GetMinLength returns the minimum length constraint if present
func (*TagInfo) GetPattern ¶
GetPattern returns the regex pattern constraint if present
func (*TagInfo) IsRequired ¶
IsRequired returns true if the field has a required constraint