I have a schema to validate with Ajv in Node.js. There is a recurrent pattern on the properties of the json to convalidate, the possible keys value are 1,2,3,4,5. The question is, it’s possible with a regex expression to express only one property that will explain to ajv that the keys value of the json object could be an integer between one and five? And if so, how?
Below there is an example of the current code.
const Ajv = require("ajv")
const ajv = new Ajv()
const validate_setparameters = ajv.compile(
{
type: "object",
properties: {
"1": { type: "integer"},
"2": { type: "integer"},
"3": { type: "integer"},
"4": { type: "integer"},
"5": { type: "integer"}
},
additionalProperties: false,
minProperties: 1
}
)
console.log(validate_setparameters({"3":1}))