dirigible
dirigible copied to clipboard
[Templates] Integrate JSON Schema Validator
Integrate JSON Schema Validator like AJV in Dirigible:
- https://github.com/ajv-validator/ajv
- https://ajv.js.org/
Applicable for use cases of BPMN, EDM, API level or in samples:
const Ajv = require("ajv")
const ajv = new Ajv()
const schema = {
type: "object",
properties: {
foo: {type: "integer"},
bar: {type: "string"}
},
required: ["foo"],
additionalProperties: false
}
const data = {foo: 1, bar: "abc"}
const valid = ajv.validate(schema, data)
if (!valid) console.log(ajv.errors)
Available as WebJar dependency:
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>ajv</artifactId>
<version>8.11.0</version>
</dependency>
It should be possible to require the WebJar as follows:
let Ajv = require("/webjars/ajv/8.11.0/dist/ajv");
let ajv = new Ajv();
Related to:
- https://github.com/eclipse/dirigible/issues/2132