@pdtf/schemas 0.5.10 → 0.5.13

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 CHANGED
@@ -8,8 +8,7 @@ const baspiLegalInformation = require("./src/schemas/baspi-b-legal-information.j
8
8
  const energyPerformanceCertificate = require("./src/schemas/energy-performance-certificate.json");
9
9
  const titleDeed = require("./src/schemas/title-deed.json");
10
10
  const geoJson = require("./src/schemas/GeoJSON.json");
11
- const pdtfClaim = require("./src/schemas/pdtf-claim.json");
12
- const verifiedClaim = require("./src/schemas/verified_claims-12.json");
11
+ const verifiedClaimsSchema = require("./src/schemas/pdtf-verified-claims.json");
13
12
 
14
13
  const subSchemas = {
15
14
  "https://homebuyingandsellinggroup.co.uk/schemas/baspi-a-material-facts.json":
@@ -26,6 +25,7 @@ const propertyPackSchema = dereference(propertyPack, (id) => subSchemas[id]);
26
25
 
27
26
  const ajv = new Ajv({
28
27
  allErrors: true,
28
+ // schema contains additional baspiRef and RDSRef metadata which is not strictly valid
29
29
  strictSchema: false
30
30
  });
31
31
  // Adds date formats among other types to the validator.
@@ -52,6 +52,7 @@ const getTitleAtPath = (schema, path, rootPath = path) => {
52
52
  let pathArray = path.split("/").slice(1);
53
53
  if (pathArray.length === 1 && pathArray[0] === "") {
54
54
  if (schema.title) return schema.title;
55
+ if (schema.title === "") return ""; // deliberately blank
55
56
  // no 'title' property present, so we use the property name to create a readable descriptor
56
57
  const propertyName = rootPath
57
58
  .split("/")
@@ -96,6 +97,5 @@ module.exports = {
96
97
  getSubschema,
97
98
  getSubschemaValidator,
98
99
  getTitleAtPath,
99
- pdtfClaim,
100
- verifiedClaim
100
+ verifiedClaimsSchema
101
101
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdtf/schemas",
3
- "version": "0.5.10",
3
+ "version": "0.5.13",
4
4
  "description": "Property Data Trust Framework Schemas and Utilities",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -0,0 +1,42 @@
1
+ {
2
+ "verification": {
3
+ "trust_framework": "uk_pdtf",
4
+ "time": "2022-01-25T13:16:44.527Z",
5
+ "evidence": [
6
+ {
7
+ "verification_method": {
8
+ "type": "auth"
9
+ },
10
+ "type": "vouch",
11
+ "attestation": {
12
+ "voucher": {
13
+ "name": "Maria Harris"
14
+ },
15
+ "type": "digital_attestation"
16
+ }
17
+ },
18
+ {
19
+ "type": "document",
20
+ "attachments": [
21
+ {
22
+ "digest": {
23
+ "alg": "md5",
24
+ "value": "randomHashValue"
25
+ },
26
+ "url": "https://fakeFileStore.com/some/kind/of/file",
27
+ "desc": "proofOfAddress.pdf"
28
+ }
29
+ ]
30
+ }
31
+ ]
32
+ },
33
+ "claims": {
34
+ "/propertyPack/materialFacts/propertyToBeSold/councilTax": {
35
+ "councilTaxBand": "D",
36
+ "councilTaxAffectingAlterations": {
37
+ "yesNo": "Yes",
38
+ "details": "Extension added in 2005 to add bedroom with ensuite shower room. Certificate of Compliance issued 17th Feb 2006 and council tax updated"
39
+ }
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "verification": {
3
+ "time": "2022-01-25T07:52:14.318Z",
4
+ "trust_framework": "uk_pdtf",
5
+ "evidence": [
6
+ {
7
+ "type": "electronic_record",
8
+ "record": {
9
+ "source": {
10
+ "name": "Royal Mail Postcode Address File record via ideal-postcodes.co.uk"
11
+ },
12
+ "type": "paf"
13
+ }
14
+ }
15
+ ]
16
+ },
17
+ "claims": {
18
+ "/propertyPack/materialFacts/propertyToBeSold/address": {
19
+ "address1": "3 The Hollys",
20
+ "address2": "Birtley",
21
+ "town": "CHESTER LE STREET",
22
+ "county": "County Durham",
23
+ "postcode": "DH3 1QN"
24
+ }
25
+ }
26
+ }
@@ -2,15 +2,17 @@
2
2
  "$schema": "https://homebuyingandsellinggroup.co.uk/schemas/property-pack.json",
3
3
  "uprn": 100000059583,
4
4
  "propertyPack": {
5
- "sellers": [
6
- {
7
- "name": { "firstName": "John", "lastName": "Davies" },
8
- "dateOfBirth": "1975-12-25",
9
- "mobileNumber": "07777 222333",
10
- "email": "john@theseller.com",
11
- "address": { "address1": "10 Downend Park", "postcode": "BS7 9PU" }
12
- }
13
- ],
5
+ "sellers": {
6
+ "sellerInformation": [
7
+ {
8
+ "name": { "firstName": "John", "lastName": "Davies" },
9
+ "dateOfBirth": "1975-12-25",
10
+ "mobileNumber": "07777 222333",
11
+ "email": "john@theseller.com",
12
+ "address": { "address1": "10 Downend Park", "postcode": "BS7 9PU" }
13
+ }
14
+ ]
15
+ },
14
16
  "materialFacts": {
15
17
  "address": {
16
18
  "address1": "10 Downend Park",
@@ -23,7 +25,9 @@
23
25
  "energyEfficiencyRating": "A"
24
26
  },
25
27
  "delayFactors": {
26
- "yesNo": "No"
28
+ "hasDelayFactors": {
29
+ "yesNo": "No"
30
+ }
27
31
  },
28
32
  "ownership": {
29
33
  "ownershipType": "Freehold"
@@ -0,0 +1,25 @@
1
+ {
2
+ "verification": {
3
+ "trust_framework": "uk_pdtf",
4
+ "time": "2022-01-25T13:05:03.108Z",
5
+ "evidence": [
6
+ {
7
+ "type": "vouch",
8
+ "attestation": {
9
+ "type": "digital_attestation",
10
+ "voucher": {
11
+ "name": "Maria Harris"
12
+ }
13
+ },
14
+ "verification_method": {
15
+ "type": "auth"
16
+ }
17
+ }
18
+ ]
19
+ },
20
+ "claims": {
21
+ "/propertyPack/materialFacts/propertyToBeSold/delayFactors/hasDelayFactors": {
22
+ "yesNo": "No"
23
+ }
24
+ }
25
+ }
@@ -41,8 +41,15 @@
41
41
  "baspiRef": "A1.2",
42
42
  "RDSRef": "Metadata/PotentialDelays,Metadata/PotentialDelayDuration",
43
43
  "title": "Delay Factors",
44
- "$ref": "#/$defs/yesNoDetailIfYes",
45
- "description": "Are you aware of any factors which might delay or complicate the sale? E.g. family split, pending application for grant of probate, absent seller or unregistered title? If yes, provide details and likely timescale for delay (if known)"
44
+ "type": "object",
45
+ "required": ["hasDelayFactors"],
46
+ "properties": {
47
+ "hasDelayFactors": {
48
+ "title": "Are you aware of any factors which might delay or complicate the sale?",
49
+ "description": "E.g. family split, pending application for grant of probate, absent seller or unregistered title? If yes, provide details and likely timescale for delay (if known)",
50
+ "$ref": "#/$defs/yesNoDetailIfYes"
51
+ }
52
+ }
46
53
  },
47
54
  "ownership": {
48
55
  "baspiRef": "A1.3",
@@ -0,0 +1,417 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://homebuyingandsellinggroup.co.uk/schemas/pdtf-verified-claims.json",
4
+ "definitions": {
5
+ "date_type": {
6
+ "type": "string",
7
+ "format": "date"
8
+ },
9
+ "time_type": {
10
+ "type": "string",
11
+ "format": "date-time"
12
+ },
13
+ "document_number": {
14
+ "type": "string"
15
+ },
16
+ "document_details": {
17
+ "type": "object",
18
+ "properties": {
19
+ "type": {
20
+ "type": "string"
21
+ },
22
+ "document_number": {
23
+ "$ref": "#/definitions/document_number"
24
+ },
25
+ "number": {
26
+ "$ref": "#/definitions/document_number"
27
+ },
28
+ "personal_number": {
29
+ "type": "string"
30
+ },
31
+ "serial_number": {
32
+ "type": "string"
33
+ },
34
+ "date_of_issuance": {
35
+ "$ref": "#/definitions/date_type"
36
+ },
37
+ "date_of_expiry": {
38
+ "$ref": "#/definitions/date_type"
39
+ },
40
+ "issuer": {
41
+ "type": "object",
42
+ "properties": {
43
+ "name": {
44
+ "type": "string"
45
+ },
46
+ "formatted": {
47
+ "type": "string"
48
+ },
49
+ "street_address": {
50
+ "type": "string"
51
+ },
52
+ "locality": {
53
+ "type": "string"
54
+ },
55
+ "region": {
56
+ "type": "string"
57
+ },
58
+ "postal_code": {
59
+ "type": "string"
60
+ },
61
+ "country": {
62
+ "type": "string"
63
+ },
64
+ "country_code": {
65
+ "type": "string"
66
+ },
67
+ "jurisdiction": {
68
+ "type": "string"
69
+ }
70
+ }
71
+ }
72
+ }
73
+ },
74
+ "validation_method": {
75
+ "type": "object",
76
+ "properties": {
77
+ "type": {
78
+ "type": "string"
79
+ }
80
+ }
81
+ },
82
+ "verification_method": {
83
+ "type": "object",
84
+ "properties": {
85
+ "type": {
86
+ "type": "string"
87
+ }
88
+ }
89
+ },
90
+ "evidence": {
91
+ "type": "object",
92
+ "properties": {
93
+ "type": {
94
+ "type": "string",
95
+ "enum": ["document", "electronic_record", "vouch"]
96
+ },
97
+ "attachments": {
98
+ "$ref": "#/definitions/attachments"
99
+ }
100
+ },
101
+ "required": ["type"],
102
+ "allOf": [
103
+ {
104
+ "if": {
105
+ "properties": {
106
+ "type": {
107
+ "const": "document"
108
+ }
109
+ }
110
+ },
111
+ "then": {
112
+ "properties": {
113
+ "validation_method": {
114
+ "$ref": "#/definitions/validation_method"
115
+ },
116
+ "verification_method": {
117
+ "$ref": "#/definitions/verification_method"
118
+ },
119
+ "verifier": {
120
+ "type": "object",
121
+ "properties": {
122
+ "organization": {
123
+ "type": "string"
124
+ },
125
+ "txn": {
126
+ "type": "string"
127
+ }
128
+ }
129
+ },
130
+ "time": {
131
+ "$ref": "#/definitions/time_type"
132
+ },
133
+ "document_details": {
134
+ "$ref": "#/definitions/document_details"
135
+ }
136
+ }
137
+ },
138
+ "else": {}
139
+ },
140
+ {
141
+ "if": {
142
+ "properties": {
143
+ "type": {
144
+ "value": "electronic_record"
145
+ }
146
+ }
147
+ },
148
+ "then": {
149
+ "properties": {
150
+ "validation_method": {
151
+ "$ref": "#/definitions/validation_method"
152
+ },
153
+ "verification_method": {
154
+ "$ref": "#/definitions/verification_method"
155
+ },
156
+ "verifier": {
157
+ "type": "object",
158
+ "properties": {
159
+ "organization": {
160
+ "type": "string"
161
+ },
162
+ "txn": {
163
+ "type": "string"
164
+ }
165
+ }
166
+ },
167
+ "time": {
168
+ "$ref": "#/definitions/time_type"
169
+ },
170
+ "record": {
171
+ "type": "object",
172
+ "properties": {
173
+ "type": {
174
+ "type": "string"
175
+ },
176
+ "personal_number": {
177
+ "type": "string"
178
+ },
179
+ "created_at": {
180
+ "$ref": "#/definitions/date_type"
181
+ },
182
+ "date_of_expiry": {
183
+ "$ref": "#/definitions/date_type"
184
+ },
185
+ "source": {
186
+ "type": "object",
187
+ "properties": {
188
+ "name": {
189
+ "type": "string"
190
+ },
191
+ "formatted": {
192
+ "type": "string"
193
+ },
194
+ "street_address": {
195
+ "type": "string"
196
+ },
197
+ "locality": {
198
+ "type": "string"
199
+ },
200
+ "region": {
201
+ "type": "string"
202
+ },
203
+ "postal_code": {
204
+ "type": "string"
205
+ },
206
+ "country": {
207
+ "type": "string"
208
+ },
209
+ "country_code": {
210
+ "type": "string"
211
+ },
212
+ "jurisdiction": {
213
+ "type": "string"
214
+ }
215
+ }
216
+ }
217
+ }
218
+ }
219
+ }
220
+ },
221
+ "else": {}
222
+ },
223
+ {
224
+ "if": {
225
+ "properties": {
226
+ "type": {
227
+ "value": "vouch"
228
+ }
229
+ }
230
+ },
231
+ "then": {
232
+ "properties": {
233
+ "validation_method": {
234
+ "$ref": "#/definitions/validation_method"
235
+ },
236
+ "verification_method": {
237
+ "$ref": "#/definitions/verification_method"
238
+ },
239
+ "verifier": {
240
+ "type": "object",
241
+ "properties": {
242
+ "organization": {
243
+ "type": "string"
244
+ },
245
+ "txn": {
246
+ "type": "string"
247
+ }
248
+ }
249
+ },
250
+ "time": {
251
+ "$ref": "#/definitions/time_type"
252
+ },
253
+ "attestation": {
254
+ "type": "object",
255
+ "properties": {
256
+ "type": {
257
+ "type": "string",
258
+ "const": "digital_attestation"
259
+ },
260
+ "reference_number": {
261
+ "type": "string"
262
+ },
263
+ "personal_number": {
264
+ "type": "string"
265
+ },
266
+ "date_of_issuance": {
267
+ "$ref": "#/definitions/date_type"
268
+ },
269
+ "date_of_expiry": {
270
+ "$ref": "#/definitions/date_type"
271
+ },
272
+ "voucher": {
273
+ "type": "object",
274
+ "properties": {
275
+ "name": {
276
+ "type": "string"
277
+ },
278
+ "birthdate": {
279
+ "$ref": "#/definitions/date_type"
280
+ },
281
+ "formatted": {
282
+ "type": "string"
283
+ },
284
+ "street_address": {
285
+ "type": "string"
286
+ },
287
+ "locality": {
288
+ "type": "string"
289
+ },
290
+ "region": {
291
+ "type": "string"
292
+ },
293
+ "postal_code": {
294
+ "type": "string"
295
+ },
296
+ "country": {
297
+ "type": "string"
298
+ },
299
+ "occupation": {
300
+ "type": "string"
301
+ },
302
+ "organization": {
303
+ "type": "string"
304
+ }
305
+ }
306
+ }
307
+ }
308
+ }
309
+ }
310
+ },
311
+ "else": {}
312
+ }
313
+ ]
314
+ },
315
+ "digest": {
316
+ "type": "object",
317
+ "properties": {
318
+ "alg": {
319
+ "type": "string"
320
+ },
321
+ "value": {
322
+ "type": "string",
323
+ "contentEncoding": "base64"
324
+ }
325
+ },
326
+ "required": ["alg", "value"]
327
+ },
328
+ "external_attachment": {
329
+ "type": "object",
330
+ "properties": {
331
+ "desc": {
332
+ "type": "string"
333
+ },
334
+ "digest": {
335
+ "$ref": "#/definitions/digest"
336
+ },
337
+ "url": {
338
+ "type": "string",
339
+ "format": "uri"
340
+ },
341
+ "access_token": {
342
+ "type": ["string", "null"]
343
+ },
344
+ "expires_in": {
345
+ "type": "integer",
346
+ "minimum": 1
347
+ }
348
+ },
349
+ "required": ["digest", "url"]
350
+ },
351
+ "attachments": {
352
+ "type": "array",
353
+ "minItems": 1,
354
+ "items": {
355
+ "$ref": "#/definitions/external_attachment"
356
+ }
357
+ },
358
+ "verified_claims_def": {
359
+ "type": "object",
360
+ "properties": {
361
+ "verification": {
362
+ "type": "object",
363
+ "properties": {
364
+ "trust_framework": {
365
+ "type": "string",
366
+ "const": "uk_pdtf"
367
+ },
368
+ "time": {
369
+ "$ref": "#/definitions/time_type"
370
+ },
371
+ "evidence": {
372
+ "type": "array",
373
+ "minItems": 1,
374
+ "items": {
375
+ "oneOf": [
376
+ {
377
+ "$ref": "#/definitions/evidence"
378
+ }
379
+ ]
380
+ }
381
+ }
382
+ },
383
+ "required": ["trust_framework"],
384
+ "additionalProperties": true
385
+ },
386
+ "claims": {
387
+ "type": "object",
388
+ "patternProperties": {
389
+ "^(/|([a-zA-Z0-9/-]+)+$)": { "type": "object" }
390
+ },
391
+ "minProperties": 1,
392
+ "additionalProperties": false
393
+ }
394
+ },
395
+ "required": ["verification", "claims"],
396
+ "additionalProperties": false
397
+ }
398
+ },
399
+ "type": "object",
400
+ "required": ["verified_claims"],
401
+ "properties": {
402
+ "verified_claims": {
403
+ "anyOf": [
404
+ {
405
+ "$ref": "#/definitions/verified_claims_def"
406
+ },
407
+ {
408
+ "type": "array",
409
+ "items": {
410
+ "$ref": "#/definitions/verified_claims_def"
411
+ }
412
+ }
413
+ ]
414
+ }
415
+ },
416
+ "additionalProperties": false
417
+ }
@@ -18,66 +18,67 @@
18
18
  "propertyPack": {
19
19
  "title": "Property Pack",
20
20
  "type": "object",
21
- "required": ["sellers"],
22
21
  "properties": {
23
22
  "sellers": {
24
23
  "RDSRef": "",
25
- "title": "About the sellers",
26
- "type": "array",
27
- "minItems": 1,
28
- "items": {
29
- "type": "object",
30
- "title": "Seller information",
31
- "required": [
32
- "name",
33
- "dateOfBirth",
34
- "mobileNumber",
35
- "email",
36
- "address"
37
- ],
38
- "properties": {
39
- "name": {
40
- "title": "Name",
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": {
41
33
  "type": "object",
42
- "required": ["firstName", "lastName"],
34
+ "title": "Seller Details",
35
+ "required": [
36
+ "name",
37
+ "dateOfBirth",
38
+ "mobileNumber",
39
+ "email",
40
+ "address"
41
+ ],
43
42
  "properties": {
44
- "firstName": {
45
- "RDSRef": "",
46
- "title": "First name",
47
- "type": "string"
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
+ }
48
62
  },
49
- "middleNames": {
50
- "title": "Middle name(s)",
51
- "type": "string"
63
+ "dateOfBirth": {
64
+ "title": "Date of birth",
65
+ "type": "string",
66
+ "format": "date"
52
67
  },
53
- "lastName": {
54
- "title": "Last name",
68
+ "mobileNumber": {
69
+ "title": "Mobile number",
55
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"
56
80
  }
57
81
  }
58
- },
59
- "dateOfBirth": {
60
- "title": "Date of birth",
61
- "type": "string",
62
- "format": "date"
63
- },
64
- "mobileNumber": {
65
- "title": "Mobile number",
66
- "type": "string"
67
- },
68
- "email": {
69
- "title": "Email address",
70
- "type": "string",
71
- "format": "email"
72
- },
73
- "address": {
74
- "title": "Address",
75
- "$ref": "#/$defs/address"
76
- },
77
- "amlCheckResult": {
78
- "title": "AML check result",
79
- "type": "string",
80
- "enum": ["clear", "consider"]
81
82
  }
82
83
  }
83
84
  }
@@ -4,11 +4,11 @@
4
4
  "definitions": {
5
5
  "date_type": {
6
6
  "type": "string",
7
- "pattern": "^(?:(?:(?:(?:(?:[1-9]\\d)(?:0[48]|[2468][048]|[13579][26])|(?:(?:[2468][048]|[13579][26])00))(\\/|-|\\.)(?:0?2\\1(?:29)))|(?:(?:[1-9]\\d{3})(\\/|-|\\.)(?:(?:(?:0?[13578]|1[02])\\2(?:31))|(?:(?:0?[13-9]|1[0-2])\\2(?:29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\\2(?:0?[1-9]|1\\d|2[0-8])))))$"
7
+ "format": "date"
8
8
  },
9
9
  "time_type": {
10
10
  "type": "string",
11
- "pattern": "^(?:[\\+-]?\\d{4}(?!\\d{2}\\b))(?:(-?)(?:(?:0[1-9]|1[0-2])(?:\\1(?:[12]\\d|0[1-9]|3[01]))?|W(?:[0-4]\\d|5[0-2])(?:-?[1-7])?|(?:00[1-9]|0[1-9]\\d|[12]\\d{2}|3(?:[0-5]\\d|6[1-6])))(?:[T\\s](?:(?:(?:[01]\\d|2[0-3])(?:(:?)[0-5]\\d)?|24\\:?00)(?:[\\.,]\\d+(?!:))?)?(?:\\2[0-5]\\d(?:[\\.,]\\d+)?)?(?:[zZ]|(?:[\\+-])(?:[01]\\d|2[0-3]):?(?:[0-5]\\d)?)?)?)?$"
11
+ "format": "date-time"
12
12
  },
13
13
  "document_number": {
14
14
  "type": "string"
@@ -77,7 +77,7 @@
77
77
  "type": {
78
78
  "type": "string"
79
79
  },
80
- "policy":{
80
+ "policy": {
81
81
  "type": "string"
82
82
  },
83
83
  "procedure": {
@@ -94,7 +94,7 @@
94
94
  "type": {
95
95
  "type": "string"
96
96
  },
97
- "policy":{
97
+ "policy": {
98
98
  "type": "string"
99
99
  },
100
100
  "procedure": {
@@ -123,15 +123,13 @@
123
123
  "$ref": "#/definitions/attachments"
124
124
  }
125
125
  },
126
- "required": [
127
- "type"
128
- ],
126
+ "required": ["type"],
129
127
  "allOf": [
130
128
  {
131
129
  "if": {
132
130
  "properties": {
133
131
  "type": {
134
- "value": "electronic_signature"
132
+ "const": "electronic_signature"
135
133
  }
136
134
  }
137
135
  },
@@ -157,6 +155,7 @@
157
155
  "if": {
158
156
  "properties": {
159
157
  "type": {
158
+ "type": "string",
160
159
  "pattern": "^(id_)*document$"
161
160
  }
162
161
  }
@@ -200,7 +199,7 @@
200
199
  "if": {
201
200
  "properties": {
202
201
  "type": {
203
- "value": "electronic_record"
202
+ "const": "electronic_record"
204
203
  }
205
204
  }
206
205
  },
@@ -269,7 +268,7 @@
269
268
  "type": "string"
270
269
  },
271
270
  "jurisdiction": {
272
- "type": "string"
271
+ "type": "string"
273
272
  }
274
273
  }
275
274
  }
@@ -283,7 +282,7 @@
283
282
  "if": {
284
283
  "properties": {
285
284
  "type": {
286
- "value": "vouch"
285
+ "const": "vouch"
287
286
  }
288
287
  }
289
288
  },
@@ -372,7 +371,7 @@
372
371
  "if": {
373
372
  "properties": {
374
373
  "type": {
375
- "value": "utility_bill"
374
+ "const": "utility_bill"
376
375
  }
377
376
  }
378
377
  },
@@ -424,10 +423,7 @@
424
423
  "contentEncoding": "base64"
425
424
  }
426
425
  },
427
- "required": [
428
- "alg",
429
- "value"
430
- ]
426
+ "required": ["alg", "value"]
431
427
  },
432
428
  "external_attachment": {
433
429
  "type": "object",
@@ -450,10 +446,7 @@
450
446
  "minimum": 1
451
447
  }
452
448
  },
453
- "required": [
454
- "digest",
455
- "url"
456
- ]
449
+ "required": ["digest", "url"]
457
450
  },
458
451
  "embedded_attachment": {
459
452
  "type": "object",
@@ -469,10 +462,7 @@
469
462
  "contentEncoding": "base64"
470
463
  }
471
464
  },
472
- "required": [
473
- "content_type",
474
- "content"
475
- ]
465
+ "required": ["content_type", "content"]
476
466
  },
477
467
  "attachments": {
478
468
  "type": "array",
@@ -503,7 +493,7 @@
503
493
  "assurance_process": {
504
494
  "type": "object",
505
495
  "properties": {
506
- "policy":{
496
+ "policy": {
507
497
  "type": "string"
508
498
  },
509
499
  "procedure": {
@@ -532,9 +522,7 @@
532
522
  }
533
523
  }
534
524
  },
535
- "required": [
536
- "trust_framework"
537
- ],
525
+ "required": ["trust_framework"],
538
526
  "additionalProperties": true
539
527
  },
540
528
  "claims": {
@@ -542,30 +530,27 @@
542
530
  "minProperties": 1
543
531
  }
544
532
  },
545
- "required": [
546
- "verification",
547
- "claims"
548
- ],
533
+ "required": ["verification", "claims"],
549
534
  "additionalProperties": false
550
535
  },
551
536
  "distributed_claims_available_def": {
552
537
  "type": "object",
553
538
  "properties": {},
554
539
  "additionalProperties": {
555
- "$ref": "verified_claims_request-12.json#definitions/verified_claims_def"
540
+ "$ref": "#/definitions/verified_claims_def"
556
541
  }
557
542
  },
558
543
  "aggregated_claims": {
544
+ "type": "object",
559
545
  "properties": {
560
546
  "JWT": {
561
547
  "type": "string"
562
548
  }
563
549
  },
564
- "required": [
565
- "JWT"
566
- ]
550
+ "required": ["JWT"]
567
551
  },
568
552
  "distributed_claims": {
553
+ "type": "object",
569
554
  "properties": {
570
555
  "endpoint": {
571
556
  "type": "string"
@@ -574,10 +559,7 @@
574
559
  "type": "string"
575
560
  }
576
561
  },
577
- "required": [
578
- "endpoint",
579
- "access_token"
580
- ]
562
+ "required": ["endpoint", "access_token"]
581
563
  },
582
564
  "_claim_sources": {
583
565
  "anyOf": [
@@ -590,6 +572,8 @@
590
572
  ]
591
573
  }
592
574
  },
575
+ "type": "object",
576
+ "required": ["verified_claims"],
593
577
  "properties": {
594
578
  "verified_claims": {
595
579
  "anyOf": [
@@ -634,4 +618,4 @@
634
618
  }
635
619
  }
636
620
  }
637
- }
621
+ }
@@ -0,0 +1,63 @@
1
+ const jp = require("jsonpointer");
2
+ const Ajv = require("ajv");
3
+ const addFormats = require("ajv-formats");
4
+
5
+ const { getSubschemaValidator, getTitleAtPath } = require("../../index.js");
6
+
7
+ const verifiedClaimsSchema = require("../schemas/pdtf-verified-claims.json");
8
+ const exampleElectronicRecord = require("../examples/exampleElectronicRecord.json");
9
+ const exampleVouch = require("../examples/exampleVouch.json");
10
+ const exampleDocumentedVouch = require("../examples/exampleDocumentedVouch.json");
11
+
12
+ const ajv = new Ajv({
13
+ allErrors: true,
14
+ strictSchema: false
15
+ });
16
+ addFormats(ajv);
17
+
18
+ const validator = ajv.compile(verifiedClaimsSchema);
19
+
20
+ test("valid vouch sample is valid", () => {
21
+ const isValid = validator({ verified_claims: exampleVouch });
22
+ expect(isValid).toBe(true);
23
+ });
24
+
25
+ test("valid electronic record sample is valid", () => {
26
+ const isValid = validator({ verified_claims: exampleElectronicRecord });
27
+ expect(isValid).toBe(true);
28
+ });
29
+
30
+ test("valid documented vouch sample is valid", () => {
31
+ const isValid = validator({ verified_claims: exampleDocumentedVouch });
32
+ expect(isValid).toBe(true);
33
+ });
34
+
35
+ test("claim with missing claims is invalid", () => {
36
+ const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
37
+ delete clonedVouch.claims;
38
+ const isValid = validator({ verified_claims: clonedVouch });
39
+ expect(isValid).toBe(false);
40
+ });
41
+
42
+ test.only("claim with invalid claims path is invalid", () => {
43
+ const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
44
+ const originalPath = Object.keys(clonedVouch.claims)[0];
45
+ const data = clonedVouch.claims[originalPath];
46
+ clonedVouch.claims = { "invalidPath//of?someKind": data };
47
+ const isValid = validator({ verified_claims: clonedVouch });
48
+ expect(isValid).toBe(false);
49
+ });
50
+
51
+ test("verification with invalid evidence type is invalid", () => {
52
+ const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
53
+ clonedVouch.verification.evidence[0].type = "something invalid";
54
+ const isValid = validator({ verified_claims: clonedVouch });
55
+ expect(isValid).toBe(false);
56
+ });
57
+
58
+ test("verification with no framework type is invalid", () => {
59
+ const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
60
+ delete clonedVouch.verification.trust_framework;
61
+ const isValid = validator({ verified_claims: clonedVouch });
62
+ expect(isValid).toBe(false);
63
+ });
@@ -7,7 +7,7 @@ const {
7
7
  getSubschemaValidator,
8
8
  getTitleAtPath
9
9
  } = require("../../index.js");
10
- const examplePropertyPack = require("./examplePropertyPack.json");
10
+ const examplePropertyPack = require("../examples/examplePropertyPack.json");
11
11
 
12
12
  test("exports a property pack schema", () => {
13
13
  expect(propertyPackSchema).not.toBeNull();
@@ -15,7 +15,6 @@ test("exports a property pack schema", () => {
15
15
 
16
16
  test("sample is valid", () => {
17
17
  const isValid = validator(examplePropertyPack);
18
- console.log(validator.errors);
19
18
  expect(isValid).toBe(true);
20
19
  });
21
20
 
@@ -1,27 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://homebuyingandsellinggroup.co.uk/schemas/pdtf-claim.json",
4
- "type": "object",
5
- "title": "Property Data Trust Framework Claim",
6
- "description": "PDTF verified claims are implemented in accordance with the OpenID Connect Verified Claims model, within which the actual claims object should conform to this schema to ensure the necessary metadata is attached",
7
- "properties": {
8
- "schema": {
9
- "type": "string",
10
- "format": "uri",
11
- "description": "The $id of the JSONSchema against which the path and data have been generated, for example https://homebuyingandsellinggroup.co.uk/schemas/0.1.0/pdtf.json"
12
- },
13
- "path": {
14
- "type": "string",
15
- "description": "The JSON Pointer reference to the location in the schema corresponding to the new data as defined at https://datatracker.ietf.org/doc/html/rfc6901, for example /propertyPack/propertyToBeSold/address"
16
- },
17
- "data": {
18
- "type": "string",
19
- "description": "A JSON object representing the segment of the overall data structure which is being provided."
20
- },
21
- "attribution": {
22
- "type": "string",
23
- "description": "Details of any attribution, copyright or licencing requirements relating to the provided data"
24
- }
25
- },
26
- "required": ["schema", "path", "data"]
27
- }