.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / table / node_modules / ajv / dist / vocabularies / applicator / patternProperties.js
diff --git a/.config/coc/extensions/node_modules/coc-prettier/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js b/.config/coc/extensions/node_modules/coc-prettier/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js
new file mode 100644 (file)
index 0000000..1f2f9fe
--- /dev/null
@@ -0,0 +1,69 @@
+"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 util_2 = require("../../compile/util");
+const def = {
+    keyword: "patternProperties",
+    type: "object",
+    schemaType: "object",
+    code(cxt) {
+        const { gen, schema, data, parentSchema, it } = cxt;
+        const { opts } = it;
+        const patterns = code_1.schemaProperties(it, schema);
+        // TODO mark properties matching patterns with always valid schemas as evaluated
+        if (patterns.length === 0)
+            return;
+        const checkProperties = opts.strictSchema && !opts.allowMatchingProperties && parentSchema.properties;
+        const valid = gen.name("valid");
+        if (it.props !== true && !(it.props instanceof codegen_1.Name)) {
+            it.props = util_2.evaluatedPropsToName(gen, it.props);
+        }
+        const { props } = it;
+        validatePatternProperties();
+        function validatePatternProperties() {
+            for (const pat of patterns) {
+                if (checkProperties)
+                    checkMatchingProperties(pat);
+                if (it.allErrors) {
+                    validateProperties(pat);
+                }
+                else {
+                    gen.var(valid, true); // TODO var
+                    validateProperties(pat);
+                    gen.if(valid);
+                }
+            }
+        }
+        function checkMatchingProperties(pat) {
+            for (const prop in checkProperties) {
+                if (new RegExp(pat).test(prop)) {
+                    util_1.checkStrictMode(it, `property ${prop} matches pattern ${pat} (use allowMatchingProperties)`);
+                }
+            }
+        }
+        function validateProperties(pat) {
+            gen.forIn("key", data, (key) => {
+                gen.if(codegen_1._ `${code_1.usePattern(gen, pat)}.test(${key})`, () => {
+                    cxt.subschema({
+                        keyword: "patternProperties",
+                        schemaProp: pat,
+                        dataProp: key,
+                        dataPropType: util_2.Type.Str,
+                    }, valid);
+                    if (it.opts.unevaluated && props !== true) {
+                        gen.assign(codegen_1._ `${props}[${key}]`, true);
+                    }
+                    else if (!it.allErrors) {
+                        // can short-circuit if `unevaluatedProperties` is not supported (opts.next === false)
+                        // or if all properties were evaluated (props === true)
+                        gen.if(codegen_1.not(valid), () => gen.break());
+                    }
+                });
+            });
+        }
+    },
+};
+exports.default = def;
+//# sourceMappingURL=patternProperties.js.map
\ No newline at end of file