# `Uuid`

A universally unique identifier, in lower case with hyphens.

Use it as an id for records. Jadpo generates version 7 for a new record's `id`. For a sortable id as shorter text, use [`Ulid`](/docs/types/type-ulid.md).

## Shape

One value, with no fields to fill in. As text it reads `0192f0c4-9a1e-7b3c-8d2e-4f5a6b7c8d9e`.

## Example

```jadpo
Uuid("0192f0c4-9a1e-7b3c-8d2e-4f5a6b7c8d9e")
```

`text.parse(raw, as: Uuid)` reads one from text that comes from outside. Text that isn't one at all fails `malformed`, such as `0192f0c4` or `not-a-uuid`.

## Good to know

- It accepts any version. A type built on it can fix one with `version:`.
- `==` tells you whether two are the same. `<` and `list.sort_by` don't take it.

## In JSON

A string, in a request, a response or `json.write`:

```json
"0192f0c4-9a1e-7b3c-8d2e-4f5a6b7c8d9e"
```

## Details

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

`Uuid` is in the group Software, and has been in Jadpo since 0.1.0.

### Text form

`text.from` writes one standard text form, the same form `text.parse` reads back: `0192f0c4-9a1e-7b3c-8d2e-4f5a6b7c8d9e`.

### How it is stored

It is stored in one column named for the field, of type `uuid`. `0192f0c4-9a1e-7b3c-8d2e-4f5a6b7c8d9e` is stored as `'0192f0c4-9a1e-7b3c-8d2e-4f5a6b7c8d9e'::uuid`.

### How it is shown to people

`text.format(value, locale:)` shows it to people in their locale.

With `locale: Locale.en_gb`:

| Value | Shown |
|---|---|
| `0192f0c4-9a1e-7b3c-8d2e-4f5a6b7c8d9e` | `0192f0c4-9a1e-7b3c-8d2e-4f5a6b7c8d9e` |

### Operations

It also takes `text.parse`, `text.from`, `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>
