-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathvalidateStrict.js
More file actions
29 lines (26 loc) · 930 Bytes
/
validateStrict.js
File metadata and controls
29 lines (26 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import * as mandatory from './lib/mandatoryTests.js'
import * as optional from './lib/optionalTests.js'
import * as informative from './lib/informativeTests.js'
import * as schema from './lib/schemaTests.js'
import validate from './lib/validate.js'
const validTests =
/** @type {import('./lib/shared/types.js').DocumentTest[]} */ (
Object.values(mandatory)
)
.concat(Object.values(optional))
.concat(Object.values(informative))
.concat(Object.values(schema))
/**
* @param {Array<import('./lib/shared/types.js').DocumentTest>} tests
* @param {any} doc
*/
export default async function (tests, doc) {
for (const test of tests) {
if (!validTests.includes(test)) {
throw new Error(
'Execution of test functions not defined in the library is prohibited. See https://github.com/secvisogram/csaf-validator-lib#strict-mode for more details.'
)
}
}
return validate(tests, doc)
}