aboutsummaryrefslogtreecommitdiff
path: root/sandbox/testAppNevena/Front/node_modules/ajv/dist/vocabularies/validation/required.js
diff options
context:
space:
mode:
authorNevena Bojovic <nenabojov@gmail.com>2022-03-01 20:05:50 +0100
committerNevena Bojovic <nenabojov@gmail.com>2022-03-01 20:05:50 +0100
commit291803c31f829fe0d32bb3207bc11def95a7408c (patch)
treec7d43107d79291b19d8c9eceefbe91c9f9a52acf /sandbox/testAppNevena/Front/node_modules/ajv/dist/vocabularies/validation/required.js
parent1fa69862057db4db53cfda5be9c24b4228ef63f7 (diff)
Urađena test aplikacija. Povezan front i back.
Diffstat (limited to 'sandbox/testAppNevena/Front/node_modules/ajv/dist/vocabularies/validation/required.js')
-rw-r--r--sandbox/testAppNevena/Front/node_modules/ajv/dist/vocabularies/validation/required.js79
1 files changed, 79 insertions, 0 deletions
diff --git a/sandbox/testAppNevena/Front/node_modules/ajv/dist/vocabularies/validation/required.js b/sandbox/testAppNevena/Front/node_modules/ajv/dist/vocabularies/validation/required.js
new file mode 100644
index 00000000..1d8e2926
--- /dev/null
+++ b/sandbox/testAppNevena/Front/node_modules/ajv/dist/vocabularies/validation/required.js
@@ -0,0 +1,79 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+const code_1 = require("../code");
+const codegen_1 = require("../../compile/codegen");
+const util_1 = require("../../compile/util");
+const error = {
+ message: ({ params: { missingProperty } }) => (0, codegen_1.str) `must have required property '${missingProperty}'`,
+ params: ({ params: { missingProperty } }) => (0, codegen_1._) `{missingProperty: ${missingProperty}}`,
+};
+const def = {
+ keyword: "required",
+ type: "object",
+ schemaType: "array",
+ $data: true,
+ error,
+ code(cxt) {
+ const { gen, schema, schemaCode, data, $data, it } = cxt;
+ const { opts } = it;
+ if (!$data && schema.length === 0)
+ return;
+ const useLoop = schema.length >= opts.loopRequired;
+ if (it.allErrors)
+ allErrorsMode();
+ else
+ exitOnErrorMode();
+ if (opts.strictRequired) {
+ const props = cxt.parentSchema.properties;
+ const { definedProperties } = cxt.it;
+ for (const requiredKey of schema) {
+ if ((props === null || props === void 0 ? void 0 : props[requiredKey]) === undefined && !definedProperties.has(requiredKey)) {
+ const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
+ const msg = `required property "${requiredKey}" is not defined at "${schemaPath}" (strictRequired)`;
+ (0, util_1.checkStrictMode)(it, msg, it.opts.strictRequired);
+ }
+ }
+ }
+ function allErrorsMode() {
+ if (useLoop || $data) {
+ cxt.block$data(codegen_1.nil, loopAllRequired);
+ }
+ else {
+ for (const prop of schema) {
+ (0, code_1.checkReportMissingProp)(cxt, prop);
+ }
+ }
+ }
+ function exitOnErrorMode() {
+ const missing = gen.let("missing");
+ if (useLoop || $data) {
+ const valid = gen.let("valid", true);
+ cxt.block$data(valid, () => loopUntilMissing(missing, valid));
+ cxt.ok(valid);
+ }
+ else {
+ gen.if((0, code_1.checkMissingProp)(cxt, schema, missing));
+ (0, code_1.reportMissingProp)(cxt, missing);
+ gen.else();
+ }
+ }
+ function loopAllRequired() {
+ gen.forOf("prop", schemaCode, (prop) => {
+ cxt.setParams({ missingProperty: prop });
+ gen.if((0, code_1.noPropertyInData)(gen, data, prop, opts.ownProperties), () => cxt.error());
+ });
+ }
+ function loopUntilMissing(missing, valid) {
+ cxt.setParams({ missingProperty: missing });
+ gen.forOf(missing, schemaCode, () => {
+ gen.assign(valid, (0, code_1.propertyInData)(gen, data, missing, opts.ownProperties));
+ gen.if((0, codegen_1.not)(valid), () => {
+ cxt.error();
+ gen.break();
+ });
+ }, codegen_1.nil);
+ }
+ },
+};
+exports.default = def;
+//# sourceMappingURL=required.js.map \ No newline at end of file