@pdtf/schemas 2.1.2-1 → 2.3.0-1

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.
@@ -59,9 +59,11 @@
59
59
  },
60
60
  "priceInformation": {
61
61
  "price": {},
62
- "priceQualifier": {}
62
+ "priceQualifier": {},
63
+ "disposal": {}
63
64
  },
64
65
  "summaryDescription": {},
66
+ "marketingTenure": {},
65
67
  "media": {
66
68
  "mediaType": {},
67
69
  "mediaUrl": {},
@@ -108,7 +110,8 @@
108
110
  "secondary": {},
109
111
  "college": {},
110
112
  "private": {}
111
- }
113
+ },
114
+ "otherRating": {}
112
115
  },
113
116
  "transport": {
114
117
  "name": {},
@@ -3721,11 +3724,7 @@
3721
3724
  "consequentialChargingBasis": {}
3722
3725
  }
3723
3726
  },
3724
- "recommendedActionIndicator": {},
3725
- "actionAlertRating": {},
3726
- "summary": {},
3727
- "recommendations": {},
3728
- "complianceStatement": {}
3727
+ "riskResults": {}
3729
3728
  }
3730
3729
  },
3731
3730
  "documents": {
@@ -3735,5 +3734,48 @@
3735
3734
  "documentType": {},
3736
3735
  "externalIds": {}
3737
3736
  }
3737
+ },
3738
+ "valuationComparisonData": {
3739
+ "propertyDetails": {
3740
+ "propertyListingInfo": {
3741
+ "listingType": {},
3742
+ "soldDate": {},
3743
+ "soldPrice": {},
3744
+ "listedDate": {},
3745
+ "listPrice": {}
3746
+ },
3747
+ "propertyFullDescription": {},
3748
+ "uprn": {},
3749
+ "propertyType": {},
3750
+ "marketingTenure": {},
3751
+ "basicDetails": {
3752
+ "bedrooms": {},
3753
+ "bathrooms": {},
3754
+ "buildInformation": {
3755
+ "internalArea": {
3756
+ "area": {},
3757
+ "units": {}
3758
+ },
3759
+ "yearOfBuild": {}
3760
+ }
3761
+ },
3762
+ "media": {
3763
+ "mediaType": {},
3764
+ "mediaUrl": {},
3765
+ "caption": {}
3766
+ }
3767
+ },
3768
+ "propertyPricing": {
3769
+ "rentalEstimate": {
3770
+ "estimatedAmount": {},
3771
+ "paymentFrequency": {}
3772
+ },
3773
+ "estimatedPrice": {},
3774
+ "yield": {},
3775
+ "priceEstimationDetails": {
3776
+ "credibilitySources": {},
3777
+ "pricingMethodology": {}
3778
+ }
3779
+ }
3738
3780
  }
3739
3781
  }
@@ -255,6 +255,32 @@ test("correctly gets a subschema validator for a TA6 overlay which fails to vali
255
255
  expect(isValid).toBe(false);
256
256
  });
257
257
 
