@pdtf/schemas 0.6.12 → 0.6.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
@@ -120,8 +120,7 @@ const getTitleAtPath = (schema, path, rootPath = path) => {
120
120
  };
121
121
 
122
122
  const validateVerifiedClaims = (verifiedClaimsArray) => {
123
-
124
- const validatorVClaims = ajv.compile(verifiedClaimsSchema);
123
+ const validatorVClaims = ajv.compile(verifiedClaimsSchema);
125
124
 
126
125
  const validationErrorsArr = [];
127
126
  const vClaimSchValidation = validatorVClaims({
@@ -133,17 +132,21 @@ const validatorVClaims = ajv.compile(verifiedClaimsSchema);
133
132
  }
134
133
 
135
134
  verifiedClaimsArray.forEach((claim) => {
136
- const [path] = Object.keys(claim.claims);
137
-
138
- const validPath = isPathValid(path);
139
- if (validPath) {
140
- const subValidator = getSubschemaValidator(path);
141
- const isValid = subValidator(claim.claims[path]);
142
- if (!isValid) {
143
- validationErrorsArr.push(...subValidator.errors);
135
+ const paths = Object.keys(claim.claims);
136
+
137
+ for (const path of paths) {
138
+ const validPath = isPathValid(path);
139
+ if (validPath) {
140
+ const subValidator = getSubschemaValidator(path);
141
+ const isValid = subValidator(claim.claims[path]);
142
+ if (!isValid) {
143
+ validationErrorsArr.push(...subValidator.errors);
144
+ }
145
+ } else {
146
+ validationErrorsArr.push(
147
+ `Path ${path} is not a valid PDTF schema path`
148
+ );
144
149
  }
145
- } else {
146
- validationErrorsArr.push(`Path ${path} is not a valid PDTF schema path`);
147
150
  }
148
151
  });
149
152
 
@@ -151,6 +154,7 @@ const validatorVClaims = ajv.compile(verifiedClaimsSchema);
151
154
  };
152
155
 
153
156
 
157
+
154
158
  module.exports = {
155
159
  transactionSchema,
156
160
  validator,
package/package.json CHANGED
@@ -1,36 +1,36 @@
1
1
  {
2
- "name": "@pdtf/schemas",
3
- "version": "0.6.12",
4
- "description": "Property Data Trust Framework Schemas and Utilities",
5
- "main": "index.js",
6
- "directories": {
7
- "doc": "docs"
8
- },
9
- "scripts": {
10
- "test": "jest",
11
- "test:watch": "jest --watch"
12
- },
13
- "repository": {
14
- "type": "git",
15
- "url": "git+https://github.com/Property-Data-Trust-Framework/schemas.git"
16
- },
17
- "keywords": [
18
- "PDTF",
19
- "Schemas"
20
- ],
21
- "author": "",
22
- "license": "MIT",
23
- "bugs": {
24
- "url": "https://github.com/Property-Data-Trust-Framework/schemas/issues"
25
- },
26
- "homepage": "https://github.com/Property-Data-Trust-Framework/schemas#readme",
27
- "dependencies": {
28
- "@jdw/jst": "^2.0.0-beta.15",
29
- "ajv": "^8.10.0",
30
- "ajv-formats": "^2.1.1",
31
- "jsonpointer": "^5.0.0"
32
- },
33
- "devDependencies": {
34
- "jest": "^27.5.1"
35
- }
36
- }
2
+ "name": "@pdtf/schemas",
3
+ "version": "0.6.13",
4
+ "description": "Property Data Trust Framework Schemas and Utilities",
5
+ "main": "index.js",
6
+ "directories": {
7
+ "doc": "docs"
8
+ },
9
+ "scripts": {
10
+ "test": "jest",
11
+ "test:watch": "jest --watch"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/Property-Data-Trust-Framework/schemas.git"
16
+ },
17
+ "keywords": [
18
+ "PDTF",
19
+ "Schemas"
20
+ ],
21
+ "author": "",
22
+ "license": "MIT",
23
+ "bugs": {
24
+ "url": "https://github.com/Property-Data-Trust-Framework/schemas/issues"
25
+ },
26
+ "homepage": "https://github.com/Property-Data-Trust-Framework/schemas#readme",
27
+ "dependencies": {
28
+ "@jdw/jst": "^2.0.0-beta.15",
29
+ "ajv": "^8.10.0",
30
+ "ajv-formats": "^2.1.1",
31
+ "jsonpointer": "^5.0.0"
32
+ },
33
+ "devDependencies": {
34
+ "jest": "^27.5.1"
35
+ }
36
+ }
@@ -4,19 +4,7 @@
4
4
  "time": "2022-01-25T13:16:44.527Z",
5
5
  "evidence": [
6
6
  {
7
- "verification_method": {
8
- "type": "auth"
9
- },
10
7
  "type": "vouch",
11
- "attestation": {
12
- "voucher": {
13
- "name": "Maria Harris"
14
- },
15
- "type": "digital_attestation"
16
- }
17
- },
18
- {
19
- "type": "document",
20
8
  "attachments": [
21
9
  {
22
10
  "digest": {
@@ -26,7 +14,16 @@
26
14
  "url": "https://fakeFileStore.com/some/kind/of/file",
27
15
  "desc": "proofOfAddress.pdf"
28
16
  }
29
- ]
17
+ ],
18
+ "verification_method": {
19
+ "type": "auth"
20
+ },
21
+ "attestation": {
22
+ "voucher": {
23
+ "name": "Maria Harris"
24
+ },
25
+ "type": "digital_attestation"
26
+ }
30
27
  }
31
28
  ]
32
29
  },
@@ -341,7 +341,65 @@ test("returns an array of errors if data in the path is in invalid format", () =
341
341
  ]);
342
342
  });
