@pdtf/schemas 0.6.12 → 0.6.15
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 +22 -16
- package/package.json +1 -1
- package/src/examples/exampleDocumentedVouch.json +10 -13
- package/src/examples/exampleTransaction.json +3 -11
- package/src/schemas/baspi-a-material-facts.json +26 -8
- package/src/tests/transactionSchema.test.js +0 -207
- package/src/tests/verifiedClaimsValidator.test.js +96 -0
package/index.js
CHANGED
|
@@ -119,38 +119,44 @@ const getTitleAtPath = (schema, path, rootPath = path) => {
|
|
|
119
119
|
}
|
|
120
120
|
};
|
|
121
121
|
|
|
122
|
-
const validateVerifiedClaims = (
|
|
123
|
-
|
|
124
|
-
const validatorVClaims = ajv.compile(verifiedClaimsSchema);
|
|
122
|
+
const validateVerifiedClaims = (verifiedClaims) => {
|
|
123
|
+
const validatorVClaims = ajv.compile(verifiedClaimsSchema);
|
|
125
124
|
|
|
126
125
|
const validationErrorsArr = [];
|
|
127
126
|
const vClaimSchValidation = validatorVClaims({
|
|
128
|
-
verified_claims:
|
|
127
|
+
verified_claims: verifiedClaims,
|
|
129
128
|
});
|
|
130
129
|
|
|
131
130
|
if (!vClaimSchValidation) {
|
|
132
131
|
validationErrorsArr.push(validatorVClaims.errors);
|
|
133
132
|
}
|
|
134
133
|
|
|
134
|
+
const verifiedClaimsArray = Array.isArray(verifiedClaims)
|
|
135
|
+
? verifiedClaims
|
|
136
|
+
: [verifiedClaims];
|
|
137
|
+
|
|
135
138
|
verifiedClaimsArray.forEach((claim) => {
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
const paths = Object.keys(claim.claims);
|
|
140
|
+
|
|
141
|
+
for (const path of paths) {
|
|
142
|
+
const validPath = isPathValid(path);
|
|
143
|
+
if (validPath) {
|
|
144
|
+
const subValidator = getSubschemaValidator(path);
|
|
145
|
+
const isValid = subValidator(claim.claims[path]);
|
|
146
|
+
if (!isValid) {
|
|
147
|
+
validationErrorsArr.push(...subValidator.errors);
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
validationErrorsArr.push(
|
|
151
|
+
`Path ${path} is not a valid PDTF schema path`
|
|
152
|
+
);
|
|
144
153
|
}
|
|
145
|
-
} else {
|
|
146
|
-
validationErrorsArr.push(`Path ${path} is not a valid PDTF schema path`);
|
|
147
154
|
}
|
|
148
155
|
});
|
|
149
156
|
|
|
150
157
|
return validationErrorsArr;
|
|
151
158
|
};
|
|
152
159
|
|
|
153
|
-
|
|
154
160
|
module.exports = {
|
|
155
161
|
transactionSchema,
|
|
156
162
|
validator,
|
|
@@ -159,5 +165,5 @@ module.exports = {
|
|
|
159
165
|
getSubschemaValidator,
|
|
160
166
|
getTitleAtPath,
|
|
161
167
|
verifiedClaimsSchema,
|
|
162
|
-
validateVerifiedClaims
|
|
168
|
+
validateVerifiedClaims,
|
|
163
169
|
};
|
package/package.json
CHANGED
|
@@ -4,19 +4,7 @@
|
|
|
4
4
|
"time": "2022-01-25T13:16:44.527Z",
|
|
5
5
|
"evidence": [
|
|
6
6
|
{
|
|
7
|
-
"verification_method": {
|
|
8
|
-
"type": "auth"
|
|
9
|
-
},
|
|
10
7
|
"type": "vouch",
|
|
11
|
-
"attestation": {
|
|
12
|
-
"voucher": {
|
|
13
|
-
"name": "Maria Harris"
|
|
14
|
-
},
|
|
15
|
-
"type": "digital_attestation"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"type": "document",
|
|
20
8
|
"attachments": [
|
|
21
9
|
{
|
|
22
10
|
"digest": {
|
|
@@ -26,7 +14,16 @@
|
|
|
26
14
|
"url": "https://fakeFileStore.com/some/kind/of/file",
|
|
27
15
|
"desc": "proofOfAddress.pdf"
|
|
28
16
|
}
|
|
29
|
-
]
|
|
17
|
+
],
|
|
18
|
+
"verification_method": {
|
|
19
|
+
"type": "auth"
|
|
20
|
+
},
|
|
21
|
+
"attestation": {
|
|
22
|
+
"voucher": {
|
|
23
|
+
"name": "Maria Harris"
|
|
24
|
+
},
|
|
25
|
+
"type": "digital_attestation"
|
|
26
|
+
}
|
|
30
27
|
}
|
|
31
28
|
]
|
|
32
29
|
},
|
|
@@ -201,24 +201,21 @@
|
|
|
201
201
|
"maintenanceAgreements": {
|
|
202
202
|
"yesNo": "No"
|
|
203
203
|
},
|
|
204
|
-
"yesNo": "
|
|
205
|
-
"
|
|
204
|
+
"yesNo": "To be connected",
|
|
205
|
+
"dateToBeConnected": "2022-12-15",
|
|
206
206
|
"supplier": "Northumbria Water"
|
|
207
207
|
},
|
|
208
208
|
"mainsSurfaceWaterDrainage": {
|
|
209
209
|
"maintenanceAgreements": {
|
|
210
210
|
"yesNo": "No"
|
|
211
211
|
},
|
|
212
|
-
"yesNo": "Yes"
|
|
213
|
-
"connected": "Yes",
|
|
214
|
-
"supplier": "Northumbria Water"
|
|
212
|
+
"yesNo": "Yes"
|
|
215
213
|
},
|
|
216
214
|
"mainsFoulDrainage": {
|
|
217
215
|
"maintenanceAgreements": {
|
|
218
216
|
"yesNo": "No"
|
|
219
217
|
},
|
|
220
218
|
"yesNo": "Yes",
|
|
221
|
-
"connected": "Yes",
|
|
222
219
|
"supplier": "Northumbria Water"
|
|
223
220
|
}
|
|
224
221
|
},
|
|
@@ -228,7 +225,6 @@
|
|
|
228
225
|
"yesNo": "No"
|
|
229
226
|
},
|
|
230
227
|
"yesNo": "Yes",
|
|
231
|
-
"connected": "Yes",
|
|
232
228
|
"supplier": "Octopus Energy"
|
|
233
229
|
},
|
|
234
230
|
"gas": {
|
|
@@ -236,7 +232,6 @@
|
|
|
236
232
|
"yesNo": "No"
|
|
237
233
|
},
|
|
238
234
|
"yesNo": "Yes",
|
|
239
|
-
"connected": "Yes",
|
|
240
235
|
"supplier": "Octopus Energy"
|
|
241
236
|
},
|
|
242
237
|
"lpg": {
|
|
@@ -250,7 +245,6 @@
|
|
|
250
245
|
"yesNo": "No"
|
|
251
246
|
},
|
|
252
247
|
"yesNo": "Yes",
|
|
253
|
-
"connected": "Yes",
|
|
254
248
|
"supplier": "EE"
|
|
255
249
|
},
|
|
256
250
|
"cableSatelliteTV": {
|
|
@@ -258,7 +252,6 @@
|
|
|
258
252
|
"yesNo": "No"
|
|
259
253
|
},
|
|
260
254
|
"yesNo": "Yes",
|
|
261
|
-
"connected": "Yes",
|
|
262
255
|
"supplier": "Sky"
|
|
263
256
|
},
|
|
264
257
|
"broadband": {
|
|
@@ -266,7 +259,6 @@
|
|
|
266
259
|
"yesNo": "No"
|
|
267
260
|
},
|
|
268
261
|
"yesNo": "Yes",
|
|
269
|
-
"connected": "Yes",
|
|
270
262
|
"supplier": "EE"
|
|
271
263
|
},
|
|
272
264
|
"solarPanels": {
|
|
@@ -792,7 +792,7 @@
|
|
|
792
792
|
"yesNo": {
|
|
793
793
|
"type": "string",
|
|
794
794
|
"title": "",
|
|
795
|
-
"enum": ["Yes", "No"]
|
|
795
|
+
"enum": ["Yes", "To be connected", "No"]
|
|
796
796
|
}
|
|
797
797
|
},
|
|
798
798
|
"dependencies": {
|
|
@@ -887,22 +887,40 @@
|
|
|
887
887
|
"yesNo": {
|
|
888
888
|
"enum": ["Yes"]
|
|
889
889
|
},
|
|
890
|
-
"
|
|
891
|
-
"title": "
|
|
890
|
+
"supplier": {
|
|
891
|
+
"title": "Supplier (if known)",
|
|
892
892
|
"type": "string",
|
|
893
893
|
"minLength": 1
|
|
894
894
|
},
|
|
895
|
+
"maintenanceAgreements": {
|
|
896
|
+
"title": "Do you have any licences, maintenance agreements, contracts or service agreements in relation to this service?",
|
|
897
|
+
"$ref": "#/$defs/yesNoDetailIfYes"
|
|
898
|
+
}
|
|
899
|
+
},
|
|
900
|
+
"required": ["maintenanceAgreements"]
|
|
901
|
+
},
|
|
902
|
+
{
|
|
903
|
+
"properties": {
|
|
904
|
+
"yesNo": {
|
|
905
|
+
"enum": ["To be connected"]
|
|
906
|
+
},
|
|
907
|
+
"dateToBeConnected": {
|
|
908
|
+
"title": "Date to be connected",
|
|
909
|
+
"type": "string",
|
|
910
|
+
"format": "date"
|
|
911
|
+
},
|
|
895
912
|
"supplier": {
|
|
896
913
|
"title": "Supplier (if known)",
|
|
897
|
-
"type": "string"
|
|
898
|
-
"minLength": 1
|
|
914
|
+
"type": "string"
|
|
899
915
|
},
|
|
900
916
|
"maintenanceAgreements": {
|
|
917
|
+
"BASPIRef": "A7.2",
|
|
918
|
+
"RDSRef": "Services/Certificates,Services/OtherServices/Certificates",
|
|
901
919
|
"title": "Do you have any licences, maintenance agreements, contracts or service agreements in relation to this service?",
|
|
902
920
|
"$ref": "#/$defs/yesNoDetailIfYes"
|
|
903
921
|
}
|
|
904
922
|
},
|
|
905
|
-
"required": ["
|
|
923
|
+
"required": ["dateToBeConnected", "maintenanceAgreements"]
|
|
906
924
|
}
|
|
907
925
|
]
|
|
908
926
|
}
|
|
@@ -1529,7 +1547,7 @@
|
|
|
1529
1547
|
"$ref": "#/$defs/yesNoDetailIfYes"
|
|
1530
1548
|
}
|
|
1531
1549
|
},
|
|
1532
|
-
"required": ["
|
|
1550
|
+
"required": ["maintenanceAgreements"]
|
|
1533
1551
|
},
|
|
1534
1552
|
{
|
|
1535
1553
|
"properties": {
|
|
@@ -1552,7 +1570,7 @@
|
|
|
1552
1570
|
"$ref": "#/$defs/yesNoDetailIfYes"
|
|
1553
1571
|
}
|
|
1554
1572
|
},
|
|
1555
|
-
"required": ["dateToBeConnected"]
|
|
1573
|
+
"required": ["dateToBeConnected", "maintenanceAgreements"]
|
|
1556
1574
|
}
|
|
1557
1575
|
]
|
|
1558
1576
|
}
|
|
@@ -7,7 +7,6 @@ const {
|
|
|
7
7
|
isPathValid,
|
|
8
8
|
getSubschemaValidator,
|
|
9
9
|
getTitleAtPath,
|
|
10
|
-
validateVerifiedClaims
|
|
11
10
|
} = require("../../index.js");
|
|
12
11
|
const exampleTransaction = require("../examples/exampleTransaction.json");
|
|
13
12
|
|
|
@@ -183,209 +182,3 @@ test("correctly gets titles across schemas, arrays and non-existient title prope
|
|
|
183
182
|
)
|
|
184
183
|
).toBe("Current energy rating");
|
|
185
184
|
});
|
|
186
|
-
|
|
187
|
-
test("returns an array with an error stating if path is incorrect", () => {
|
|
188
|
-
const vClaims = [
|
|
189
|
-
{
|
|
190
|
-
verification: {
|
|
191
|
-
trust_framework: "uk_pdtf",
|
|
192
|
-
time: "2022-01-25T13:16:44.527Z",
|
|
193
|
-
evidence: [
|
|
194
|
-
{
|
|
195
|
-
verification_method: {
|
|
196
|
-
type: "auth",
|
|
197
|
-
},
|
|
198
|
-
type: "vouch",
|
|
199
|
-
attestation: {
|
|
200
|
-
voucher: {
|
|
201
|
-
name: "Maria Harris",
|
|
202
|
-
},
|
|
203
|
-
type: "digital_attestation",
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
type: "document",
|
|
208
|
-
attachments: [
|
|
209
|
-
{
|
|
210
|
-
digest: {
|
|
211
|
-
alg: "md5",
|
|
212
|
-
value: "randomHashValue",
|
|
213
|
-
},
|
|
214
|
-
url: "https://fakeFileStore.com/some/kind/of/file",
|
|
215
|
-
desc: "proofOfAddress.pdf",
|
|
216
|
-
},
|
|
217
|
-
],
|
|
218
|
-
},
|
|
219
|
-
],
|
|
220
|
-
},
|
|
221
|
-
claims: {
|
|
222
|
-
"/propertyPack/INVALID/materialFacts/councilTax": {
|
|
223
|
-
councilTaxBand: "D",
|
|
224
|
-
councilTaxAffectingAlterations: {
|
|
225
|
-
yesNo: "Yes",
|
|
226
|
-
details:
|
|
227
|
-
"Extension added in 2005 to add bedroom with ensuite shower room. Certificate of Compliance issued 17th Feb 2006 and council tax updated",
|
|
228
|
-
},
|
|
229
|
-
},
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
];
|
|
233
|
-
expect(validateVerifiedClaims(vClaims)).toEqual([
|
|
234
|
-
"Path /propertyPack/INVALID/materialFacts/councilTax is not a valid PDTF schema path",
|
|
235
|
-
]);
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
test("returns an empty array if path is correct", () => {
|
|
239
|
-
const vClaims = [
|
|
240
|
-
{
|
|
241
|
-
verification: {
|
|
242
|
-
trust_framework: "uk_pdtf",
|
|
243
|
-
time: "2022-01-25T13:16:44.527Z",
|
|
244
|
-
evidence: [
|
|
245
|
-
{
|
|
246
|
-
verification_method: {
|
|
247
|
-
type: "auth",
|
|
248
|
-
},
|
|
249
|
-
type: "vouch",
|
|
250
|
-
attestation: {
|
|
251
|
-
voucher: {
|
|
252
|
-
name: "Maria Harris",
|
|
253
|
-
},
|
|
254
|
-
type: "digital_attestation",
|
|
255
|
-
},
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
type: "document",
|
|
259
|
-
attachments: [
|
|
260
|
-
{
|
|
261
|
-
digest: {
|
|
262
|
-
alg: "md5",
|
|
263
|
-
value: "randomHashValue",
|
|
264
|
-
},
|
|
265
|
-
url: "https://fakeFileStore.com/some/kind/of/file",
|
|
266
|
-
desc: "proofOfAddress.pdf",
|
|
267
|
-
},
|
|
268
|
-
],
|
|
269
|
-
},
|
|
270
|
-
],
|
|
271
|
-
},
|
|
272
|
-
claims: {
|
|
273
|
-
"/propertyPack/materialFacts/councilTax": {
|
|
274
|
-
councilTaxBand: "D",
|
|
275
|
-
councilTaxAffectingAlterations: {
|
|
276
|
-
yesNo: "Yes",
|
|
277
|
-
details:
|
|
278
|
-
"Extension added in 2005 to add bedroom with ensuite shower room. Certificate of Compliance issued 17th Feb 2006 and council tax updated",
|
|
279
|
-
},
|
|
280
|
-
},
|
|
281
|
-
},
|
|
282
|
-
},
|
|
283
|
-
];
|
|
284
|
-
expect(validateVerifiedClaims(vClaims)).toEqual([]);
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
test("returns an array of errors if data in the path is in invalid format", () => {
|
|
288
|
-
const vClaims = [
|
|
289
|
-
{
|
|
290
|
-
verification: {
|
|
291
|
-
trust_framework: "uk_pdtf",
|
|
292
|
-
time: "2022-01-25T13:16:44.527Z",
|
|
293
|
-
evidence: [
|
|
294
|
-
{
|
|
295
|
-
verification_method: {
|
|
296
|
-
type: "auth",
|
|
297
|
-
},
|
|
298
|
-
type: "vouch",
|
|
299
|
-
attestation: {
|
|
300
|
-
voucher: {
|
|
301
|
-
name: "Maria Harris",
|
|
302
|
-
},
|
|
303
|
-
type: "digital_attestation",
|
|
304
|
-
},
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
type: "document",
|
|
308
|
-
attachments: [
|
|
309
|
-
{
|
|
310
|
-
digest: {
|
|
311
|
-
alg: "md5",
|
|
312
|
-
value: "randomHashValue",
|
|
313
|
-
},
|
|
314
|
-
url: "https://fakeFileStore.com/some/kind/of/file",
|
|
315
|
-
desc: "proofOfAddress.pdf",
|
|
316
|
-
},
|
|
317
|
-
],
|
|
318
|
-
},
|
|
319
|
-
],
|
|
320
|
-
},
|
|
321
|
-
claims: {
|
|
322
|
-
"/propertyPack/materialFacts/councilTax": {
|
|
323
|
-
councilTaxBand: "D",
|
|
324
|
-
councilTaxAffectingAlterationsINVALID: {
|
|
325
|
-
yesNo: "Yes",
|
|
326
|
-
details:
|
|
327
|
-
"Extension added in 2005 to add bedroom with ensuite shower room. Certificate of Compliance issued 17th Feb 2006 and council tax updated",
|
|
328
|
-
},
|
|
329
|
-
},
|
|
330
|
-
},
|
|
331
|
-
},
|
|
332
|
-
];
|
|
333
|
-
expect(validateVerifiedClaims(vClaims)).toEqual([
|
|
334
|
-
{
|
|
335
|
-
instancePath: "",
|
|
336
|
-
schemaPath: "#/required",
|
|
337
|
-
keyword: "required",
|
|
338
|
-
params: { missingProperty: "councilTaxAffectingAlterations" },
|
|
339
|
-
message: "must have required property 'councilTaxAffectingAlterations'",
|
|
340
|
-
},
|
|
341
|
-
]);
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
test("returns an empty array of errors if data in the path is in valid format", () => {
|
|
345
|
-
const vClaims = [
|
|
346
|
-
{
|
|
347
|
-
verification: {
|
|
348
|
-
trust_framework: "uk_pdtf",
|
|
349
|
-
time: "2022-01-25T13:16:44.527Z",
|
|
350
|
-
evidence: [
|
|
351
|
-
{
|
|
352
|
-
verification_method: {
|
|
353
|
-
type: "auth",
|
|
354
|
-
},
|
|
355
|
-
type: "vouch",
|
|
356
|
-
attestation: {
|
|
357
|
-
voucher: {
|
|
358
|
-
name: "Maria Harris",
|
|
359
|
-
},
|
|
360
|
-
type: "digital_attestation",
|
|
361
|
-
},
|
|
362
|
-
},
|
|
363
|
-
{
|
|
364
|
-
type: "document",
|
|
365
|
-
attachments: [
|
|
366
|
-
{
|
|
367
|
-
digest: {
|
|
368
|
-
alg: "md5",
|
|
369
|
-
value: "randomHashValue",
|
|
370
|
-
},
|
|
371
|
-
url: "https://fakeFileStore.com/some/kind/of/file",
|
|
372
|
-
desc: "proofOfAddress.pdf",
|
|
373
|
-
},
|
|
374
|
-
],
|
|
375
|
-
},
|
|
376
|
-
],
|
|
377
|
-
},
|
|
378
|
-
claims: {
|
|
379
|
-
"/propertyPack/materialFacts/councilTax": {
|
|
380
|
-
councilTaxBand: "D",
|
|
381
|
-
councilTaxAffectingAlterations: {
|
|
382
|
-
yesNo: "Yes",
|
|
383
|
-
details:
|
|
384
|
-
"Extension added in 2005 to add bedroom with ensuite shower room. Certificate of Compliance issued 17th Feb 2006 and council tax updated",
|
|
385
|
-
},
|
|
386
|
-
},
|
|
387
|
-
},
|
|
388
|
-
},
|
|
389
|
-
];
|
|
390
|
-
expect(validateVerifiedClaims(vClaims)).toEqual([]);
|
|
391
|
-
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
const { validateVerifiedClaims } = require("../../index.js");
|
|
2
|
+
|
|
3
|
+
const exampleVouch = require("../examples/exampleVouch.json");
|
|
4
|
+
const exampleDocumentedVouch = require("../examples/exampleDocumentedVouch.json");
|
|
5
|
+
|
|
6
|
+
test("returns an empty array for a valid claim", () => {
|
|
7
|
+
expect(validateVerifiedClaims(exampleVouch)).toEqual([]);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test("returns an empty array for a valid array of claims", () => {
|
|
11
|
+
const claimsArray = [exampleVouch, exampleDocumentedVouch];
|
|
12
|
+
expect(validateVerifiedClaims(claimsArray)).toEqual([]);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("returns an array with an error stating if path is incorrect", () => {
|
|
16
|
+
const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
|
|
17
|
+
const originalPath = Object.keys(clonedVouch.claims)[0];
|
|
18
|
+
const data = clonedVouch.claims[originalPath];
|
|
19
|
+
clonedVouch.claims = {
|
|
20
|
+
"/propertyPack/INVALID/materialFacts/councilTax": data,
|
|
21
|
+
};
|
|
22
|
+
expect(validateVerifiedClaims(clonedVouch)).toEqual([
|
|
23
|
+
"Path /propertyPack/INVALID/materialFacts/councilTax is not a valid PDTF schema path",
|
|
24
|
+
]);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("returns an array of errors if data in the path is in invalid format", () => {
|
|
28
|
+
const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
|
|
29
|
+
clonedVouch.claims = {
|
|
30
|
+
"/propertyPack/materialFacts/councilTax": {
|
|
31
|
+
councilTaxBand: "D",
|
|
32
|
+
councilTaxAffectingAlterationsINVALID: {
|
|
33
|
+
yesNo: "Yes",
|
|
34
|
+
details:
|
|
35
|
+
"Extension added in 2005 to add bedroom with ensuite shower room. Certificate of Compliance issued 17th Feb 2006 and council tax updated",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
expect(validateVerifiedClaims(clonedVouch)).toEqual([
|
|
40
|
+
{
|
|
41
|
+
instancePath: "",
|
|
42
|
+
schemaPath: "#/required",
|
|
43
|
+
keyword: "required",
|
|
44
|
+
params: { missingProperty: "councilTaxAffectingAlterations" },
|
|
45
|
+
message: "must have required property 'councilTaxAffectingAlterations'",
|
|
46
|
+
},
|
|
47
|
+
]);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("returns an array of errors for verified claim with multiple paths", () => {
|
|
51
|
+
const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
|
|
52
|
+
clonedVouch.claims = {
|
|
53
|
+
"/propertyPack/materialFacts/cousncilTaxBad": {
|
|
54
|
+
councilTaxBand: "D",
|
|
55
|
+
councilTaxAffectingAlterations: {
|
|
56
|
+
yesNo: "Yes",
|
|
57
|
+
details:
|
|
58
|
+
"Extension added in 2005 to add bedroom with ensuite shower room. Certificate of Compliance issued 17th Feb 2006 and council tax updated",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
"/propertyPack/materialFacts/councilTaxBadTwo": {
|
|
62
|
+
councilTaxBand: "D",
|
|
63
|
+
councilTaxAffectingAlterations: {
|
|
64
|
+
yesNo: "Yes",
|
|
65
|
+
details:
|
|
66
|
+
"Extension added in 2005 to add bedroom with ensuite shower room. Certificate of Compliance issued 17th Feb 2006 and council tax updated",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
expect(validateVerifiedClaims(clonedVouch)).toEqual([
|
|
71
|
+
"Path /propertyPack/materialFacts/cousncilTaxBad is not a valid PDTF schema path",
|
|
72
|
+
"Path /propertyPack/materialFacts/councilTaxBadTwo is not a valid PDTF schema path",
|
|
73
|
+
]);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test("returns an empty array of errors for verified claim with multiple valid paths", () => {
|
|
77
|
+
const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
|
|
78
|
+
clonedVouch.claims = {
|
|
79
|
+
"/propertyPack/materialFacts/councilTax": {
|
|
80
|
+
councilTaxBand: "D",
|
|
81
|
+
councilTaxAffectingAlterations: {
|
|
82
|
+
yesNo: "Yes",
|
|
83
|
+
details:
|
|
84
|
+
"Extension added in 2005 to add bedroom with ensuite shower room. Certificate of Compliance issued 17th Feb 2006 and council tax updated",
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
"/propertyPack/materialFacts/address": {
|
|
88
|
+
line1: "property.line1",
|
|
89
|
+
line2: "property.line2",
|
|
90
|
+
town: "property.city",
|
|
91
|
+
county: "property.province",
|
|
92
|
+
postcode: "property.postcode",
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
expect(validateVerifiedClaims(clonedVouch)).toEqual([]);
|
|
96
|
+
});
|