field

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package field defines declarative authoring values used to describe Ridu collection fields.

Field definitions do not render admin components and do not depend on a storage implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeSlug

func NormalizeSlug(value string) string

NormalizeSlug converts a source or manual value into Ridu's deterministic URL-segment form. ASCII letters are lowercased, digits and underscores are retained, whitespace and hyphen runs become one hyphen, and other characters are removed.

Types

type ArrayOption

type ArrayOption interface {
	Option
	// contains filtered or unexported methods
}

ArrayOption can be passed to repeatable array fields.

func ArrayRowLabels

func ArrayRowLabels(labels RowLabels) ArrayOption

ArrayRowLabels configures singular and plural display names for array rows. It is separate from RowLabel, which identifies a child value used as a row heading.

func MaxRows

func MaxRows(value int) ArrayOption

MaxRows sets the maximum accepted array length.

func MinRows

func MinRows(value int) ArrayOption

MinRows sets the minimum accepted array length.

func RowLabel

func RowLabel(path string) ArrayOption

RowLabel selects a child property used for array row headings.

type Block

type Block struct {
	// Key is the stable discriminator stored with block values.
	Key string
	// Label is the author-facing block type name.
	Label string
	// LabelTranslations overrides Label for configured admin interface languages.
	LabelTranslations map[string]string
	// Fields defines the values stored by this block type.
	Fields []Definition
}

Block is one discriminated layout allowed by a blocks field.

func BlockType

func BlockType(key, label string, fields ...Definition) Block

BlockType constructs one member of a discriminated blocks field.

func (Block) WithLabelTranslations

func (block Block) WithLabelTranslations(translations map[string]string) Block

WithLabelTranslations returns a detached block type with localized display labels.

type BlocksOption

type BlocksOption interface {
	Option
	// contains filtered or unexported methods
}

BlocksOption can be passed to discriminated blocks fields.

func BlockTypes

func BlockTypes(blocks ...Block) BlocksOption

BlockTypes supplies the allowed discriminated layouts for a blocks field.

type Category

type Category string

Category describes the broad behavior a field contributes to a resolved schema. Schema manifests use categories to avoid treating every field as an unstructured type string.

const (
	CategoryScalar       Category = "scalar"
	CategoryNested       Category = "nested"
	CategoryPresentation Category = "presentation"
	CategoryRelationship Category = "relationship"
	CategoryUpload       Category = "upload"
	CategoryPlugin       Category = "plugin"
)

type CheckboxOption

type CheckboxOption interface {
	Option
	// contains filtered or unexported methods
}

CheckboxOption can be passed to checkbox fields.

type Choice

type Choice struct {
	// Value is the exact string stored in documents and sent over APIs.
	Value string
	// Label is the author-facing name shown in selection controls.
	Label string
	// LabelTranslations overrides Label for configured admin interface languages.
	LabelTranslations map[string]string
}

Choice is one allowed value and its author-facing label for a select field.

func (Choice) WithLabelTranslations

func (choice Choice) WithLabelTranslations(translations map[string]string) Choice

WithLabelTranslations returns a detached choice with localized display labels.

type CommonOption

CommonOption applies to every built-in and plugin field kind.

func AdminComponent

func AdminComponent(pluginKey, component string, config json.RawMessage) CommonOption

AdminComponent selects one component exported by a statically paired admin plugin while retaining this field's built-in storage and runtime semantics. Config must be deterministic JSON safe to expose in the schema manifest.

func Columns

func Columns(value int) CommonOption

Columns assigns the field one to twelve columns in the admin's row grid.

func Description

func Description(value string) CommonOption

Description adds supporting text below the field in authoring interfaces.

func DescriptionTranslations

func DescriptionTranslations(translations map[string]string) CommonOption

DescriptionTranslations adds localized supporting text for admin languages.

func Hidden

func Hidden() CommonOption

Hidden removes the field from the admin renderer without changing access, validation, defaults, storage, or submission behavior.

func Label

func Label(label string) CommonOption

Label overrides the humanized field name shown to authors.

func LabelTranslations

func LabelTranslations(translations map[string]string) CommonOption

LabelTranslations adds localized field labels for admin languages.

func Placeholder

func Placeholder(value string) CommonOption

