customfield

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFieldNameRequired  = errors.New("field name is required and must be between 1 and 200 characters")
	ErrFieldSlugInvalid   = errors.New("field slug must be between 1 and 200 characters and contain only lowercase letters, numbers, and underscores")
	ErrFieldTypeInvalid   = errors.New("field type must be one of: text, textarea, number, date, datetime, email, url, select, checkbox")
	ErrSelectRequiresOpts = errors.New("select fields require an options list")
	ErrSelectEmptyOption  = errors.New("select field options must not contain empty or blank strings")
	ErrNumberMinGTMax     = errors.New("min cannot be greater than max")
	ErrMaxLengthInvalid   = errors.New("max_length must be greater than 0 and is only valid for text and textarea fields")
	ErrDuplicateFieldSlug = errors.New("duplicate field slug")
)

Functions

func ValidateField

func ValidateField(f FieldSchema) error

func ValidateFieldName

func ValidateFieldName(name string) error

func ValidateFieldSlug

func ValidateFieldSlug(slug string) error

func ValidateFieldType

func ValidateFieldType(t FieldType) error

func ValidateFields

func ValidateFields(fields []FieldSchema) error

func ValidateMaxLength

func ValidateMaxLength(t FieldType, maxLength *int) error

func ValidateNumberRange

func ValidateNumberRange(t FieldType, min, max *float64) error

func ValidateSelectOptions

func ValidateSelectOptions(t FieldType, options []string) error

Types

type FieldSchema

type FieldSchema struct {
	Name      string    `json:"name" toml:"name"`
	Slug      string    `json:"slug" toml:"slug"`
	Type      FieldType `json:"type" toml:"type"`
	Required  bool      `json:"required,omitempty" toml:"required,omitempty"`
	Options   []string  `json:"options,omitempty" toml:"options,omitempty"`
	Min       *float64  `json:"min,omitempty" toml:"min,omitempty"`
	Max       *float64  `json:"max,omitempty" toml:"max,omitempty"`
	MaxLength *int      `json:"maxLength,omitempty" toml:"max_length,omitempty"`
}

type FieldType

type FieldType string
const (
	FieldTypeText     FieldType = "text"
	FieldTypeTextarea FieldType = "textarea"
	FieldTypeNumber   FieldType = "number"
	FieldTypeDate     FieldType = "date"
	FieldTypeDatetime FieldType = "datetime"
	FieldTypeEmail    FieldType = "email"
	FieldTypeUrl      FieldType = "url"
	FieldTypeSelect   FieldType = "select"
	FieldTypeCheckbox FieldType = "checkbox"
)

Jump to

Keyboard shortcuts

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