@aml-org/amf-custom-validator
Advanced tools
Comparing version 1.6.0 to 1.7.0-SNAPSHOT.1
22
index.js
@@ -10,3 +10,3 @@ require(__dirname + "/lib/wasm_exec_node"); | ||
const run = function(profile, data, debug) { | ||
const validateKernel = function(profile, data, debug) { | ||
let before = new Date() | ||
@@ -19,5 +19,13 @@ const res = __AMF__validateCustomProfile(profile,data, debug); | ||
const validateWithReportConfigurationKernel = function(profile, data, debug, reportConfig) { | ||
let before = new Date() | ||
const res = __AMF__validateCustomProfileWithConfiguration(profile,data, debug, undefined, reportConfig); | ||
let after = new Date(); | ||
if (debug) console.log("Elapsed : " + (after - before)) | ||
return res; | ||
} | ||
const validateCustomProfile = function(profile, data, debug, cb) { | ||
if (initialized) { | ||
let res = run(profile, data, debug); | ||
let res = validateKernel(profile, data, debug); | ||
cb(res,undefined); | ||
@@ -29,2 +37,11 @@ } else { | ||
const validateCustomProfileWithReportConfiguration = function(profile, data, debug, reportConfig, cb) { | ||
if (initialized) { | ||
let res = validateWithReportConfigurationKernel(profile, data, debug, reportConfig); | ||
cb(res,undefined); | ||
} else { | ||
cb(undefined,new Error("WASM/GO not initialized")) | ||
} | ||
} | ||
const runGenerateRego = function(profile) { | ||
@@ -88,4 +105,5 @@ const res = __AMF__generateRego(profile); | ||
module.exports.validate = validateCustomProfile; | ||
module.exports.validateWithReportConfiguration = validateCustomProfileWithReportConfiguration; | ||
module.exports.generateRego = generateRego; | ||
module.exports.normalizeInput = normalizeInput; | ||
module.exports.exit = exit; |
{ | ||
"name": "@aml-org/amf-custom-validator", | ||
"version": "1.6.0", | ||
"version": "1.7.0-SNAPSHOT.1", | ||
"description": "AMF validator backed by OPA Rego", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -96,2 +96,30 @@ const fs = require("fs"); | ||
}) | ||
describe('validate with configuration', () => { | ||
it("must match expected report output", (done) => { | ||
const profile = fs.readFileSync(__dirname + "/../../../test/data/integration/profile26/profile.yaml").toString() | ||
const data = fs.readFileSync(__dirname + "/../../../test/data/integration/profile26/negative.data.jsonld").toString() | ||
const validator = require(__dirname + "/../index") | ||
validator.initialize(() => { | ||
const reportConfig = { | ||
"IncludeReportCreationTime": false, | ||
"ReportSchemaIri": "http://a.ml/report", | ||
"LexicalSchemaIri": "http://a.ml/lexical" | ||
} | ||
validator.validateWithReportConfiguration(profile, data, false, reportConfig, (r, err) => { | ||
if (err) { | ||
done(err); | ||
} else { | ||
let report = JSON.parse(r) | ||
assert.ok(report[0]["doc:encodes"][0]["dateCreated"] === undefined) | ||
assert.strictEqual(report[0]["@context"]["reportSchema"], "http://a.ml/report#/declarations/") | ||
assert.strictEqual(report[0]["@context"]["lexicalSchema"], "http://a.ml/lexical#/declarations/") | ||
validator.exit(); | ||
done(); | ||
} | ||
}); | ||
}) | ||
}); | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5727999
739
2
12