-- dependencies -- neither SELECT is_jsonb_valid('{"dependencies":{"bar":["foo"]}}', '{}'); is_jsonb_valid ---------------- t (1 row) -- nondependant SELECT is_jsonb_valid('{"dependencies":{"bar":["foo"]}}', '{"foo":1}'); is_jsonb_valid ---------------- t (1 row) -- with dependency SELECT is_jsonb_valid('{"dependencies":{"bar":["foo"]}}', '{"foo":1,"bar":2}'); is_jsonb_valid ---------------- t (1 row) -- missing dependency SELECT is_jsonb_valid('{"dependencies":{"bar":["foo"]}}', '{"bar":2}'); is_jsonb_valid ---------------- f (1 row) -- ignores arrays SELECT is_jsonb_valid('{"dependencies":{"bar":["foo"]}}', '["bar"]'); is_jsonb_valid ---------------- t (1 row) -- ignores strings SELECT is_jsonb_valid('{"dependencies":{"bar":["foo"]}}', '"foobar"'); is_jsonb_valid ---------------- t (1 row) -- ignores other non-objects SELECT is_jsonb_valid('{"dependencies":{"bar":["foo"]}}', '12'); is_jsonb_valid ---------------- t (1 row) -- multiple dependencies -- neither SELECT is_jsonb_valid('{"dependencies":{"quux":["foo","bar"]}}', '{}'); is_jsonb_valid ---------------- t (1 row) -- nondependants SELECT is_jsonb_valid('{"dependencies":{"quux":["foo","bar"]}}', '{"foo":1,"bar":2}'); is_jsonb_valid ---------------- t (1 row) -- with dependencies SELECT is_jsonb_valid('{"dependencies":{"quux":["foo","bar"]}}', '{"foo":1,"bar":2,"quux":3}'); is_jsonb_valid ---------------- t (1 row) -- missing dependency SELECT is_jsonb_valid('{"dependencies":{"quux":["foo","bar"]}}', '{"foo":1,"quux":2}'); is_jsonb_valid ---------------- f (1 row) -- missing other dependency SELECT is_jsonb_valid('{"dependencies":{"quux":["foo","bar"]}}', '{"bar":1,"quux":2}'); is_jsonb_valid ---------------- f (1 row) -- missing both dependencies SELECT is_jsonb_valid('{"dependencies":{"quux":["foo","bar"]}}', '{"quux":1}'); is_jsonb_valid ---------------- f (1 row) -- multiple dependencies subschema -- valid SELECT is_jsonb_valid('{"dependencies":{"bar":{"properties":{"foo":{"type":"integer"},"bar":{"type":"integer"}}}}}', '{"foo":1,"bar":2}'); is_jsonb_valid ---------------- t (1 row) -- no dependency SELECT is_jsonb_valid('{"dependencies":{"bar":{"properties":{"foo":{"type":"integer"},"bar":{"type":"integer"}}}}}', '{"foo":"quux"}'); is_jsonb_valid ---------------- t (1 row) -- wrong type SELECT is_jsonb_valid('{"dependencies":{"bar":{"properties":{"foo":{"type":"integer"},"bar":{"type":"integer"}}}}}', '{"foo":"quux","bar":2}'); is_jsonb_valid ---------------- f (1 row) -- wrong type other SELECT is_jsonb_valid('{"dependencies":{"bar":{"properties":{"foo":{"type":"integer"},"bar":{"type":"integer"}}}}}', '{"foo":2,"bar":"quux"}'); is_jsonb_valid ---------------- f (1 row) -- wrong type both SELECT is_jsonb_valid('{"dependencies":{"bar":{"properties":{"foo":{"type":"integer"},"bar":{"type":"integer"}}}}}', '{"foo":"quux","bar":"quux"}'); is_jsonb_valid ---------------- f (1 row)