From a5d209d723356e33a600d8179f0a4c04d62e3d01 Mon Sep 17 00:00:00 2001 From: Moises Sacal Date: Fri, 1 Nov 2024 11:55:10 +1000 Subject: [PATCH 1/2] for https://github.com/Language-Research-Technology/ro-crate-js/issues/21 --- lib/validator.js | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) 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 + } + ); + } } } } From 177995006dfdfb045ece7e2b72fb78b5b7182490 Mon Sep 17 00:00:00 2001 From: Moises Sacal Date: Fri, 1 Nov 2024 13:52:29 +1000 Subject: [PATCH 2/2] increased version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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": {