I’m trying to validate this scheme and don’t understand why it failed.
{
“id”: 1,
“displayName”: “Age”,
“createdAt”: “2021-07-06T19:22:10Z”,
“modifiedAt”: “2021-07-06T19:22:10Z”
}
var Ajv = require(‘ajv’),
ajv = new Ajv({
logger: console,
allErrors: true,
verbose: true
}),
schema = {
“type”: “object”,
“properties”: {
“id”: {
“type”: “integer”
},
“displayName”: {
“type”: “string”
},
“createdAt”: {
“type”: “string”
},
“modifiedAt”: {
“type”: “string”
}
},
“required”: [
“id”,
“displayName”,
“createdAt”,
“modifiedAt”
]
};
pm.test(‘Schema is valid’, function () {
var data = pm.response.json();
pm.expect(ajv.validate(schema, data), printErrors(ajv)).to.be.true;
});