Skip to content

is_jsonb_valid

Native JSONB validation against JSON Schema drafts 4 and 7

Overview

PackageVersionCategoryLicenseLanguage
is_jsonb_valid0.1.4FEATMITC
IDExtensionBinLibLoadCreateTrustRelocSchema
2765is_jsonb_validNoYesNoYesNoNo-
Relatedpg_jsonschema jsonschema postgres-json-schema jsquery

Remote $ref and format validation are unsupported; local $ref resolution is limited. Ships two libraries under one extension identity.

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY0.1.41817161514is_jsonb_valid-
RPMPIGSTY0.1.41817161514is_jsonb_valid_$v-
DEBPIGSTY0.1.41817161514postgresql-$v-is-jsonb-valid-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
el8.aarch64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
el9.x86_64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
el9.aarch64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
el10.x86_64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
el10.aarch64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
d12.x86_64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
d12.aarch64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
d13.x86_64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
d13.aarch64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
u22.x86_64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
u22.aarch64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
u24.x86_64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
u24.aarch64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
u26.x86_64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
u26.aarch64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4

Build

You can build the RPM / DEB packages for is_jsonb_valid using pig build:

pig build pkg is_jsonb_valid         # build RPM / DEB packages

Install

You can install is_jsonb_valid directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add repo and update cache

Install the extension using pig or apt/yum/dnf:

Install
pig install is_jsonb_valid;          # Install for current active PG version
pig
pig ext install -y is_jsonb_valid -v 18  # PG 18
pig ext install -y is_jsonb_valid -v 17  # PG 17
pig ext install -y is_jsonb_valid -v 16  # PG 16
pig ext install -y is_jsonb_valid -v 15  # PG 15
pig ext install -y is_jsonb_valid -v 14  # PG 14
dnf
dnf install -y is_jsonb_valid_18       # PG 18
dnf install -y is_jsonb_valid_17       # PG 17
dnf install -y is_jsonb_valid_16       # PG 16
dnf install -y is_jsonb_valid_15       # PG 15
dnf install -y is_jsonb_valid_14       # PG 14
apt
apt install -y postgresql-18-is-jsonb-valid   # PG 18
apt install -y postgresql-17-is-jsonb-valid   # PG 17
apt install -y postgresql-16-is-jsonb-valid   # PG 16
apt install -y postgresql-15-is-jsonb-valid   # PG 15
apt install -y postgresql-14-is-jsonb-valid   # PG 14

Create Extension:

CREATE EXTENSION is_jsonb_valid;

Usage

Sources:

is_jsonb_valid provides native boolean validation of JSONB values against JSON Schema Draft 4 or Draft 7. It is suitable for checks and predicates that need only pass/fail output; it does not return a path or diagnostic explaining a failed keyword.

Core Workflow

Choose the function that matches the schema draft and pass the schema first, followed by the value being validated.

CREATE EXTENSION is_jsonb_valid;

SELECT is_jsonb_valid(
    '{"type":"object","required":["id"],"properties":{"id":{"type":"integer"}}}'::jsonb,
    '{"id":42}'::jsonb
);

SELECT is_jsonb_valid_draft_v7(
    '{"if":{"exclusiveMaximum":0},"else":{"multipleOf":2}}'::jsonb,
    '4'::jsonb
);

The two functions are strict and immutable in version 0.1.4. This makes them usable in constraints and indexes when the schema is stable.

CREATE TABLE events (
    payload jsonb NOT NULL,
    CONSTRAINT events_payload_valid CHECK (
        is_jsonb_valid(
            '{"type":"object","required":["id"]}'::jsonb,
            payload
        )
    )
);

Draft Boundary and Limitations

The base validator follows Draft 4; the explicitly named alternative follows Draft 7. Select deliberately, because keyword meaning differs between drafts and the extension does not infer the draft from a schema declaration.

At the pinned revision, remote references are unsupported. Local references are limited to definitions reachable from the schema root, and identifier changes along a reference chain are not resolved. Format validation is also unsupported. These gaps mean a true result is only a claim about the implemented subset, not every behavior in the complete JSON Schema specifications.

No preload or restart is declared. Keep schema literals and application expectations under version control, and add representative valid and invalid cases whenever a constraint depends on this extension.

Was this page helpful?