Placeholder configures the empty-state prompt shown by compatible admin controls. It is presentation metadata and does not affect stored values.

func PlaceholderTranslations

func PlaceholderTranslations(translations map[string]string) CommonOption

PlaceholderTranslations localizes the placeholder for admin interface languages. Placeholder must provide the canonical fallback text.

func ReadOnly

func ReadOnly() CommonOption

ReadOnly prevents editing in the admin; it is presentation metadata, not authorization.

func Required

func Required() CommonOption

Required rejects missing, null, and field-type-specific empty values during validation.

func ShowWhen

func ShowWhen(path, equals string) CommonOption

ShowWhen is the concise string-equality form of ShowWhenCondition. Its path is sibling-scoped, so nested fields read from their current object or row.

func ShowWhenCondition

func ShowWhenCondition(condition Condition) CommonOption

ShowWhenCondition attaches one typed condition expression to a field. Conditions control presentation only; they never grant field or collection access.

func Sidebar() CommonOption

Sidebar places a root field in the document editor's responsive right rail. Nested sidebar placement is rejected while resolving application config.

func Tab

func Tab(label string) CommonOption

Tab places the field in a named admin form tab.

func TabTranslations

func TabTranslations(translations map[string]string) CommonOption

TabTranslations localizes the direct admin tab configured by Tab.

type Condition

type Condition struct {
	// contains filtered or unexported fields
}

Condition is an immutable, deterministic presentation expression. It never grants access or removes a hidden value from a document.

func All

func All(conditions ...Condition) Condition

All requires every child condition to match.

func Any

func Any(conditions ...Condition) Condition

Any requires at least one child condition to match.

func Document

func Document[Value ConditionScalar](path string, operator ConditionOperator, values ...Value) Condition

Document compares a scalar path resolved from the document root.

func Not

func Not(condition Condition) Condition

Not negates one child condition.

func Sibling

func Sibling[Value ConditionScalar](path string, operator ConditionOperator, values ...Value) Condition

Sibling compares a scalar path resolved from the current field's parent object or row.

func (Condition) Conditions

func (condition Condition) Conditions() []Condition

Conditions returns detached child expressions for All, Any, and Not nodes.

func (Condition) Kind

func (condition Condition) Kind() ConditionKind

Kind reports whether this node is a logical group, negation, or predicate.

func (Condition) Operator

func (condition Condition) Operator() ConditionOperator

Operator returns the predicate's scalar comparison operator.

func (Condition) Path

func (condition Condition) Path() string

Path returns the predicate path relative to its configured scope.

func (Condition) Scope

func (condition Condition) Scope() ConditionScope

Scope reports which value tree a predicate reads.

func (Condition) Values

func (condition Condition) Values() []DefaultValue

Values returns detached, canonically encoded predicate operands.

type ConditionKind

type ConditionKind string

ConditionKind identifies one node in a presentation-only condition tree.

const (
	ConditionKindAll       ConditionKind = "all"
	ConditionKindAny       ConditionKind = "any"
	ConditionKindNot       ConditionKind = "not"
	ConditionKindPredicate ConditionKind = "predicate"
)

type ConditionOperator

type ConditionOperator string

ConditionOperator identifies one scalar predicate operation.

const (
	ConditionEquals    ConditionOperator = "equals"
	ConditionNotEquals ConditionOperator = "notEquals"
	ConditionOneOf     ConditionOperator = "oneOf"
)

type ConditionScalar

type ConditionScalar interface {
	~string | ~bool | ~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~float32 | ~float64
}

ConditionScalar is the finite scalar vocabulary accepted by condition predicates.

type ConditionScope

type ConditionScope string

ConditionScope selects the value tree used by a condition predicate.

const (
	// ConditionScopeDocument resolves paths from the document root.
	ConditionScopeDocument ConditionScope = "document"
	// ConditionScopeSibling resolves paths from the current field's parent object or row.
	ConditionScopeSibling ConditionScope = "sibling"
)

type DatePickerAppearance

type DatePickerAppearance string

DatePickerAppearance controls the native date control shown by the admin. Values remain strings on the wire: dates use YYYY-MM-DD, times use HH:mm, and date-times use RFC 3339 timestamps.

