Skip to content

Commit c536042

Browse files
committed
validate eventDate properties against a regexp and use the appropriate reference
1 parent 44814df commit c536042

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

lib/rdap-validator.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const rdapValidator = {};
22

3+
const iso8601DateTimeRegexp = /^\d{4,}-\d{2}-\d{2}[Tt]\d{2}:\d{2}:\d{2}/gi;
4+
35
const self = rdapValidator;
46

57
export default rdapValidator;
@@ -957,22 +959,30 @@ self.validateEvent = function (event) {
957959
);
958960

959961
} else if ("eventDate" == k) {
962+
self.pushSpec("rfc3339");
960963
var pass;
961964

962-
try {
963-
new Date(event.eventDate);
964-
pass = true;
965-
966-
} catch (e) {
965+
if (!iso8601DateTimeRegexp.test()) {
967966
pass = false;
968967

968+
} else {
969+
try {
970+
new Date(event.eventDate);
971+
pass = true;
972+
973+
} catch (e) {
974+
pass = false;
975+
976+
}
969977
}
970978

971979
self.add(
972980
pass,
973981
"The 'eventDate' property MUST be a valid date/time.",
974-
"section-4.5",
982+
"section-5.6",
975983
);
984+
985+
self.popSpec("rfc3339");
976986
}
977987
}
978988

@@ -2680,6 +2690,7 @@ self.referenceBase = "https://validator.rdap.org/specs/";
26802690
* Path segments for specifications.
26812691
*/
26822692
self.referenceURLs = {
2693+
"rfc3339": "vanilla/rfc3339.html",
26832694
"rfc6350": "vanilla/rfc6350.html",
26842695
"rfc7095": "vanilla/rfc7095.html",
26852696
"rfc7480": "vanilla/rfc7480.html",

0 commit comments

Comments
 (0)