diff --git a/xsd-schema-validator/index.d.ts b/xsd-schema-validator/index.d.ts new file mode 100644 index 0000000000..ae321e563b --- /dev/null +++ b/xsd-schema-validator/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for xsd-schema-validator 0.5 +// Project: https://github.com/nikku/node-xsd-schema-validator#readme +// Definitions by: Zlatko Andonovski +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace XsdSchemaValidator { + export function validateXML(xml: string|NodeJS.ReadableStream|{file: string}, pathToXsd: string, callback: (err: Error, result: { + valid: boolean; + messages: string[]; + result: string; + }) => void): void; +} + +export = XsdSchemaValidator; \ No newline at end of file diff --git a/xsd-schema-validator/tsconfig.json b/xsd-schema-validator/tsconfig.json new file mode 100644 index 0000000000..2786abcd0a --- /dev/null +++ b/xsd-schema-validator/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "xsd-schema-validator-tests.ts" + ] +} diff --git a/xsd-schema-validator/tslint.json b/xsd-schema-validator/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/xsd-schema-validator/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/xsd-schema-validator/xsd-schema-validator-tests.ts b/xsd-schema-validator/xsd-schema-validator-tests.ts new file mode 100644 index 0000000000..f210198ade --- /dev/null +++ b/xsd-schema-validator/xsd-schema-validator-tests.ts @@ -0,0 +1,15 @@ +import fs = require("fs"); +import validator = require("xsd-schema-validator"); + + +validator.validateXML("", 'resources/foo.xsd', function(err, result) { + if (err) { + throw err; + } else return result.valid; +}); +validator.validateXML(fs.createReadStream('some.xml'), "schema.xsd", (err) => { + if (err) throw err; +}); +validator.validateXML({ file: "some.xml" }, "schema.xsd", (err) => { + if (err) throw err; +}); \ No newline at end of file