@pdtf/schemas 0.5.15 → 0.6.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/_config.yml ADDED
@@ -0,0 +1 @@
1
+ theme: jekyll-theme-minimal
package/index.js CHANGED
@@ -2,7 +2,7 @@ const { dereference } = require("@jdw/jst");
2
2
  const Ajv = require("ajv");
3
3
  const addFormats = require("ajv-formats");
4
4
 
5
- const propertyPack = require("./src/schemas/property-pack.json");
5
+ const pdtfTransaction = require("./src/schemas/pdtf-transaction.json");
6
6
  const baspiMaterialFacts = require("./src/schemas/baspi-a-material-facts.json");
7
7
  const baspiLegalInformation = require("./src/schemas/baspi-b-legal-information.json");
8
8
  const energyPerformanceCertificate = require("./src/schemas/energy-performance-certificate.json");
@@ -11,17 +11,18 @@ const geoJson = require("./src/schemas/GeoJSON.json");
11
11
  const verifiedClaimsSchema = require("./src/schemas/pdtf-verified-claims.json");
12
12
 
13
13
  const subSchemas = {
14
- "https://homebuyingandsellinggroup.co.uk/schemas/baspi-a-material-facts.json":
14
+ "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/baspi-a-material-facts.json":
15
15
  baspiMaterialFacts,
16
- "https://homebuyingandsellinggroup.co.uk/schemas/baspi-b-legal-information.json":
16
+ "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/baspi-b-legal-information.json":
17
17
  baspiLegalInformation,
18
- "https://homebuyingandsellinggroup.co.uk/schemas/energy-performance-certificate.json":
18
+ "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/energy-performance-certificate.json":
19
19
  energyPerformanceCertificate,
20
20
  "https://geojson.org/schema/GeoJSON.json": geoJson,
21
- "https://homebuyingandsellinggroup.co.uk/schemas/title-deed.json": titleDeed,
21
+ "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/title-deed.json":
22
+ titleDeed,
22
23
  };
23
24
 
24
- const propertyPackSchema = dereference(propertyPack, (id) => subSchemas[id]);
25
+ const transactionSchema = dereference(pdtfTransaction, (id) => subSchemas[id]);
25
26
 
