tagparser

package
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package tagparser provides shared tag parsing functionality for GoZod. Extracted from types/struct.go to enable reuse by cmd/gozodgen and other components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FieldInfo

type FieldInfo struct {
	Name     string       // Go field name
	Type     reflect.Type // field type
	TypeName string       // AST type name for circular reference detection
	JSONName string       // from json tag, or Go field name
	GoZodTag string       // raw gozod tag value
	Rules    []TagRule    // parsed validation rules
	Required bool         // has "required" rule
	Optional bool         // pointer without required
	Nilable  bool         // has "nilable" rule
}

FieldInfo represents parsed information about a struct field.

type TagParser

type TagParser struct {
	// contains filtered or unexported fields
}

TagParser handles gozod tag parsing with configurable tag name.

func New

func New() *TagParser

New creates a TagParser with the default "gozod" tag name.

func NewWithTagName

func NewWithTagName(name string) *TagParser

NewWithTagName creates a TagParser with a custom tag name.

func (*TagParser) ParseStructTags

func (p *TagParser) ParseStructTags(typ reflect.Type) ([]FieldInfo, error)

ParseStructTags parses all gozod tags in a struct type and returns FieldInfo for each exported field.

func (*TagParser) ParseTagString

func (p *TagParser) ParseTagString(tag string) ([]TagRule, error)

ParseTagString parses a single tag string into TagRule values.

type TagRule

type TagRule struct {
	Name   string   // e.g., "min", "max", "email"
	Params []string // e.g., ["2"] for "min=2"
}

TagRule represents a single validation rule parsed from a tag.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL