# JSON Schema checks for jsonb

> pg_jsonschema check constraints for jsonb columns with a `schema` in the `json` config, so the database enforces the same shape as the types. A trigger reports what failed through jsonschema_validation_errors, which the client maps to a validation error.

- Category: Database primitives
- Module: `jsonb-schemas`
- Modes: `managed`
- Docs: https://bettersupabase.com/docs/blocks/jsonb-schemas
- Page: https://bettersupabase.com/blocks/jsonb-schemas

## Install

```bash
npx better-supabase add jsonb-schemas
```

## Configure

Add the block to `better-supabase.config.ts`:

```ts
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  blocks: {
    // Modes: "managed". The default is "managed".
    "jsonb-schemas": { mode: "managed" },
  },
});
```

## Client

The block is SQL only: call its functions from your policies, RPCs and the other modules.
