Documentation
¶
Index ¶
- Variables
- func ValidateField(f FieldSchema) error
- func ValidateFieldName(name string) error
- func ValidateFieldSlug(slug string) error
- func ValidateFieldType(t FieldType) error
- func ValidateFields(fields []FieldSchema) error
- func ValidateMaxLength(t FieldType, maxLength *int) error
- func ValidateNumberRange(t FieldType, min, max *float64) error
- func ValidateSelectOptions(t FieldType, options []string) error
- type FieldSchema
- type FieldType
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 ValidateFieldSlug ¶
func ValidateFieldType ¶
func ValidateFields ¶
func ValidateFields(fields []FieldSchema) error
func ValidateMaxLength ¶
func ValidateNumberRange ¶
func ValidateSelectOptions ¶
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" )
Click to show internal directories.
Click to hide internal directories.