Skip to content
This repository was archived by the owner on Apr 7, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions validation/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const validate = (schemaFile, objectFile, object) => {
const validated = ajv.validate(schema, object);
const passValue = validated ? "PASS" : "FAIL";
console.log(`${objectFile} <- ${schemaFile} : ${passValue}`);
if (!validated) console.log(ajv.errors)
return validated;
};

Expand All @@ -30,13 +31,13 @@ let passCount = 0;
for (let schemaFile of schemaFiles) {
// TODO: Validate each model schema matches the base schema.
const exampleFiles = globSync(
path.join(path.dirname(schemaFile), "examples/*.json")
path.join(path.dirname(schemaFile), "examples/**/*.json")
);
for (let exampleFile of exampleFiles) {
testCount++;
const exampleObj = JSON.parse(fs.readFileSync(exampleFile));
const baseSchemaPassed = validate(baseSchemaFile, exampleFile);
const metadataSchemaPassed = validate(metadataSchemaFile, exampleFile, {metadata: exampleObj["metadata"] || {}});
const metadataSchemaPassed = validate(metadataSchemaFile, exampleFile, { metadata: exampleObj["metadata"] || {} });
const filePassed = validate(schemaFile, exampleFile);
// The validation is true only if everything passes all the times. One failure and you're out!
const testPassed = baseSchemaPassed & metadataSchemaPassed & filePassed;
Expand Down