Skip to content

Conversation

@tsibley
Copy link
Member

@tsibley tsibley commented Jul 23, 2021

Example of using JSON Schema to validate or partially validate/constrain some of our document or details columns. Outdated due to early format for receiving.presence_absence that was never used, but usage of JSON Schema in the database maybe useful to think about again as the API surface increases.

tsibley added 2 commits April 9, 2019 11:38
Vendors <https://github.com/gavinwahl/postgres-json-schema> by
unbundling the extension into a vanilla function.

Since we intend to stay compatible with cloud database providers (Azure,
AWS), we can't install custom Pg extensions.  Luckily, this JSON Schema
extension is written in PL/pgSQL and under an MIT-style license, which
means we can vendor the definitions very easily ourselves.

I tweaked the functions to mark them parallel-safe and to return null
(instead of true!) when given a null JSON document to validate.
Light validation to ensure consistent high-level structure while leaving
the identifiers for source and target material up to convention.

JSON Schema validation happens in the database itself, following the
principle of making the database the ultimate authority on data
integrity and validation.
@tsibley tsibley changed the title trs/wip/json schema trs/wip/json-schema Jul 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants