tagparser

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 2 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 // Go field type
	TypeName string       // AST-based type name string for circular reference detection
	JsonName string       // JSON field name (from json tag or field name)
	GozodTag string       // Raw gozod tag value
	Rules    []TagRule    // Parsed validation rules
	Required bool         // Whether field is required (has "required" rule)
	Optional bool         // Whether field should be optional (pointer type without required)
	Nilable  bool         // Whether field 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 new TagParser with default "gozod" tag name

func NewWithTagName

func NewWithTagName(tagName string) *TagParser

NewWithTagName creates a new TagParser with custom tag name

func (*TagParser) ParseStructTags

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

ParseStructTags parses all gozod tags in a struct type and returns field information

func (*TagParser) ParseTagString

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

ParseTagString parses a single tag string into validation rules

type TagRule

type TagRule struct {
	Name   string   // Rule name (e.g., "min", "max", "email")
	Params []string // Rule parameters (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