type

DefaultContext

The request and surrounding values available to a field’s dynamic default callback.

Context properties

PropertyTypeDescription
Contextcontext.ContextCancellation and deadline for this operation. Pass ctx.Context to ctx.Local.FindByID.
OperationKindThe document action, such as Create or Duplicate. It can be Update when an edit adds a new object, row, or translation; a default callback does not imply a new document.
ActorActorThe signed-in document, its auth collection, and a snapshot of its fields. Actor.ID is empty for an anonymous request; Actor is a value, not a pointer.
Localeschema.LocaleCodeThe exact content locale being initialized, or an empty string without localization. Locale fallback is not treated as stored input.
RootViewRoot document fields available at this point. Values may be incomplete or not yet validated; do not expect results from other dynamic defaults.
SiblingsViewFields in the same enclosing object or row. For seo.title, this is seo; for a title at the document root, this is Root. It has the same timing limits as Root.
PriorViewPreviously saved fields in the same enclosing object or row, matched by stable row key. Empty for a new nested object, row, or translation. During duplication the root can contain source values, while copied rows with new keys have no prior row.
LocalReaderRead a known document with FindByID. Reads enforce this actor’s access rules, use the exact locale without fallback, and share the active transaction and cancellation. This reader cannot write documents.
IDIDThe document identifier. It may still be empty before a newly created document receives an ID.
CollectionIDschema.StableIDThe collection’s framework identifier, not its authored slug. Empty for a global.
GlobalIDschema.StableIDThe global’s framework identifier, not its authored slug. Empty for a collection.
AllLocalesboolWhether Root retains locale-keyed values. A visit to one exact localized value receives false.
OccurrenceIDOccurrenceIDAn opaque identifier for this field value, including stable row keys and the exact locale. Most callbacks do not need it; do not parse it or build one from an array index.
SchemaOccurrenceIDOccurrenceIDAn opaque identifier grouping the same configured field across rows and locales. Most callbacks can use Siblings instead of tracking this identifier.

How it works

Ridu supplies this context to DefaultFrom callbacks. Read Root, Siblings, and Prior as snapshots; changing a local copy does not change the document. Return Present(value) from the callback to supply this field’s initial value.

View.String, View.Get, and View.Lookup accept one direct child name. Read a nested object before looking up its child; passing "seo.title" does not traverse the object.

A default sees values at initialization, not the completed candidate passed to a validator. Use request information or already available input, and avoid dependencies between dynamic defaults.

Full signature

Related guides