Skip to content

Commit 061d229

Browse files
committed
remove unevaluatedKeywords
1 parent b814f7c commit 061d229

File tree

2 files changed

+0
-96
lines changed

2 files changed

+0
-96
lines changed

src/keywordErrorMessage.test.js

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,69 +1172,4 @@ describe("Error messages", async () => {
11721172
}
11731173
]);
11741174
});
1175-
1176-
test("should fail when an unevaluated item has the wrong type", async () => {
1177-
registerSchema({
1178-
$schema: "https://json-schema.org/draft/2020-12/schema",
1179-
prefixItems: [{ type: "number" }],
1180-
unevaluatedItems: { type: "string" }
1181-
}, schemaUri);
1182-
1183-
const instance = [1, "two", false];
1184-
1185-
/** @type OutputFormat */
1186-
const output = {
1187-
valid: false,
1188-
errors: [
1189-
{
1190-
absoluteKeywordLocation: "https://example.com/main#/unevaluatedItems/type",
1191-
instanceLocation: "#/2"
1192-
}
1193-
]
1194-
};
1195-
1196-
const result = await betterJsonSchemaErrors(instance, output, schemaUri);
1197-
expect(result.errors).to.eql([
1198-
{
1199-
schemaLocation: "https://example.com/main#/unevaluatedItems/type",
1200-
instanceLocation: "#/2",
1201-
message: localization.getTypeErrorMessage(["string"], "boolean")
1202-
}
1203-
]);
1204-
});
1205-
1206-
test("should fail when an unevaluated property has the wrong type", async () => {
1207-
registerSchema({
1208-
$schema: "https://json-schema.org/draft/2020-12/schema",
1209-
properties: {
1210-
known: { type: "string" }
1211-
},
1212-
unevaluatedProperties: { type: "number" }
1213-
}, schemaUri);
1214-
1215-
const instance = {
1216-
known: "a string",
1217-
unknown: "this should have been a number"
1218-
};
1219-
1220-
/** @type OutputFormat */
1221-
const output = {
1222-
valid: false,
1223-
errors: [
1224-
{
1225-
absoluteKeywordLocation: "https://example.com/main#/unevaluatedProperties/type",
1226-
instanceLocation: "#/unknown"
1227-
}
1228-
]
1229-
};
1230-
1231-
const result = await betterJsonSchemaErrors(instance, output, schemaUri);
1232-
expect(result.errors).to.eql([
1233-
{
1234-
schemaLocation: "https://example.com/main#/unevaluatedProperties/type",
1235-
instanceLocation: "#/unknown",
1236-
message: localization.getTypeErrorMessage("number", "string")
1237-
}
1238-
]);
1239-
});
12401175
});

src/normalizeOutputFormat/normalizeOutput.js

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -300,37 +300,6 @@ keywordHandlers["https://json-schema.org/keyword/additionalProperties"] = {
300300
simpleApplicator: true
301301
};
302302

303-
keywordHandlers["https://json-schema.org/keyword/unevaluatedItems"] = {
304-
evaluate(/** @type string[] */ [, unevaluatedItemsSchemaLocation], ast, instance, errorIndex) {
305-
/** @type NormalizedOutput[] */
306-
const outputs = [];
307-
if (Instance.typeOf(instance) !== "array") {
308-
return outputs;
309-
}
310-
for (const itemNode of Instance.iter(instance)) {
311-
outputs.push(evaluateSchema(unevaluatedItemsSchemaLocation, ast, itemNode, errorIndex));
312-
}
313-
return outputs;
314-
},
315-
simpleApplicator: true
316-
};
317-
318-
keywordHandlers["https://json-schema.org/keyword/unevaluatedProperties"] = {
319-
evaluate(/** @type string[] */ [, unevaluatedPropertiesSchemaLocation], ast, instance, errorIndex) {
320-
/** @type NormalizedOutput[] */
321-
const outputs = [];
322-
if (Instance.typeOf(instance) !== "object") {
323-
return outputs;
324-
}
325-
326-
for (const [, propertyValue] of Instance.entries(instance)) {
327-
outputs.push(evaluateSchema(unevaluatedPropertiesSchemaLocation, ast, propertyValue, errorIndex));
328-
}
329-
return outputs;
330-
},
331-
simpleApplicator: true
332-
};
333-
334303
keywordHandlers["https://json-schema.org/keyword/definitions"] = {
335304
appliesTo() {
336305
return false;

0 commit comments

Comments
 (0)