const (
	DatePickerDayOnly    DatePickerAppearance = "dayOnly"
	DatePickerDayAndTime DatePickerAppearance = "dayAndTime"
	DatePickerTimeOnly   DatePickerAppearance = "timeOnly"
)

type DefaultKind

type DefaultKind string

DefaultKind identifies the scalar type carried by a field default.

const (
	DefaultString  DefaultKind = "string"
	DefaultNumber  DefaultKind = "number"
	DefaultBoolean DefaultKind = "boolean"
)

type DefaultOption

type DefaultOption interface {
	StringOption
	NumberOption
	CheckboxOption
	SelectOption
}

DefaultOption applies to fields with a concrete scalar default value.

func Default

func Default[Value ~string | ~bool | ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~float32 | ~float64](value Value) DefaultOption

Default sets a typed string, number, or boolean field default.

type DefaultValue

type DefaultValue struct {
	// contains filtered or unexported fields
}

DefaultValue is the normalized scalar value produced by Default.

func (DefaultValue) Kind

func (value DefaultValue) Kind() DefaultKind

Kind reports whether the normalized default is a string, number, or boolean.

func (DefaultValue) String

func (value DefaultValue) String() string

String returns the canonical textual encoding written to the manifest.

type Definition

type Definition struct {
	// contains filtered or unexported fields
}

Definition is an immutable authoring description created by a field constructor. Slice-bearing accessors return copies so plugins and callers cannot mutate a definition after construction.

func Array

func Array(name string, options ...ArrayOption) Definition

Array defines a repeatable list of objects whose children are configured with Fields.

func Blocks

func Blocks(name string, options ...BlocksOption) Definition

Blocks defines a repeatable list of discriminated layouts configured with BlockTypes.

func Checkbox

func Checkbox(name string, options ...CheckboxOption) Definition

Checkbox defines a boolean field rendered as an on/off control in the admin.

func Code

func Code(name string, options ...StringOption) Definition

Code defines a source-code string with an optional editor language hint.

func Collapsible

func Collapsible(name string, initiallyCollapsed bool, fields ...Definition) Definition

Collapsible groups fields in a presentation-only disclosure. Child fields retain their paths.

func Date

func Date(name string, options ...StringOption) Definition

Date defines a string field containing a normalized date, time, or timestamp value.

func Email

func Email(name string, options ...StringOption) Definition

Email defines a string field validated as an email address.

func Group

func Group(name string, options ...GroupOption) Definition

Group defines a nested object whose children are configured with Fields.

func JSON

func JSON(name string, options ...JSONOption) Definition

JSON defines a field containing arbitrary JSON-compatible data.

func Join

func Join(name, collection, on string, options ...JoinOption) Definition

Join defines a read-only inverse relationship populated from target documents.

func Number

func Number(name string, options ...NumberOption) Definition

Number defines a numeric field.

func Plugin

func Plugin(name, pluginKey string, config json.RawMessage, options ...PluginOption) Definition

Plugin creates a declarative custom field owned by a compiled plugin.

func Point

func Point(name string, options ...JSONOption) Definition

Point defines a GeoJSON-style longitude/latitude tuple.

func Radio

func Radio(name string, options ...SelectOption) Definition

Radio defines a string constrained to choices and rendered as a radio group.

func Relationship

func Relationship(name string, options ...RelationshipOption) Definition

Relationship defines a reference to one or more documents in other collections.

func Row

func Row(fields ...Definition) Definition

Row groups fields into one presentation-only admin row. Its children retain their ordinary document paths and storage identities.

func Select

func Select(name string, options ...SelectOption) Definition

Select defines a string field constrained to configured Choices.

func Slug

func Slug(name, sourcePath string, options ...StringOption) Definition

Slug defines a required, unique, indexed text field whose value is generated from sourcePath until an author supplies a manual value. The source may be a direct string field or a string field beneath non-repeated groups.

Slugs intentionally use ordinary text storage and generated string contracts. Localization and defaults are not supported by this first-class helper.

func Tabs

func Tabs(tabs ...TabDefinition) Definition

Tabs groups named data-bearing and unnamed presentation-only authoring tabs.

func Text

func Text(name string, options ...StringOption) Definition

