core: Fields

import core "ganigeorgiev.com/pocketbase/pocketbase/core"

Part of core.

Types

AutodateField

type AutodateField struct {
	// Name (required) is the unique name of the field.
	Name string `form:"name" json:"name"`

	// Id is the unique stable field identifier.
	//
	// It is automatically generated from the name when adding to a collection FieldsList.
	Id string `form:"id" json:"id"`

	// System prevents the renaming and removal of the field.
	System bool `form:"system" json:"system"`

	// Hidden hides the field from the API response.
	Hidden bool `form:"hidden" json:"hidden"`

	// Presentable hints the Dashboard UI to use the underlying
	// field record value in the relation preview label.
	Presentable bool `form:"presentable" json:"presentable"`

	// OnCreate auto sets the current datetime as field value on record create.
	OnCreate bool `form:"onCreate" json:"onCreate"`

	// OnUpdate auto sets the current datetime as field value on record update.
	OnUpdate bool `form:"onUpdate" json:"onUpdate"`
}

AutodateField defines an "autodate" type field, aka. field which datetime value could be auto set on record create/update.

This field is usually used for defining timestamp fields like "created" and "updated".

Requires either both or at least one of the OnCreate or OnUpdate options to be set.

AutodateField.ColumnType

func (f *AutodateField) ColumnType(app App) string

ColumnType implements Field.ColumnType interface method.

AutodateField.FindSetter

func (f *AutodateField) FindSetter(key string) SetterFunc

FindSetter implements the SetterFinder interface.

AutodateField.GetHidden

func (f *AutodateField) GetHidden() bool

GetHidden implements Field.GetHidden interface method.

AutodateField.GetId

func (f *AutodateField) GetId() string

GetId implements Field.GetId interface method.

AutodateField.GetName

func (f *AutodateField) GetName() string

GetName implements Field.GetName interface method.

AutodateField.GetSystem

func (f *AutodateField) GetSystem() bool

GetSystem implements Field.GetSystem interface method.

AutodateField.Intercept

func (f *AutodateField) Intercept(
	app App,
	record *Record,
	actionName string,
	actionFunc func() error,
) error

Intercept implements the RecordInterceptor interface.

AutodateField.PrepareValue

func (f *AutodateField) PrepareValue(record *Record, raw any) (any, error)

PrepareValue implements Field.PrepareValue interface method.

AutodateField.SetHidden

func (f *AutodateField) SetHidden(hidden bool)

SetHidden implements Field.SetHidden interface method.

AutodateField.SetId

func (f *AutodateField) SetId(id string)

SetId implements Field.SetId interface method.

AutodateField.SetName

func (f *AutodateField) SetName(name string)

SetName implements Field.SetName interface method.

AutodateField.SetSystem

func (f *AutodateField) SetSystem(system bool)

SetSystem implements Field.SetSystem interface method.

AutodateField.Type

func (f *AutodateField) Type() string

Type implements Field.Type interface method.

AutodateField.ValidateSettings

func (f *AutodateField) ValidateSettings(app App, collection *Collection) error

ValidateSettings implements Field.ValidateSettings interface method.

AutodateField.ValidateValue

func (f *AutodateField) ValidateValue(app App, record *Record) error

ValidateValue implements Field.ValidateValue interface method.

BoolField

type BoolField struct {
	// Name (required) is the unique name of the field.
	Name string `form:"name" json:"name"`

	// Id is the unique stable field identifier.
	//
	// It is automatically generated from the name when adding to a collection FieldsList.
	Id string `form:"id" json:"id"`

	// System prevents the renaming and removal of the field.
	System bool `form:"system" json:"system"`

	// Hidden hides the field from the API response.
	Hidden bool `form:"hidden" json:"hidden"`

	// Presentable hints the Dashboard UI to use the underlying
	// field record value in the relation preview label.
	Presentable bool `form:"presentable" json:"presentable"`

	// Help is an extra text explaining what the field is about.
	// It is usually shown in Dashboard UI under the field input.
	Help string `form:"help" json:"help"`

	// Required will require the field value to be always "true".
	Required bool `form:"required" json:"required"`
}

BoolField defines "bool" type field to store a single true/false value.

The respective zero record field value is false.

BoolField.ColumnType

func (f *BoolField) ColumnType(app App) string

ColumnType implements Field.ColumnType interface method.

BoolField.GetHidden

func (f *BoolField) GetHidden() bool

GetHidden implements Field.GetHidden interface method.

BoolField.GetId

func (f *BoolField) GetId() string

GetId implements Field.GetId interface method.

BoolField.GetName

func (f *BoolField) GetName() string

GetName implements Field.GetName interface method.

BoolField.GetSystem

func (f *BoolField) GetSystem() bool

GetSystem implements Field.GetSystem interface method.

BoolField.PrepareValue

func (f *BoolField) PrepareValue(record *Record, raw any) (any, error)

PrepareValue implements Field.PrepareValue interface method.

BoolField.SetHidden

func (f *BoolField) SetHidden(hidden bool)

SetHidden implements Field.SetHidden interface method.

BoolField.SetId

func (f *BoolField) SetId(id string)

SetId implements Field.SetId interface method.

BoolField.SetName

func (f *BoolField) SetName(name string)

SetName implements Field.SetName interface method.

BoolField.SetSystem

func (f *BoolField) SetSystem(system bool)

SetSystem implements Field.SetSystem interface method.

BoolField.Type

func (f *BoolField) Type() string

Type implements Field.Type interface method.

BoolField.ValidateSettings

func (f *BoolField) ValidateSettings(app App, collection *Collection) error

ValidateSettings implements Field.ValidateSettings interface method.

BoolField.ValidateValue

func (f *BoolField) ValidateValue(app App, record *Record) error

ValidateValue implements Field.ValidateValue interface method.

DateField

type DateField struct {
	// Name (required) is the unique name of the field.
	Name string `form:"name" json:"name"`

	// Id is the unique stable field identifier.
	//
	// It is automatically generated from the name when adding to a collection FieldsList.
	Id string `form:"id" json:"id"`

	// System prevents the renaming and removal of the field.
	System bool `form:"system" json:"system"`

	// Hidden hides the field from the API response.
	Hidden bool `form:"hidden" json:"hidden"`

	// Presentable hints the Dashboard UI to use the underlying
	// field record value in the relation preview label.
	Presentable bool `form:"presentable" json:"presentable"`

	// Help is an extra text explaining what the field is about.
	// It is usually shown in Dashboard UI under the field input.
	Help string `form:"help" json:"help"`

	// Min specifies the min allowed field value.
	//
	// Leave it empty to skip the validator.
	Min types.DateTime `form:"min" json:"min"`

	// Max specifies the max allowed field value.
	//
	// Leave it empty to skip the validator.
	Max types.DateTime `form:"max" json:"max"`

	// Required will require the field value to be non-zero [types.DateTime].
	Required bool `form:"required" json:"required"`
}

