MCPcopy
hub / github.com/NaturalIntelligence/fast-xml-parser / validate

Function validate

spec/validator_spec.js:15–37  ·  view source on GitHub ↗
(xmlData, error, line = 1, col)

Source from the content-addressed store, hash-verified

13const __dirname = dirname(__filename);
14
15function validate(xmlData, error, line = 1, col) {
16 const result = XMLValidator.validate(xmlData);
17 // console.log(result);
18 if (error) {
19
20 const keys = Object.keys(error);
21 const expected = {
22 code: keys[0],
23 msg: error[keys[0]],
24 line,
25 col,
26 };
27
28 // don't evaluate col if it is not set by the test case
29 if(col === undefined) {
30 delete expected.col;
31 delete result.err.col;
32 }
33 expect(result.err).toEqual(expected);
34 } else {
35 expect(result).toBe(true);
36 }
37}
38
39function validateFile(fileName, ...args) {
40 const fileNamePath = path.join(__dirname, "assets/" + fileName);

Callers 2

validateFileFunction · 0.70
validator_spec.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…