type

LiveValidationContext

The request and surrounding values available to a live server validation callback.

Context properties

PropertyTypeDescription
Contextcontext.ContextCancellation and deadline for this feedback request. Pass ctx.Context to reads and other cancellable work; replacing it cannot remove the original cancellation.
OperationKindCreate for a new collection document; Update for an existing document or any global, including its first save.
CollectionIDschema.StableIDThe collection’s framework identifier, not its slug or document ID. Empty for a global.
GlobalIDschema.StableIDThe global’s framework identifier, not its slug. Empty for a collection.
IDIDThe saved document ID. Empty for a new collection document.
ActorActorThe authenticated document, its auth collection, and a snapshot of its fields. Actor.ID is empty for an anonymous request.
Localeschema.LocaleCodeThe exact content locale being checked, or empty without localization. Saved and submitted values never include locale fallback; all-locales requests are unsupported.
RootViewReadable unsaved document values, retaining omitted update fields from storage. In a detached embedded editor, this is the parent document before Apply; the detached payload is in Siblings.
SiblingsViewReadable values in the current enclosing object or row, including retained update fields. For seo.title, this is seo. No defaults or save hooks have run.
PriorViewReadable saved values for this enclosing object or row in the exact locale. Rows match by stable key and block type, never by index. Empty for a new object, row, embedded item, or translation.
InputViewSubmitted values in this enclosing object before retaining omitted update fields. Lookup distinguishes an omitted property from one explicitly set to null. The separate value argument contains the value after retention.
LocalReaderRead a known document with FindByID, enforcing this user’s access rules in the same read-only transaction and exact locale. Reads run no lifecycle hooks, defaults, or computed outputs. This reader cannot write.

How it works

Ridu supplies this context to field.LiveValidator callbacks. Its values are snapshots of an unfinished form. They have not passed save transforms or full field validation.

View.Get, View.String, and View.Lookup read one direct child name. To read seo.title, first read the seo object; a dotted string does not traverse a View.

Use Input to ask what the request submitted, Siblings to check the current object, and Prior to compare it with saved data. Readability rules can hide values from all these views.

Full signature

type LiveValidationContext struct { // Context carries the original request deadline and cancellation. Context context.Context // Operation is Create for a new collection document, or Update for document // edits and globals (including a global's first save). Operation Kind // CollectionID or GlobalID identifies the owning resource, not its document. CollectionID schema.StableID GlobalID schema.StableID // ID is the saved document ID, or empty for a new collection document. ID ID // Actor is the authenticated document and its auth collection. Actor Actor // Locale selects one exact translation. Live checks never use fallback values // as persisted or submitted data and do not accept all-locales requests. Locale schema.LocaleCode // Root contains readable unsaved document values with omitted update data // retained from storage. In a detached embedded editor it is the parent // document before Apply; the detached payload is available through Siblings. Root View // Siblings contains the readable current enclosing object or repeated row. // Retained update fields are included, without defaults or write hooks. Siblings View // Prior is the readable persisted enclosing object or row in this exact // locale. Repeated rows match by stable key and Block case, never by index. // It is empty for new objects, rows, embedded items and translations. Prior View // Input contains the submitted enclosing object before retention. Lookup // distinguishes omitted properties from explicitly submitted null values. // The separate typed Value argument describes the current value after retention. Input View // Local reads an authorized document in the same read-only transaction, actor // and exact locale. It runs no document lifecycle hooks, defaults or computed // outputs, and grants no writes. Original cancellation cannot be replaced. Local Reader }

Source operation/live_validation.go:13

Related guides