# sanitizeForJsonb

**Kind:** Function

**Source:** [`atloria-monorepo/apps/api/src/technical-docs/sanitize-jsonb.ts`](https://github.com/sherkety/atloria/blob/main/atloria-monorepo/apps/api/src/technical-docs/sanitize-jsonb.ts#L10)

Deep-sanitize a value before persisting it into a Postgres `jsonb` column.

Postgres `jsonb` cannot store the NUL character (U+0000) and chokes on other C0 control
characters. These leak in from parsed source (minified bundles, generated/binary-ish files)
and, at monorepo scale, a single bad byte deep in a multi-megabyte snapshot fails the whole
upsert with `unexpected end of hex escape`. Strip them (and lone UTF-16 surrogates, which are
not valid text) so the snapshot always persists. Tab / newline / carriage-return are kept.

## Signature

```ts
function sanitizeForJsonb(value: T): T
```

## Parameters

| Name | Type |
|---|---|
| `value` | `T` |

**Returns:** `T`
