forked from FHIR/ig-registry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate.js
29 lines (28 loc) · 1012 Bytes
/
validate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
checkRegistry(source) {
guides = JSON.parse(source);
for (var i = 0; i < out.guides.length; i++) {
var g = out.guides[i];
if (g['npm-name'] == null)
throw "A npm package name is required";
if (g.name == null)
throw "A name is required for guide "+g['npm-name'];
if (g.category == null)
throw "A category is required for guide "+g.name;
if (g.description == null)
throw "A description is required for guide "+g.name;
if (g.authority == null)
throw "An authority is required for guide "+g.name;
if (g.country == null)
throw "A country is required for guide "+g.name;
}
for (var i1 = 0; i1 < out.guides.length; i1++) {
var g1 = out.guides[i1];
for (var i2 = i1+1; i2 < out.guides.length; i2++) {
var g2 = out.guides[i2];
if (g1.name = g2.name)
throw "The name '"+g1.name+"' is duplicated";
if (g1['npm-name'] = g2['npm-name'])
throw "The package name '"+g1['npm-name']+"' is duplicated";
}
}
}