Using pg_jsonschema for JSON data integrity
JSON Schema (https://json-schema.org/) is a well-known and widespread standard of defining and enforcing JSON data structure. Within Supabase, you can activate the pg_jsonschema
database extension to be able to use utilities to confirm such JSON validation directly within Postgres. Now, I don’t want to explain this too deeply, but I want to give you a heads-up on what this can do for you.
The following SQL expression, with pg_jsonschema
extension activated, will return true
:
SELECT json_matches_schema( '{ "type": "object", "properties": { "foobar": { "type": "string" ...