From 22a0d56c2ec8a7f5d4fd6bac4d508dd758d829f7 Mon Sep 17 00:00:00 2001 From: Goldsmith42 Date: Sat, 17 Dec 2016 04:06:58 +0100 Subject: [PATCH] Defintions for xsd-schema-validator (#13392) * Added definition for async-polling * async-polling tests with noImplicitAny * Definitions for xsd-schema-validator --- xsd-schema-validator/index.d.ts | 16 ++++++++++++++++ xsd-schema-validator/tsconfig.json | 19 +++++++++++++++++++ xsd-schema-validator/tslint.json | 1 + .../xsd-schema-validator-tests.ts | 15 +++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 xsd-schema-validator/index.d.ts create mode 100644 xsd-schema-validator/tsconfig.json create mode 100644 xsd-schema-validator/tslint.json create mode 100644 xsd-schema-validator/xsd-schema-validator-tests.ts 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