type
RawTransform
Change one field’s input before it is converted to its Go type.
Arguments
| Argument | Type | Description |
|---|---|---|
ctx | operation.WriteContext | The operation, user, surrounding field values, and access-checked reader for this phase. |
value | operation.Value[store.Value] | The raw input for this field, which may be invalid. Empty means omitted; Present(store.Null()) means explicit null. |
Returns
Return operation.Keep[store.Value]() to leave the input unchanged, operation.Replace(...) to replace this field, or an error to stop.
(operation.Change[store.Value], error)How it works
Use in BeforeValidate or BeforeDuplicate. Context views are copies; changing them cannot change another field.
Full signature
type RawTransform func(
operation.WriteContext,
operation.Value[store.Value],
) (operation.Change[store.Value], error)Related types
WriteContextWriteContext supplies snapshots to raw and typed field transforms. Raw hooks see input at their phase and may receive omitted or malformed values. Typed write hooks see a completed candidate and their field's logical value.
ValueValue carries an optional logical value. Its zero value is empty. For raw input, empty means omitted and Present(store.Null()) means explicit null. For typed scalars, empty is the portable empty state, not a durable absence encoding. T must follow its own ownership contract; this carrier does not deep-clone arbitrary mutable application values.
ValueAn immutable scalar, object, list, or populated document value.
ChangeChange is an explicit keep-or-replace result. Its zero value means keep. Replacing with Empty clears the callback's own logical value; it does not create an external patch command or durable scalar removal representation.