@mml-io/mml-schema-validator 0.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +51 -0
- package/build/index.js.map +7 -0
- package/package.json +21 -0
- package/src/declaration.d.ts +4 -0
- package/src/index.ts +1 -0
- package/src/validate.ts +11 -0
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# MML Schema Validator
|
|
2
|
+
|
|
3
|
+
This package contains:
|
|
4
|
+
* [`src/validate.ts`](./src/validate.ts) - A function that validates an MML document against the schema.
|
|
5
|
+
* [`test/`](./test) - A set of tests that are used to validate the schema is valid against known-valid documents.
|
|
6
|
+
|
|
7
|
+
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../src/index";
|
package/build/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/index.ts
|
|
30
|
+
var src_exports = {};
|
|
31
|
+
__export(src_exports, {
|
|
32
|
+
validateMMLDocument: () => validateMMLDocument
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(src_exports);
|
|
35
|
+
|
|
36
|
+
// src/validate.ts
|
|
37
|
+
var import_mml_schema = require("@mml-io/mml-schema");
|
|
38
|
+
var import_xsd_validator = __toESM(require("xsd-validator"));
|
|
39
|
+
function validateMMLDocument(document) {
|
|
40
|
+
const result = (0, import_xsd_validator.default)(document, import_mml_schema.schemaXML);
|
|
41
|
+
if (result === true) {
|
|
42
|
+
return null;
|
|
43
|
+
} else {
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
validateMMLDocument
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts", "../src/validate.ts"],
|
|
4
|
+
"sourcesContent": ["export * from \"./validate\";\n", "import { schemaXML } from \"@mml-io/mml-schema\";\nimport validateAgainstSchema from \"xsd-validator\";\n\nexport function validateMMLDocument(document: string): Array<Error> | null {\n const result = validateAgainstSchema(document, schemaXML);\n if (result === true) {\n return null;\n } else {\n return result;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,wBAA0B;AAC1B,2BAAkC;AAE3B,SAAS,oBAAoB,UAAuC;AACzE,QAAM,aAAS,qBAAAA,SAAsB,UAAU,2BAAS;AACxD,MAAI,WAAW,MAAM;AACnB,WAAO;AAAA,EACT,OAAO;AACL,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": ["validateAgainstSchema"]
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mml-io/mml-schema-validator",
|
|
3
|
+
"version": "0.0.42",
|
|
4
|
+
"main": "./build/index.js",
|
|
5
|
+
"types": "./build/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"/build",
|
|
8
|
+
"/src"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"type-check": "tsc --noEmit",
|
|
12
|
+
"build": "node ./build.js --build",
|
|
13
|
+
"iterate": "node ./build.js --watch",
|
|
14
|
+
"npm-publish": "npm run build && publish-if-not-exists --access=public",
|
|
15
|
+
"test": "jest"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@mml-io/mml-schema": "^0.0.42",
|
|
19
|
+
"xsd-validator": "1.0.2"
|
|
20
|
+
}
|
|
21
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./validate";
|
package/src/validate.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { schemaXML } from "@mml-io/mml-schema";
|
|
2
|
+
import validateAgainstSchema from "xsd-validator";
|
|
3
|
+
|
|
4
|
+
export function validateMMLDocument(document: string): Array<Error> | null {
|
|
5
|
+
const result = validateAgainstSchema(document, schemaXML);
|
|
6
|
+
if (result === true) {
|
|
7
|
+
return null;
|
|
8
|
+
} else {
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
}
|