Text defines a single-line string field.

func Textarea

func Textarea(name string, options ...StringOption) Definition

Textarea defines a multi-line plain-text field.

func UI

func UI(name string, options ...CommonOption) Definition

UI defines presentation-only content. It is omitted from stored and generated document values.

func Upload

func Upload(name string, options ...UploadOption) Definition

Upload defines a reference to documents in an upload-enabled collection.

func Virtual

func Virtual(name string, valueType ValueType, options ...CommonOption) Definition

Virtual declares a computed output field whose resolver lives on the collection or global.

func (Definition) AdminComponent

func (d Definition) AdminComponent() (pluginKey, component string, config json.RawMessage, ok bool)

AdminComponent returns the optional statically registered admin plugin renderer selected for this field. The returned configuration is detached from the immutable definition.

func (Definition) Blocks

func (d Definition) Blocks() []Block

Blocks returns a deep copy of the allowed block types.

func (Definition) Category

func (d Definition) Category() Category

Category returns the behavioral category for the definition's field kind.

func (Definition) Choices

func (d Definition) Choices() []Choice

Choices returns a copy of the select choices.

func (Definition) CodeLanguage

func (d Definition) CodeLanguage() string

CodeLanguage is the editor language hint for a code field.

func (Definition) Columns

func (d Definition) Columns() int

Columns returns the requested one-to-twelve-column admin grid width, or zero.

func (Definition) Condition

func (d Definition) Condition() *Condition

Condition returns a copy of the configured presentation condition, if any.

func (Definition) DatePickerAppearance

func (d Definition) DatePickerAppearance() DatePickerAppearance

DatePickerAppearance returns the configured date control, defaulting to day-only.

func (Definition) Default

func (d Definition) Default() (DefaultValue, bool)

Default returns the configured typed scalar default.

func (Definition) Description

func (d Definition) Description() string

Description returns the configured author-facing supporting text.

func (Definition) DescriptionTranslations

func (d Definition) DescriptionTranslations() map[string]string

DescriptionTranslations returns localized supporting text by admin language.

func (Definition) Fields

func (d Definition) Fields() []Definition

Fields returns a deep copy of the nested child definitions.

func (Definition) Hidden

func (d Definition) Hidden() bool

Hidden reports whether the admin should omit this field from presentation.

func (Definition) Index

func (d Definition) Index() bool

Index reports whether the field should have a non-unique database index. Unique fields already receive a unique index even when this is false.

func (Definition) InitiallyCollapsed

func (d Definition) InitiallyCollapsed() bool

InitiallyCollapsed reports whether a collapsible presentation group starts closed.

func (Definition) Issues

func (d Definition) Issues() []Issue

Issues returns a copy of constructor and option compatibility issues.

func (Definition) JoinAllowCreate

func (d Definition) JoinAllowCreate() bool

JoinAllowCreate reports whether the admin may offer inline target creation.

func (Definition) JoinCollection

func (d Definition) JoinCollection() string

JoinCollection is the collection queried by an inverse join.

func (Definition) JoinDefaultColumns

func (d Definition) JoinDefaultColumns() []string

JoinDefaultColumns returns the target fields shown by the inverse-join table.

func (Definition) JoinDefaultSort

func (d Definition) JoinDefaultSort() string

JoinDefaultSort returns the target sort expression, including an optional descending prefix.

func (Definition) JoinLimit

func (d Definition) JoinLimit() int

JoinLimit is the maximum related documents returned for an inverse join.

func (Definition) JoinOn

func (d Definition) JoinOn() string

JoinOn is the target relationship path matched against the source document ID.

func (Definition) Kind

func (d Definition) Kind() Kind

Kind returns the concrete authoring field kind.

func (Definition) Label

func (d Definition) Label() string

Label returns the explicit author-facing label, if one was configured.

func (Definition) LabelTranslations

func (d Definition) LabelTranslations() map[string]string

LabelTranslations returns localized author-facing labels by admin language.

func (Definition) Localized

func (d Definition) Localized() bool

Localized reports whether the field stores an independent value for each configured application locale.

func (Definition) Max

func (d Definition) Max() (float64, bool)

Max returns the inclusive maximum accepted by a number field.

