From 291803c31f829fe0d32bb3207bc11def95a7408c Mon Sep 17 00:00:00 2001 From: Nevena Bojovic Date: Tue, 1 Mar 2022 20:05:50 +0100 Subject: Urađena test aplikacija. Povezan front i back. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/vocabularies/validation/limitProperties.ts | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/validation/limitProperties.ts (limited to 'sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/validation/limitProperties.ts') diff --git a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/validation/limitProperties.ts b/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/validation/limitProperties.ts new file mode 100644 index 00000000..e72124a7 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/validation/limitProperties.ts @@ -0,0 +1,26 @@ +import type {CodeKeywordDefinition, KeywordErrorDefinition} from "../../types" +import type {KeywordCxt} from "../../compile/validate" +import {_, str, operators} from "../../compile/codegen" + +const error: KeywordErrorDefinition = { + message({keyword, schemaCode}) { + const comp = keyword === "maxProperties" ? "more" : "fewer" + return str`must NOT have ${comp} than ${schemaCode} items` + }, + params: ({schemaCode}) => _`{limit: ${schemaCode}}`, +} + +const def: CodeKeywordDefinition = { + keyword: ["maxProperties", "minProperties"], + type: "object", + schemaType: "number", + $data: true, + error, + code(cxt: KeywordCxt) { + const {keyword, data, schemaCode} = cxt + const op = keyword === "maxProperties" ? operators.GT : operators.LT + cxt.fail$data(_`Object.keys(${data}).length ${op} ${schemaCode}`) + }, +} + +export default def -- cgit v1.2.3