-- allOf -- allOf SELECT is_jsonb_valid('{"allOf":[{"properties":{"bar":{"type":"integer"}},"required":["bar"]},{"properties":{"foo":{"type":"string"}},"required":["foo"]}]}', '{"foo":"baz","bar":2}'); is_jsonb_valid ---------------- t (1 row) -- mismatch second SELECT is_jsonb_valid('{"allOf":[{"properties":{"bar":{"type":"integer"}},"required":["bar"]},{"properties":{"foo":{"type":"string"}},"required":["foo"]}]}', '{"foo":"baz"}'); is_jsonb_valid ---------------- f (1 row) -- mismatch first SELECT is_jsonb_valid('{"allOf":[{"properties":{"bar":{"type":"integer"}},"required":["bar"]},{"properties":{"foo":{"type":"string"}},"required":["foo"]}]}', '{"bar":2}'); is_jsonb_valid ---------------- f (1 row) -- wrong type SELECT is_jsonb_valid('{"allOf":[{"properties":{"bar":{"type":"integer"}},"required":["bar"]},{"properties":{"foo":{"type":"string"}},"required":["foo"]}]}', '{"foo":"baz","bar":"quux"}'); is_jsonb_valid ---------------- f (1 row) -- allOf with base schema -- valid SELECT is_jsonb_valid('{"properties":{"bar":{"type":"integer"}},"required":["bar"],"allOf":[{"properties":{"foo":{"type":"string"}},"required":["foo"]},{"properties":{"baz":{"type":"null"}},"required":["baz"]}]}', '{"foo":"quux","bar":2,"baz":null}'); is_jsonb_valid ---------------- t (1 row) -- mismatch base schema SELECT is_jsonb_valid('{"properties":{"bar":{"type":"integer"}},"required":["bar"],"allOf":[{"properties":{"foo":{"type":"string"}},"required":["foo"]},{"properties":{"baz":{"type":"null"}},"required":["baz"]}]}', '{"foo":"quux","baz":null}'); is_jsonb_valid ---------------- f (1 row) -- mismatch first allOf SELECT is_jsonb_valid('{"properties":{"bar":{"type":"integer"}},"required":["bar"],"allOf":[{"properties":{"foo":{"type":"string"}},"required":["foo"]},{"properties":{"baz":{"type":"null"}},"required":["baz"]}]}', '{"bar":2,"baz":null}'); is_jsonb_valid ---------------- f (1 row) -- mismatch second allOf SELECT is_jsonb_valid('{"properties":{"bar":{"type":"integer"}},"required":["bar"],"allOf":[{"properties":{"foo":{"type":"string"}},"required":["foo"]},{"properties":{"baz":{"type":"null"}},"required":["baz"]}]}', '{"foo":"quux","bar":2}'); is_jsonb_valid ---------------- f (1 row) -- mismatch both SELECT is_jsonb_valid('{"properties":{"bar":{"type":"integer"}},"required":["bar"],"allOf":[{"properties":{"foo":{"type":"string"}},"required":["foo"]},{"properties":{"baz":{"type":"null"}},"required":["baz"]}]}', '{"bar":2}'); is_jsonb_valid ---------------- f (1 row) -- allOf simple types -- valid SELECT is_jsonb_valid('{"allOf":[{"maximum":30},{"minimum":20}]}', '25'); is_jsonb_valid ---------------- t (1 row) -- mismatch one SELECT is_jsonb_valid('{"allOf":[{"maximum":30},{"minimum":20}]}', '35'); is_jsonb_valid ---------------- f (1 row)