func (Definition) MaxLength

func (d Definition) MaxLength() (int, bool)

MaxLength returns the maximum accepted Unicode code-point length.

func (Definition) MaxRows

func (d Definition) MaxRows() int

MaxRows is the maximum accepted length for an array, or zero when unbounded.

func (Definition) Min

func (d Definition) Min() (float64, bool)

Min returns the inclusive minimum accepted by a number field.

func (Definition) MinLength

func (d Definition) MinLength() (int, bool)

MinLength returns the minimum accepted Unicode code-point length.

func (Definition) MinRows

func (d Definition) MinRows() int

MinRows is the minimum accepted length for an array.

func (Definition) Name

func (d Definition) Name() string

Name returns the document property name authored for the field.

func (Definition) Placeholder

func (d Definition) Placeholder() string

Placeholder returns the canonical empty-state prompt for compatible admin controls.

func (Definition) PlaceholderTranslations

func (d Definition) PlaceholderTranslations() map[string]string

PlaceholderTranslations returns localized placeholder text by admin language.

func (Definition) PluginConfig

func (d Definition) PluginConfig() json.RawMessage

PluginConfig returns a copy of the plugin-owned serialized configuration.

func (Definition) PluginKey

func (d Definition) PluginKey() string

PluginKey returns the compiled plugin responsible for a custom field.

func (Definition) PluginReferenceKeys

func (d Definition) PluginReferenceKeys() []string

PluginReferenceKeys returns JSON property names whose string values contain public collection slugs and therefore participate in content renames and persisted reference-shape migration safety.

func (Definition) ReadOnly

func (d Definition) ReadOnly() bool

ReadOnly reports whether the admin should prevent editing this field.

func (Definition) ReferenceDeleteAction

func (d Definition) ReferenceDeleteAction() ReferenceDeleteAction

ReferenceDeleteAction returns the explicitly authored hard-delete policy. An empty action means config resolution must apply the deterministic default for the reference shape.

func (Definition) RelationshipFilters

func (d Definition) RelationshipFilters() []RelationshipFilterRule

RelationshipFilters returns configured multi-rule and polymorphic option filters.

func (Definition) RelationshipHasMany

func (d Definition) RelationshipHasMany() bool

RelationshipHasMany reports whether the field stores multiple references.

func (Definition) RelationshipTarget

func (d Definition) RelationshipTarget() string

RelationshipTarget returns the first configured target slug, or an empty string.

func (Definition) RelationshipTargets

func (d Definition) RelationshipTargets() []string

RelationshipTargets returns a copy of all configured target slugs.

func (Definition) Required

func (d Definition) Required() bool

Required reports whether validation rejects a missing, null, or field-type-specific empty value.

func (Definition) RowLabel

func (d Definition) RowLabel() string

RowLabel is the child property used to label array rows in the admin.

func (Definition) RowLabelComponent

func (d Definition) RowLabelComponent() (pluginKey, component string, config json.RawMessage, ok bool)

RowLabelComponent returns the optional statically registered admin plugin component selected for array or blocks row headings. The returned configuration is detached from the immutable definition.

func (Definition) RowLabels

func (d Definition) RowLabels() RowLabels

RowLabels returns optional singular and plural author-facing array row names.

func (Definition) SelectDefaults

func (d Definition) SelectDefaults() []string

SelectDefaults returns the configured ordered default choices for a multi-select.

func (Definition) SelectHasMany

func (d Definition) SelectHasMany() bool

SelectHasMany reports whether a select stores an ordered list of choices.

func (Definition) Sidebar

func (d Definition) Sidebar() bool

Sidebar reports whether a root field belongs in the document editor's right rail.

func (Definition) SlugSource

func (d Definition) SlugSource() (string, bool)

SlugSource returns the source field path for a text-backed slug helper. The boolean distinguishes an invalid empty source from an ordinary text field.

func (Definition) Step

func (d Definition) Step() (float64, bool)

Step returns the positive admin input increment for a number field. It is presentation metadata and does not impose divisibility validation.

func (Definition) Tab

func (d Definition) Tab() string

Tab returns the named admin form tab, or an empty string.

func (Definition) TabTranslations

func (d Definition) TabTranslations() map[string]string

