@pdtf/schemas 0.5.5 → 0.5.6
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 +24 -21
- package/package.json +1 -2
package/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
const { dereference } = require("@jdw/jst");
|
|
2
|
+
const Ajv = require("ajv");
|
|
3
|
+
const addFormats = require("ajv-formats");
|
|
4
|
+
|
|
5
|
+
const propertyPack = require("./src/schemas/property-pack.json");
|
|
6
|
+
const baspiMaterialFacts = require("./src/schemas/baspi-a-material-facts.json");
|
|
7
|
+
const baspiLegalInformation = require("./src/schemas/baspi-b-legal-information.json");
|
|
8
|
+
const energyPerformanceCertificate = require("./src/schemas/energy-performance-certificate.json");
|
|
9
|
+
const titleDeed = require("./src/schemas/title-deed.json");
|
|
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");
|
|
13
13
|
|
|
14
14
|
const subSchemas = {
|
|
15
15
|
"https://homebuyingandsellinggroup.co.uk/schemas/baspi-a-material-facts.json":
|
|
@@ -22,10 +22,7 @@ const subSchemas = {
|
|
|
22
22
|
"https://homebuyingandsellinggroup.co.uk/schemas/title-deed.json": titleDeed
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
propertyPack,
|
|
27
|
-
(id) => subSchemas[id]
|
|
28
|
-
);
|
|
25
|
+
const propertyPackSchema = dereference(propertyPack, (id) => subSchemas[id]);
|
|
29
26
|
|
|
30
27
|
const ajv = new Ajv({
|
|
31
28
|
allErrors: true,
|
|
@@ -34,9 +31,9 @@ const ajv = new Ajv({
|
|
|
34
31
|
// Adds date formats among other types to the validator.
|
|
35
32
|
addFormats(ajv);
|
|
36
33
|
|
|
37
|
-
|
|
34
|
+
const validator = ajv.compile(propertyPackSchema);
|
|
38
35
|
|
|
39
|
-
|
|
36
|
+
const getSubschema = (path) => {
|
|
40
37
|
const pathArray = path.split("/").slice(1);
|
|
41
38
|
if (pathArray.length < 1) {
|
|
42
39
|
return schema;
|
|
@@ -46,9 +43,15 @@ export const getSubschema = (path) => {
|
|
|
46
43
|
}, propertyPackSchema);
|
|
47
44
|
};
|
|
48
45
|
|
|
49
|
-
|
|
46
|
+
const getSubschemaValidator = (path) => {
|
|
50
47
|
return ajv.getSchema(path) || ajv.compile(getSubschema(path));
|
|
51
48
|
};
|
|
52
49
|
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
module.exports = {
|
|
51
|
+
propertyPackSchema,
|
|
52
|
+
validator,
|
|
53
|
+
getSubschema,
|
|
54
|
+
getSubschemaValidator,
|
|
55
|
+
pdtfClaim,
|
|
56
|
+
verifiedClaim
|
|
57
|
+
};
|