json - Create a schema to check a column isn't null -
if have json table-like structure looks this:
{ "table": { "rows": [ [ 0, null, 1, 2, null ], [ null, 1, 2, 3, null ], [ 1, 2, 3, null, null ], [ null, null, 1, 2, 1 ] ] }
i can validate schema (note, i'm using draft 3 because that's library validating schema using, draft 4 might possible if go find different library):
{ "$schema": "http://json-schema.org/draft-03/schema#", "title": "table data", "description": "a table @ least 1 row of data 5 columns per row", "type": "object", "properties": { "table" : { "description" : "a table", "type": "object", "properties": { "rows": { "required" : true, "description": "an array of rows", "type" : "array", "minitems" : 1, "items" : { "type": "array", "minitems": 5, "maxitems": 5 } } }, "required":true } } }
this checking have table
, table
has rows
rows
array @ least 1 item. rows arrays , arrays have 5
items (columns). easy enough.
what check is, each column (0...4
) there exists at least 1 row
value not null. possible express in json schema? or beyond can done it.
Comments
Post a Comment