TabTranslations returns localized direct-tab labels by admin language.

func (Definition) Tabs

func (d Definition) Tabs() []TabDefinition

Tabs returns a deep copy of the configured named and unnamed tabs.

func (Definition) Unique

func (d Definition) Unique() bool

Unique reports whether values must be distinct within the collection.

func (Definition) ValueType

func (d Definition) ValueType() ValueType

ValueType is the declared output contract for a virtual field.

func (Definition) WithLabelTranslations

func (d Definition) WithLabelTranslations(translations map[string]string) Definition

WithLabelTranslations returns an immutable copy with localized labels. It is useful for presentation definitions such as Collapsible that do not accept options.

type GroupOption

type GroupOption interface {
	Option
	// contains filtered or unexported methods
}

GroupOption can be passed to nested group fields.

type Issue

type Issue struct {
	// Code is a stable machine-readable problem identifier.
	Code string
	// Path locates the invalid property within the field definition.
	Path string
	// Message explains how to correct the problem.
	Message string
}

Issue records a definition problem relative to the field. Config resolution prefixes Path with the field's exact location in the application config.

type JSONOption

type JSONOption interface {
	Option
	// contains filtered or unexported methods
}

JSONOption can be passed to JSON fields.

type JoinOption

type JoinOption interface {
	Option
	// contains filtered or unexported methods
}

JoinOption can be passed to inverse join fields.

func JoinAllowCreate

func JoinAllowCreate(value bool) JoinOption

JoinAllowCreate controls whether the inverse-join browser offers inline target creation.

func JoinColumns

func JoinColumns(paths ...string) JoinOption

JoinColumns selects target document fields shown in the inverse-join table.

func JoinDefaultSort

func JoinDefaultSort(value string) JoinOption

JoinDefaultSort selects the initial target sort. Prefix the path with "-" for descending order.

func JoinLimit

func JoinLimit(value int) JoinOption

JoinLimit bounds the number of documents embedded by an inverse join.

type Kind

type Kind string

Kind identifies a built-in authoring field definition.

const (
	KindText         Kind = "text"
	KindCode         Kind = "code"
	KindSelect       Kind = "select"
	KindRadio        Kind = "radio"
	KindPoint        Kind = "point"
	KindRelationship Kind = "relationship"
	KindUpload       Kind = "upload"
	KindGroup        Kind = "group"
	KindTextarea     Kind = "textarea"
	KindEmail        Kind = "email"
	KindDate         Kind = "date"
	KindNumber       Kind = "number"
	KindCheckbox     Kind = "checkbox"
	KindJSON         Kind = "json"
	KindArray        Kind = "array"
	KindBlocks       Kind = "blocks"
	KindTabs         Kind = "tabs"
	KindRow          Kind = "row"
	KindUI           Kind = "ui"
	KindCollapsible  Kind = "collapsible"
	KindJoin         Kind = "join"
	KindVirtual      Kind = "virtual"
	KindPlugin       Kind = "plugin"
)

type LocalizedOption

LocalizedOption applies to every stored field kind. Presentation-only join, UI, and virtual fields cannot own localized values.

func Localized

func Localized() LocalizedOption

Localized stores an independent field value for each configured content locale. Required and unique validation are evaluated per locale.

type NestedOption

type NestedOption interface {
	GroupOption
	ArrayOption
}

NestedOption configures group and array children.

func Fields

func Fields(fields ...Definition) NestedOption

Fields configures the child definitions stored inside a group or each array item.

type NumberOption

type NumberOption interface {
	Option
	// contains filtered or unexported methods
}

NumberOption can be passed to number fields.

func Max

func Max(value float64) NumberOption

Max sets the inclusive maximum accepted by a number field.

func Min

func Min(value float64) NumberOption

Min sets the inclusive minimum accepted by a number field.

func Step

func Step(value float64) NumberOption

Step sets the positive increment exposed by number inputs. It does not add server-side divisibility validation.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is the sealed base contract implemented by every field option. Constructors accept narrower interfaces so incompatible options fail at compile time.

type PluginOption

type PluginOption interface {
	Option
	// contains filtered or unexported methods
}

PluginOption can be passed to fields supplied by compiled plugins.

func CollectionReferenceKeys

