-- uniqueItems validation -- unique array of integers is valid SELECT is_jsonb_valid('{"uniqueItems":true}', '[1,2]'); is_jsonb_valid ---------------- t (1 row) -- non-unique array of integers is invalid SELECT is_jsonb_valid('{"uniqueItems":true}', '[1,1]'); is_jsonb_valid ---------------- f (1 row) -- numbers are unique if mathematically unequal SELECT is_jsonb_valid('{"uniqueItems":true}', '[1,1,1]'); is_jsonb_valid ---------------- f (1 row) -- unique array of objects is valid SELECT is_jsonb_valid('{"uniqueItems":true}', '[{"foo":"bar"},{"foo":"baz"}]'); is_jsonb_valid ---------------- t (1 row) -- non-unique array of objects is invalid SELECT is_jsonb_valid('{"uniqueItems":true}', '[{"foo":"bar"},{"foo":"bar"}]'); is_jsonb_valid ---------------- f (1 row) -- unique array of nested objects is valid SELECT is_jsonb_valid('{"uniqueItems":true}', '[{"foo":{"bar":{"baz":true}}},{"foo":{"bar":{"baz":false}}}]'); is_jsonb_valid ---------------- t (1 row) -- non-unique array of nested objects is invalid SELECT is_jsonb_valid('{"uniqueItems":true}', '[{"foo":{"bar":{"baz":true}}},{"foo":{"bar":{"baz":true}}}]'); is_jsonb_valid ---------------- f (1 row) -- unique array of arrays is valid SELECT is_jsonb_valid('{"uniqueItems":true}', '[["foo"],["bar"]]'); is_jsonb_valid ---------------- t (1 row) -- non-unique array of arrays is invalid SELECT is_jsonb_valid('{"uniqueItems":true}', '[["foo"],["foo"]]'); is_jsonb_valid ---------------- f (1 row) -- 1 and true are unique SELECT is_jsonb_valid('{"uniqueItems":true}', '[1,true]'); is_jsonb_valid ---------------- t (1 row) -- 0 and false are unique SELECT is_jsonb_valid('{"uniqueItems":true}', '[0,false]'); is_jsonb_valid ---------------- t (1 row) -- unique heterogeneous types are valid SELECT is_jsonb_valid('{"uniqueItems":true}', '[{},[1],true,null,1]'); is_jsonb_valid ---------------- t (1 row) -- non-unique heterogeneous types are invalid SELECT is_jsonb_valid('{"uniqueItems":true}', '[{},[1],true,null,{},1]'); is_jsonb_valid ---------------- f (1 row)