@pdtf/schemas 0.7.0 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +7 -6
- package/package.json +1 -1
- package/src/examples/exampleAddParticipantVouch.json +32 -0
- package/src/examples/exampleDocumentedVouch.json +2 -1
- package/src/mappings/adf.js +198 -0
- package/src/schemas/{baspi-b-legal-information.json → legal-information.json} +18 -10
- package/src/schemas/{baspi-a-material-facts.json → material-facts.json} +434 -140
- package/src/schemas/pdtf-transaction.json +2 -2
- package/src/schemas/pdtf-verified-claims.json +7 -11
- package/src/tests/pdtfVerifiedClaims.test.js +9 -9
- package/src/tests/transactionSchema.test.js +4 -4
- package/src/tests/verifiedClaimsValidator.test.js +5 -5
- package/src/schemas/verified_claims-12.json +0 -621
|
@@ -345,6 +345,9 @@
|
|
|
345
345
|
"expires_in": {
|
|
346
346
|
"type": "integer",
|
|
347
347
|
"minimum": 1
|
|
348
|
+
},
|
|
349
|
+
"pdtfSchemaPath": {
|
|
350
|
+
"type": "string"
|
|
348
351
|
}
|
|
349
352
|
},
|
|
350
353
|
"required": ["digest", "url"]
|
|
@@ -401,17 +404,10 @@
|
|
|
401
404
|
"required": ["verified_claims"],
|
|
402
405
|
"properties": {
|
|
403
406
|
"verified_claims": {
|
|
404
|
-
"
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
{
|
|
409
|
-
"type": "array",
|
|
410
|
-
"items": {
|
|
411
|
-
"$ref": "#/definitions/verified_claims_def"
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
]
|
|
407
|
+
"type": "array",
|
|
408
|
+
"items": {
|
|
409
|
+
"$ref": "#/definitions/verified_claims_def"
|
|
410
|
+
}
|
|
415
411
|
}
|
|
416
412
|
},
|
|
417
413
|
"additionalProperties": false
|
|
@@ -15,38 +15,38 @@ addFormats(ajv);
|
|
|
15
15
|
const validator = ajv.compile(verifiedClaimsSchema);
|
|
16
16
|
|
|
17
17
|
test("valid vouch sample is valid", () => {
|
|
18
|
-
const isValid = validator({ verified_claims: exampleVouch });
|
|
18
|
+
const isValid = validator({ verified_claims: [exampleVouch] });
|
|
19
19
|
expect(isValid).toBe(true);
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
test("valid electronic record sample is valid", () => {
|
|
23
|
-
const isValid = validator({ verified_claims: exampleElectronicRecord });
|
|
23
|
+
const isValid = validator({ verified_claims: [exampleElectronicRecord] });
|
|
24
24
|
expect(isValid).toBe(true);
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
test("valid documented vouch sample is valid", () => {
|
|
28
|
-
const isValid = validator({ verified_claims: exampleDocumentedVouch });
|
|
28
|
+
const isValid = validator({ verified_claims: [exampleDocumentedVouch] });
|
|
29
29
|
expect(isValid).toBe(true);
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
test("sample with primitive claims value is valid", () => {
|
|
33
33
|
const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
|
|
34
34
|
clonedVouch.claims = { "/propertyPack/uprn": 123456 };
|
|
35
|
-
const isValid = validator({ verified_claims: clonedVouch });
|
|
35
|
+
const isValid = validator({ verified_claims: [clonedVouch] });
|
|
36
36
|
expect(isValid).toBe(true);
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
test("sample with undefined claims value is also valid, but this would fail when the payload is validated", () => {
|
|
40
40
|
const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
|
|
41
41
|
clonedVouch.claims = { "/propertyPack/uprn": undefined };
|
|
42
|
-
const isValid = validator({ verified_claims: clonedVouch });
|
|
42
|
+
const isValid = validator({ verified_claims: [clonedVouch] });
|
|
43
43
|
expect(isValid).toBe(true);
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
test("claim with missing claims is invalid", () => {
|
|
47
47
|
const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
|
|
48
48
|
delete clonedVouch.claims;
|
|
49
|
-
const isValid = validator({ verified_claims: clonedVouch });
|
|
49
|
+
const isValid = validator({ verified_claims: [clonedVouch] });
|
|
50
50
|
expect(isValid).toBe(false);
|
|
51
51
|
});
|
|
52
52
|
|
|
@@ -55,20 +55,20 @@ test("claim with invalid claims path is invalid", () => {
|
|
|
55
55
|
const originalPath = Object.keys(clonedVouch.claims)[0];
|
|
56
56
|
const data = clonedVouch.claims[originalPath];
|
|
57
57
|
clonedVouch.claims = { "invalidPath//of?someKind": data };
|
|
58
|
-
const isValid = validator({ verified_claims: clonedVouch });
|
|
58
|
+
const isValid = validator({ verified_claims: [clonedVouch] });
|
|
59
59
|
expect(isValid).toBe(false);
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
test("verification with invalid evidence type is invalid", () => {
|
|
63
63
|
const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
|
|
64
64
|
clonedVouch.verification.evidence[0].type = "something invalid";
|
|
65
|
-
const isValid = validator({ verified_claims: clonedVouch });
|
|
65
|
+
const isValid = validator({ verified_claims: [clonedVouch] });
|
|
66
66
|
expect(isValid).toBe(false);
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
test("verification with no framework type is invalid", () => {
|
|
70
70
|
const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
|
|
71
71
|
delete clonedVouch.verification.trust_framework;
|
|
72
|
-
const isValid = validator({ verified_claims: clonedVouch });
|
|
72
|
+
const isValid = validator({ verified_claims: [clonedVouch] });
|
|
73
73
|
expect(isValid).toBe(false);
|
|
74
74
|
});
|
|
@@ -90,14 +90,14 @@ test("correctly gets a subschema through a dependency", () => {
|
|
|
90
90
|
|
|
91
91
|
test("correctly gets another subschema through a dependency", () => {
|
|
92
92
|
const subschema = getSubschema(
|
|
93
|
-
"/propertyPack/materialFacts/ownership/
|
|
93
|
+
"/propertyPack/materialFacts/ownership/lengthOfLeaseInYears"
|
|
94
94
|
);
|
|
95
95
|
expect(subschema.title).toBe("Length of lease (years)");
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
test("correctly gets yet another subschema through a dependency", () => {
|
|
99
99
|
const subschema = getSubschema(
|
|
100
|
-
"/propertyPack/materialFacts/ownership/
|
|
100
|
+
"/propertyPack/materialFacts/ownership/rentIncrease/details"
|
|
101
101
|
);
|
|
102
102
|
expect(subschema.title).toBe("Details");
|
|
103
103
|
});
|
|
@@ -143,13 +143,13 @@ test("correctly gets titles across schemas, arrays and non-existient title prope
|
|
|
143
143
|
expect(
|
|
144
144
|
getTitleAtPath(
|
|
145
145
|
transactionSchema,
|
|
146
|
-
"/propertyPack/materialFacts/ownership/
|
|
146
|
+
"/propertyPack/materialFacts/ownership/lengthOfLeaseInYears"
|
|
147
147
|
)
|
|
148
148
|
).toBe("Length of lease (years)");
|
|
149
149
|
expect(
|
|
150
150
|
getTitleAtPath(
|
|
151
151
|
transactionSchema,
|
|
152
|
-
"/propertyPack/materialFacts/ownership/
|
|
152
|
+
"/propertyPack/materialFacts/ownership/annualServiceCharge"
|
|
153
153
|
)
|
|
154
154
|
).toBe(
|
|
155
155
|
"Amount of current annual service charge/estate rentcharge/maintenance contribution (£)"
|
|
@@ -4,7 +4,7 @@ const exampleVouch = require("../examples/exampleVouch.json");
|
|
|
4
4
|
const exampleDocumentedVouch = require("../examples/exampleDocumentedVouch.json");
|
|
5
5
|
|
|
6
6
|
test("returns an empty array for a valid claim", () => {
|
|
7
|
-
expect(validateVerifiedClaims(exampleVouch)).toEqual([]);
|
|
7
|
+
expect(validateVerifiedClaims([exampleVouch])).toEqual([]);
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
test("returns an empty array for a valid array of claims", () => {
|
|
@@ -19,7 +19,7 @@ test("returns an array with an error stating if path is incorrect", () => {
|
|
|
19
19
|
clonedVouch.claims = {
|
|
20
20
|
"/propertyPack/INVALID/materialFacts/councilTax": data,
|
|
21
21
|
};
|
|
22
|
-
expect(validateVerifiedClaims(clonedVouch)).toEqual([
|
|
22
|
+
expect(validateVerifiedClaims([clonedVouch])).toEqual([
|
|
23
23
|
"Path /propertyPack/INVALID/materialFacts/councilTax is not a valid PDTF schema path",
|
|
24
24
|
]);
|
|
25
25
|
});
|
|
@@ -36,7 +36,7 @@ test("returns an array of errors if data in the path is in invalid format", () =
|
|
|
36
36
|
},
|
|
37
37
|
},
|
|
38
38
|
};
|
|
39
|
-
expect(validateVerifiedClaims(clonedVouch)).toEqual([
|
|
39
|
+
expect(validateVerifiedClaims([clonedVouch])).toEqual([
|
|
40
40
|
{
|
|
41
41
|
instancePath: "",
|
|
42
42
|
schemaPath: "#/required",
|
|
@@ -67,7 +67,7 @@ test("returns an array of errors for verified claim with multiple paths", () =>
|
|
|
67
67
|
},
|
|
68
68
|
},
|
|
69
69
|
};
|
|
70
|
-
expect(validateVerifiedClaims(clonedVouch)).toEqual([
|
|
70
|
+
expect(validateVerifiedClaims([clonedVouch])).toEqual([
|
|
71
71
|
"Path /propertyPack/materialFacts/cousncilTaxBad is not a valid PDTF schema path",
|
|
72
72
|
"Path /propertyPack/materialFacts/councilTaxBadTwo is not a valid PDTF schema path",
|
|
73
73
|
]);
|
|
@@ -92,5 +92,5 @@ test("returns an empty array of errors for verified claim with multiple valid pa
|
|
|
92
92
|
postcode: "property.postcode",
|
|
93
93
|
},
|
|
94
94
|
};
|
|
95
|
-
expect(validateVerifiedClaims(clonedVouch)).toEqual([]);
|
|
95
|
+
expect(validateVerifiedClaims([clonedVouch])).toEqual([]);
|
|
96
96
|
});
|