nikku / node-xsd-schema-validator

A schema (XSD) validator for NodeJS
https://www.npmjs.com/package/xsd-schema-validator
MIT License
52 stars 24 forks source link

Validation failing with "invalid xml" for incorrect file path #24

Open Lukenickerson opened 3 years ago

Lukenickerson commented 3 years ago

Describe the Bug

When providing the wrong path to a file, the error given is invalid xml (status=WITH_ERRORS). Nothing in the error points to the real problem: the path provided is not a file.

Steps to Reproduce

const validator = require('xsd-schema-validator');
const schemaFile = './path/to/schema.xsd';
const file = './foo.xml'; // Wrong path - file does not exist
validator.validateXML({ file }, schemaFile, function(err, result) {
   if (err) throw err;
});

Expected Behavior

Error should give some indication that the file you're trying to test is not actually where you think it was.

Environment

nikku commented 3 years ago

Thanks for raising this issue. Would you like to contribute a fix via a PR?