@pdtf/schemas 0.11.0-4 → 0.11.0-5
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 +8 -12
- package/package.json +1 -1
- package/src/schemas/v1/legal-information.json +477 -526
- package/src/schemas/v1/material-facts.json +832 -900
- package/src/schemas/v1/searches/drainage-and-water.json +40 -48
- package/src/schemas/v1/searches/local-searches-required.json +20 -24
- package/src/schemas/v1/searches.json +146 -152
- package/src/tests/pdtfVerifiedClaims.test.js +1 -0
package/index.js
CHANGED
|
@@ -37,6 +37,7 @@ const ajv = new Ajv({
|
|
|
37
37
|
allErrors: true,
|
|
38
38
|
// schema contains additional baspiRef and RDSRef metadata which is not strictly valid
|
|
39
39
|
strictSchema: false,
|
|
40
|
+
discriminator: true,
|
|
40
41
|
});
|
|
41
42
|
// Adds date formats among other types to the validator.
|
|
42
43
|
addFormats(ajv);
|
|
@@ -45,18 +46,14 @@ const validator = ajv.compile(transactionSchema);
|
|
|
45
46
|
|
|
46
47
|
const getSubschema = (path) => {
|
|
47
48
|
const pathArray = path.split("/").slice(1);
|
|
48
|
-
if (pathArray.length < 1)
|
|
49
|
-
return transactionSchema;
|
|
50
|
-
}
|
|
51
|
-
|
|
49
|
+
if (pathArray.length < 1) return transactionSchema;
|
|
52
50
|
return pathArray.reduce((schema, pathElement) => {
|
|
53
51
|
if (schema.type === "array") return schema.items;
|
|
54
52
|
if (schema.properties[pathElement]) return schema.properties[pathElement];
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
53
|
+
const discriminator = schema.discriminator?.propertyName;
|
|
54
|
+
if (discriminator) {
|
|
57
55
|
// only single dependency discriminator, oneOf keyword is supported
|
|
58
|
-
const
|
|
59
|
-
const oneOfs = dependencies[dependencyDiscriminator].oneOf;
|
|
56
|
+
const oneOfs = schema.oneOf;
|
|
60
57
|
const matchingOneOf = oneOfs.find(
|
|
61
58
|
(oneOf) => oneOf["properties"][pathElement]
|
|
62
59
|
);
|
|
@@ -112,11 +109,10 @@ const getTitleAtPath = (schema, path, rootPath = path) => {
|
|
|
112
109
|
subSchema = schema.items;
|
|
113
110
|
return getTitleAtPath(subSchema, subPath, rootPath);
|
|
114
111
|
}
|
|
115
|
-
const
|
|
116
|
-
if (
|
|
112
|
+
const discriminator = schema.discriminator?.propertyName;
|
|
113
|
+
if (discriminator) {
|
|
117
114
|
// only single dependency discriminator, oneOf keyword is supported
|
|
118
|
-
const
|
|
119
|
-
const oneOfs = dependencies[dependencyDiscriminator].oneOf;
|
|
115
|
+
const oneOfs = schema.oneOf;
|
|
120
116
|
const matchingOneOf = oneOfs.find(
|
|
121
117
|
(oneOf) => oneOf["properties"][propertyName]
|
|
122
118
|
);
|