var Validator = require(‘jsonschema’).Validator;var v = new Validator(); // Address, to be embedded on Personvar addressSchema = { “id”: “/SimpleAddress”, “type”: “object”, “properties”: { “lines”: { “type”: “array”, “items”: {“type”: “string”} }, “zip”: {“type”: “string”}, “city”: {“type”: “string”}, “country”: {“type”: “string”} }, “required”: [“country”]}; // Personvar schema = { “id”: “/SimplePerson”, “type”: “object”, “properties”: { “name”: {“type”: “string”}, “address”: {“$ref”: “/SimpleAddress”}, “votes”: {“type”: “integer”, “minimum”: 1} }}; var p = { “name”: “Barack Obama”, “address”: { “lines”: [ “1600 Pennsylvania Avenue Northwest” ], “zip”: “DC 20500”, “city”: “Washington”, “country”: “USA” }, “votes”: “lots”}; v.addSchema(addressSchema, ‘/SimpleAddress’);console.log(v.validate(p, schema)); Here is what the above code is Doing: 1. Create a Validator object. 2. Define a schema for an address. 3. Define a schema for a person. 4. Create a person object. 5. Add the address schema to the Validator object. 6. Validate the person object against the person schema.