jsonschema - How do I validate a single JSON object against my schema containing all definitions? -
i built json schema in pieces, 1 schema per object need validate, , tested each component before moving on next. individually, work designed.
next, pasted schemas 1 big schema file , tried validate 1 of test objects against it. passed should have failed. appears none of schemas being applied , passing. specifically, in schema snippet included below, object has datainterfaceid
of -1
still passes validation. evertyhing worked until merged individual schemas 1 file.
this schema, trimmed down minimum necessary reproduce issue:
{ '$schema': 'http: //json-schema.org/draft-04/schema', 'type': 'object', 'id': 'http: //sampleuri/', 'required': false, 'properties': { 'equipmentschedule': { 'title': 'equipmentschedule', 'required': false, 'description': 'equipmentschedule', 'type': 'object', 'properties': { 'datainterfaceid': { 'type': 'integer', 'minimum': 1, 'required': true } } } } }
even if required elements missing, validation passes. why not working , how resolve issue? thanks!
sorry late response, draft 4 requirements implemented follows:
{ "$schema": "http: //json-schema.org/draft-04/schema", "type": "object", "id": "http: //sampleuri/", "properties": { "equipmentschedule": { "title": "equipmentschedule", "description": "equipmentschedule", "type": "object", "properties": { "datainterfaceid": { "type": "integer", "minimum": 1 } }, "required": [ "datainterfaceid" ] } } }
petru explained reasoning best, decided show example like.
Comments
Post a Comment