---
url: /guide/rules.md
description: >-
  Prevent double bookings with optional buffers, and add your own validation
  rules that run for drags, keyboard moves and modals.
---

# Conflicts & Rules

## Overlaps

```php
$scheduler->preventOverlaps(bufferMinutes: 10);
```

Overlapping bookings on the same resource are refused, with the clashing event named in the message. The buffer keeps a gap between bookings.

## Your own rules

```php
$scheduler->validateUsing(function (Appointment $record, CarbonImmutable $start, ?Staff $resource): ?string {
    return $start->isWeekend() && ! $resource?->works_weekends
        ? 'Weekend bookings need a weekend practitioner.'
        : null;
});
```

Return a message to refuse the change, or `null` to allow it.

## Where rules run

The same rules run for every change:

* drag to move and drag to resize
* drag across rows
* keyboard moves with `Alt` + arrows
* the create and edit modals

The browser flags conflicts while you drag; the server re-checks before saving.