343
343
 
344
- test("returns an empty array of errors if data in the path is in valid format", () => {
344
+ test("returns an array of errors for verified claim with multiple paths", () => {
345
+ const vClaims = [
346
+ {
347
+ verification: {
348
+ trust_framework: "uk_pdtf",
349
+ time: "2022-01-25T13:16:44.527Z",
350
+ evidence: [
351
+ {
352
+ verification_method: {
353
+ type: "auth",
354
+ },
355
+ type: "vouch",
356
+ attestation: {
357
+ voucher: {
358
+ name: "Maria Harris",
359
+ },
360
+ type: "digital_attestation",
361
+ },
362
+ },
363
+ {
364
+ type: "document",
365
+ attachments: [
366
+ {
367
+ digest: {
368
+ alg: "md5",
369
+ value: "randomHashValue",
370
+ },
371
+ url: "https://fakeFileStore.com/some/kind/of/file",
372
+ desc: "proofOfAddress.pdf",
373
+ },
374
+ ],
375
+ },
376
+ ],
377
+ },
378
+ claims: {
379
+ "/propertyPack/materialFacts/cousncilTaxBad": {
380
+ councilTaxBand: "D",
381
+ councilTaxAffectingAlterations: {
382
+ yesNo: "Yes",
383
+ details:
384
+ "Extension added in 2005 to add bedroom with ensuite shower room. Certificate of Compliance issued 17th Feb 2006 and council tax updated",
385
+ },
386
+ },
387
+ "/propertyPack/materialFacts/councilTaxBadTwo": {
388
+ councilTaxBand: "D",
389
+ councilTaxAffectingAlterations: {
390
+ yesNo: "Yes",
391
+ details:
392
+ "Extension added in 2005 to add bedroom with ensuite shower room. Certificate of Compliance issued 17th Feb 2006 and council tax updated",
393
+ },
394
+ },
395
+ },
396
+ },
397
+ ];
398
+ expect(validateVerifiedClaims(vClaims)).toEqual(["Path /propertyPack/materialFacts/cousncilTaxBad is not a valid PDTF schema path",
399
+ "Path /propertyPack/materialFacts/councilTaxBadTwo is not a valid PDTF schema path"]);
400
+ });
401
+
402
+ test("returns an empty array of errors for verified claim with multiple paths", () => {
345
403
  const vClaims = [
346
404
  {
347
405
  verification: {
@@ -384,6 +442,13 @@ test("returns an empty array of errors if data in the path is in valid format",
384
442
  "Extension added in 2005 to add bedroom with ensuite shower room. Certificate of Compliance issued 17th Feb 2006 and council tax updated",
385
443
  },
386
444
  },
445
+ "/propertyPack/materialFacts/address": {
446
+ line1: "property.line1",
447
+ line2: "property.line2",
448
+ town: "property.city",
449
+ county: "property.province",
450
+ postcode: "property.postcode",
451
+ },
387
452
  },
388
453
  },
389
454
  ];