Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
gbicann committed Jul 9, 2024
1 parent aa6e67d commit 415eea9
Showing 1 changed file with 45 additions and 21 deletions.
66 changes: 45 additions & 21 deletions lib/rdap-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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");
Expand Down Expand Up @@ -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;
}

0 comments on commit 415eea9

Please sign in to comment.