mensagem de erro
const schema = {
type: "object",
required: ["foo", "bar"],
allOf: [
{
properties: {
foo: {type: "integer", minimum: 2},
bar: {type: "string", minLength: 2},
},
additionalProperties: false,
},
],
errorMessage: {
type: "data should be an object",
properties: {
foo: "data.foo should be integer >= 2",
bar: "data.bar should be string with length >= 2",
},
_: 'data should have properties "foo" and "bar" only',
},
}
const validate = ajv.compile(schema)
console.log(validate({})) // false
console.log(validate.errors) // processed errors
Average Addax