@pdtf/schemas 2.1.2-1 → 2.2.0
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/README.md +1 -1
- package/package.json +1 -1
- package/src/examples/v2/exampleTransaction.json +18 -93
- package/src/schemas/v1/material-facts.json +22 -0
- package/src/schemas/v1/searches/local-searches-required.json +2 -2
- package/src/schemas/v1/searches.json +2 -2
- package/src/schemas/v2/combined.json +273 -124
- package/src/schemas/v2/overlays/baspi.json +1 -1
- package/src/schemas/v2/overlays/con29R.json +2 -2
- package/src/schemas/v2/overlays/lpe1.json +24 -9
- package/src/schemas/v2/overlays/piq.json +952 -89
- package/src/schemas/v2/overlays/ta6.json +1 -1
- package/src/schemas/v2/pdtf-transaction.json +180 -122
- package/src/schemas/v2/skeleton.json +6 -7
- package/src/utils/hmlrLLC1.json +38 -119
- package/src/tests/v1/pdtfVerifiedClaims.test.js +0 -75
- package/src/tests/v1/transactionSchema.test.js +0 -227
- package/src/tests/v1/verifiedClaimsValidator.test.js +0 -96
package/src/utils/hmlrLLC1.json
CHANGED
|
@@ -25,22 +25,12 @@
|
|
|
25
25
|
"type": "string"
|
|
26
26
|
},
|
|
27
27
|
"CreationDate": {
|
|
28
|
-
"type": "
|
|
29
|
-
"
|
|
30
|
-
"Value": {
|
|
31
|
-
"type": "string",
|
|
32
|
-
"format": "date"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
28
|
+
"type": "string",
|
|
29
|
+
"format": "date"
|
|
35
30
|
},
|
|
36
31
|
"RegistrationDate": {
|
|
37
|
-
"type": "
|
|
38
|
-
"
|
|
39
|
-
"Value": {
|
|
40
|
-
"type": "string",
|
|
41
|
-
"format": "date"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
32
|
+
"type": "string",
|
|
33
|
+
"format": "date"
|
|
44
34
|
},
|
|
45
35
|
"Category": {
|
|
46
36
|
"type": "string"
|
|
@@ -56,74 +46,37 @@
|
|
|
56
46
|
},
|
|
57
47
|
"Location": {
|
|
58
48
|
"type": "object",
|
|
59
|
-
"required": ["
|
|
49
|
+
"required": ["line1", "Postcode"],
|
|
60
50
|
"properties": {
|
|
61
|
-
"
|
|
62
|
-
"type": "
|
|
63
|
-
"required": ["Postcode"],
|
|
64
|
-
"properties": {
|
|
65
|
-
"Postcode": {
|
|
66
|
-
"type": "string"
|
|
67
|
-
}
|
|
68
|
-
}
|
|
51
|
+
"line1": {
|
|
52
|
+
"type": "string"
|
|
69
53
|
},
|
|
70
|
-
"
|
|
71
|
-
"type": "
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"Value": {
|
|
79
|
-
"type": "number"
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
"minItems": 0
|
|
84
|
-
},
|
|
85
|
-
"Line": {
|
|
86
|
-
"type": "array",
|
|
87
|
-
"items": {
|
|
88
|
-
"type": "string"
|
|
89
|
-
},
|
|
90
|
-
"minItems": 0
|
|
91
|
-
}
|
|
92
|
-
}
|
|
54
|
+
"line2": {
|
|
55
|
+
"type": "string"
|
|
56
|
+
},
|
|
57
|
+
"line3": {
|
|
58
|
+
"type": "string"
|
|
59
|
+
},
|
|
60
|
+
"Postcode": {
|
|
61
|
+
"type": "string"
|
|
93
62
|
}
|
|
94
63
|
}
|
|
95
64
|
},
|
|
96
65
|
"LocationDominantBuilding": {
|
|
97
66
|
"type": "object",
|
|
98
|
-
"required": ["
|
|
67
|
+
"required": ["line1", "Postcode"],
|
|
99
68
|
"properties": {
|
|
100
|
-
"
|
|
101
|
-
"type": "
|
|
102
|
-
"required": ["Postcode"],
|
|
103
|
-
"properties": {
|
|
104
|
-
"Postcode": {
|
|
105
|
-
"type": "string"
|
|
106
|
-
}
|
|
107
|
-
}
|
|
69
|
+
"line1": {
|
|
70
|
+
"type": "string"
|
|
108
71
|
},
|
|
109
|
-
"
|
|
110
|
-
"type": "
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
"minItems": 0
|
|
118
|
-
},
|
|
119
|
-
"Line": {
|
|
120
|
-
"type": "array",
|
|
121
|
-
"items": {
|
|
122
|
-
"type": "string"
|
|
123
|
-
},
|
|
124
|
-
"minItems": 0
|
|
125
|
-
}
|
|
126
|
-
}
|
|
72
|
+
"line2": {
|
|
73
|
+
"type": "string"
|
|
74
|
+
},
|
|
75
|
+
"line3": {
|
|
76
|
+
"type": "string"
|
|
77
|
+
},
|
|
78
|
+
"Postcode": {
|
|
79
|
+
"type": "string"
|
|
127
80
|
}
|
|
128
81
|
}
|
|
129
82
|
},
|
|
@@ -162,45 +115,19 @@
|
|
|
162
115
|
},
|
|
163
116
|
"ApplicantAddress": {
|
|
164
117
|
"type": "object",
|
|
165
|
-
"required": ["
|
|
118
|
+
"required": ["line1", "Postcode"],
|
|
166
119
|
"properties": {
|
|
167
|
-
"
|
|
168
|
-
"type": "
|
|
169
|
-
"required": ["Postcode"],
|
|
170
|
-
"properties": {
|
|
171
|
-
"Postcode": {
|
|
172
|
-
"type": "string"
|
|
173
|
-
}
|
|
174
|
-
}
|
|
120
|
+
"line1": {
|
|
121
|
+
"type": "string"
|
|
175
122
|
},
|
|
176
|
-
"
|
|
177
|
-
"type": "
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
"Value": {
|
|
185
|
-
"type": "number"
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
"minItems": 0
|
|
190
|
-
},
|
|
191
|
-
"Line": {
|
|
192
|
-
"type": "array",
|
|
193
|
-
"items": {
|
|
194
|
-
"type": "object",
|
|
195
|
-
"properties": {
|
|
196
|
-
"Value": {
|
|
197
|
-
"type": "string"
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
"minItems": 0
|
|
202
|
-
}
|
|
203
|
-
}
|
|
123
|
+
"line2": {
|
|
124
|
+
"type": "string"
|
|
125
|
+
},
|
|
126
|
+
"line3": {
|
|
127
|
+
"type": "string"
|
|
128
|
+
},
|
|
129
|
+
"Postcode": {
|
|
130
|
+
"type": "string"
|
|
204
131
|
}
|
|
205
132
|
}
|
|
206
133
|
},
|
|
@@ -257,15 +184,7 @@
|
|
|
257
184
|
"minItems": 0
|
|
258
185
|
},
|
|
259
186
|
"ChargeExtent": {
|
|
260
|
-
"type": "
|
|
261
|
-
"properties": {
|
|
262
|
-
"Value": {
|
|
263
|
-
"type": "string"
|
|
264
|
-
},
|
|
265
|
-
"format": {
|
|
266
|
-
"type": "string"
|
|
267
|
-
}
|
|
268
|
-
}
|
|
187
|
+
"type": "string"
|
|
269
188
|
}
|
|
270
189
|
}
|
|
271
190
|
},
|
|
@@ -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
|
-
});
|