@kumologica/builder
Version:
Kumologica build and deploy module
34 lines (29 loc) • 724 B
JavaScript
const Ajv = require('ajv');
const klSchema = require('./kl-flow-schema.json');
const validateKumologicaFlow = (flowContent) => {
const ajv = new Ajv();
try {
const validate = ajv.compile(klSchema);
// Validate the document against the schema
const valid = validate(flowContent);
if (valid) {
return {
valid: true,
errors: undefined
}
} else {
return {
valid: false,
errors: validate.errors
}
}
}catch(err){
return {
valid: false,
errors: err
}
}
}
module.exports = {
validateKumologicaFlow
}