parser

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FieldsToGoStruct

func FieldsToGoStruct(fields []Field) string

FieldsToGoStruct generates Go struct field declarations

func FieldsToSQLColumns

func FieldsToSQLColumns(fields []Field) string

FieldsToSQLColumns generates SQL column definitions

func MapType

func MapType(typ string) (goType, sqlType string, isTextarea bool, err error)

MapType maps a user-provided type to Go and SQL types. Also handles references syntax: references:table_name[:on_delete_action] Returns: goType, sqlType, isTextarea, error

Types

type Field

type Field struct {
	Name            string
	Type            string
	GoType          string
	SQLType         string
	IsReference     bool
	ReferencedTable string
	OnDelete        string   // CASCADE, SET NULL, RESTRICT, etc.
	IsTextarea      bool     // true if field should render as textarea
	IsSelect        bool     // true if field should render as <select>
	SelectOptions   []string // options for select fields
	IsFile          bool     // true if field is a file upload
	IsImage         bool     // true if field is an image upload (subset of file)
	Metadata        FieldMetadata
}

func ParseFields

func ParseFields(args []string) ([]Field, error)

ParseFields parses field definitions in the format "name:type name2:type2"

type FieldMetadata

type FieldMetadata struct {
	ValidateTag   string // e.g. "required,email", "required,min=8"
	HTMLInputType string // e.g. "email", "url", "tel", "password", "text", "number"
	HTMLMinLength int    // 0 = not set
	HTMLMaxLength int    // 0 = not set
	HTMLStep      string // e.g. "0.01" for floats
	IsPassword    bool   // suppress value echo in edit forms
}

FieldMetadata holds validation and HTML rendering metadata derived from the field type.

func GetFieldMetadata

func GetFieldMetadata(fieldType string) FieldMetadata

GetFieldMetadata returns validation and HTML metadata for a given field type.

Jump to

Keyboard shortcuts

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