26
27
  const ajv = new Ajv({
27
28
  allErrors: true,
@@ -31,17 +32,25 @@ const ajv = new Ajv({
31
32
  // Adds date formats among other types to the validator.
32
33
  addFormats(ajv);
33
34
 
34
- const validator = ajv.compile(propertyPackSchema);
35
+ const validator = ajv.compile(transactionSchema);
35
36
 
36
37
  const getSubschema = (path) => {
37
38
  const pathArray = path.split("/").slice(1);
38
39
  if (pathArray.length < 1) {
39
- return propertyPackSchema;
40
+ return transactionSchema;
40
41
  }
41
42
  return pathArray.reduce((schema, pathElement) => {
42
43
  if (schema.type === "array") return schema.items;
43
44
  return schema.properties[pathElement];
44
- }, propertyPackSchema);
45
+ }, transactionSchema);
46
+ };
47
+
48
+ const isPathValid = (path) => {
49
+ try {
50
+ return getSubschema(path) !== undefined;
51
+ } catch (err) {
52
+ return false;
53
+ }
45
54
  };
46
55
 
47
56
  const getSubschemaValidator = (path) => {
@@ -100,9 +109,10 @@ const getTitleAtPath = (schema, path, rootPath = path) => {
100
109
  };
101
110
 
102
111
  module.exports = {
103
- propertyPackSchema,
112
+ transactionSchema,
104
113
  validator,
105
114
  getSubschema,
115
+ isPathValid,
106
116
  getSubschemaValidator,
107
117
  getTitleAtPath,
108
118
  verifiedClaimsSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdtf/schemas",
3
- "version": "0.5.15",
3
+ "version": "0.6.3",
4
4
  "description": "Property Data Trust Framework Schemas and Utilities",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -31,7 +31,7 @@
31
31
  ]
32
32
  },
33
33
  "claims": {
34
- "/propertyPack/materialFacts/propertyToBeSold/councilTax": {
34
+ "/propertyPack/materialFacts/councilTax": {
35
35
  "councilTaxBand": "D",
36
36
  "councilTaxAffectingAlterations": {
37
37
  "yesNo": "Yes",
@@ -5,9 +5,13 @@
5
5
  "evidence": [
6
6
  {
7
7
  "type": "electronic_record",
8
+ "verifier": {
9
+ "organization": "Property Pack Assembly Software Ltd"
10
+ },
8
11
  "record": {
9
12
  "source": {
10
- "name": "Royal Mail Postcode Address File record via ideal-postcodes.co.uk"
13
+ "name": "Royal Mail Postcode Address File",
14
+ "rights": "(c) Royal Mail"
11
15
  },
12
16
  "type": "postcode_address_file"
13
17
  }
@@ -1,19 +1,23 @@
1
1
  {
2
- "$schema": "https://homebuyingandsellinggroup.co.uk/schemas/property-pack.json",
3
- "uprn": 100000059583,
2
+ "$schema": "https://homebuyingandsellinggroup.co.uk/schemas/pdtf-transaction.json",
3
+ "transactionId": "3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a",
4
+ "status": "active",
5
+ "participants": [
6
+ {
7
+ "name": {
8
+ "forenames": "Peter Ronald",
9
+ "surname": "Hetherington-Smythe"
10
+ },
11
+ "dateOfBirth": "1975-12-25",
12
+ "phone": "07777 222333",
13
+ "email": "peter@theseller.com",
14
+ "address": { "address1": "47 Park Road", "postcode": "AL3 5AF" },
15
+ "role": "Seller"
16
+ }
17
+ ],
4
18
  "propertyPack": {
5
- "sellers": {
6
- "sellerInformation": [
7
- {
8
- "name": { "firstName": "Peter", "lastName": "Hetherington-Smythe" },
9
- "dateOfBirth": "1975-12-25",
10
- "mobileNumber": "07777 222333",
11
- "email": "john@theseller.com",
12
- "address": { "address1": "47 Park Road", "postcode": "AL3 5AF" }
13
- }
14
- ]
15
- },
16
19
  "materialFacts": {
20
+ "uprn": 1241304304,
17
21
  "address": {
18
22
  "address1": "47 Park Road",
19
23
  "address2": "",
@@ -18,7 +18,7 @@
18
18
  ]
19
19
  },
20
20
  "claims": {
21
- "/propertyPack/materialFacts/propertyToBeSold/delayFactors/hasDelayFactors": {
21
+ "/propertyPack/materialFacts/delayFactors/hasDelayFactors": {
22
22
  "yesNo": "No"
23
23
  }
24
24
  }
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://homebuyingandsellinggroup.co.uk/schemas/baspi-a-material-facts.json",
3
+ "$id": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/baspi-a-material-facts.json",
4
4
  "type": "object",
5
5
  "title": "Material facts at the point of marketing",
6
6
  "description": "BASPI v2.0 Part A - Disclosure of material facts at the point of marketing, supporting mapping to BASPI, Law Society and RICS Data Schema elements.",
7
7
  "baspiRef": "A",
8
8
  "required": [
9
+ "uprn",
9
10
  "address",
10
11
  "delayFactors",
11
12
  "ownership",
@@ -31,6 +32,11 @@
31
32
  "consumerProtectionRegulationsDeclaration"
32
33
  ],
33
34
  "properties": {
35
+ "uprn": {
36
+ "RDSRef": "Property/GUID/{name='UPRN',id=?}",
37
+ "title": "Unique Property Reference Number ",
38
+ "type": "integer"
39
+ },
34
40
  "address": {
35
41
  "baspiRef": "A1.1",
36
42
  "RDSRef": "Property/Address/xal:AddressDetails",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://homebuyingandsellinggroup.co.uk/schemas/baspi-b-legal-information.json",
3
+ "$id": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/baspi-b-legal-information.json",
4
4
  "type": "object",
5
5
  "title": "Additional information required for the legal process",
6
6
  "description": "A schema defining Part B of BASPI v2.0 spporting mapping to BASPI, Law Society and RICS Data Schema elements.",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://homebuyingandsellinggroup.co.uk/schemas/energy-performance-certificate.json",
3
+ "$id": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/energy-performance-certificate.json",
4
4
  "type": "object",
5
5
  "title": "Energy Performance Certificate and Recommendations Schema, supporting data retrieved from https://epc.opendatacommunities.org ",
6
6
  "description": "Mirrors the Domestic EPC Glossary at https://epc.opendatacommunities.org/docs/guidance#glossary",
@@ -0,0 +1,275 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/pdtf-transaction.json",
4
+ "type": "object",
5
+ "title": "Property Data Trust Framework Transaction Schema",
6
+ "description": "A schema defining the PDTF transaction data structure, supporting mapping to BASPI, Law Society and RICS Data Schema elements.",
7
+ "required": [
8
+ "$schema",
9
+ "transactionId",
10
+ "status",
11
+ "participants",
12
+ "propertyPack"
13
+ ],
14
+ "properties": {
15
+ "$schema": {
16
+ "type": "string"
17
+ },
18
+ "transactionId": {
19
+ "title": "UUID for the transaction",
20
+ "type": "string",
21
+ "format": "uuid"
22
+ },
23
+ "status": {
24
+ "type": "string",
25
+ "enum": ["active", "cancelled", "completed"]
26
+ },
27
+ "participants": {
28
+ "title": "Transaction participants",
29
+ "type": "array",
30
+ "minItems": 1,
31
+ "items": {
32
+ "type": "object",
33
+ "title": "Participant Details",
34
+ "required": ["name", "email", "role"],
35
+ "properties": {
36
+ "name": {
37
+ "title": "",
38
+ "type": "object",
39
+ "required": ["forenames", "surname"],
40
+ "properties": {
41
+ "forenames": {
42
+ "title": "Forenames",
43
+ "type": "string"
44
+ },
45
+ "preferredName": {
46
+ "title": "Preferred name / known as",
47
+ "type": "string"
48
+ },
49
+ "surname": {
50
+ "title": "Surname",
51
+ "type": "string"
52
+ }
53
+ }
54
+ },
55
+ "dateOfBirth": {
56
+ "title": "Date of birth",
57
+ "type": "string",
58
+ "format": "date"
59
+ },
60
+ "phone": {
61
+ "title": "Phone number",
62
+ "type": "string"
63
+ },
64
+ "email": {
65
+ "title": "Email address",
66
+ "type": "string",
67
+ "format": "email"
68
+ },
69
+ "address": {
70
+ "title": "Address",
71
+ "$ref": "#/$defs/address"
72
+ },
73
+ "organisation": {
74
+ "title": "Organisation",
75
+ "type": "string"
76
+ },
77
+ "organisationReference": {
78
+ "title": "Reference",
79
+ "type": "string"
80
+ },
81
+ "role": {
82
+ "title": "Role",
83
+ "type": "string",
84
+ "enum": [
85
+ "Seller",
86
+ "Seller's Conveyancer",
87
+ "Prospective Buyer",
88
+ "Buyer",
89
+ "Buyer's Conveyancer",
90
+ "Estate Agent"
91
+ ]
92
+ }
93
+ }
94
+ }
95
+ },
96
+ "propertyPack": {
97
+ "title": "Property Pack",
98
+ "type": "object",
99
+ "properties": {
100
+ "materialFacts": {
101
+ "$ref": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/baspi-a-material-facts.json"
102
+ },
103
+ "additionalLegalInfo": {
104
+ "$ref": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/baspi-b-legal-information.json"
105
+ },
106
+ "titlesToBeSold": {
107
+ "RDSRef": "",
108
+ "title": "Title(s) as registered with HMLR which are included in the sale",
109
+ "type": "array",
110
+ "items": {
111
+ "type": "object",
112
+ "title": "Registered Title",
113
+ "properties": {
114
+ "titleNumber": {
115
+ "RDSRef": "",
116
+ "title": "Title Number",
117
+ "type": "string"
118
+ },
119
+ "titleExtents": {
120
+ "RDSRef": "",
121
+ "title": "Title Extents",
122
+ "description": "One or more index polygons describing indicative location of registered title from National Polygon Dataset",
123
+ "type": "array",
124
+ "items": {
125
+ "$ref": "https://geojson.org/schema/GeoJSON.json"
126
+ }
127
+ },
128
+ "registerExtract": {
129
+ "title": "HMLR Register Extract",
130
+ "$ref": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/title-deed.json"
131
+ }
132
+ }
133
+ }
134
+ },
135
+ "energyPerformanceCertificate": {
136
+ "RDSRef": "",
137
+ "title": "Energy Performance Certificate",
138
+ "$ref": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/energy-performance-certificate.json"
139
+ },
140
+ "risks": {
141
+ "RDSRef": "",
142
+ "title": "Risks",
143
+ "type": "object",
144
+ "properties": {
145
+ "coalMining": {
146
+ "title": "Coal mining",
147
+ "$ref": "#/$defs/riskIndicatorAndSearch"
148
+ },
149
+ "flood": {
150
+ "title": "Flood",
151
+ "$ref": "#/$defs/riskIndicatorAndSearch"
152
+ },
153
+ "miningAndGroundStability": {
154
+ "title": "Mining and ground stability",
155
+ "type": "object",
156
+ "properties": {
157
+ "bathStone": {
158
+ "title": "Bath Stone",
159
+ "$ref": "#/$defs/riskIndicatorAndSearch"
160
+ },
161
+ "metalliferousTin": {
162
+ "title": "Matalliferous (Tin)",
163
+ "$ref": "#/$defs/riskIndicatorAndSearch"
164
+ },
165
+ "kaolinAndBallClay": {
166
+ "title": "Kaolin and ball clay",
167
+ "$ref": "#/$defs/riskIndicatorAndSearch"
168
+ },
169
+ "limestone": {
170
+ "title": "Limestone",
171
+ "$ref": "#/$defs/riskIndicatorAndSearch"
172
+ },
173
+ "brine": {
174
+ "title": "Brine",
175
+ "$ref": "#/$defs/riskIndicatorAndSearch"
176
+ },
177
+ "groundStability": {
178
+ "title": "Ground stability",
179
+ "$ref": "#/$defs/riskIndicatorAndSearch"
180
+ },
181
+ "nonCoalMining": {
182
+ "title": "Non coal mining",
183
+ "$ref": "#/$defs/riskIndicatorAndSearch"
184
+ },
185
+ "groundMovement": {
186
+ "title": "Ground movement",
187
+ "$ref": "#/$defs/riskIndicatorAndSearch"
188
+ },
189
+ "mineral": {
190
+ "title": "Mineral",
191
+ "$ref": "#/$defs/riskIndicatorAndSearch"
192
+ }
193
+ }
194
+ },
195
+ "energyAndInfrastructure": {
196
+ "title": "Energy and infrastructure",
197
+ "type": "object",
198
+ "properties": {
199
+ "hs2": {
200
+ "title": "HS2",
201
+ "$ref": "#/$defs/riskIndicatorAndSearch"
202
+ },
203
+ "crossrail": {
204
+ "title": "Crossrail",
205
+ "$ref": "#/$defs/riskIndicatorAndSearch"
206
+ },
207
+ "londonUnderground": {
208
+ "title": "London Underground",
209
+ "$ref": "#/$defs/riskIndicatorAndSearch"
210
+ },
211
+ "energyExploration": {
212
+ "title": "Energy exploration",
213
+ "$ref": "#/$defs/riskIndicatorAndSearch"
214
+ },
215
+ "windFarms": {
216
+ "title": "Wind farms",
217
+ "$ref": "#/$defs/riskIndicatorAndSearch"
218
+ },
219
+ "solarFarms": {
220
+ "title": "Solar farms",
221
+ "$ref": "#/$defs/riskIndicatorAndSearch"
222
+ },
223
+ "renewablePowerPlants": {
224
+ "title": "Renewable power plants",
225
+ "$ref": "#/$defs/riskIndicatorAndSearch"
226
+ }
227
+ }
228
+ }
229
+ }
230
+ }
231
+ }
232
+ }
233
+ },
234
+ "$defs": {
235
+ "address": {
236
+ "type": "object",
237
+ "properties": {
238
+ "address1": {
239
+ "title": "Address 1",
240
+ "type": "string",
241
+ "minLength": 1
242
+ },
243
+ "address2": {
244
+ "title": "Address 2",
245
+ "type": "string"
246
+ },
247
+ "town": {
248
+ "title": "Town",
249
+ "type": "string"
250
+ },
251
+ "county": {
252
+ "title": "County",
253
+ "type": "string"
254
+ },
255
+ "postcode": {
256
+ "title": "Postcode",
257
+ "type": "string",
258
+ "minLength": 1
259
+ }
260
+ },
261
+ "required": ["address1", "postcode"]
262
+ },
263
+ "riskIndicatorAndSearch": {
264
+ "type": "object",
265
+ "properties": {
266
+ "hasRisk": {
267
+ "title": "",
268
+ "type": "string",
269
+ "enum": ["Yes", "No"]
270
+ }
271
+ },
272
+ "required": ["address1", "postcode"]
273
+ }
274
+ }
275
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://homebuyingandsellinggroup.co.uk/schemas/pdtf-verified-claims.json",
3
+ "$id": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/pdtf-verified-claims.json",
4
4
  "definitions": {
5
5
  "date_type": {
6
6
  "type": "string",
@@ -134,8 +134,7 @@
134
134
  "$ref": "#/definitions/document_details"
135
135
  }
136
136
  }
137
- },
138
- "else": {}
137
+ }
139
138
  },
140
139
  {
141
140
  "if": {
@@ -155,6 +154,7 @@
155
154
  },
156
155
  "verifier": {
157
156
  "type": "object",
157
+ "required": ["organization"],
158
158
  "properties": {
159
159
  "organization": {
160
160
  "type": "string"
@@ -169,6 +169,7 @@
169
169
  },
170
170
  "record": {
171
171
  "type": "object",
172
+ "required": ["source"],
172
173
  "properties": {
173
174
  "type": {
174
175
  "type": "string"
@@ -184,6 +185,7 @@
184
185
  },
185
186
  "source": {
186
187
  "type": "object",
188
+ "required": ["name"],
187
189
  "properties": {
188
190
  "name": {
189
191
  "type": "string"
@@ -211,14 +213,14 @@
211
213
  },
212
214
  "jurisdiction": {
213
215
  "type": "string"
214
- }
216
+ },
217
+ "rights": { "type": "string" }
215
218
  }
216
219
  }
217
220
  }
218
221
  }
219
222
  }
220
- },
221
- "else": {}
223
+ }
222
224
  },
223
225
  {
224
226
  "if": {
@@ -307,8 +309,7 @@
307
309
  }
308
310
  }
309
311
  }
310
- },
311
- "else": {}
312
+ }
312
313
  }
313
314
  ]
314
315
  },
@@ -386,7 +387,7 @@
386
387
  "claims": {
387
388
  "type": "object",
388
389
  "patternProperties": {
389
- "^(/|([a-zA-Z0-9/-]+)+$)": { "type": "object" }
390
+ "^(/|([a-zA-Z0-9/-]+)+$)": {}
390
391
  },
391
392
  "minProperties": 1,
392
393
  "additionalProperties": false
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://homebuyingandsellinggroup.co.uk/schemas/title-deed.json",
3
+ "$id": "https://raw.githubusercontent.com/Property-Data-Trust-Framework/schemas/master/src/schemas/title-deed.json",
4
4
  "title": "HMLR Official Copy Register Extract",
5
5
  "description": "A schema mirroring the V2_1 XML version of the HMLR Register Extract web service.",
6
6
  "definitions": {
@@ -29,6 +29,20 @@ test("valid documented vouch sample is valid", () => {
29
29
  expect(isValid).toBe(true);
30
30
  });
31
31
 
32
+ test("sample with primitive claims value is valid", () => {
33
+ const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
34
+ clonedVouch.claims = { "/propertyPack/uprn": 123456 };
35
+ const isValid = validator({ verified_claims: clonedVouch });
36
+ expect(isValid).toBe(true);
37
+ });
38
+
39
+ test("sample with undefined claims value is also valid, but this would fail when the payload is validated", () => {
40
+ const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
41
+ clonedVouch.claims = { "/propertyPack/uprn": undefined };
42
+ const isValid = validator({ verified_claims: clonedVouch });
43
+ expect(isValid).toBe(true);
44
+ });
45
+
32
46
  test("claim with missing claims is invalid", () => {
33
47
  const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
34
48
  delete clonedVouch.claims;
@@ -1,40 +1,41 @@
1
1
  const jp = require("jsonpointer");
2
2
 
3
3
  const {
4
- propertyPackSchema,
4
+ transactionSchema,
5
5
  validator,
6
6
  getSubschema,
7
+ isPathValid,
7
8
  getSubschemaValidator,
8
9
  getTitleAtPath,
9
10
  } = require("../../index.js");
10
- const examplePropertyPack = require("../examples/examplePropertyPack.json");
11
+ const exampleTransaction = require("../examples/exampleTransaction.json");
11
12
 
12
13
  test("exports a property pack schema", () => {
13
- expect(propertyPackSchema).not.toBeNull();
14
+ expect(transactionSchema).not.toBeNull();
14
15
  });
15
16
 
16
17
  test("sample is valid", () => {
17
- const isValid = validator(examplePropertyPack);
18
+ const isValid = validator(exampleTransaction);
18
19
  if (!isValid) console.log(validator.errors);
19
20
  expect(isValid).toBe(true);
20
21
  });
21
22
 
22
23
  test("invalid sample is invalid", () => {
23
- const clonedExamplePropertyPack = JSON.parse(
24
- JSON.stringify(examplePropertyPack)
24
+ const clonedExampleTransaction = JSON.parse(
25
+ JSON.stringify(exampleTransaction)
25
26
  );
26
- delete clonedExamplePropertyPack.propertyPack.materialFacts.notices;
27
- const isValid = validator(clonedExamplePropertyPack);
27
+ delete clonedExampleTransaction.propertyPack.materialFacts.notices;
28
+ const isValid = validator(clonedExampleTransaction);
28
29
  expect(isValid).toBe(false);
29
30
  });
30
31
 
31
32
  test("sample with missing dependent required fields is invalid", () => {
32
- const clonedExamplePropertyPack = JSON.parse(
33
- JSON.stringify(examplePropertyPack)
33
+ const clonedExampleTransaction = JSON.parse(
34
+ JSON.stringify(exampleTransaction)
34
35
  );
35
- clonedExamplePropertyPack.propertyPack.materialFacts.ownership.ownershipType =
36
+ clonedExampleTransaction.propertyPack.materialFacts.ownership.ownershipType =
36
37
  "leashold";
37
- const isValid = validator(clonedExamplePropertyPack);
38
+ const isValid = validator(clonedExampleTransaction);
38
39
  expect(isValid).toBe(false);
39
40
  });
40
41
 
@@ -43,6 +44,26 @@ test("correctly gets a top level subschema", () => {
43
44
  expect(subschema.title).toBe("Property Pack");
44
45
  });
45
46
 
47
+ test("correctly identifies a valid path", () => {
48
+ const isValid = isPathValid("/propertyPack/materialFacts");
49
+ expect(isValid).toBe(true);
50
+ });
51
+
52
+ test("correctly identifies an undefined invalid path", () => {
53
+ const isValid = isPathValid("/propertyPack/materialItems");
54
+ expect(isValid).toBe(false);
55
+ });
56
+
57
+ test("correctly identifies an error generating invalid path", () => {
58
+ const isValid = isPathValid("/propertyPack/materialItems/someProperty/item");
59
+ expect(isValid).toBe(false);
60
+ });
61
+
62
+ test("correctly identifies an array invalid path", () => {
63
+ const isValid = isPathValid("/propertyPack/materialFacts/1/item");
64
+ expect(isValid).toBe(false);
65
+ });
66
+
46
67
  test("correctly gets a subschema", () => {
47
68
  const subschema = getSubschema("/propertyPack/materialFacts/notices");
48
69
  expect(subschema.title).toBe("Notices which Affect the Property");
@@ -56,10 +77,8 @@ test("correctly gets a subschema through an arrays element", () => {
56
77
  });
57
78
 
58
79
  test("correctly gets another subschema through an arrays element", () => {
59
- const subschema = getSubschema(
60
- "/propertyPack/sellers/sellerInformation/0/name/firstName"
61
- );
62
- expect(subschema.title).toBe("First name");
80
+ const subschema = getSubschema("/participants/0/name/forenames");
81
+ expect(subschema.title).toBe("Forenames");
63
82
  });
64
83
 
65
84
  test("correctly gets a subschema validator which is already cached", () => {
@@ -76,7 +95,7 @@ test("correctly gets a subschema validator which is already cached", () => {
76
95
  test("correctly gets a subschema validator which validates", () => {
77
96
  const path = "/propertyPack/materialFacts/notices";
78
97
  const validator = getSubschemaValidator(path);
79
- const data = jp.get(examplePropertyPack, path);
98
+ const data = jp.get(exampleTransaction, path);
80
99
  expect(data.neighbourDevelopment.yesNo).toBe("No");
81
100
  let isValid = validator(data);
82
101
  expect(isValid).toBe(true);
@@ -88,51 +107,48 @@ test("correctly gets a subschema validator which validates", () => {
88
107
  test("correctly gets titles across schemas, arrays and non-existient title properties", () => {
89
108
  expect(
90
109
  getTitleAtPath(
91
- propertyPackSchema,
110
+ transactionSchema,
92
111
  "/propertyPack/materialFacts/ownership/ownershipType"
93
112
  )
94
113
  ).toBe("What type of ownership is the property?");
95
114
  expect(
96
115
  getTitleAtPath(
97
- propertyPackSchema,
116
+ transactionSchema,
98
117
  "/propertyPack/materialFacts/ownership/leaseholdDetails/lengthOfLeaseInYears"
99
118
  )
100
119
  ).toBe("Length of lease (years)");
101
120
  expect(
102
121
  getTitleAtPath(
103
- propertyPackSchema,
122
+ transactionSchema,
104
123
  "/propertyPack/materialFacts/ownership/managedFreeholdOrCommonhold/annualServiceCharge"
105
124
  )
106
125
  ).toBe(
107
126
  "Amount of current annual service charge/estate rentcharge/maintenance contribution (£)"
108
127
  );
109
128
  expect(
110
- getTitleAtPath(
111
- propertyPackSchema,
112
- "/propertyPack/materialFacts/invalidPath"
113
- )
129
+ getTitleAtPath(transactionSchema, "/propertyPack/materialFacts/invalidPath")
114
130
  ).toBe(undefined);
115
131
  expect(
116
132
  getTitleAtPath(
117
- propertyPackSchema,
133
+ transactionSchema,
118
134
  "/propertyPack/titlesToBeSold/0/registerExtract"
119
135
  )
120
136
  ).toBe("HMLR Official Copy Register Extract");
121
137
  expect(
122
138
  getTitleAtPath(
123
- propertyPackSchema,
139
+ transactionSchema,
124
140
  "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/PropertyAddress"
125
141
  )
126
142
  ).toBe("Property address");
127
143
  expect(
128
144
  getTitleAtPath(
129
- propertyPackSchema,
145
+ transactionSchema,
130
146
  "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/InvalidProp"
131
147
  )
132
148
  ).toBe(undefined);
133
149
  expect(
134
150
  getTitleAtPath(
135
- propertyPackSchema,
151
+ transactionSchema,
136
152
  "/propertyPack/energyPerformanceCertificate/certificate/currentEnergyRating"
137
153
  )
138
154
  ).toBe("Current energy rating");
@@ -1,159 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://homebuyingandsellinggroup.co.uk/schemas/property-pack.json",
4
- "type": "object",
5
- "title": "Property Data Trust Framework Schema",
6
- "description": "A schema defining the PDTF Property Pack data structure, supporting mapping to BASPI, Law Society and RICS Data Schema elements.",
7
- "required": ["$schema", "uprn", "propertyPack"],
8
- "properties": {
9
- "$schema": {
10
- "title": "The version reference ($id) of the PDTF Schema used",
11
- "type": "string"
12
- },
13
- "uprn": {
14
- "RDSRef": "Property/GUID/{name='UPRN',id=?}",
15
- "title": "Unique Property Reference Number ",
16
- "type": "integer"
17
- },
18
- "propertyPack": {
19
- "title": "Property Pack",
20
- "type": "object",
21
- "properties": {
22
- "sellers": {
23
- "RDSRef": "",
24
- "title": "Information about the sellers",
25
- "type": "object",
26
- "required": ["sellerInformation"],
27
- "properties": {
28
- "sellerInformation": {
29
- "title": "",
30
- "type": "array",
31
- "minItems": 1,
32
- "items": {
33
- "type": "object",
34
- "title": "Seller Details",
35
- "required": [
36
- "name",
37
- "dateOfBirth",
38
- "mobileNumber",
39
- "email",
40
- "address"
41
- ],
42
- "properties": {
43
- "name": {
44
- "title": "",
45
- "type": "object",
46
- "required": ["firstName", "lastName"],
47
- "properties": {
48
- "firstName": {
49
- "RDSRef": "",
50
- "title": "First name",
51
- "type": "string"
52
- },
53
- "middleNames": {
54
- "title": "Middle name(s)",
55
- "type": "string"
56
- },
57
- "lastName": {
58
- "title": "Last name",
59
- "type": "string"
60
- }
61
- }
62
- },
63
- "dateOfBirth": {
64
- "title": "Date of birth",
65
- "type": "string",
66
- "format": "date"
67
- },
68
- "mobileNumber": {
69
- "title": "Mobile number",
70
- "type": "string"
71
- },
72
- "email": {
73
- "title": "Email address",
74
- "type": "string",
75
- "format": "email"
76
- },
77
- "address": {
78
- "title": "Address",
79
- "$ref": "#/$defs/address"
80
- }
81
- }
82
- }
83
- }
84
- }
85
- },
86
- "materialFacts": {
87
- "$ref": "https://homebuyingandsellinggroup.co.uk/schemas/baspi-a-material-facts.json"
88
- },
89
- "additionalLegalInfo": {
90
- "$ref": "https://homebuyingandsellinggroup.co.uk/schemas/baspi-b-legal-information.json"
91
- },
92
- "titlesToBeSold": {
93
- "RDSRef": "",
94
- "title": "Title(s) as registered with HMLR which are included in the sale",
95
- "type": "array",
96
- "items": {
97
- "type": "object",
98
- "title": "Registered Title",
99
- "properties": {
100
- "titleNumber": {
101
- "RDSRef": "",
102
- "title": "Title Number",
103
- "type": "string"
104
- },
105
- "titleExtents": {
106
- "RDSRef": "",
107
- "title": "Title Extents",
108
- "description": "One or more index polygons describing indicative location of registered title from National Polygon Dataset",
109
- "type": "array",
110
- "items": {
111
- "$ref": "https://geojson.org/schema/GeoJSON.json"
112
- }
113
- },
114
- "registerExtract": {
115
- "title": "HMLR Register Extract",
116
- "$ref": "https://homebuyingandsellinggroup.co.uk/schemas/title-deed.json"
117
- }
118
- }
119
- }
120
- },
121
- "energyPerformanceCertificate": {
122
- "RDSRef": "",
123
- "title": "Energy Performance Certificate",
124
- "$ref": "https://homebuyingandsellinggroup.co.uk/schemas/energy-performance-certificate.json"
125
- }
126
- }
127
- }
128
- },
129
- "$defs": {
130
- "address": {
131
- "type": "object",
132
- "properties": {
133
- "address1": {
134
- "title": "Address 1",
135
- "type": "string",
136
- "minLength": 1
137
- },
138
- "address2": {
139
- "title": "Address 2",
140
- "type": "string"
141
- },
142
- "town": {
143
- "title": "Town",
144
- "type": "string"
145
- },
146
- "county": {
147
- "title": "County",
148
- "type": "string"
149
- },
150
- "postcode": {
151
- "title": "Postcode",
152
- "type": "string",
153
- "minLength": 1
154
- }
155
- },
156
- "required": ["address1", "postcode"]
157
- }
158
- }
159
- }