@aml-org/amf-custom-validator 1.3.0-SNAPSHOT.91 → 1.3.0-SNAPSHOT.93

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/lib/main.wasm.gz CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aml-org/amf-custom-validator",
3
- "version": "1.3.0-SNAPSHOT.91",
3
+ "version": "1.3.0-SNAPSHOT.93",
4
4
  "description": "AMF validator backed by OPA Rego",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/test/simple.js CHANGED
@@ -1,14 +1,14 @@
1
1
  const fs = require("fs");
2
2
  var assert = require('assert');
3
3
 
4
+ function invalidReport(report) {
5
+ return report[0]["doc:encodes"][0]["conforms"] === false
6
+ }
7
+
4
8
  describe('validator', () => {
5
9
 
6
10
  describe('validate', () => {
7
11
 
8
- function invalidReport(report) {
9
- return report[0]["doc:encodes"][0]["conforms"] === false
10
- }
11
-
12
12
  it("should load the WASM code, validate a profile, exit", (done) => {
13
13
  const profile = fs.readFileSync(__dirname + "/../../../test/data/integration/profile10/profile.yaml").toString()
14
14
  const data = fs.readFileSync(__dirname + "/../../../test/data/integration/profile10/negative.data.jsonld").toString()
@@ -72,4 +72,25 @@ describe('validator', () => {
72
72
  })
73
73
 
74
74
  })
75
+
76
+ describe('validate with message expressions', () => {
77
+
78
+ it("validate and compute message expression value", (done) => {
79
+ const profile = fs.readFileSync(__dirname + "/../../../test/data/integration/profile26/profile.yaml").toString()
80
+ const data = fs.readFileSync(__dirname + "/../../../test/data/integration/profile26/negative.data.jsonld").toString()
81
+ const validator = require(__dirname + "/../index")
82
+ validator.initialize(() => {
83
+ validator.validate(profile, data, false, (r, err) => {
84
+ if (err) {
85
+ done(err);
86
+ } else {
87
+ let report = JSON.parse(r)
88
+ assert.ok(report[0]["doc:encodes"][0]["result"][0]["resultMessage"] === "Movie 'Disaster Movie' has a rating of 1.9 but it does not have at least 10 reviews (actual reviews: 5) to support that rating")
89
+ validator.exit();
90
+ done();
91
+ }
92
+ });
93
+ })
94
+ });
95
+ })
75
96
  })