# `Dimensions`

A box's length, width and height.

Use it for parcels and products. For a picture's size in pixels, use [`ImageDimensions`](/docs/types/type-image-dimensions.md). For one measurement, use [`Length`](/docs/types/type-length.md).

## Shape

| Field | Type | Required? |
|---|---|---|
| `length` | [`Length`](/docs/types/type-length.md) | Yes |
| `width` | [`Length`](/docs/types/type-length.md) | Yes |
| `height` | [`Length`](/docs/types/type-length.md) | Yes |

## Example

```jadpo
Dimensions { length: 30cm width: 20cm height: 10cm }
```

## Good to know

- None can be below zero. `text.format` shows centimetres, `30 × 20 × 10 cm`, or another unit with `unit:`.
- `==` tells you whether two are the same. `<` and `list.sort_by` don't take it, so sort by one of its parts instead.

## In JSON

An object of its parts, in a request, a response or `json.write`:

```json
{"length":{"value":"0.3","unit":"metre"},"width":{"value":"0.2","unit":"metre"},"height":{"value":"0.1","unit":"metre"}}
{"length":{"value":"1.2","unit":"metre"},"width":{"value":"0.8","unit":"metre"},"height":{"value":"0.144","unit":"metre"}}
{"length":{"value":"0.3048","unit":"metre"},"width":{"value":"0.2286","unit":"metre"},"height":{"value":"0.1016","unit":"metre"}}
```

## Details

<details>
<summary>Text form, storage, how it is shown, and operations</summary>

`Dimensions` is in the group Commerce and logistics, and has been in Jadpo since 0.1.0.

### Text form

It has no single text form, so `text.from` and `text.parse` don't take it.

### How it is stored

It is stored in 3 columns, each named for the field, `_` and its suffix. This is `{"length":{"value":"1.2","unit":"metre"},"width":{"value":"0.8","unit":"metre"},"height":{"value":"0.144","unit":"metre"}}`:

| Column | Type | Holds |
|---|---|---|
| `<field>_length` | `numeric(38, 6)` | `1.2` |
| `<field>_width` | `numeric(38, 6)` | `0.8` |
| `<field>_height` | `numeric(38, 6)` | `0.144` |

### How it is shown to people

`text.format(value, locale:)` shows it to people in their locale. A call may also give `unit:`.

With `locale: Locale.en_gb`:

| Value | Shown |
|---|---|
| `{"length":{"value":"0.3","unit":"metre"},"width":{"value":"0.2","unit":"metre"},"height":{"value":"0.1","unit":"metre"}}` | `30 × 20 × 10 cm` |
| `{"length":{"value":"1.2","unit":"metre"},"width":{"value":"0.8","unit":"metre"},"height":{"value":"0.144","unit":"metre"}}` | `120 × 80 × 14.4 cm` |
| `{"length":{"value":"12","unit":"inch"},"width":{"value":"9","unit":"inch"},"height":{"value":"4","unit":"inch"}}` | `30.48 × 22.86 × 10.16 cm` |

### Operations

It also takes `text.format`, `json.read`, `json.write` and `==`. [How every standard type behaves](/docs/every-standard-type-meets-one-contract.md) says how they work.

</details>
