# Function: contract()

```ts
function contract<C>(
   schema, 
   that, 
   why
): Contract;
```

Defined in: [packages/core/src/records/contract-builder.ts:582](https://github.com/leifriksheim/minca/blob/main/core/src/records/contract-builder.ts#L582)

One condition of a contract, built in TypeScript: `body` is typed from
`schema` (a collection definition, a validator, or JSON Schema), and the
result is the `{ that, else }` a definition's `contract.check` holds.

```ts
const famous = contract(Fame, ({ body, versions, link }) =>
  versions(body.reactions)
    .where((r) => r.collection.eq('app.reaction').and(r.link('on').eq(link('on'))))
    .map((r) => r.author)
    .distinct()
    .count()
    .gte(5),
  'Needs five different people',
);
```

Throws when what it builds is not a condition the library would define.

## Type Parameters

| Type Parameter |
| ------ |
| <a id="type-parameter-c"></a> `C` *extends* `object` |

## Parameters

| Parameter | Type |
| ------ | ------ |
| `schema` | `C` |
| `that` | (`scope`) => [`BoolLike`](https://minca.dev/api/core/type-aliases/BoolLike.md) |
| `why` | `string` |

## Returns

[`Contract`](https://minca.dev/api/core/interfaces/Contract.md)
