I have a column that stores json. I am trying to make sure that only an array of objects can be stored in this column as described in the json schema below. The schema is working except for that I am able to save the attribute show
as a string when it should be forced to be a boolean. For example, [{"name"=>"primary_phone", "show"=> "some text"}]
is saving correctly but it shouldn't. How do I enforce that show must be a boolean?
{
"type": "array",
"items": {
"definitions": {
"name": { "type": "string" },
"show": {"type": "boolean"}
},
"required": ["name", "show"]
}
}
CodePudding user response:
Your schema under "items" is invalid. Perhaps you meant "properties" instead of "definitions"?