258
+ test("correctly gets a subschema validator for an NTS overlay", () => {
259
+ const path = "/propertyPack";
260
+ const clonedExampleTransaction = JSON.parse(
261
+ JSON.stringify(exampleTransaction)
262
+ );
263
+ const data = jp.get(clonedExampleTransaction, path);
264
+ const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
265
+ "nts2023",
266
+ ]);
267
+ let isValid = validator(data);
268
+ expect(isValid).toBe(false);
269
+ });
270
+
271
+ test("correctly gets a subschema validator for an LPE1 overlay", () => {
272
+ const path = "/propertyPack";
273
+ const clonedExampleTransaction = JSON.parse(
274
+ JSON.stringify(exampleTransaction)
275
+ );
276
+ const data = jp.get(clonedExampleTransaction, path);
277
+ const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
278
+ "lpe1ed4",
279
+ ]);
280
+ let isValid = validator(data);
281
+ expect(isValid).toBe(false);
282
+ });
283
+
258
284
  test("correctly gets a subschema validator which validates", () => {
259
285
  const path = "/propertyPack/materialFacts/notices";
260
286
  const validator = getSubschemaValidator(path);
@@ -1,75 +0,0 @@
1
- const Ajv = require("ajv");
2
- const addFormats = require("ajv-formats");
3
-
4
- const verifiedClaimsSchema = require("../../schemas/v1/pdtf-verified-claims.json");
5
- const exampleElectronicRecord = require("../../examples/v1/exampleElectronicRecord.json");
6
- const exampleVouch = require("../../examples/v1/exampleVouch.json");
7
- const exampleDocumentedVouch = require("../../examples/v1/exampleDocumentedVouch.json");
8
-
9
- const ajv = new Ajv({
10
- allErrors: true,
11
- strictSchema: false,
12
- discriminator: true,
13
- });
14
- addFormats(ajv);
15
-
16
- const validator = ajv.compile(verifiedClaimsSchema);
17
-
18
- test("valid vouch sample is valid", () => {
19
- const isValid = validator({ verified_claims: [exampleVouch] });
20
- expect(isValid).toBe(true);
21
- });
22
-
23
- test("valid electronic record sample is valid", () => {
24
- const isValid = validator({ verified_claims: [exampleElectronicRecord] });
25
- expect(isValid).toBe(true);
26
- });
27
-
28
- test("valid documented vouch sample is valid", () => {
29
- const isValid = validator({ verified_claims: [exampleDocumentedVouch] });
30
- expect(isValid).toBe(true);
31
- });
32
-
33
- test("sample with primitive claims value is valid", () => {
34
- const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
35
- clonedVouch.claims = { "/propertyPack/uprn": 123456 };
36
- const isValid = validator({ verified_claims: [clonedVouch] });
37
- expect(isValid).toBe(true);
38
- });
39
-
40
- test("sample with undefined claims value is also valid, but this would fail when the payload is validated", () => {
41
- const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
42
- clonedVouch.claims = { "/propertyPack/uprn": undefined };
43
- const isValid = validator({ verified_claims: [clonedVouch] });
44
- expect(isValid).toBe(true);
45
- });
46
-
47
- test("claim with missing claims is invalid", () => {
48
- const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
49
- delete clonedVouch.claims;
50
- const isValid = validator({ verified_claims: [clonedVouch] });
51
- expect(isValid).toBe(false);
52
- });
53
-
54
- test("claim with invalid claims path is invalid", () => {
55
- const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
56
- const originalPath = Object.keys(clonedVouch.claims)[0];
57
- const data = clonedVouch.claims[originalPath];
58
- clonedVouch.claims = { "invalidPath//of?someKind": data };
59
- const isValid = validator({ verified_claims: [clonedVouch] });
60
- expect(isValid).toBe(false);
61
- });
62
-
63
- test("verification with invalid evidence type is invalid", () => {
64
- const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
65
- clonedVouch.verification.evidence[0].type = "something invalid";
66
- const isValid = validator({ verified_claims: [clonedVouch] });
67
- expect(isValid).toBe(false);
68
- });
69
-
70
- test("verification with no framework type is invalid", () => {
71
- const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
72
- delete clonedVouch.verification.trust_framework;
73
- const isValid = validator({ verified_claims: [clonedVouch] });
74
- expect(isValid).toBe(false);
75
- });
@@ -1,227 +0,0 @@
1
- const jp = require("jsonpointer");
2
-
3
- const {
4
- transactionSchema,
5
- validator,
6
- getSubschema,
7
- isPathValid,
8
- getSubschemaValidator,
9
- getTitleAtPath,
10
- } = require("../../../index.js");
11
- const exampleTransaction = require("../../examples/v1/exampleTransaction.json");
12
-
13
- const getV1Subschema = (path) => {
14
- return getSubschema(
15
- path,
16
- "https://trust.propdata.org.uk/schemas/v1/pdtf-transaction.json",
17
- null
18
- );
19
- };
20
-
21
- test("exports a property pack schema", () => {
22
- expect(transactionSchema).not.toBeNull();
23
- });
24
-
25
- test("sample is valid", () => {
26
- const isValid = validator(exampleTransaction);
27
- if (!isValid) console.log(validator.errors);
28
- expect(isValid).toBe(true);
29
- });
30
-
31
- test("invalid sample is invalid", () => {
32
- const clonedExampleTransaction = JSON.parse(
33
- JSON.stringify(exampleTransaction)
34
- );
35
- delete clonedExampleTransaction.propertyPack.materialFacts.notices;
36
- const isValid = validator(clonedExampleTransaction);
37
- expect(isValid).toBe(false);
38
- });
39
-
40
- test("sample with missing dependent required fields is invalid", () => {
41
- const clonedExampleTransaction = JSON.parse(
42
- JSON.stringify(exampleTransaction)
43
- );
44
- clonedExampleTransaction.propertyPack.materialFacts.ownership.ownershipsToBeTransferred[0].ownershipType =
45
- "leasehold";
46
- const isValid = validator(clonedExampleTransaction);
47
- expect(isValid).toBe(false);
48
- });
49
-
50
- test("correctly gets a top level subschema", () => {
51
- const subschema = getSubschema("/propertyPack");
52
- expect(subschema.title).toBe("Property Pack");
53
- });
54
-
55
- test("correctly identifies a valid path", () => {
56
- const isValid = isPathValid("/propertyPack/materialFacts");
57
- expect(isValid).toBe(true);
58
- });
59
-
60
- test("correctly identifies an undefined invalid path", () => {
61
- const isValid = isPathValid("/propertyPack/materialItems");
62
- expect(isValid).toBe(false);
63
- });
64
-
65
- test("correctly identifies an error generating invalid path", () => {
66
- const isValid = isPathValid("/propertyPack/materialItems/someProperty/item");
67
- expect(isValid).toBe(false);
68
- });
69
-
70
- test("correctly identifies an array invalid path", () => {
71
- const isValid = isPathValid("/propertyPack/materialFacts/1/item");
72
- expect(isValid).toBe(false);
73
- });
74
-
75
- test("correctly gets a subschema", () => {
76
- const subschema = getV1Subschema("/propertyPack/materialFacts/notices");
77
- expect(subschema.title).toBe("Notices which Affect the Property");
78
- });
79
-
80
- test("correctly gets a subschema through an arrays element", () => {
81
- const subschema = getV1Subschema(
82
- "/propertyPack/titlesToBeSold/0/registerExtract"
83
- );
84
- expect(subschema.title).toBe("HMLR Official Copy Register Extract");
85
- });
86
-
87
- test("correctly gets another subschema through an arrays element", () => {
88
- const subschema = getV1Subschema("/participants/0/name/firstName");
89
- expect(subschema.title).toBe("First name");
90
- });
91
-
92
- test("correctly gets a subschema through a dependency", () => {
93
- const subschema = getV1Subschema(
94
- "/propertyPack/materialFacts/delayFactors/hasDelayFactors/details"
95
- );
96
- expect(subschema.title).toBe("Details");
97
- });
98
-
99
- test("correctly gets another subschema through a dependency", () => {
100
- const subschema = getV1Subschema(
101
- "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/lengthOfLeaseInYears"
102
- );
103
- expect(subschema.title).toBe("Length of lease (years)");
104
- });
105
-
106
- test("correctly gets yet another subschema through a dependency", () => {
107
- const subschema = getV1Subschema(
108
- "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/rentIncrease/details"
109
- );
110
- expect(subschema.title).toBe("Details");
111
- });
112
-
113
- test("correctly gets yet, yet another subschema through a dependency", () => {
114
- const subschema = getV1Subschema(
115
- "/propertyPack/materialFacts/listingAndConservation/isConservationArea/yesNo"
116
- );
117
- expect(subschema.type).toBe("string");
118
- expect(subschema.enum).toStrictEqual(["Yes", "No"]);
119
- });
120
-
121
- test("correctly gets yet, yet, yet another subschema through a dependency", () => {
122
- const subschema = getV1Subschema(
123
- "/propertyPack/materialFacts/otherIssues/flooding/typeOfFlooding/groundWater/yesNo"
124
- );
125
- expect(subschema.type).toBe("string");
126
- expect(subschema.enum).toStrictEqual(["Yes", "No"]);
127
- });
128
-
129
- test("correctly gets yet, yet, yet another subschema through a second item dependency", () => {
130
- const subschema = getV1Subschema(
131
- "/propertyPack/materialFacts/otherIssues/flooding/typeOfFlooding"
132
- );
133
- expect(subschema.type).toBe("object");
134
- });
135
-
136
- test("correctly gets yes another subschema but through a non-baspi oneOf structure", () => {
137
- const subschema = getV1Subschema(
138
- "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/RestrictionDetails/RestrictionEntry/ChargeRestriction/EntryDetails/EntryText"
139
- );
140
- expect(subschema).toEqual({ type: "string" });
141
- });
142
-
143
- test("correctly gets yes another subschema but through a non-baspi oneOf structure with array option", () => {
144
- const subschema = getV1Subschema(
145
- "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/RestrictionDetails/RestrictionEntry/0/ChargeRestriction/EntryDetails/EntryText"
146
- );
147
- expect(subschema).toEqual({ type: "string" });
148
- });
149
-
150
- test("correctly gets a subschema validator which is already cached", () => {
151
- const validator = getSubschemaValidator(
152
- "/propertyPack/materialFacts/energyEfficiency/certificate"
153
- );
154
- expect(validator).not.toBeNull();
155
- const anotherValidator = getSubschemaValidator(
156
- "/propertyPack/materialFacts/energyEfficiency/certificate"
157
- );
158
- expect(anotherValidator).not.toBeNull();
159
- });
160
-
161
- test("correctly gets a subschema validator which validates", () => {
162
- const path = "/propertyPack/materialFacts/notices";
163
- const validator = getSubschemaValidator(path);
164
- const data = jp.get(exampleTransaction, path);
165
- expect(data.neighbourDevelopment.yesNo).toBe("No");
166
- let isValid = validator(data);
167
- expect(isValid).toBe(true);
168
- data.neighbourDevelopment.yesNo = "Invalid string";
169
- isValid = validator(data);
170
- expect(isValid).toBe(false);
171
- });
172
-
173
- test("correctly gets titles across schemas, arrays and non-existient title properties", () => {
174
- expect(
175
- getTitleAtPath(
176
- transactionSchema,
177
- "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/ownershipType"
178
- )
179
- ).toBe("What type of ownership is the property?");
180
- expect(
181
- getTitleAtPath(
182
- transactionSchema,
183
- "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/lengthOfLeaseInYears"
184
- )
185
- ).toBe("Length of lease (years)");
186
- expect(
187
- getTitleAtPath(
188
- transactionSchema,
189
- "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/annualServiceCharge"
190
- )
191
- ).toBe(
192
- "Amount of current annual service charge/estate rentcharge/maintenance contribution (£)"
193
- );
194
- expect(
195
- getTitleAtPath(transactionSchema, "/propertyPack/materialFacts/invalidPath")
196
- ).toBe(undefined);
197
- expect(
198
- getTitleAtPath(
199
- transactionSchema,
200
- "/propertyPack/titlesToBeSold/0/registerExtract"
201
- )
202
- ).toBe("HMLR Official Copy Register Extract");
203
- expect(
204
- getTitleAtPath(
205
- transactionSchema,
206
- "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/PropertyAddress"
207
- )
208
- ).toBe("Property address");
209
- expect(
210
- getTitleAtPath(
211
- transactionSchema,
212
- "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/InvalidProp"
213
- )
214
- ).toBe(undefined);
215
- expect(
216
- getTitleAtPath(
217
- transactionSchema,
218
- "/propertyPack/energyPerformanceCertificate/certificate/currentEnergyRating"
219
- )
220
- ).toBe("Current energy rating");
221
- expect(
222
- getTitleAtPath(
223
- transactionSchema,
224
- "/propertyPack/additionalLegalInfo/occupiers/othersAged17OrOver/aged17OrOverNames/0/firstName"
225
- )
226
- ).toBe("First Name");
227
- });
@@ -1,96 +0,0 @@
1
- const { validateVerifiedClaims } = require("../../../index.js");
2
-
3
- const exampleVouch = require("../../examples/v1/exampleVouch.json");
4
- const exampleDocumentedVouch = require("../../examples/v1/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
- });