Skip to content

resolveNullableSaveValue

resolveNullableSaveValue(props): unknown

Defined in: packages/core/src/fields/utils.ts:319

Resolves one field’s form value for the save payload.

undefined always becomes null, regardless of nullable — Convex’s client argument serializer drops an explicit undefined key before the request ever reaches the server, so a cleared field with no other empty representation (a scalar relationship/upload’s deselect, a bytes control’s own Clear action) would otherwise vanish from the payload entirely and the stored value would never change. null survives the wire; prepareEdit (core db/prepareEdit.ts) translates it back on arrival — a nullable field stores the literal null, a non-nullable OPTIONAL field is unset, a non-nullable REQUIRED field fails its normal required validation.

Beyond that: clearing a nullable scalar field’s input (its own empty representation, per isDisplayValueEmpty) also writes null. A toggle field’s value is already null or already a real value (set directly by its own FormFieldLayout null toggle) and passes through unchanged.

Input props.

AdminDataField

The resolved field definition.

unknown

The field’s current form value.

unknown

null when value is undefined, regardless of field type; otherwise value, or null when field.nullable, the field has no null toggle, and value is that field’s own empty representation.