func CollectionReferenceKeys(keys ...string) PluginOption

CollectionReferenceKeys declares plugin-owned JSON properties whose string values are collection slugs at any nested depth. Every declared key may target any configured collection. Ridu uses this contract for semantic renames and fail-closed persisted-data migration safety across current values and version history; arbitrary plugin JSON is never guessed.

type ReferenceDeleteAction

type ReferenceDeleteAction string

ReferenceDeleteAction controls how a hard-deleted target affects current relationship and upload values that point at it. Historical version snapshots are immutable and are not reconciled by this policy.

const (
	// ReferenceDeleteNullify clears a singular reference or removes matching
	// members from a has-many reference.
	ReferenceDeleteNullify ReferenceDeleteAction = "nullify"
	// ReferenceDeleteRestrict rejects the target hard delete while a current
	// document still references it.
	ReferenceDeleteRestrict ReferenceDeleteAction = "restrict"
)

type RelationshipFilterOperator

type RelationshipFilterOperator string

RelationshipFilterOperator is the finite predicate vocabulary used to narrow admin choices.

const (
	FilterEquals           RelationshipFilterOperator = "equals"
	FilterNotEquals        RelationshipFilterOperator = "notEquals"
	FilterLike             RelationshipFilterOperator = "like"
	FilterContains         RelationshipFilterOperator = "contains"
	FilterGreaterThan      RelationshipFilterOperator = "greaterThan"
	FilterGreaterThanEqual RelationshipFilterOperator = "greaterThanEqual"
	FilterLessThan         RelationshipFilterOperator = "lessThan"
	FilterLessThanEqual    RelationshipFilterOperator = "lessThanEqual"
)

type RelationshipFilterRule

type RelationshipFilterRule struct {
	Collection string
	TargetPath string
	Operator   RelationshipFilterOperator
	SourcePath string
	Literal    *DefaultValue
}

RelationshipFilterRule derives one target predicate from current document data. Collection optionally limits the rule to one target of a polymorphic relationship.

func OptionFilter

func OptionFilter(targetPath string, operator RelationshipFilterOperator, sourcePath string) RelationshipFilterRule

OptionFilter derives one relationship-choice predicate from current document data.

func OptionFilterFor

func OptionFilterFor(collection, targetPath string, operator RelationshipFilterOperator, sourcePath string) RelationshipFilterRule

OptionFilterFor limits an option-filter rule to one target of a polymorphic relationship.

func OptionFilterValue

func OptionFilterValue[Value ~string | ~bool | ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~float32 | ~float64](targetPath string, operator RelationshipFilterOperator, value Value) RelationshipFilterRule

OptionFilterValue compares a target field with one static scalar value. Literal filters are applied by both admin pickers and server-side reference admission.

func OptionFilterValueFor

func OptionFilterValueFor[Value ~string | ~bool | ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~float32 | ~float64](collection, targetPath string, operator RelationshipFilterOperator, value Value) RelationshipFilterRule

OptionFilterValueFor limits a static option filter to one polymorphic target.

type RelationshipOption

type RelationshipOption interface {
	Option
	// contains filtered or unexported methods
}

RelationshipOption can be passed to relationship fields.

func ToAny

func ToAny(collectionSlugs ...string) RelationshipOption

ToAny permits a polymorphic relationship to reference any listed collection.

type RelationshipOrUploadOption

type RelationshipOrUploadOption interface {
	RelationshipOption
	UploadOption
}

RelationshipOrUploadOption configures reference fields.

func FilterOptionRules

func FilterOptionRules(rules ...RelationshipFilterRule) RelationshipOrUploadOption

FilterOptionRules adds combinable nested and target-specific reference predicates. The rules drive pickers and are revalidated server-side.

func HasMany

HasMany changes a reference field from one document to a list of documents.

func OnDelete

OnDelete configures current-document behavior when a referenced target is hard deleted. Nullify clears singular values and removes matching list members; Restrict rejects the target delete. Required references always resolve to Restrict and reject an explicit Nullify action so automatic reconciliation cannot create a value that ordinary validation forbids. Version snapshots are never rewritten.

func To

func To(collectionSlug string) RelationshipOrUploadOption

To selects the one collection referenced by a relationship or upload field.

