diff --git a/lib/validator.js b/lib/validator.js index 798d3e0..c8700aa 100644 --- a/lib/validator.js +++ b/lib/validator.js @@ -381,24 +381,26 @@ class Validator { let id = "datePublishedFormat" let clause = `datePublished: MUST be a string in [ISO 8601 date format][DateTime] and SHOULD be specified to at least the precision of a day, MAY be a timestamp down to the millisecond.` if (root?.datePublished) { - if (!root.datePublished[0].match(/^\d{4}-?([0]\d|1[0-2])?-?([0-2]\d|3[01])?/)) { - this.log( - { - id, - status: "error", - message: `datePublished does not start with a compliant date in this format: YYYY, YYYY-MM or YYYY-MM-DD`, - clause - } - ); - } else { - this.log( - { - id, - status: "success", - message: "datePublished is in compliant format.", - clause - } - ); + for(let dP of root.datePublished) { + if (dP && !dP.match(/^\d{4}-?([0]\d|1[0-2])?-?([0-2]\d|3[01])?/)) { + this.log( + { + id, + status: "error", + message: `datePublished does not start with a compliant date in this format: YYYY, YYYY-MM or YYYY-MM-DD`, + clause + } + ); + } else { + this.log( + { + id, + status: "success", + message: "datePublished is in compliant format.", + clause + } + ); + } } } } diff --git a/package-lock.json b/package-lock.json index 73b2402..595b5ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ro-crate", - "version": "3.4.0", + "version": "3.4.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ro-crate", - "version": "3.4.0", + "version": "3.4.2", "license": "GPL-3.0-or-later", "dependencies": { "commander": "^12.0.0", diff --git a/package.json b/package.json index 3682557..0b19871 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ro-crate", - "version": "3.4.1", + "version": "3.4.2", "description": "Research Object Crate (RO-Crate) utilities for making and consuming crates", "main": "index.js", "scripts": {