2022-05-27 10:32:23 +03:00
|
|
|
export const def = {
|
2022-06-15 17:36:57 +03:00
|
|
|
code (a) {
|
|
|
|
const { gen: b , schema: c , parentSchema: d , data: e , it: f } = a;
|
|
|
|
if (f.opts.removeAdditional === "all" && d.additionalProperties === undefined) {
|
|
|
|
additionalProperties_1.default.code(new validate_1.KeywordCxt(f, additionalProperties_1.default, "additionalProperties"));
|
2022-05-27 10:32:23 +03:00
|
|
|
}
|
2022-06-15 17:36:57 +03:00
|
|
|
const g = (0, code_1.allSchemaProperties)(c);
|
|
|
|
for (const h of g){
|
|
|
|
f.definedProperties.add(h);
|
2022-05-27 10:32:23 +03:00
|
|
|
}
|
2022-06-15 17:36:57 +03:00
|
|
|
if (f.opts.unevaluated && g.length && f.props !== true) {
|
|
|
|
f.props = util_1.mergeEvaluated.props(b, (0, util_1.toHash)(g), f.props);
|
2022-05-27 10:32:23 +03:00
|
|
|
}
|
2022-06-15 17:36:57 +03:00
|
|
|
const i = g.filter((a)=>!(0, util_1.alwaysValidSchema)(f, c[a]));
|
|
|
|
if (i.length === 0) return;
|
|
|
|
const j = b.name("valid");
|
|
|
|
for (const k of i){
|
|
|
|
if (l(k)) {
|
|
|
|
m(k);
|
2022-05-27 10:32:23 +03:00
|
|
|
} else {
|
2022-06-15 17:36:57 +03:00
|
|
|
b.if((0, code_1.propertyInData)(b, e, k, f.opts.ownProperties));
|
|
|
|
m(k);
|
|
|
|
if (!f.allErrors) b.else().var(j, true);
|
2022-05-27 10:32:23 +03:00
|
|
|
b.endIf();
|
|
|
|
}
|
2022-06-15 17:36:57 +03:00
|
|
|
a.it.definedProperties.add(k);
|
|
|
|
a.ok(j);
|
2022-05-27 10:32:23 +03:00
|
|
|
}
|
2022-06-15 17:36:57 +03:00
|
|
|
function l(a) {
|
|
|
|
return (f.opts.useDefaults && !f.compositeRule && c[a].default !== undefined);
|
2022-05-27 10:32:23 +03:00
|
|
|
}
|
2022-06-15 17:36:57 +03:00
|
|
|
function m(b) {
|
|
|
|
a.subschema({
|
2022-05-27 10:32:23 +03:00
|
|
|
keyword: "properties",
|
2022-06-15 17:36:57 +03:00
|
|
|
schemaProp: b,
|
|
|
|
dataProp: b
|
|
|
|
}, j);
|
2022-05-27 10:32:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|