Setu-TS
    Preparing search index...

    Function checkWritePrecondition

    • Validates a conditional predicate (and, for an update, its payload) and returns private copies of both.

      Validation runs on the copies, and a conditional write sends the copies, so the predicate the backend receives is exactly the one that was validated — even when the caller's object changes its keys or values between reads. An own __proto__ key is refused in the predicate and in the payload. Refusal reasons contain no caller-supplied field names or values.

      Parameters

      • where: unknown

        A non-empty plain equality map of string or finite-number values

      Returns WritePreconditionCheck<undefined>

      A refusal reason, or a copy of where

      const checked = checkWritePrecondition({ status: 'pending' });
      if (checked.ok) checked.where; // { status: 'pending' }

      0.9.0

    • Validates a conditional predicate and its update payload, returning private copies of both.

      Parameters

      • where: unknown

        A non-empty plain equality map of string or finite-number values

      • data: unknown

        A plain update payload with at least one own field

      Returns WritePreconditionCheck<Record<string, unknown>>

      A refusal reason, or copies of where and data

      checkWritePrecondition({ status: 'pending' }, { status: 'sent' }).ok; // true
      checkWritePrecondition({ status: 'pending' }, {}).ok; // false

      0.9.0