2.0.1 • Published 2 months ago
@bpmn-io/element-templates-validator v2.0.1
element-templates-validator
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
2.0.1
2 months ago
1.8.2
3 months ago
2.0.0
3 months ago
1.8.1
3 months ago
1.8.0
3 months ago
1.7.0
5 months ago
1.6.1
5 months ago
1.2.0
7 months ago
1.1.0
8 months ago
1.0.0
8 months ago
1.6.0
5 months ago
1.5.0
6 months ago
1.4.0
6 months ago
0.15.0
9 months ago
0.14.0
1 year ago
0.13.0
1 year ago
0.12.0
1 year ago
0.11.0
2 years ago
0.10.0
2 years ago
0.9.0
2 years ago
0.8.1
2 years ago
0.8.0
2 years ago
0.7.0
2 years ago
0.6.0
2 years ago
0.5.0
2 years ago
0.4.0
2 years ago
0.3.0
3 years ago
0.2.0
3 years ago
0.1.0
3 years ago