const Ajv = require("ajv"); const ajv = new Ajv(); const schema = { type: "object", properties: { name: { type: "string" }, age: { type: "integer" } }, required: ["name", "age"] }; const data = { name: "Ali", age: 25 }; const validate = ajv.compile(schema); const valid = validate(data); if (!valid) console.log(validate.errors); else console.log("Data is valid");