type

RawTransform

Change one field’s input before it is converted to its Go type.

Arguments

ArgumentTypeDescription
ctxoperation.WriteContextThe operation, user, surrounding field values, and access-checked reader for this phase.
valueoperation.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

Related types

  • WriteContext

    WriteContext 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.

  • Value

    Value 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.

  • Value

    An immutable scalar, object, list, or populated document value.

  • Change

    Change 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.

Related guides