@bpmn-io/element-templates-validator

2.3.3 • Public • Published

element-templates-validator

CI

Validate element templates based on JSON Schema.

Installation

npm i --save @bpmn-io/element-templates-validator

Usage

Given an example element template:

import { validate } from '@bpmn-io/element-templates-validator';

import sample from './test/fixtures/rpa-broken.json';

const {
  valid,
  errors
} = validate(sample);

if (!valid) {
  console.error('Invalid JSON detected:', errors);
}

This will print detailed information about errors inside the sample:

[
  {
    "keyword": "type",
    "dataPath": "",
    "schemaPath": "#/type",
    "params": {
      "type": "object"
    },
    "message": "must be object",
    "dataPointer": {
      "value": {
        "line": 0,
        "column": 0,
        "pos": 0
      },
      "valueEnd": {
        "line": 177,
        "column": 1,
        "pos": 4825
      }
    }
  }
  ...
]

It's also possible to validate multiple objects at once

import { validateAll } from '@bpmn-io/element-templates-validator';

import samples from './test/fixtures/multiple-errors.json';

const {
  valid,
  results
} = validateAll(samples);

if (!valid) {
  console.error('Invalid JSON objects detected:', results.filter(r => !r.valid));
}

License

MIT

/@bpmn-io/element-templates-validator/

    Package Sidebar

    Install

    npm i @bpmn-io/element-templates-validator

    Weekly Downloads

    8,515

    Version

    2.3.3

    License

    MIT

    Unpacked Size

    869 kB

    Total Files

    5

    Last publish

    Collaborators

    • bpmn-io-admin
    • nikku
    • barmac
    • philippfromme
    • maxtru
    • abdul99ahad
    • skaiir-camunda
    • vsgoulart
    • jarekdanielak
    • simon-steinruecken-camunda