1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const codegen_1 = require("../../compile/codegen");
|
4 | const util_1 = require("../../compile/util");
|
5 | const error = {
|
6 | message: "property name must be valid",
|
7 | params: ({ params }) => (0, codegen_1._) `{propertyName: ${params.propertyName}}`,
|
8 | };
|
9 | const def = {
|
10 | keyword: "propertyNames",
|
11 | type: "object",
|
12 | schemaType: ["object", "boolean"],
|
13 | error,
|
14 | code(cxt) {
|
15 | const { gen, schema, data, it } = cxt;
|
16 | if ((0, util_1.alwaysValidSchema)(it, schema))
|
17 | return;
|
18 | const valid = gen.name("valid");
|
19 | gen.forIn("key", data, (key) => {
|
20 | cxt.setParams({ propertyName: key });
|
21 | cxt.subschema({
|
22 | keyword: "propertyNames",
|
23 | data: key,
|
24 | dataTypes: ["string"],
|
25 | propertyName: key,
|
26 | compositeRule: true,
|
27 | }, valid);
|
28 | gen.if((0, codegen_1.not)(valid), () => {
|
29 | cxt.error(true);
|
30 | if (!it.allErrors)
|
31 | gen.break();
|
32 | });
|
33 | });
|
34 | cxt.ok(valid);
|
35 | },
|
36 | };
|
37 | exports.default = def;
|
38 |
|
\ | No newline at end of file |