diff --git a/package.json b/package.json index 175b667..65141ac 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "@openactive/data-model-validator": "^2.0.0", "cache-parser": "^1.2.4", "jsonpath": "^1.1.1", + "lodash": "^4.17.21", "luxon": "^1.4.2", "node-fetch": "^2.2.0" } diff --git a/src/rules/page/required-property-values-rule.js b/src/rules/page/required-property-values-rule.js index 36d5b5c..7b42db1 100644 --- a/src/rules/page/required-property-values-rule.js +++ b/src/rules/page/required-property-values-rule.js @@ -1,3 +1,4 @@ +const _ = require('lodash'); const { ValidationErrorCategory, ValidationErrorSeverity, @@ -141,8 +142,7 @@ const RequiredPropertyValuesRule = class extends RpdeRule { if (node.data.items instanceof Array) { for (const item of node.data.items) { if ( - typeof item !== 'object' - || item instanceof Array + !_.isPlainObject(item) ) { invalidProps.item += 1; } @@ -172,7 +172,7 @@ const RequiredPropertyValuesRule = class extends RpdeRule { } if ( typeof item.data !== 'undefined' - && (typeof item.data !== 'object' || item.data instanceof Array) + && !_.isPlainObject(item.data) ) { invalidProps.data += 1; }