DateField defines "date" type field to store a single types.DateTime value.

The respective zero record field value is the zero types.DateTime.

DateField.ColumnType

func (f *DateField) ColumnType(app App) string

ColumnType implements Field.ColumnType interface method.

DateField.GetHidden

func (f *DateField) GetHidden() bool

GetHidden implements Field.GetHidden interface method.

DateField.GetId

func (f *DateField) GetId() string

GetId implements Field.GetId interface method.

DateField.GetName

func (f *DateField) GetName() string

GetName implements Field.GetName interface method.

DateField.GetSystem

func (f *DateField) GetSystem() bool

GetSystem implements Field.GetSystem interface method.

DateField.PrepareValue

func (f *DateField) PrepareValue(record *Record, raw any) (any, error)

PrepareValue implements Field.PrepareValue interface method.

DateField.SetHidden

func (f *DateField) SetHidden(hidden bool)

SetHidden implements Field.SetHidden interface method.

DateField.SetId

func (f *DateField) SetId(id string)

SetId implements Field.SetId interface method.

DateField.SetName

func (f *DateField) SetName(name string)

SetName implements Field.SetName interface method.

DateField.SetSystem

func (f *DateField) SetSystem(system bool)

SetSystem implements Field.SetSystem interface method.

DateField.Type

func (f *DateField) Type() string

Type implements Field.Type interface method.

DateField.ValidateSettings

func (f *DateField) ValidateSettings(app App, collection *Collection) error

ValidateSettings implements Field.ValidateSettings interface method.

DateField.ValidateValue

func (f *DateField) ValidateValue(app App, record *Record) error

ValidateValue implements Field.ValidateValue interface method.

EditorField

type EditorField struct {
	// Name (required) is the unique name of the field.
	Name string `form:"name" json:"name"`

	// Id is the unique stable field identifier.
	//
	// It is automatically generated from the name when adding to a collection FieldsList.
	Id string `form:"id" json:"id"`

	// System prevents the renaming and removal of the field.
	System bool `form:"system" json:"system"`

	// Hidden hides the field from the API response.
	Hidden bool `form:"hidden" json:"hidden"`

	// Presentable hints the Dashboard UI to use the underlying
	// field record value in the relation preview label.
	Presentable bool `form:"presentable" json:"presentable"`

	// Help is an extra text explaining what the field is about.
	// It is usually shown in Dashboard UI under the field input.
	Help string `form:"help" json:"help"`

	// MaxSize specifies the maximum size of the allowed field value (in bytes and up to 2^53-1).
	//
	// If zero, a default limit of ~5MB is applied.
	MaxSize int64 `form:"maxSize" json:"maxSize"`

	// ConvertURLs is usually used to instruct the editor whether to
	// apply url conversion (eg. stripping the domain name in case the
	// urls are using the same domain as the one where the editor is loaded).
	//
	// (see also https://www.tiny.cloud/docs/tinymce/6/url-handling/#convert_urls)
	ConvertURLs bool `form:"convertURLs" json:"convertURLs"`

	// Required will require the field value to be non-empty string.
	Required bool `form:"required" json:"required"`
}

EditorField defines "editor" type field to store HTML formatted text.

The respective zero record field value is empty string.

EditorField.CalculateMaxBodySize

func (f *EditorField) CalculateMaxBodySize() int64

CalculateMaxBodySize implements the MaxBodySizeCalculator interface.

EditorField.ColumnType

func (f *EditorField) ColumnType(app App) string

ColumnType implements Field.ColumnType interface method.

EditorField.GetHidden

func (f *EditorField) GetHidden() bool

GetHidden implements Field.GetHidden interface method.

EditorField.GetId

func (f *EditorField) GetId() string

GetId implements Field.GetId interface method.

EditorField.GetName

func (f *EditorField) GetName() string

GetName implements Field.GetName interface method.

EditorField.GetSystem

func (f *EditorField) GetSystem() bool

GetSystem implements Field.GetSystem interface method.

EditorField.PrepareValue

func (f *EditorField) PrepareValue(record *Record, raw any) (any, error)

PrepareValue implements Field.PrepareValue interface method.

EditorField.SetHidden

func (f *EditorField) SetHidden(hidden bool)

SetHidden implements Field.SetHidden interface method.

EditorField.SetId

func (f *EditorField) SetId(id string)

SetId implements Field.SetId interface method.

EditorField.SetName

func (f *EditorField) SetName(name string)

SetName implements Field.SetName interface method.

EditorField.SetSystem

func (f *EditorField) SetSystem(system bool)

SetSystem implements Field.SetSystem interface method.

EditorField.Type

func (f *EditorField) Type() string

Type implements Field.Type interface method.

EditorField.ValidateSettings

func (f *EditorField) ValidateSettings(app App, collection *Collection) error

ValidateSettings implements Field.ValidateSettings interface method.

EditorField.ValidateValue

func (f *EditorField) ValidateValue(app App, record *Record) error

ValidateValue implements Field.ValidateValue interface method.

EmailField

type EmailField struct {
	// Name (required) is the unique name of the field.
	Name string `form:"name" json:"name"`

	// Id is the unique stable field identifier.
	//
	// It is automatically generated from the name when adding to a collection FieldsList.
	Id string `form:"id" json:"id"`

	// System prevents the renaming and removal of the field.
	System bool `form:"system" json:"system"`

	// Hidden hides the field from the API response.
	Hidden bool `form:"hidden" json:"hidden"`

	// Presentable hints the Dashboard UI to use the underlying
	// field record value in the relation preview label.
	Presentable bool `form:"presentable" json:"presentable"`

	// Help is an extra text explaining what the field is about.
	// It is usually shown in Dashboard UI under the field input.
	Help string `form:"help" json:"help"`

	// ExceptDomains will require the email domain to NOT be included in the listed ones.
	//
	// This validator can be set only if OnlyDomains is empty.
	ExceptDomains []string `form:"exceptDomains" json:"exceptDomains"`

	// OnlyDomains will require the email domain to be included in the listed ones.
	//
	// This validator can be set only if ExceptDomains is empty.
	OnlyDomains []string `form:"onlyDomains" json:"onlyDomains"`

	// Required will require the field value to be non-empty email string.
	Required bool `form:"required" json:"required"`
}

EmailField defines "email" type field for storing a single email string address.

The respective zero record field value is empty string.

EmailField.ColumnType

func (f *EmailField) ColumnType(app App) string

ColumnType implements Field.ColumnType interface method.

EmailField.GetHidden

func (f *EmailField) GetHidden() bool

GetHidden implements Field.GetHidden interface method.

EmailField.GetId

func (f *EmailField) GetId() string

GetId implements Field.GetId interface method.

EmailField.GetName

func (f *EmailField) GetName() string

GetName implements Field.GetName interface method.

EmailField.GetSystem

func (f *EmailField) GetSystem() bool

GetSystem implements Field.GetSystem interface method.

EmailField.PrepareValue

func (f *EmailField) PrepareValue(record *Record, raw any) (any, error)

PrepareValue implements Field.PrepareValue interface method.

EmailField.SetHidden

func (f *EmailField) SetHidden(hidden bool)

SetHidden implements Field.SetHidden interface method.

EmailField.SetId

func (f *EmailField) SetId(id string)

SetId implements Field.SetId interface method.

EmailField.SetName

func (f *EmailField) SetName(name string)

SetName implements Field.SetName interface method.

EmailField.SetSystem

func (f *EmailField) SetSystem(system bool)

SetSystem implements Field.SetSystem interface method.

EmailField.Type

func (f *EmailField) Type() string

Type implements Field.Type interface method.

EmailField.ValidateSettings

func (f *EmailField) ValidateSettings(app App, collection *Collection) error

ValidateSettings implements Field.ValidateSettings interface method.

EmailField.ValidateValue

func (f *EmailField) ValidateValue(app App, record *Record) error

ValidateValue implements Field.ValidateValue interface method.

Field

type Field interface {

	// GetId returns the field id.
	GetId() string

	// SetId changes the field id.
	SetId(id string)

	// GetName returns the field name.
	GetName() string

	// SetName changes the field name.
	SetName(name string)

	// GetSystem returns the field system flag state.
	GetSystem() bool

	// SetSystem changes the field system flag state.
	SetSystem(system bool)

	// GetHidden returns the field hidden flag state.
	GetHidden() bool

	// SetHidden changes the field hidden flag state.
	SetHidden(hidden bool)

	// Type returns the unique type of the field.
	Type() string

	// ColumnType returns the DB column definition of the field.
	ColumnType(app App) string

	// PrepareValue returns a properly formatted field value based on the provided raw one.
	//
	// This method is also called on record construction to initialize its default field value.
	PrepareValue(record *Record, raw any) (any, error)

	// ValidateSettings validates the current field value associated with the provided record.
	ValidateValue(app App, record *Record) error

	// ValidateSettings validates the current field settings.
	ValidateSettings(app App, collection *Collection) error
}

Field defines a common interface that all Collection fields should implement.

FieldFactoryFunc

type FieldFactoryFunc func() Field

FieldFactoryFunc defines a simple function to construct a specific Field instance.

FieldsList

type FieldsList []Field

FieldsList defines a Collection slice of fields.

NewFieldsList

func NewFieldsList(fields ...Field) FieldsList

NewFieldsList creates a new FieldsList instance with the provided fields.

FieldsList.Add

func (l *FieldsList) Add(fields ...Field)

Add adds one or more fields to the current list.

By default this method will try to REPLACE existing fields with the new ones by their id or by their name if the new field doesn't have an explicit id.

If no matching existing field is found, it will APPEND the field to the end of the list.

In all cases, if any of the new fields don't have an explicit id it will auto generate a default one for them (the id value doesn't really matter and it is mostly used as a stable identifier in case of a field rename).

FieldsList.AddAt

func (l *FieldsList) AddAt(pos int, fields ...Field)

AddAt is the same as Add but insert/move the fields at the specific position.

If pos < 0, then this method acts the same as calling Add.

If pos > FieldsList total items, then the specified fields are inserted/moved at the end of the list.

FieldsList.AddMarshaledJSON

func (l *FieldsList) AddMarshaledJSON(rawJSON []byte) error

AddMarshaledJSON parses the provided raw json data and adds the found fields into the current list (following the same rule as the Add method).

The rawJSON argument could be one of:

  • serialized array of field objects
  • single field object.

Example:

l.AddMarshaledJSON([]byte{`{"type":"text", name: "test"}`})
l.AddMarshaledJSON([]byte{`[{"type":"text", name: "test1"}, {"type":"text", name: "test2"}]`})

FieldsList.AddMarshaledJSONAt

func (l *FieldsList) AddMarshaledJSONAt(pos int, rawJSON []byte) error

AddMarshaledJSONAt is the same as AddMarshaledJSON but insert/move the fields at the specific position.

If pos < 0, then this method acts the same as calling AddMarshaledJSON.

If pos > FieldsList total items, then the specified fields are inserted/moved at the end of the list.

FieldsList.AsMap

func (l FieldsList) AsMap() map[string]Field

AsMap returns a map with all registered list field. The returned map is indexed with each field name.

FieldsList.Clone

func (l FieldsList) Clone() (FieldsList, error)

Clone creates a deep clone of the current list.

FieldsList.FieldNames

func (l FieldsList) FieldNames() []string

FieldNames returns a slice with the name of all list fields.

FieldsList.GetById

func (l FieldsList) GetById(fieldId string) Field

GetById returns a single field by its id.

FieldsList.GetByName

func (l FieldsList) GetByName(fieldName string) Field

GetByName returns a single field by its name.

FieldsList.MarshalJSON

func (l FieldsList) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

FieldsList.RemoveById

func (l *FieldsList) RemoveById(fieldId string)

RemoveById removes a single field by its id.

This method does nothing if field with the specified id doesn't exist.

FieldsList.RemoveByName

func (l *FieldsList) RemoveByName(fieldName string)

RemoveByName removes a single field by its name.

This method does nothing if field with the specified name doesn't exist.

FieldsList.Scan

func (l *FieldsList) Scan(value any) error

Scan implements sql.Scanner interface to scan the provided value into the current FieldsList instance.

FieldsList.String

func (l FieldsList) String() string

String returns the string representation of the current list.

FieldsList.UnmarshalJSON

func (l *FieldsList) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler and loads the provided json data into the current FieldsList.

FieldsList.Value

func (l FieldsList) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

FileField

type FileField struct {
	// Name (required) is the unique name of the field.
	Name string `form:"name" json:"name"`

	// Id is the unique stable field identifier.
	//
	// It is automatically generated from the name when adding to a collection FieldsList.
	Id string `form:"id" json:"id"`

	// System prevents the renaming and removal of the field.
	System bool `form:"system" json:"system"`

	// Hidden hides the field from the API response.
	Hidden bool `form:"hidden" json:"hidden"`

	// Presentable hints the Dashboard UI to use the underlying
	// field record value in the relation preview label.
	Presentable bool `form:"presentable" json:"presentable"`

	// Help is an extra text explaining what the field is about.
	// It is usually shown in Dashboard UI under the field input.
	Help string `form:"help" json:"help"`

	// MaxSize specifies the maximum size of a single uploaded file (in bytes and up to 2^53-1).
	//
	// If zero, a default limit of 5MB is applied.
	MaxSize int64 `form:"maxSize" json:"maxSize"`

	// MaxSelect specifies the max allowed files.
	//
	// For multiple files the value must be > 1, otherwise fallbacks to single (default).
	MaxSelect int `form:"maxSelect" json:"maxSelect"`

	// MimeTypes specifies an optional list of the allowed file mime types.
	//
	// Leave it empty to disable the validator.
	MimeTypes []string `form:"mimeTypes" json:"mimeTypes"`

	// Thumbs specifies an optional list of the supported thumbs for image based files.
	//
	// Each entry must be in one of the following formats:
	//
	//   - WxH  (eg. 100x300) - crop to WxH viewbox (from center)
	//   - WxHt (eg. 100x300t) - crop to WxH viewbox (from top)
	//   - WxHb (eg. 100x300b) - crop to WxH viewbox (from bottom)
	//   - WxHf (eg. 100x300f) - fit inside a WxH viewbox (without cropping)
	//   - 0xH  (eg. 0x300)    - resize to H height preserving the aspect ratio
	//   - Wx0  (eg. 100x0)    - resize to W width preserving the aspect ratio
	Thumbs []string `form:"thumbs" json:"thumbs"`

	// Protected will require the users to provide a special file token to access the file.
	//
	// Note that by default all files are publicly accessible.
	//
	// For the majority of the cases this is fine because by default
	// all file names have random part appended to their name which
	// need to be known by the user before accessing the file.
	Protected bool `form:"protected" json:"protected"`

	// Required will require the field value to have at least one file.
	Required bool `form:"required" json:"required"`
}

