Skip to content

Commit 415eea9

Browse files
committed
updated
1 parent aa6e67d commit 415eea9

File tree

1 file changed

+45
-21
lines changed

1 file changed

+45
-21
lines changed

lib/rdap-validator.js

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,6 @@ const self = rdapValidator;
44

55
export default rdapValidator;
66

7-
self.referenceBase = "https://validator.rdap.org/specs/";
8-
9-
self.referenceURLs = {
10-
"rfc7480": "vanilla/rfc7480.html",
11-
"rfc7481": "vanilla/rfc7481.html",
12-
"rfc9082": "vanilla/rfc9082.html",
13-
"rfc9083": "vanilla/rfc9083.html",
14-
"rfc9224": "vanilla/rfc9224.html",
15-
"rfc9537": "vanilla/rfc9537.html",
16-
"feb24-rp": "gtld/2024-02/rdap-response-profile-21feb24-en.pdf",
17-
"feb24-tig": "gtld/2024-02/rdap-technical-implementation-guide-21feb24-en.pdf",
18-
"nro": "rir/2021-01/nro-rdap-profile.txt",
19-
};
20-
21-
self.ref = function(f, spec=null) {
22-
return self.referenceBase + self.referenceURLs[spec ?? self.currentSpec] + "#" + f;
23-
}
24-
257
/**
268
* Initiate a test run.
279
* @param {null|string} url
@@ -272,6 +254,7 @@ self.validateNotices = function(notices) {
272254
if (self.add(
273255
self.isArray(notices),
274256
"The 'notices' property MUST be an array.",
257+
"section-4.3",
275258
)) {
276259
self.iterate(
277260
notices,
@@ -291,17 +274,20 @@ self.validateObjectClassName = function(record, type) {
291274

292275
if (!self.add(
293276
record.hasOwnProperty("objectClassName"),
294-
"Record MUST have the 'objectClassName' property."
277+
"Record MUST have the 'objectClassName' property.",
278+
"section-4.9"
295279
)) return;
296280

297281
if (!self.add(
298282
self.isString(record.objectClassName),
299-
"The 'objectClassName' property MUST be a string."
283+
"The 'objectClassName' property MUST be a string.",
284+
"section-4.9"
300285
)) return;
301286

302287
self.add(
303288
type == record.objectClassName,
304-
"The value of the 'objectClassName' property ('" + record.objectClassName + "') MUST be '" + type + "'."
289+
"The value of the 'objectClassName' property ('" + record.objectClassName + "') MUST be '" + type + "'.",
290+
self.objectClassNameReferences[type],
305291
);
306292

307293
self.popPath(".objectClassName");
@@ -2523,3 +2509,41 @@ self.add = function(result, message, ref) {
25232509
self.addMessage = function(message) {
25242510
self.add(null, message);
25252511
}
2512+
2513+
/**
2514+
* base URL of all specifications
2515+
*/
2516+
self.referenceBase = "https://validator.rdap.org/specs/";
2517+
2518+
/**
2519+
* path segments for specifications
2520+
*/
2521+
self.referenceURLs = {
2522+
"rfc7480": "vanilla/rfc7480.html",
2523+
"rfc7481": "vanilla/rfc7481.html",
2524+
"rfc9082": "vanilla/rfc9082.html",
2525+
"rfc9083": "vanilla/rfc9083.html",
2526+
"rfc9224": "vanilla/rfc9224.html",
2527+
"rfc9537": "vanilla/rfc9537.html",
2528+
"feb24-rp": "gtld/2024-02/rdap-response-profile-21feb24-en.pdf",
2529+
"feb24-tig": "gtld/2024-02/rdap-technical-implementation-guide-21feb24-en.pdf",
2530+
"nro": "rir/2021-01/nro-rdap-profile.txt",
2531+
};
2532+
2533+
/**
2534+
* section references for particular object types
2535+
*/
2536+
self.objectClassNameReferences = {
2537+
"entity": "section-5.1",
2538+
"nameserver": "section-5.2",
2539+
"domain": "section-5.3",
2540+
"ip network": "section-5.4",
2541+
"autnum": "section-5.5",
2542+
};
2543+
2544+
/**
2545+
* generate a URL given the current specification and a fragment
2546+
*/
2547+
self.ref = function(fragment, alternateSpec=null) {
2548+
return self.referenceBase + self.referenceURLs[alternateSpec ?? self.currentSpec] + "#" + fragment;
2549+
}

0 commit comments

Comments
 (0)