---
url: https://trigger.beyondthecloud.dev/before-delete/add-ons/bypassable.md
description: >-
  Skip a before delete Validator or Writer for the chunk when a condition holds,
  such as a static flag or a batch purge.
---

# BeforeDelete.Bypassable

Skip a handler for the whole chunk when a condition holds, such as a static flag, a batch job or a custom permission.

**Signature**

```apex
public interface Bypassable {
    Boolean bypassOnBeforeDeleteWhen();
}
```

* `bypassOnBeforeDeleteWhen()`: called once per chunk, before parents load. Returns `true` to skip this handler for this chunk.

**Example**

::: code-group

```apex [Skeleton]
public with sharing class ContactValidator implements BeforeDelete.Validator, BeforeDelete.Bypassable {
    public static Boolean isBypassed = false;

    public Boolean bypassOnBeforeDeleteWhen() {
        return ContactValidator.isBypassed;
    }

    public Boolean addErrorOnBeforeDeleteWhen(TriggerTypes.DeleteRecord record) {
        return record.isTrue(Contact.DoNotCall);
    }

    public void addErrorOnBeforeDelete(TriggerTypes.RejectableDeleteRecord record) {
        record.addError('A Do Not Call contact cannot be deleted.');
    }
}
```

:::

## Rules {#rules}

* **To skip single records, use the predicate.** Return false from `addErrorOnBeforeDeleteWhen` or `writeOnBeforeDeleteWhen`.
* **Reset static flags.** A static flag lasts the whole transaction, nested saves included. Reset it in a `finally` block after the DML it was meant for.
* **Only this context.** [Apex bypasses](/guide/bypasses#apex) cover every context, and `bypass().handler(X.class)` never matches an inner class. A [`TriggerHandler__mdt`](/api/custom-metadata#trigger-handler) record covers the one context it names, for every user.

::: warning
The method runs outside the error handling. An exception in `bypassOnBeforeDeleteWhen()` is not logged, ContinueOnError does not apply, and the delete fails.
:::
