Sorry, we don't support your browser.  Install a modern browser

JSON Schema validation#32

The ability to write our own schema for our JSON fields would really help ensuring the constitency of our data stored in the DB.

This schema validation should be checked against when inserting/updating records through the UI, or through the API.

I’d suggest to use AJV which seems to be reliable JSON schema validator, with lots of built-in features: https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md

A benchmark of open source JSON Schema validators should be done, but AFAIK AJV is one of the most used out there, with great performances.

a year ago
Changed the title from "API - JSON Schema validation" to "JSON Schema validation"
a year ago
Merged into Field Validations#24
a year ago

JSON fields are very good when working on a draft model, or something that’s likely to change very regularly and we don’t want to change the API at every change, or want to try things out fast.

But they’re currently also very unfriendly to non-developers, mostly because we can store tons of stuff there and there is no schema validation, meaning a single misplaced “ can hurt our feelings. (see https://feedback.graphcms.com/32 about that)

The idea would be to use the schema validation to generate a better UI (basically, one input per field), so that editors can use a JSON field similarly to a native GraphCMS field. Obviously, this feature would highly rely on the schema validation to resolve fields types (visual aspect, validation, etc.)

A good first step would be to handle most-used types, such as:

url
integer
string
decimal
boolean

a year ago