func ToMany

func ToMany(collectionSlug string) RelationshipOrUploadOption

ToMany is shorthand for To(collectionSlug) plus HasMany.

type RowLabelComponentOption

type RowLabelComponentOption interface {
	ArrayOption
	BlocksOption
}

RowLabelComponentOption selects a custom row-label renderer for repeatable array and blocks fields.

func RowLabelComponent

func RowLabelComponent(pluginKey, component string, config json.RawMessage) RowLabelComponentOption

RowLabelComponent selects one row-label component exported by a statically paired admin plugin. Config must be deterministic JSON safe to expose in the schema manifest. The component changes presentation only; RowLabel remains available as its string fallback and for accessible action labels.

type RowLabels

type RowLabels struct {
	Singular             string
	Plural               string
	SingularTranslations map[string]string
	PluralTranslations   map[string]string
}

RowLabels contains optional singular and plural display names for array rows. RowLabel remains the separate child-field path used to derive each row heading.

type SelectOption

type SelectOption interface {
	Option
	// contains filtered or unexported methods
}

SelectOption can be passed to select fields.

func Choices

func Choices(choices ...Choice) SelectOption

Choices supplies the complete allowed value and label set for a select field.

func DefaultChoices

func DefaultChoices(values ...string) SelectOption

DefaultChoices supplies the ordered default value for a multi-select.

func Multiple

func Multiple() SelectOption

Multiple changes a select from one choice to an ordered list of choices.

func OneOf

func OneOf(values ...string) SelectOption

OneOf derives author-facing labels from concise select values.

type StringOption

type StringOption interface {
	Option
	// contains filtered or unexported methods
}

StringOption can be passed to text, textarea, email, and date fields.

func Language

func Language(value string) StringOption

Language configures the syntax language hint for a code editor.

func MaxLength

func MaxLength(value int) StringOption

MaxLength sets the inclusive maximum Unicode code-point length for text, textarea, and code fields.

func MinLength

func MinLength(value int) StringOption

MinLength sets the inclusive minimum Unicode code-point length for text, textarea, and code fields.

func PickerAppearance

func PickerAppearance(value DatePickerAppearance) StringOption

PickerAppearance configures a date field as day-only, day-and-time, or time-only. It mirrors Payload's pickerAppearance vocabulary while retaining Ridu's typed Go config.

type TabDefinition

type TabDefinition struct {
	// Name is the optional document property contributed by a data-bearing tab.
	Name string
	// Label is the author-facing tab trigger.
	Label string
	// LabelTranslations overrides Label for configured admin interface languages.
	LabelTranslations map[string]string
	// Fields defines the values shown inside the tab.
	Fields []Definition
}

TabDefinition is one authoring section inside a Tabs presentation field. Tabs with a Name store their children beneath that document property; unnamed tabs only affect the admin layout and leave child document paths unchanged.

func NamedTab

func NamedTab(name, label string, fields ...Definition) TabDefinition

NamedTab defines a data-bearing tab. Its children are stored beneath name, matching Payload's named-tab document shape.

func UnnamedTab

func UnnamedTab(label string, fields ...Definition) TabDefinition

UnnamedTab defines a presentation-only tab. Its children retain their ordinary document paths.

func (TabDefinition) WithLabelTranslations

func (tab TabDefinition) WithLabelTranslations(translations map[string]string) TabDefinition

WithLabelTranslations returns a detached tab with localized trigger labels.

type UniqueOption

UniqueOption applies to field kinds with supported scalar/reference indexes.

func Index

func Index() UniqueOption

Index requests a non-unique database index for a supported scalar or singular reference field. Unique fields already receive a unique index.

func Unique

func Unique() UniqueOption

Unique requires values to be distinct within the collection.

type UploadOption

type UploadOption interface {
	Option
	// contains filtered or unexported methods
}

UploadOption can be passed to upload-reference fields.

type ValueType

type ValueType string

ValueType identifies the generated and runtime value contract of a virtual field.

const (
	ValueString  ValueType = "string"
	ValueNumber  ValueType = "number"
	ValueBoolean ValueType = "boolean"
	ValueJSON    ValueType = "json"
)

Jump to

Keyboard shortcuts

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