FileField defines "file" type field for managing record file(s).

Only the file name is stored as part of the record value. New files (aka. files to upload) are expected to be of *filesystem.File.

If MaxSelect is not set or <= 1, then the field value is expected to be a single record id.

If MaxSelect is > 1, then the field value is expected to be a slice of record ids.

The respective zero record field value is either empty string (single) or empty string slice (multiple).

---

The following additional setter keys are available:

  • "fieldName+" - append one or more files to the existing record one. For example:

    // []string{"old1.txt", "old2.txt", "new1_ajkvass.txt", "new2_klhfnwd.txt"} record.Set("documents+", []*filesystem.File{new1, new2})

  • "+fieldName" - prepend one or more files to the existing record one. For example:

    // []string{"new1_ajkvass.txt", "new2_klhfnwd.txt", "old1.txt", "old2.txt",} record.Set("+documents", []*filesystem.File{new1, new2})

  • "fieldName-" - subtract/delete one or more files from the existing record one. For example:

    // []string{"old2.txt",} record.Set("documents-", "old1.txt")

FileField.CalculateMaxBodySize

func (f *FileField) CalculateMaxBodySize() int64

CalculateMaxBodySize implements the MaxBodySizeCalculator interface.

FileField.ColumnType

func (f *FileField) ColumnType(app App) string

ColumnType implements Field.ColumnType interface method.

FileField.DriverValue

func (f *FileField) DriverValue(record *Record) (driver.Value, error)

DriverValue implements the DriverValuer interface.

FileField.FindGetter

func (f *FileField) FindGetter(key string) GetterFunc

FindGetter implements the GetterFinder interface.

FileField.FindSetter

func (f *FileField) FindSetter(key string) SetterFunc

FindSetter implements the SetterFinder interface.

FileField.GetHidden

func (f *FileField) GetHidden() bool

GetHidden implements Field.GetHidden interface method.

FileField.GetId

func (f *FileField) GetId() string

GetId implements Field.GetId interface method.

FileField.GetName

func (f *FileField) GetName() string

GetName implements Field.GetName interface method.

FileField.GetSystem

func (f *FileField) GetSystem() bool

GetSystem implements Field.GetSystem interface method.

FileField.Intercept

func (f *FileField) Intercept(
	app App,
	record *Record,
	actionName string,
	actionFunc func() error,
) error

Intercept implements the RecordInterceptor interface.

note: files delete after records deletion is handled globally by the app FileManager hook

FileField.IsMultiple

func (f *FileField) IsMultiple() bool

IsMultiple implements MultiValuer interface and checks whether the current field options support multiple values.

FileField.PrepareValue

func (f *FileField) PrepareValue(record *Record, raw any) (any, error)

PrepareValue implements Field.PrepareValue interface method.

FileField.SetHidden

func (f *FileField) SetHidden(hidden bool)

SetHidden implements Field.SetHidden interface method.

FileField.SetId

func (f *FileField) SetId(id string)

SetId implements Field.SetId interface method.

FileField.SetName

func (f *FileField) SetName(name string)

SetName implements Field.SetName interface method.

FileField.SetSystem

func (f *FileField) SetSystem(system bool)

SetSystem implements Field.SetSystem interface method.

FileField.Type

func (f *FileField) Type() string

Type implements Field.Type interface method.

FileField.ValidateSettings

func (f *FileField) ValidateSettings(app App, collection *Collection) error

ValidateSettings implements Field.ValidateSettings interface method.

FileField.ValidateValue

func (f *FileField) ValidateValue(app App, record *Record) error

ValidateValue implements Field.ValidateValue interface method.

GeoPointField

type GeoPointField struct {
	// Name (required) is the unique name of the field.
	Name string `form:"name" json:"name"`

	// Id is the unique stable field identifier.
	//
	// It is automatically generated from the name when adding to a collection FieldsList.
	Id string `form:"id" json:"id"`

	// System prevents the renaming and removal of the field.
	System bool `form:"system" json:"system"`

	// Hidden hides the field from the API response.
	Hidden bool `form:"hidden" json:"hidden"`

	// Presentable hints the Dashboard UI to use the underlying
	// field record value in the relation preview label.
	Presentable bool `form:"presentable" json:"presentable"`

	// Help is an extra text explaining what the field is about.
	// It is usually shown in Dashboard UI under the field input.
	Help string `form:"help" json:"help"`

	// Required will require the field coordinates to be non-zero (aka. not "Null Island").
	Required bool `form:"required" json:"required"`
}

GeoPointField defines "geoPoint" type field for storing latitude and longitude GPS coordinates.

You can set the record field value as types.GeoPoint, map or serialized json object with lat-lon props. The stored value is always converted to types.GeoPoint. Nil, empty map, empty bytes slice, etc. results in zero types.GeoPoint.

Examples of updating a record's GeoPointField value programmatically:

