parser

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MIT Imports: 4 Imported by: 0

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