# RestBeforeDutyRule

Industry: Workforce

A rest required before each duty: "10 hours off in the 24 before a duty", "rest before duty at least as long as the duty before it, and never under 12 hours".

```ts
import type { RestBeforeDutyRule } 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` | `"restBeforeDuty"` | Selects this rule kind. |
| `restStatuses` | `S[]` | The statuses that are rest. |
| `minimum` | `string` | The least rest required, a positive ISO 8601 duration of exact time. |
| `within` | `string` | How far before a duty the rest is looked for, a positive ISO 8601 duration of exact time. With `orFactor` the rest is the one right before the duty, which `within` does not cut. |
| `orFactor?` | `object` | A requirement that grows with the previous duty: the larger of `k` × its length and `floor`. |
| `orFactor.k` | `number` | The multiple of the previous duty's length, a positive finite number. It is read as the shortest decimal `String(k)` prints, exactly: `1.1` is eleven tenths, and `0.1 + 0.2` is 0.30000000000000004. The product is rounded up to the nanosecond. |
| `orFactor.floor` | `string` | The least the requirement can be, a positive ISO 8601 duration of exact time. |

## Definition

```ts
type RestBeforeDutyRule<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: "restBeforeDuty";
  /** The statuses that are rest. */
  restStatuses: S[];
  /** The least rest required, a positive ISO 8601 duration of exact time. */
  minimum: string;
  /**
   * How far before a duty the rest is looked for, a positive ISO 8601 duration of exact time.
   * With `orFactor` the rest is the one right before the duty, which `within` does not cut.
   */
  within: string;
  /**
   * A requirement that grows with the previous duty: the larger of `k` × its length and `floor`.
   *
   * @defaultValue None. The requirement is `minimum`.
   */
  orFactor?: {
    /**
     * The multiple of the previous duty's length, a positive finite number. It is read as the
     * shortest decimal `String(k)` prints, exactly: `1.1` is eleven tenths, and `0.1 + 0.2` is
     * 0.30000000000000004. The product is rounded up to the nanosecond.
     */
    k: number;
    /** The least the requirement can be, a positive ISO 8601 duration of exact time. */
    floor: 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)