record.Set("location", types.GeoPoint{Lat: 123, Lon: 456})
record.Set("location", map[string]any{"lat":123, "lon":456})
record.Set("location", []byte(`{"lat":123, "lon":456}`)

GeoPointField.ColumnType

func (f *GeoPointField) ColumnType(app App) string

ColumnType implements Field.ColumnType interface method.

GeoPointField.GetHidden

func (f *GeoPointField) GetHidden() bool

GetHidden implements Field.GetHidden interface method.

GeoPointField.GetId

func (f *GeoPointField) GetId() string

GetId implements Field.GetId interface method.

GeoPointField.GetName

func (f *GeoPointField) GetName() string

GetName implements Field.GetName interface method.

GeoPointField.GetSystem

func (f *GeoPointField) GetSystem() bool

GetSystem implements Field.GetSystem interface method.

GeoPointField.PrepareValue

func (f *GeoPointField) PrepareValue(record *Record, raw any) (any, error)

PrepareValue implements Field.PrepareValue interface method.

GeoPointField.SetHidden

func (f *GeoPointField) SetHidden(hidden bool)

SetHidden implements Field.SetHidden interface method.

GeoPointField.SetId

func (f *GeoPointField) SetId(id string)

SetId implements Field.SetId interface method.

GeoPointField.SetName

func (f *GeoPointField) SetName(name string)

SetName implements Field.SetName interface method.

GeoPointField.SetSystem

func (f *GeoPointField) SetSystem(system bool)

SetSystem implements Field.SetSystem interface method.

GeoPointField.Type

func (f *GeoPointField) Type() string

Type implements Field.Type interface method.

GeoPointField.ValidateSettings

func (f *GeoPointField) ValidateSettings(app App, collection *Collection) error

ValidateSettings implements Field.ValidateSettings interface method.

GeoPointField.ValidateValue

func (f *GeoPointField) ValidateValue(app App, record *Record) error

ValidateValue implements Field.ValidateValue interface method.

JSONField

type JSONField struct {
	// Name (required) is the unique name of the field.
	Name string `form:"name" json:"name"`

	// Id is the unique stable field identifier.
	//
	// It is automatically generated from the name when adding to a collection FieldsList.
	Id string `form:"id" json:"id"`

	// System prevents the renaming and removal of the field.
	System bool `form:"system" json:"system"`

	// Hidden hides the field from the API response.
	Hidden bool `form:"hidden" json:"hidden"`

	// Presentable hints the Dashboard UI to use the underlying
	// field record value in the relation preview label.
	Presentable bool `form:"presentable" json:"presentable"`

	// Help is an extra text explaining what the field is about.
	// It is usually shown in Dashboard UI under the field input.
	Help string `form:"help" json:"help"`

	// MaxSize specifies the maximum size of the allowed field value (in bytes and up to 2^53-1).
	//
	// If zero, a default limit of 1MB is applied.
	MaxSize int64 `form:"maxSize" json:"maxSize"`

	// Required will require the field value to be non-empty JSON value
	// (aka. not "null", `""`, "[]", "{}").
	Required bool `form:"required" json:"required"`
}

JSONField defines "json" type field for storing any serialized JSON value.

The respective zero record field value is the zero types.JSONRaw.

JSONField.CalculateMaxBodySize

func (f *JSONField) CalculateMaxBodySize() int64

CalculateMaxBodySize implements the MaxBodySizeCalculator interface.

JSONField.ColumnType

func (f *JSONField) ColumnType(app App) string

ColumnType implements Field.ColumnType interface method.

JSONField.GetHidden

func (f *JSONField) GetHidden() bool

GetHidden implements Field.GetHidden interface method.

JSONField.GetId

func (f *JSONField) GetId() string

GetId implements Field.GetId interface method.

JSONField.GetName

func (f *JSONField) GetName() string

GetName implements Field.GetName interface method.

JSONField.GetSystem

func (f *JSONField) GetSystem() bool

GetSystem implements Field.GetSystem interface method.

JSONField.PrepareValue

func (f *JSONField) PrepareValue(record *Record, raw any) (any, error)

PrepareValue implements Field.PrepareValue interface method.

JSONField.SetHidden

func (f *JSONField) SetHidden(hidden bool)

SetHidden implements Field.SetHidden interface method.

JSONField.SetId

func (f *JSONField) SetId(id string)

SetId implements Field.SetId interface method.

JSONField.SetName

func (f *JSONField) SetName(name string)

SetName implements Field.SetName interface method.

JSONField.SetSystem

func (f *JSONField) SetSystem(system bool)

SetSystem implements Field.SetSystem interface method.

JSONField.Type

func (f *JSONField) Type() string

Type implements Field.Type interface method.

JSONField.ValidateSettings

func (f *JSONField) ValidateSettings(app App, collection *Collection) error

ValidateSettings implements Field.ValidateSettings interface method.

JSONField.ValidateValue

func (f *JSONField) ValidateValue(app App, record *Record) error

ValidateValue implements Field.ValidateValue interface method.

NumberField

type NumberField struct {
	// Name (required) is the unique name of the field.
	Name string `form:"name" json:"name"`

	// Id is the unique stable field identifier.
	//
	// It is automatically generated from the name when adding to a collection FieldsList.
	Id string `form:"id" json:"id"`

	// System prevents the renaming and removal of the field.
	System bool `form:"system" json:"system"`

	// Hidden hides the field from the API response.
	Hidden bool `form:"hidden" json:"hidden"`

	// Presentable hints the Dashboard UI to use the underlying
	// field record value in the relation preview label.
	Presentable bool `form:"presentable" json:"presentable"`

	// Help is an extra text explaining what the field is about.
	// It is usually shown in Dashboard UI under the field input.
	Help string `form:"help" json:"help"`

	// Min specifies the min allowed field value.
	//
	// Leave it nil to skip the validator.
	Min *float64 `form:"min" json:"min"`

	// Max specifies the max allowed field value.
	//
	// Leave it nil to skip the validator.
	Max *float64 `form:"max" json:"max"`

	// OnlyInt will require the field value to be integer.
	OnlyInt bool `form:"onlyInt" json:"onlyInt"`

	// Required will require the field value to be non-zero.
	Required bool `form:"required" json:"required"`
}

NumberField defines "number" type field for storing numeric (float64) value.

The respective zero record field value is 0.

The following additional setter keys are available:

  • "fieldName+" - appends to the existing record value. For example: record.Set("total+", 5)
  • "fieldName-" - subtracts from the existing record value. For example: record.Set("total-", 5)

NumberField.ColumnType

func (f *NumberField) ColumnType(app App) string

ColumnType implements Field.ColumnType interface method.

NumberField.FindSetter

func (f *NumberField) FindSetter(key string) SetterFunc

FindSetter implements the SetterFinder interface.

NumberField.GetHidden

func (f *NumberField) GetHidden() bool

GetHidden implements Field.GetHidden interface method.

NumberField.GetId

func (f *NumberField) GetId() string

GetId implements Field.GetId interface method.

NumberField.GetName

func (f *NumberField) GetName() string

GetName implements Field.GetName interface method.

NumberField.GetSystem

func (f *NumberField) GetSystem() bool

GetSystem implements Field.GetSystem interface method.

NumberField.PrepareValue

func (f *NumberField) PrepareValue(record *Record, raw any) (any, error)

PrepareValue implements Field.PrepareValue interface method.

NumberField.SetHidden

func (f *NumberField) SetHidden(hidden bool)

SetHidden implements Field.SetHidden interface method.

NumberField.SetId

func (f *NumberField) SetId(id string)

SetId implements Field.SetId interface method.

NumberField.SetName

func (f *NumberField) SetName(name string)

SetName implements Field.SetName interface method.

NumberField.SetSystem

func (f *NumberField) SetSystem(system bool)

SetSystem implements Field.SetSystem interface method.

NumberField.Type

func (f *NumberField) Type() string

Type implements Field.Type interface method.

NumberField.ValidateSettings

func (f *NumberField) ValidateSettings(app App, collection *Collection) error

ValidateSettings implements Field.ValidateSettings interface method.

NumberField.ValidateValue

func (f *NumberField) ValidateValue(app App, record *Record) error

ValidateValue implements Field.ValidateValue interface method.

PasswordField

type PasswordField struct {
	// Name (required) is the unique name of the field.
	Name string `form:"name" json:"name"`

	// Id is the unique stable field identifier.
	//
	// It is automatically generated from the name when adding to a collection FieldsList.
	Id string `form:"id" json:"id"`

	// System prevents the renaming and removal of the field.
	System bool `form:"system" json:"system"`

	// Hidden hides the field from the API response.
	Hidden bool `form:"hidden" json:"hidden"`

	// @todo remove
	//
	// Presentable hints the Dashboard UI to use the underlying
	// field record value in the relation preview label.
	Presentable bool `form:"presentable" json:"presentable"`

	// Help is an extra text explaining what the field is about.
	// It is usually shown in Dashboard UI under the field input.
	Help string `form:"help" json:"help"`

	// Pattern specifies an optional regex pattern to match against the field value.
	//
	// Leave it empty to skip the pattern check.
	Pattern string `form:"pattern" json:"pattern"`

	// Min specifies an optional required field string length.
	Min int `form:"min" json:"min"`

	// Max specifies an optional required field string length.
	//
	// If zero, fallback to max 71 bytes.
	Max int `form:"max" json:"max"`

	// Cost specifies the cost/weight/iteration/etc. bcrypt factor.
	//
	// If zero, fallback to [bcrypt.DefaultCost].
	//
	// If explicitly set, must be between [bcrypt.MinCost] and [bcrypt.MaxCost].
	Cost int `form:"cost" json:"cost"`

	// Required will require the field value to be non-empty string.
	Required bool `form:"required" json:"required"`
}

PasswordField defines "password" type field for storing bcrypt hashed strings (usually used only internally for the "password" auth collection system field).

If you want to set a direct bcrypt hash as record field value you can use the SetRaw method, for example:

// generates a bcrypt hash of "123456" and set it as field value
// (record.GetString("password") returns the plain password until persisted, otherwise empty string)
record.Set("password", "123456")

// set directly a bcrypt hash of "123456" as field value
// (record.GetString("password") returns empty string)
record.SetRaw("password", "$2a$10$.5Elh8fgxypNUWhpUUr/xOa2sZm0VIaE0qWuGGl9otUfobb46T1Pq")

The following additional getter keys are available:

  • "fieldName:hash" - returns the bcrypt hash string of the record field value (if any). For example: record.GetString("password:hash")

PasswordField.ColumnType

func (f *PasswordField) ColumnType(app App) string

ColumnType implements Field.ColumnType interface method.

PasswordField.DriverValue

func (f *PasswordField) DriverValue(record *Record) (driver.Value, error)

DriverValue implements the DriverValuer interface.

PasswordField.FindGetter

func (f *PasswordField) FindGetter(key string) GetterFunc

FindGetter implements the GetterFinder interface.

PasswordField.FindSetter

func (f *PasswordField) FindSetter(key string) SetterFunc

FindSetter implements the SetterFinder interface.

PasswordField.GetHidden

func (f *PasswordField) GetHidden() bool

GetHidden implements Field.GetHidden interface method.

PasswordField.GetId

func (f *PasswordField) GetId() string

GetId implements Field.GetId interface method.

PasswordField.GetName

func (f *PasswordField) GetName() string

GetName implements Field.GetName interface method.

PasswordField.GetSystem

func (f *PasswordField) GetSystem() bool

GetSystem implements Field.GetSystem interface method.

PasswordField.Intercept

func (f *PasswordField) Intercept(
	app App,
	record *Record,
	actionName string,
	actionFunc func() error,
) error

Intercept implements the RecordInterceptor interface.

PasswordField.PrepareValue

func (f *PasswordField) PrepareValue(record *Record, raw any) (any, error)

PrepareValue implements Field.PrepareValue interface method.

PasswordField.SetHidden

func (f *PasswordField) SetHidden(hidden bool)

SetHidden implements Field.SetHidden interface method.

PasswordField.SetId

func (f *PasswordField) SetId(id string)

SetId implements Field.SetId interface method.

PasswordField.SetName

func (f *PasswordField) SetName(name string)

SetName implements Field.SetName interface method.

PasswordField.SetSystem

func (f *PasswordField) SetSystem(system bool)

SetSystem implements Field.SetSystem interface method.

PasswordField.Type

func (f *PasswordField) Type() string

Type implements Field.Type interface method.

PasswordField.ValidateSettings

func (f *PasswordField) ValidateSettings(app App, collection *Collection) error

ValidateSettings implements Field.ValidateSettings interface method.

PasswordField.ValidateValue

func (f *PasswordField) ValidateValue(app App, record *Record) error

ValidateValue implements Field.ValidateValue interface method.

RelationField

type RelationField struct {
	// Name (required) is the unique name of the field.
	Name string `form:"name" json:"name"`

	// Id is the unique stable field identifier.
	//
	// It is automatically generated from the name when adding to a collection FieldsList.
	Id string `form:"id" json:"id"`

	// System prevents the renaming and removal of the field.
	System bool `form:"system" json:"system"`

	// Hidden hides the field from the API response.
	Hidden bool `form:"hidden" json:"hidden"`

	// Presentable hints the Dashboard UI to use the underlying
	// field record value in the relation preview label.
	Presentable bool `form:"presentable" json:"presentable"`

	// Help is an extra text explaining what the field is about.
	// It is usually shown in Dashboard UI under the field input.
	Help string `form:"help" json:"help"`

	// CollectionId is the id of the related collection.
	CollectionId string `form:"collectionId" json:"collectionId"`

	// CascadeDelete indicates whether the root model should be deleted
	// in case of delete of all linked relations.
	CascadeDelete bool `form:"cascadeDelete" json:"cascadeDelete"`

	// MinSelect indicates the min number of allowed relation records
	// that could be linked to the main model.
	//
	// No min limit is applied if it is zero or negative value.
	MinSelect int `form:"minSelect" json:"minSelect"`

	// MaxSelect indicates the max number of allowed relation records
	// that could be linked to the main model.
	//
	// For multiple select the value must be > 1, otherwise fallbacks to single (default).
	//
	// If MinSelect is set, MaxSelect must be at least >= MinSelect.
	MaxSelect int `form:"maxSelect" json:"maxSelect"`

	// Required will require the field value to be non-empty.
	Required bool `form:"required" json:"required"`
}

RelationField defines "relation" type field for storing single or multiple collection record references.

Requires the CollectionId option to be set.

If MaxSelect is not set or <= 1, then the field value is expected to be a single record id.

If MaxSelect is > 1, then the field value is expected to be a slice of record ids.

The respective zero record field value is either empty string (single) or empty string slice (multiple).

---

The following additional setter keys are available:

  • "fieldName+" - append one or more values to the existing record one. For example:

    record.Set("categories+", []string{"new1", "new2"}) // []string{"old1", "old2", "new1", "new2"}

  • "+fieldName" - prepend one or more values to the existing record one. For example:

    record.Set("+categories", []string{"new1", "new2"}) // []string{"new1", "new2", "old1", "old2"}

  • "fieldName-" - subtract one or more values from the existing record one. For example:

    record.Set("categories-", "old1") // []string{"old2"}

RelationField.ColumnType

func (f *RelationField) ColumnType(app App) string

ColumnType implements Field.ColumnType interface method.

RelationField.DriverValue

func (f *RelationField) DriverValue(record *Record) (driver.Value, error)

DriverValue implements the DriverValuer interface.

RelationField.FindSetter

func (f *RelationField) FindSetter(key string) SetterFunc

FindSetter implements SetterFinder interface method.

RelationField.GetHidden

func (f *RelationField) GetHidden() bool

GetHidden implements Field.GetHidden interface method.

RelationField.GetId

func (f *RelationField) GetId() string

GetId implements Field.GetId interface method.

RelationField.GetName

func (f *RelationField) GetName() string

GetName implements Field.GetName interface method.

RelationField.GetSystem

func (f *RelationField) GetSystem() bool

GetSystem implements Field.GetSystem interface method.

RelationField.IsMultiple

func (f *RelationField) IsMultiple() bool

IsMultiple implements MultiValuer interface and checks whether the current field options support multiple values.

RelationField.PrepareValue

func (f *RelationField) PrepareValue(record *Record, raw any) (any, error)

PrepareValue implements Field.PrepareValue interface method.

RelationField.SetHidden

func (f *RelationField) SetHidden(hidden bool)

SetHidden implements Field.SetHidden interface method.

RelationField.SetId

func (f *RelationField) SetId(id string)

SetId implements Field.SetId interface method.

RelationField.SetName

func (f *RelationField) SetName(name string)

SetName implements Field.SetName interface method.

RelationField.SetSystem

func (f *RelationField) SetSystem(system bool)

SetSystem implements Field.SetSystem interface method.

RelationField.Type

func (f *RelationField) Type() string

Type implements Field.Type interface method.

RelationField.ValidateSettings

func (f *RelationField) ValidateSettings(app App, collection *Collection) error

ValidateSettings implements Field.ValidateSettings interface method.

RelationField.ValidateValue

func (f *RelationField) ValidateValue(app App, record *Record) error

ValidateValue implements Field.ValidateValue interface method.

SelectField

type SelectField struct {
	// Name (required) is the unique name of the field.
	Name string `form:"name" json:"name"`

	// Id is the unique stable field identifier.
	//
	// It is automatically generated from the name when adding to a collection FieldsList.
	Id string `form:"id" json:"id"`

	// System prevents the renaming and removal of the field.
	System bool `form:"system" json:"system"`

	// Hidden hides the field from the API response.
	Hidden bool `form:"hidden" json:"hidden"`

	// Presentable hints the Dashboard UI to use the underlying
	// field record value in the relation preview label.
	Presentable bool `form:"presentable" json:"presentable"`

	// Help is an extra text explaining what the field is about.
	// It is usually shown in Dashboard UI under the field input.
	Help string `form:"help" json:"help"`

	// Values specifies the list of accepted values.
	Values []string `form:"values" json:"values"`

	// MaxSelect specifies the max allowed selected values.
	//
	// For multiple select the value must be > 1, otherwise fallbacks to single (default).
	MaxSelect int `form:"maxSelect" json:"maxSelect"`

	// Required will require the field value to be non-empty.
	Required bool `form:"required" json:"required"`
}

SelectField defines "select" type field for storing single or multiple string values from a predefined list.

Requires the Values option to be set.

If MaxSelect is not set or <= 1, then the field value is expected to be a single Values element.

If MaxSelect is > 1, then the field value is expected to be a subset of Values slice.

The respective zero record field value is either empty string (single) or empty string slice (multiple).

---

The following additional setter keys are available:

  • "fieldName+" - append one or more values to the existing record one. For example:

    record.Set("roles+", []string{"new1", "new2"}) // []string{"old1", "old2", "new1", "new2"}

  • "+fieldName" - prepend one or more values to the existing record one. For example:

    record.Set("+roles", []string{"new1", "new2"}) // []string{"new1", "new2", "old1", "old2"}

  • "fieldName-" - subtract one or more values from the existing record one. For example:

    record.Set("roles-", "old1") // []string{"old2"}

SelectField.ColumnType

func (f *SelectField) ColumnType(app App) string

ColumnType implements Field.ColumnType interface method.

SelectField.DriverValue

func (f *SelectField) DriverValue(record *Record) (driver.Value, error)

DriverValue implements the DriverValuer interface.

SelectField.FindSetter

func (f *SelectField) FindSetter(key string) SetterFunc

FindSetter implements the SetterFinder interface.

SelectField.GetHidden

func (f *SelectField) GetHidden() bool

GetHidden implements Field.GetHidden interface method.

SelectField.GetId

func (f *SelectField) GetId() string

GetId implements Field.GetId interface method.

SelectField.GetName

func (f *SelectField) GetName() string

GetName implements Field.GetName interface method.

SelectField.GetSystem

func (f *SelectField) GetSystem() bool

GetSystem implements Field.GetSystem interface method.

SelectField.IsMultiple

func (f *SelectField) IsMultiple() bool

IsMultiple implements MultiValuer interface and checks whether the current field options support multiple values.

SelectField.PrepareValue

func (f *SelectField) PrepareValue(record *Record, raw any) (any, error)

PrepareValue implements Field.PrepareValue interface method.

SelectField.SetHidden

func (f *SelectField) SetHidden(hidden bool)

SetHidden implements Field.SetHidden interface method.

SelectField.SetId

func (f *SelectField) SetId(id string)

SetId implements Field.SetId interface method.

SelectField.SetName

func (f *SelectField) SetName(name string)

SetName implements Field.SetName interface method.

SelectField.SetSystem

func (f *SelectField) SetSystem(system bool)

SetSystem implements Field.SetSystem interface method.

SelectField.Type

func (f *SelectField) Type() string

Type implements Field.Type interface method.

SelectField.ValidateSettings

func (f *SelectField) ValidateSettings(app App, collection *Collection) error

ValidateSettings implements Field.ValidateSettings interface method.

SelectField.ValidateValue

func (f *SelectField) ValidateValue(app App, record *Record) error

ValidateValue implements Field.ValidateValue interface method.

TextField

type TextField struct {
	// Name (required) is the unique name of the field.
	Name string `form:"name" json:"name"`

	// Id is the unique stable field identifier.
	//
	// It is automatically generated from the name when adding to a collection FieldsList.
	Id string `form:"id" json:"id"`

	// System prevents the renaming and removal of the field.
	System bool `form:"system" json:"system"`

	// Hidden hides the field from the API response.
	Hidden bool `form:"hidden" json:"hidden"`

	// Presentable hints the Dashboard UI to use the underlying
	// field record value in the relation preview label.
	Presentable bool `form:"presentable" json:"presentable"`

	// Help is an extra text explaining what the field is about.
	// It is usually shown in Dashboard UI under the field input.
	Help string `form:"help" json:"help"`

	// Min specifies the minimum required string characters.
	//
	// if zero value, no min limit is applied.
	Min int `form:"min" json:"min"`

	// Max specifies the maximum allowed string characters.
	//
	// If zero, a default limit of 5000 is applied.
	Max int `form:"max" json:"max"`

	// Pattern specifies an optional regex pattern to match against the field value.
	//
	// Leave it empty to skip the pattern check.
	Pattern string `form:"pattern" json:"pattern"`

	// AutogeneratePattern specifies an optional regex pattern that could
	// be used to generate random string from it and set it automatically
	// on record create if no explicit value is set or when the `:autogenerate` modifier is used.
	//
	// Note: the generated value still needs to satisfy min, max, pattern (if set)
	AutogeneratePattern string `form:"autogeneratePattern" json:"autogeneratePattern"`

	// Required will require the field value to be non-empty string.
	Required bool `form:"required" json:"required"`

	// PrimaryKey will mark the field as primary key.
	//
	// A single collection can have only 1 field marked as primary key.
	PrimaryKey bool `form:"primaryKey" json:"primaryKey"`
}

TextField defines "text" type field for storing any string value.

The respective zero record field value is empty string.

The following additional setter keys are available:

- "fieldName:autogenerate" - autogenerate field value if AutogeneratePattern is set. For example:

record.Set("slug:autogenerate", "") // [random value]
record.Set("slug:autogenerate", "abc-") // abc-[random value]

TextField.ColumnType

func (f *TextField) ColumnType(app App) string

ColumnType implements Field.ColumnType interface method.

TextField.FindSetter

func (f *TextField) FindSetter(key string) SetterFunc

FindSetter implements the SetterFinder interface.

TextField.GetHidden

func (f *TextField) GetHidden() bool

GetHidden implements Field.GetHidden interface method.

TextField.GetId

func (f *TextField) GetId() string

GetId implements Field.GetId interface method.

TextField.GetName

func (f *TextField) GetName() string

GetName implements Field.GetName interface method.

TextField.GetSystem

func (f *TextField) GetSystem() bool

GetSystem implements Field.GetSystem interface method.

TextField.Intercept

func (f *TextField) Intercept(
	app App,
	record *Record,
	actionName string,
	actionFunc func() error,
) error

Intercept implements the RecordInterceptor interface.

TextField.PrepareValue

func (f *TextField) PrepareValue(record *Record, raw any) (any, error)

PrepareValue implements Field.PrepareValue interface method.

TextField.SetHidden

func (f *TextField) SetHidden(hidden bool)

SetHidden implements Field.SetHidden interface method.

TextField.SetId

func (f *TextField) SetId(id string)

SetId implements Field.SetId interface method.

TextField.SetName

func (f *TextField) SetName(name string)

SetName implements Field.SetName interface method.

TextField.SetSystem

func (f *TextField) SetSystem(system bool)

SetSystem implements Field.SetSystem interface method.

TextField.Type

func (f *TextField) Type() string

Type implements Field.Type interface method.

TextField.ValidatePlainValue

func (f *TextField) ValidatePlainValue(value string) error

ValidatePlainValue validates the provided string against the field options.

TextField.ValidateSettings

func (f *TextField) ValidateSettings(app App, collection *Collection) error

ValidateSettings implements Field.ValidateSettings interface method.

TextField.ValidateValue

func (f *TextField) ValidateValue(app App, record *Record) error

ValidateValue implements Field.ValidateValue interface method.

URLField

type URLField struct {
	// Name (required) is the unique name of the field.
	Name string `form:"name" json:"name"`

	// Id is the unique stable field identifier.
	//
	// It is automatically generated from the name when adding to a collection FieldsList.
	Id string `form:"id" json:"id"`

	// System prevents the renaming and removal of the field.
	System bool `form:"system" json:"system"`

	// Hidden hides the field from the API response.
	Hidden bool `form:"hidden" json:"hidden"`

	// Presentable hints the Dashboard UI to use the underlying
	// field record value in the relation preview label.
	Presentable bool `form:"presentable" json:"presentable"`

	// Help is an extra text explaining what the field is about.
	// It is usually shown in Dashboard UI under the field input.
	Help string `form:"help" json:"help"`

	// ExceptDomains will require the URL domain to NOT be included in the listed ones.
	//
	// This validator can be set only if OnlyDomains is empty.
	ExceptDomains []string `form:"exceptDomains" json:"exceptDomains"`

	// OnlyDomains will require the URL domain to be included in the listed ones.
	//
	// This validator can be set only if ExceptDomains is empty.
	OnlyDomains []string `form:"onlyDomains" json:"onlyDomains"`

	// Required will require the field value to be non-empty URL string.
	Required bool `form:"required" json:"required"`
}

URLField defines "url" type field for storing a single URL string value.

The respective zero record field value is empty string.

URLField.ColumnType

func (f *URLField) ColumnType(app App) string

ColumnType implements Field.ColumnType interface method.

URLField.GetHidden

func (f *URLField) GetHidden() bool

GetHidden implements Field.GetHidden interface method.

URLField.GetId

func (f *URLField) GetId() string

GetId implements Field.GetId interface method.

URLField.GetName

func (f *URLField) GetName() string

GetName implements Field.GetName interface method.

URLField.GetSystem

func (f *URLField) GetSystem() bool

GetSystem implements Field.GetSystem interface method.

URLField.PrepareValue

func (f *URLField) PrepareValue(record *Record, raw any) (any, error)

PrepareValue implements Field.PrepareValue interface method.

URLField.SetHidden

func (f *URLField) SetHidden(hidden bool)

SetHidden implements Field.SetHidden interface method.

URLField.SetId

func (f *URLField) SetId(id string)

SetId implements Field.SetId interface method.

URLField.SetName

func (f *URLField) SetName(name string)

SetName implements Field.SetName interface method.

URLField.SetSystem

func (f *URLField) SetSystem(system bool)

SetSystem implements Field.SetSystem interface method.

URLField.Type

func (f *URLField) Type() string

Type implements Field.Type interface method.

URLField.ValidateSettings

func (f *URLField) ValidateSettings(app App, collection *Collection) error

ValidateSettings implements Field.ValidateSettings interface method.

URLField.ValidateValue

func (f *URLField) ValidateValue(app App, record *Record) error

ValidateValue implements Field.ValidateValue interface method.