type

Transform

Change one field’s typed value before saving.

Arguments

ArgumentTypeDescription
ctxoperation.WriteContextThe operation, user, surrounding field values, and access-checked reader for this phase.
valueoperation.Value[T]This field’s current value in its Go type, including changes from earlier hooks. Get returns the value and whether it is present.

Returns

Return Keep[T]() to leave the value unchanged, Replace(Present(value)) to set it, or Replace(Empty[T]()) to clear it. An error stops the operation.

(operation.Change[T], error)

How it works

Use in BeforeChange or BeforeOperation. Returned changes still undergo validation and field access checks.

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.

  • 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