@bpmn-io/element-templates-validator 2.7.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -2
- package/dist/index.cjs +42 -20
- package/dist/index.js +42 -20
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -27,7 +27,6 @@ const {
|
|
|
27
27
|
if (!valid) {
|
|
28
28
|
console.error('Invalid JSON detected:', errors);
|
|
29
29
|
}
|
|
30
|
-
|
|
31
30
|
```
|
|
32
31
|
|
|
33
32
|
This will print detailed information about errors inside the sample:
|
|
@@ -59,7 +58,28 @@ This will print detailed information about errors inside the sample:
|
|
|
59
58
|
]
|
|
60
59
|
```
|
|
61
60
|
|
|
62
|
-
|
|
61
|
+
You can also pass a stringified template to ensure that the `dataPointers` of the errors reflect the correct position in the original string.
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
import { validate } from '@bpmn-io/element-templates-validator';
|
|
65
|
+
|
|
66
|
+
import { readFileSync } from 'node:fs';
|
|
67
|
+
|
|
68
|
+
const sample = readFileSync('./test/fixtures/rpa-broken.json', 'utf-8');
|
|
69
|
+
|
|
70
|
+
const {
|
|
71
|
+
valid,
|
|
72
|
+
errors
|
|
73
|
+
} = validate(sample);
|
|
74
|
+
|
|
75
|
+
if (!valid) {
|
|
76
|
+
console.error('Invalid JSON detected:', errors);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
If a parsed JSON object is passed, the `dataPointers` will assume that the source template is formatted with `JSON.stringify(template, null, 2)`.
|
|
81
|
+
|
|
82
|
+
It's also possible to validate multiple objects at once. In this case, the list of templates supports only objects, not strings.
|
|
63
83
|
|
|
64
84
|
```js
|
|
65
85
|
import { validateAll } from '@bpmn-io/element-templates-validator';
|