@pdtf/schemas 0.5.8 → 0.5.9
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 +43 -1
- package/package.json +1 -1
- package/src/schemas/baspi-a-material-facts.json +93 -74
- package/src/schemas/baspi-b-legal-information.json +25 -11
- package/src/schemas/property-pack.json +27 -16
- package/src/schemas/title-deed.json +8 -2
- package/src/tests/examplePropertyPack.json +11 -7
- package/src/tests/propertyPackSchema.test.js +65 -1
package/index.js
CHANGED
|
@@ -39,7 +39,7 @@ const getSubschema = (path) => {
|
|
|
39
39
|
return schema;
|
|
40
40
|
}
|
|
41
41
|
return pathArray.reduce((propertyPackSchema, pathElement) => {
|
|
42
|
-
return propertyPackSchema
|
|
42
|
+
return propertyPackSchema.properties[pathElement];
|
|
43
43
|
}, propertyPackSchema);
|
|
44
44
|
};
|
|
45
45
|
|
|
@@ -47,11 +47,53 @@ const getSubschemaValidator = (path) => {
|
|
|
47
47
|
return ajv.getSchema(path) || ajv.compile(getSubschema(path));
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
+
const getTitleAtPath = (schema, path, rootPath = path) => {
|
|
51
|
+
if (path === "") path = "/";
|
|
52
|
+
let pathArray = path.split("/").slice(1);
|
|
53
|
+
if (pathArray.length === 1 && pathArray[0] === "") {
|
|
54
|
+
if (schema.title) return schema.title;
|
|
55
|
+
// no 'title' property present, so we use the property name to create a readable descriptor
|
|
56
|
+
const propertyName = rootPath
|
|
57
|
+
.split("/")
|
|
58
|
+
.pop()
|
|
59
|
+
.replace(/([A-Z])/g, " $1")
|
|
60
|
+
.toLowerCase()
|
|
61
|
+
.trim();
|
|
62
|
+
return propertyName.charAt(0).toUpperCase() + propertyName.slice(1);
|
|
63
|
+
}
|
|
64
|
+
const propertyName = pathArray.shift();
|
|
65
|
+
const subPath = "/" + pathArray.join("/");
|
|
66
|
+
let subSchema = schema.properties?.[propertyName];
|
|
67
|
+
if (subSchema) {
|
|
68
|
+
return getTitleAtPath(subSchema, subPath, rootPath);
|
|
69
|
+
}
|
|
70
|
+
if (schema.type === "array") {
|
|
71
|
+
subSchema = schema.items;
|
|
72
|
+
return getTitleAtPath(subSchema, subPath, rootPath);
|
|
73
|
+
}
|
|
74
|
+
const dependencies = schema.dependencies;
|
|
75
|
+
if (dependencies) {
|
|
76
|
+
// only single dependency discriminator, oneOf keyword is supported
|
|
77
|
+
const dependencyDiscriminator = Object.keys(dependencies)[0];
|
|
78
|
+
const oneOfs = dependencies[dependencyDiscriminator].oneOf;
|
|
79
|
+
const matchingOneOf = oneOfs.find(
|
|
80
|
+
(oneOf) => oneOf["properties"][propertyName]
|
|
81
|
+
);
|
|
82
|
+
if (matchingOneOf)
|
|
83
|
+
return getTitleAtPath(
|
|
84
|
+
matchingOneOf["properties"][propertyName],
|
|
85
|
+
subPath,
|
|
86
|
+
rootPath
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
50
91
|
module.exports = {
|
|
51
92
|
propertyPackSchema,
|
|
52
93
|
validator,
|
|
53
94
|
getSubschema,
|
|
54
95
|
getSubschemaValidator,
|
|
96
|
+
getTitleAtPath,
|
|
55
97
|
pdtfClaim,
|
|
56
98
|
verifiedClaim
|
|
57
99
|
};
|
package/package.json
CHANGED
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"address",
|
|
10
10
|
"delayFactors",
|
|
11
11
|
"ownership",
|
|
12
|
-
"
|
|
12
|
+
"parking",
|
|
13
13
|
"listingAndConservation",
|
|
14
|
-
"
|
|
14
|
+
"flammableExternalWallSystem",
|
|
15
15
|
"energyEfficiency",
|
|
16
16
|
"councilTax",
|
|
17
17
|
"disputesAndComplaints",
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
"annualServiceCharge",
|
|
96
96
|
"largeAdditionalExpense",
|
|
97
97
|
"additionalFeesOnSale",
|
|
98
|
-
"
|
|
99
|
-
"
|
|
98
|
+
"freeholderContactDetails",
|
|
99
|
+
"managingAgentContactDetails",
|
|
100
100
|
"managementCompanyDirectorRequirement"
|
|
101
101
|
],
|
|
102
102
|
"properties": {
|
|
@@ -165,7 +165,8 @@
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
}
|
|
168
|
+
},
|
|
169
|
+
"required": ["leaseholdDetails"]
|
|
169
170
|
},
|
|
170
171
|
{
|
|
171
172
|
"properties": {
|
|
@@ -180,8 +181,8 @@
|
|
|
180
181
|
"annualServiceCharge",
|
|
181
182
|
"largeAdditionalExpense",
|
|
182
183
|
"additionalFeesOnSale",
|
|
183
|
-
"
|
|
184
|
-
"
|
|
184
|
+
"freeholderContactDetails",
|
|
185
|
+
"managingAgentContactDetails",
|
|
185
186
|
"managementCompanyDirectorRequirement"
|
|
186
187
|
],
|
|
187
188
|
"properties": {
|
|
@@ -209,13 +210,13 @@
|
|
|
209
210
|
"freeholderContactDetails": {
|
|
210
211
|
"baspiRef": "A1.5.4",
|
|
211
212
|
"RDSRef": "TenureAgreements/Assignor",
|
|
212
|
-
"title": "The
|
|
213
|
+
"title": "The contact details of the freeholder or rentcharge owner",
|
|
213
214
|
"$ref": "#/$defs/contactDetails"
|
|
214
215
|
},
|
|
215
216
|
"managingAgentContactDetails": {
|
|
216
217
|
"baspiRef": "A1.5.5",
|
|
217
218
|
"RDSRef": "Participants/Role",
|
|
218
|
-
"title": "The
|
|
219
|
+
"title": "The contact details of the managing agent",
|
|
219
220
|
"$ref": "#/$defs/contactDetails"
|
|
220
221
|
},
|
|
221
222
|
"managementCompanyDirectorRequirement": {
|
|
@@ -226,76 +227,85 @@
|
|
|
226
227
|
}
|
|
227
228
|
}
|
|
228
229
|
}
|
|
229
|
-
}
|
|
230
|
+
},
|
|
231
|
+
"required": ["managedFreeholdOrCommonhold"]
|
|
230
232
|
}
|
|
231
233
|
]
|
|
232
234
|
}
|
|
233
235
|
}
|
|
234
236
|
},
|
|
235
|
-
"
|
|
237
|
+
"parking": {
|
|
236
238
|
"baspiRef": "A1.6",
|
|
237
239
|
"RDSRef": "Services/Parking",
|
|
238
240
|
"lawSocietyRef": "TA6/9.1",
|
|
239
|
-
"title": "Parking
|
|
241
|
+
"title": "Parking",
|
|
240
242
|
"type": "object",
|
|
241
|
-
"required": ["
|
|
243
|
+
"required": ["parkingArrangements", "electricVehicleChargingPoint"],
|
|
242
244
|
"properties": {
|
|
243
|
-
"
|
|
244
|
-
"
|
|
245
|
-
"title": "
|
|
246
|
-
"
|
|
247
|
-
"
|
|
248
|
-
"
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
245
|
+
"parkingArrangements": {
|
|
246
|
+
"type": "object",
|
|
247
|
+
"title": "Parking arrangements",
|
|
248
|
+
"required": ["parkingArrangementsType"],
|
|
249
|
+
"properties": {
|
|
250
|
+
"parkingArrangementsType": {
|
|
251
|
+
"baspiRef": "A1.6.1",
|
|
252
|
+
"title": "What type of parking arrangements are there?",
|
|
253
|
+
"type": "string",
|
|
254
|
+
"enum": [
|
|
255
|
+
"Garage",
|
|
256
|
+
"Allocated parking space",
|
|
257
|
+
"Driveway",
|
|
258
|
+
"On street",
|
|
259
|
+
"Resident permit",
|
|
260
|
+
"Metered parking",
|
|
261
|
+
"Communal parking",
|
|
262
|
+
"None",
|
|
263
|
+
"Other"
|
|
264
|
+
]
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
"dependencies": {
|
|
268
|
+
"parkingArrangementsType": {
|
|
269
|
+
"oneOf": [
|
|
270
|
+
{
|
|
271
|
+
"properties": {
|
|
272
|
+
"parkingArrangementsType": {
|
|
273
|
+
"enum": [
|
|
274
|
+
"Garage",
|
|
275
|
+
"Allocated parking space",
|
|
276
|
+
"Driveway",
|
|
277
|
+
"On street",
|
|
278
|
+
"Resident permit",
|
|
279
|
+
"Metered parking",
|
|
280
|
+
"Communal parking",
|
|
281
|
+
"None"
|
|
282
|
+
]
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
"additionalProperties": false
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
"properties": {
|
|
289
|
+
"parkingArrangementsType": {
|
|
290
|
+
"enum": ["Other"]
|
|
291
|
+
},
|
|
292
|
+
"otherParkingType": {
|
|
293
|
+
"baspiRef": "A1.6.2",
|
|
294
|
+
"title": "Please describe the other parking arrangements",
|
|
295
|
+
"type": "string"
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
"required": ["otherParkingType"]
|
|
299
|
+
}
|
|
300
|
+
]
|
|
301
|
+
}
|
|
302
|
+
}
|
|
258
303
|
},
|
|
259
304
|
"electricVehicleChargingPoint": {
|
|
260
305
|
"baspiRef": "A1.6.1",
|
|
261
306
|
"title": "Is there an electric vehicle charging point belonging to the property?",
|
|
262
307
|
"$ref": "#/$defs/yesNo"
|
|
263
308
|
}
|
|
264
|
-
},
|
|
265
|
-
"dependencies": {
|
|
266
|
-
"parkingArrangementsType": {
|
|
267
|
-
"oneOf": [
|
|
268
|
-
{
|
|
269
|
-
"properties": {
|
|
270
|
-
"parkingArrangementsType": {
|
|
271
|
-
"enum": [
|
|
272
|
-
"Garage",
|
|
273
|
-
"Allocated parking space",
|
|
274
|
-
"Driveway",
|
|
275
|
-
"On street",
|
|
276
|
-
"Resident permit",
|
|
277
|
-
"Metered parking",
|
|
278
|
-
"Communal parking",
|
|
279
|
-
"None"
|
|
280
|
-
]
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
"properties": {
|
|
286
|
-
"parkingArrangementsType": {
|
|
287
|
-
"enum": ["Other"]
|
|
288
|
-
},
|
|
289
|
-
"otherParkingType": {
|
|
290
|
-
"baspiRef": "A1.6.2",
|
|
291
|
-
"title": "Please describe the other parking arrangements",
|
|
292
|
-
"type": "string"
|
|
293
|
-
}
|
|
294
|
-
},
|
|
295
|
-
"required": ["otherParkingType"]
|
|
296
|
-
}
|
|
297
|
-
]
|
|
298
|
-
}
|
|
299
309
|
}
|
|
300
310
|
},
|
|
301
311
|
"listingAndConservation": {
|
|
@@ -375,16 +385,25 @@
|
|
|
375
385
|
}
|
|
376
386
|
}
|
|
377
387
|
},
|
|
378
|
-
"
|
|
388
|
+
"flammableExternalWallSystem": {
|
|
379
389
|
"baspiRef": "A1.8.2",
|
|
380
390
|
"RDSRef": "Property/Flags,Certificates",
|
|
381
|
-
"
|
|
382
|
-
"
|
|
383
|
-
"
|
|
384
|
-
"
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
391
|
+
"type": "object",
|
|
392
|
+
"required": ["hasFlammableExternalWallSystem"],
|
|
393
|
+
"properties": {
|
|
394
|
+
"hasFlammableExternalWallSystem": {
|
|
395
|
+
"baspiRef": "A2.1",
|
|
396
|
+
"RDSRef": "Tenure/DisputesComplaints,Tenure/LegalClaims",
|
|
397
|
+
"lawSocietyRef": "TA6/2.1",
|
|
398
|
+
"title": "Does the property have potentially flammable external wall system - including cladding and balconies etc?",
|
|
399
|
+
"type": "string",
|
|
400
|
+
"enum": [
|
|
401
|
+
"Yes (EWS form attached)",
|
|
402
|
+
"Yes (No external wall system review to hand)",
|
|
403
|
+
"No"
|
|
404
|
+
]
|
|
405
|
+
}
|
|
406
|
+
}
|
|
388
407
|
},
|
|
389
408
|
"energyEfficiency": {
|
|
390
409
|
"baspiRef": "1.8.3",
|
|
@@ -577,7 +596,7 @@
|
|
|
577
596
|
"notices": {
|
|
578
597
|
"baspiRef": "A4",
|
|
579
598
|
"title": "Notices which Affect the Property",
|
|
580
|
-
"description": "Are you aware of, or have you received any of the following notices?",
|
|
599
|
+
"description": "Are you aware of, or have you received, any of the following notices?",
|
|
581
600
|
"type": "object",
|
|
582
601
|
"required": [
|
|
583
602
|
"neighbourDevelopment",
|
|
@@ -1118,7 +1137,7 @@
|
|
|
1118
1137
|
"partOnSeparateSiteOrDeed": {
|
|
1119
1138
|
"baspiRef": "A9.2",
|
|
1120
1139
|
"RDSRef": "Tenure *with different property entity and references etc*",
|
|
1121
|
-
"title": "Is any part of the property on a separate site or separate title
|
|
1140
|
+
"title": "Is any part of the property on a separate site or separate title number e.g. garden, outbuilding, parking, garage?",
|
|
1122
1141
|
"$ref": "#/$defs/yesNoDetailIfYes"
|
|
1123
1142
|
},
|
|
1124
1143
|
"boundariesDifferFromTitlePlan": {
|
|
@@ -1300,7 +1319,7 @@
|
|
|
1300
1319
|
"RDSRef": "Tenure/OtherMaterialIssues",
|
|
1301
1320
|
"title": "Are you aware of any other material issue or information which relates to the property or has anything occurred which may affect the average person’s decision to proceed? (This disclosure is required under the Consumer Protection from Unfair Trading Regulations 2008)",
|
|
1302
1321
|
"$ref": "#/$defs/yesNoDetailIfYes",
|
|
1303
|
-
"description": "If yes, please describe this issue and any action that has been taken, if applicable
|
|
1322
|
+
"description": "If yes, please describe this issue and any action that has been taken, if applicable."
|
|
1304
1323
|
}
|
|
1305
1324
|
}
|
|
1306
1325
|
},
|
|
@@ -53,7 +53,14 @@
|
|
|
53
53
|
"RDSRef": "Participants/description=?,Participants/ActingFor/Participants/Role",
|
|
54
54
|
"title": "Sellers Conveyancer",
|
|
55
55
|
"type": "object",
|
|
56
|
-
"required": [
|
|
56
|
+
"required": [
|
|
57
|
+
"firstName",
|
|
58
|
+
"lastName",
|
|
59
|
+
"address",
|
|
60
|
+
"email",
|
|
61
|
+
"organisation",
|
|
62
|
+
"reference"
|
|
63
|
+
],
|
|
57
64
|
"properties": {
|
|
58
65
|
"firstName": {
|
|
59
66
|
"title": "First name",
|
|
@@ -63,15 +70,20 @@
|
|
|
63
70
|
"title": "Last name",
|
|
64
71
|
"type": "string"
|
|
65
72
|
},
|
|
66
|
-
"address": {
|
|
67
|
-
"title": "Address",
|
|
68
|
-
"$ref": "#/$defs/address"
|
|
69
|
-
},
|
|
70
73
|
"email": {
|
|
71
74
|
"title": "Email address",
|
|
72
75
|
"type": "string",
|
|
73
76
|
"format": "email"
|
|
74
77
|
},
|
|
78
|
+
"organisation": {
|
|
79
|
+
"title": "Organisation",
|
|
80
|
+
"type": "string"
|
|
81
|
+
},
|
|
82
|
+
"address": {
|
|
83
|
+
"title": "Address",
|
|
84
|
+
"$ref": "#/$defs/address"
|
|
85
|
+
},
|
|
86
|
+
|
|
75
87
|
"reference": {
|
|
76
88
|
"title": "Reference",
|
|
77
89
|
"type": "string"
|
|
@@ -315,8 +327,8 @@
|
|
|
315
327
|
"baspiRef": "",
|
|
316
328
|
"RDSRef": "Objects/Ownership",
|
|
317
329
|
"title": "Do you own the panels, and all equipment related to them, outright?",
|
|
318
|
-
"$ref": "#/$defs/
|
|
319
|
-
"description": "If
|
|
330
|
+
"$ref": "#/$defs/yesNoDetailIfNo",
|
|
331
|
+
"description": "If no, provide details of who owns them and the relevant documentation"
|
|
320
332
|
},
|
|
321
333
|
"panelProviderLease": {
|
|
322
334
|
"baspiRef": "B4.3.2",
|
|
@@ -366,7 +378,7 @@
|
|
|
366
378
|
"stopcockAndWaterMeterLocation": {
|
|
367
379
|
"baspiRef": "B4.6",
|
|
368
380
|
"RDSRef": "Objects/class='meters|valve|stopcock'&access=?&accessLocation=?",
|
|
369
|
-
"title": "Please describe, or attach a photograph of, the location of
|
|
381
|
+
"title": "Please describe, or attach a photograph of, the location of any stopcock and water meter",
|
|
370
382
|
"type": "string"
|
|
371
383
|
},
|
|
372
384
|
"photovoltaicMeterPanelLocation": {
|
|
@@ -375,7 +387,7 @@
|
|
|
375
387
|
"title": "Please describe, or attach a photograph of, the location of any photovoltaic panel meter",
|
|
376
388
|
"type": "string"
|
|
377
389
|
},
|
|
378
|
-
"
|
|
390
|
+
"photovoltaicBatteriesLocation": {
|
|
379
391
|
"baspiRef": "B4.8",
|
|
380
392
|
"RDSRef": "Objects/class='meters|valve|stopcock'&access=?&accessLocation=?",
|
|
381
393
|
"title": "Please describe, or attach a photograph of, the location of any photovoltaic batteries",
|
|
@@ -461,7 +473,8 @@
|
|
|
461
473
|
"hasValidGuaranteesOrWarranties": {
|
|
462
474
|
"enum": ["No"]
|
|
463
475
|
}
|
|
464
|
-
}
|
|
476
|
+
},
|
|
477
|
+
"additionalProperties": false
|
|
465
478
|
},
|
|
466
479
|
{
|
|
467
480
|
"properties": {
|
|
@@ -542,7 +555,8 @@
|
|
|
542
555
|
"baspiRef": "B5.1.11",
|
|
543
556
|
"RDSRef": "Property/Flags",
|
|
544
557
|
"title": "Please confirm that you will leave all paperwork relating to any guarantee or warranty at the property when you move out",
|
|
545
|
-
"
|
|
558
|
+
"type": "boolean",
|
|
559
|
+
"const": true
|
|
546
560
|
},
|
|
547
561
|
"outstandingClaimsOrApplications": {
|
|
548
562
|
"baspiRef": "B5.2",
|
|
@@ -29,32 +29,43 @@
|
|
|
29
29
|
"type": "object",
|
|
30
30
|
"title": "Seller information",
|
|
31
31
|
"required": [
|
|
32
|
-
"
|
|
33
|
-
"lastName",
|
|
32
|
+
"name",
|
|
34
33
|
"dateOfBirth",
|
|
35
|
-
"
|
|
34
|
+
"mobileNumber",
|
|
35
|
+
"email",
|
|
36
36
|
"address"
|
|
37
37
|
],
|
|
38
38
|
"properties": {
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
"name": {
|
|
40
|
+
"title": "Name",
|
|
41
|
+
"type": "object",
|
|
42
|
+
"required": ["firstName", "lastName"],
|
|
43
|
+
"properties": {
|
|
44
|
+
"firstName": {
|
|
45
|
+
"RDSRef": "",
|
|
46
|
+
"title": "First name",
|
|
47
|
+
"type": "string"
|
|
48
|
+
},
|
|
49
|
+
"middleNames": {
|
|
50
|
+
"title": "Middle name(s)",
|
|
51
|
+
"type": "string"
|
|
52
|
+
},
|
|
53
|
+
"lastName": {
|
|
54
|
+
"title": "Last name",
|
|
55
|
+
"type": "string"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
51
58
|
},
|
|
52
59
|
"dateOfBirth": {
|
|
53
60
|
"title": "Date of birth",
|
|
54
61
|
"type": "string",
|
|
55
62
|
"format": "date"
|
|
56
63
|
},
|
|
57
|
-
"
|
|
64
|
+
"mobileNumber": {
|
|
65
|
+
"title": "Mobile number",
|
|
66
|
+
"type": "string"
|
|
67
|
+
},
|
|
68
|
+
"email": {
|
|
58
69
|
"title": "Email address",
|
|
59
70
|
"type": "string",
|
|
60
71
|
"format": "email"
|
|
@@ -766,7 +766,13 @@
|
|
|
766
766
|
},
|
|
767
767
|
"type": "object",
|
|
768
768
|
"properties": {
|
|
769
|
-
"OCSummaryData": {
|
|
770
|
-
|
|
769
|
+
"OCSummaryData": {
|
|
770
|
+
"title": "Official Copy Summary Data",
|
|
771
|
+
"$ref": "#/definitions/Q1OCSummaryDataType"
|
|
772
|
+
},
|
|
773
|
+
"OCRegisterData": {
|
|
774
|
+
"title": "Official Copy Register Data",
|
|
775
|
+
"$ref": "#/definitions/Q1OCRegisterDataType"
|
|
776
|
+
}
|
|
771
777
|
}
|
|
772
778
|
}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
"propertyPack": {
|
|
5
5
|
"sellers": [
|
|
6
6
|
{
|
|
7
|
-
"firstName": "John",
|
|
8
|
-
"lastName": "Davies",
|
|
7
|
+
"name": { "firstName": "John", "lastName": "Davies" },
|
|
9
8
|
"dateOfBirth": "1975-12-25",
|
|
10
|
-
"
|
|
9
|
+
"mobileNumber": "07777 222333",
|
|
10
|
+
"email": "john@theseller.com",
|
|
11
11
|
"address": { "address1": "10 Downend Park", "postcode": "BS7 9PU" }
|
|
12
12
|
}
|
|
13
13
|
],
|
|
@@ -28,9 +28,11 @@
|
|
|
28
28
|
"ownership": {
|
|
29
29
|
"ownershipType": "Freehold"
|
|
30
30
|
},
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
|
|
31
|
+
"parking": {
|
|
32
|
+
"parkingArrangements": {
|
|
33
|
+
"parkingArrangementsType": "Other",
|
|
34
|
+
"otherParkingType": "Garage and double width driveway"
|
|
35
|
+
},
|
|
34
36
|
"electricVehicleChargingPoint": { "yesNo": "No" }
|
|
35
37
|
},
|
|
36
38
|
"listingAndConservation": {
|
|
@@ -44,7 +46,9 @@
|
|
|
44
46
|
"yesNo": "No"
|
|
45
47
|
}
|
|
46
48
|
},
|
|
47
|
-
"
|
|
49
|
+
"flammableExternalWallSystem": {
|
|
50
|
+
"hasFlammableExternalWallSystem": "No"
|
|
51
|
+
},
|
|
48
52
|
"councilTax": {
|
|
49
53
|
"councilTaxBand": "A",
|
|
50
54
|
"councilTaxAffectingAlterations": {
|
|
@@ -4,7 +4,8 @@ const {
|
|
|
4
4
|
propertyPackSchema,
|
|
5
5
|
validator,
|
|
6
6
|
getSubschema,
|
|
7
|
-
getSubschemaValidator
|
|
7
|
+
getSubschemaValidator,
|
|
8
|
+
getTitleAtPath
|
|
8
9
|
} = require("../../index.js");
|
|
9
10
|
const examplePropertyPack = require("./examplePropertyPack.json");
|
|
10
11
|
|
|
@@ -27,6 +28,16 @@ test("invalid sample is invalid", () => {
|
|
|
27
28
|
expect(isValid).toBe(false);
|
|
28
29
|
});
|
|
29
30
|
|
|
31
|
+
test("sample with missing dependent required fields is invalid", () => {
|
|
32
|
+
const clonedExamplePropertyPack = JSON.parse(
|
|
33
|
+
JSON.stringify(examplePropertyPack)
|
|
34
|
+
);
|
|
35
|
+
clonedExamplePropertyPack.propertyPack.materialFacts.ownership.ownershipType =
|
|
36
|
+
"leashold";
|
|
37
|
+
const isValid = validator(clonedExamplePropertyPack);
|
|
38
|
+
expect(isValid).toBe(false);
|
|
39
|
+
});
|
|
40
|
+
|
|
30
41
|
test("correctly gets a subschema", () => {
|
|
31
42
|
const subschema = getSubschema("/propertyPack/materialFacts/notices");
|
|
32
43
|
expect(subschema.title).toBe("Notices which Affect the Property");
|
|
@@ -43,3 +54,56 @@ test("correctly gets a working subschema validator", () => {
|
|
|
43
54
|
isValid = validator(data);
|
|
44
55
|
expect(isValid).toBe(false);
|
|
45
56
|
});
|
|
57
|
+
|
|
58
|
+
test("correctly gets titles across schemas, arrays and non-existient title properties", () => {
|
|
59
|
+
expect(
|
|
60
|
+
getTitleAtPath(
|
|
61
|
+
propertyPackSchema,
|
|
62
|
+
"/propertyPack/materialFacts/ownership/ownershipType"
|
|
63
|
+
)
|
|
64
|
+
).toBe("What type of ownership is the property?");
|
|
65
|
+
expect(
|
|
66
|
+
getTitleAtPath(
|
|
67
|
+
propertyPackSchema,
|
|
68
|
+
"/propertyPack/materialFacts/ownership/leaseholdDetails/lengthOfLeaseInYears"
|
|
69
|
+
)
|
|
70
|
+
).toBe("Length of lease (years)");
|
|
71
|
+
expect(
|
|
72
|
+
getTitleAtPath(
|
|
73
|
+
propertyPackSchema,
|
|
74
|
+
"/propertyPack/materialFacts/ownership/managedFreeholdOrCommonhold/annualServiceCharge"
|
|
75
|
+
)
|
|
76
|
+
).toBe(
|
|
77
|
+
"Amount of current annual service charge/estate rentcharge/maintenance contribution (£)"
|
|
78
|
+
);
|
|
79
|
+
expect(
|
|
80
|
+
getTitleAtPath(
|
|
81
|
+
propertyPackSchema,
|
|
82
|
+
"/propertyPack/materialFacts/invalidPath"
|
|
83
|
+
)
|
|
84
|
+
).toBe(undefined);
|
|
85
|
+
expect(
|
|
86
|
+
getTitleAtPath(
|
|
87
|
+
propertyPackSchema,
|
|
88
|
+
"/propertyPack/titlesToBeSold/0/registerExtract"
|
|
89
|
+
)
|
|
90
|
+
).toBe("Property Data Trust Framework HMLR Register Extract representation");
|
|
91
|
+
expect(
|
|
92
|
+
getTitleAtPath(
|
|
93
|
+
propertyPackSchema,
|
|
94
|
+
"/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/PropertyAddress"
|
|
95
|
+
)
|
|
96
|
+
).toBe("Property address");
|
|
97
|
+
expect(
|
|
98
|
+
getTitleAtPath(
|
|
99
|
+
propertyPackSchema,
|
|
100
|
+
"/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/InvalidProp"
|
|
101
|
+
)
|
|
102
|
+
).toBe(undefined);
|
|
103
|
+
expect(
|
|
104
|
+
getTitleAtPath(
|
|
105
|
+
propertyPackSchema,
|
|
106
|
+
"/propertyPack/energyPerformanceCertificate/certificate/currentEnergyRating"
|
|
107
|
+
)
|
|
108
|
+
).toBe("Current energy rating");
|
|
109
|
+
});
|