# RestRequirementRule

Industry: Workforce

A minimum of rest inside every window: "10 hours of rest in every 24, in at most two periods, one at least 6 hours long".

```ts
import type { RestRequirementRule } from "@northguild/gmt";
```

## Members

| Member | Type | Description |
| --- | --- | --- |
| `label` | `string` | The caller's name for the rule. The report is keyed by it; labels must be unique. |
| `severity?` | `"violation"` \| `"advisory"` ([`DutySeverity`](/gmt/reference/types/DutySeverity/)) | Whether a failure is a violation or an advisory. |
| `kind` | `"restRequirement"` | Selects this rule kind. |
| `restStatuses` | `S[]` | The statuses that are rest. |
| `per` | [`Period`](/gmt/reference/types/Period/) | The window the rest is counted in. |
| `minimum` | `string` | The least rest required in the window, a positive ISO 8601 duration of exact time. |
| `composition?` | `object` | How the rest may be divided: it is counted from the `maxPeriods` longest runs, the longest at least `longestAtLeast` and each other at least `othersAtLeast`. |
| `composition.maxPeriods` | `number` | The most runs the rest may come from, a positive integer. |
| `composition.longestAtLeast` | `string` | The floor on the longest run, a positive ISO 8601 duration of exact time. |
| `composition.othersAtLeast?` | `string` | The floor on every other run counted, a positive ISO 8601 duration of exact time. |
| `composite?` | `object` | A consecutive run plus additional rest in blocks: rest is the longest run, at least `consecutive`, plus the other runs of at least `blockMinimum`, which must add up to `additional`. |
| `composite.consecutive` | `string` | The floor on the longest run, a positive ISO 8601 duration of exact time. |
| `composite.additional` | `string` | The rest required beyond the longest run, a positive ISO 8601 duration of exact time. |
| `composite.blockMinimum` | `string` | The shortest block that counts, a positive ISO 8601 duration of exact time. |
| `maxGap?` | `string` | The most time allowed from the end of one run of rest, or from the log's first entry, to the start of the next run of rest, a positive ISO 8601 duration of exact time. |

## Definition

```ts
type RestRequirementRule<S extends string = string> = {
  /** The caller's name for the rule. The report is keyed by it; labels must be unique. */
  label: string;
  /**
   * Whether a failure is a violation or an advisory.
   *
   * @defaultValue `"violation"`.
   */
  severity?: DutySeverity;
  /** Selects this rule kind. */
  kind: "restRequirement";
  /** The statuses that are rest. */
  restStatuses: S[];
  /** The window the rest is counted in. */
  per: Period;
  /** The least rest required in the window, a positive ISO 8601 duration of exact time. */
  minimum: string;
  /**
   * How the rest may be divided: it is counted from the `maxPeriods` longest runs, the longest at
   * least `longestAtLeast` and each other at least `othersAtLeast`.
   *
   * @defaultValue None. Every run of rest counts.
   */
  composition?: {
    /** The most runs the rest may come from, a positive integer. */
    maxPeriods: number;
    /** The floor on the longest run, a positive ISO 8601 duration of exact time. */
    longestAtLeast: string;
    /**
     * The floor on every other run counted, a positive ISO 8601 duration of exact time.
     *
     * @defaultValue None. The other runs count at any length.
     */
    othersAtLeast?: string;
  };
  /**
   * A consecutive run plus additional rest in blocks: rest is the longest run, at least
   * `consecutive`, plus the other runs of at least `blockMinimum`, which must add up to
   * `additional`.
   *
   * @defaultValue None. Rest is counted without the split.
   */
  composite?: {
    /** The floor on the longest run, a positive ISO 8601 duration of exact time. */
    consecutive: string;
    /** The rest required beyond the longest run, a positive ISO 8601 duration of exact time. */
    additional: string;
    /** The shortest block that counts, a positive ISO 8601 duration of exact time. */
    blockMinimum: string;
  };
  /**
   * The most time allowed from the end of one run of rest, or from the log's first entry, to the
   * start of the next run of rest, a positive ISO 8601 duration of exact time.
   *
   * @defaultValue None. The time between rests is not limited.
   */
  maxGap?: string;
};
```

## Used by

- [`dutyViolations`](/gmt/reference/workforce/calculate/dutyViolations/)
- [`evaluateDutyLog`](/gmt/reference/workforce/calculate/evaluateDutyLog/)

## Source

[types/duty.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/types/duty.ts)
