From 415eea9eae3440ebb47a0b4fa19363e39e91b2ad Mon Sep 17 00:00:00 2001 From: Gavin Brown Date: Tue, 9 Jul 2024 11:27:13 +0100 Subject: [PATCH] updated --- lib/rdap-validator.js | 66 +++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/lib/rdap-validator.js b/lib/rdap-validator.js index 25a955f..3ec19a3 100644 --- a/lib/rdap-validator.js +++ b/lib/rdap-validator.js @@ -4,24 +4,6 @@ const self = rdapValidator; export default rdapValidator; -self.referenceBase = "https://validator.rdap.org/specs/"; - -self.referenceURLs = { - "rfc7480": "vanilla/rfc7480.html", - "rfc7481": "vanilla/rfc7481.html", - "rfc9082": "vanilla/rfc9082.html", - "rfc9083": "vanilla/rfc9083.html", - "rfc9224": "vanilla/rfc9224.html", - "rfc9537": "vanilla/rfc9537.html", - "feb24-rp": "gtld/2024-02/rdap-response-profile-21feb24-en.pdf", - "feb24-tig": "gtld/2024-02/rdap-technical-implementation-guide-21feb24-en.pdf", - "nro": "rir/2021-01/nro-rdap-profile.txt", -}; - -self.ref = function(f, spec=null) { - return self.referenceBase + self.referenceURLs[spec ?? self.currentSpec] + "#" + f; -} - /** * Initiate a test run. * @param {null|string} url @@ -272,6 +254,7 @@ self.validateNotices = function(notices) { if (self.add( self.isArray(notices), "The 'notices' property MUST be an array.", + "section-4.3", )) { self.iterate( notices, @@ -291,17 +274,20 @@ self.validateObjectClassName = function(record, type) { if (!self.add( record.hasOwnProperty("objectClassName"), - "Record MUST have the 'objectClassName' property." + "Record MUST have the 'objectClassName' property.", + "section-4.9" )) return; if (!self.add( self.isString(record.objectClassName), - "The 'objectClassName' property MUST be a string." + "The 'objectClassName' property MUST be a string.", + "section-4.9" )) return; self.add( type == record.objectClassName, - "The value of the 'objectClassName' property ('" + record.objectClassName + "') MUST be '" + type + "'." + "The value of the 'objectClassName' property ('" + record.objectClassName + "') MUST be '" + type + "'.", + self.objectClassNameReferences[type], ); self.popPath(".objectClassName"); @@ -2523,3 +2509,41 @@ self.add = function(result, message, ref) { self.addMessage = function(message) { self.add(null, message); } + +/** + * base URL of all specifications + */ +self.referenceBase = "https://validator.rdap.org/specs/"; + +/** + * path segments for specifications + */ +self.referenceURLs = { + "rfc7480": "vanilla/rfc7480.html", + "rfc7481": "vanilla/rfc7481.html", + "rfc9082": "vanilla/rfc9082.html", + "rfc9083": "vanilla/rfc9083.html", + "rfc9224": "vanilla/rfc9224.html", + "rfc9537": "vanilla/rfc9537.html", + "feb24-rp": "gtld/2024-02/rdap-response-profile-21feb24-en.pdf", + "feb24-tig": "gtld/2024-02/rdap-technical-implementation-guide-21feb24-en.pdf", + "nro": "rir/2021-01/nro-rdap-profile.txt", +}; + +/** + * section references for particular object types + */ +self.objectClassNameReferences = { + "entity": "section-5.1", + "nameserver": "section-5.2", + "domain": "section-5.3", + "ip network": "section-5.4", + "autnum": "section-5.5", +}; + +/** + * generate a URL given the current specification and a fragment + */ +self.ref = function(fragment, alternateSpec=null) { + return self.referenceBase + self.referenceURLs[alternateSpec ?? self.currentSpec] + "#" + fragment; +}