@opentiny/next-sdk 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1017,8 +1017,8 @@ var scope = {};
1017
1017
  var util$7 = {};
1018
1018
  Object.defineProperty(util$7, "__esModule", { value: true });
1019
1019
  util$7.checkStrictMode = util$7.getErrorPath = util$7.Type = util$7.useFunc = util$7.setEvaluated = util$7.evaluatedPropsToName = util$7.mergeEvaluated = util$7.eachItem = util$7.unescapeJsonPointer = util$7.escapeJsonPointer = util$7.escapeFragment = util$7.unescapeFragment = util$7.schemaRefOrVal = util$7.schemaHasRulesButRef = util$7.schemaHasRules = util$7.checkUnknownRules = util$7.alwaysValidSchema = util$7.toHash = void 0;
1020
- const codegen_1$q = codegen;
1021
- const code_1$9 = code$1;
1020
+ const codegen_1$v = codegen;
1021
+ const code_1$a = code$1;
1022
1022
  function toHash$2(arr) {
1023
1023
  const hash = {};
1024
1024
  for (const item of arr)
@@ -1071,9 +1071,9 @@ function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
1071
1071
  if (typeof schema == "number" || typeof schema == "boolean")
1072
1072
  return schema;
1073
1073
  if (typeof schema == "string")
1074
- return (0, codegen_1$q._)`${schema}`;
1074
+ return (0, codegen_1$v._)`${schema}`;
1075
1075
  }
1076
- return (0, codegen_1$q._)`${topSchemaRef}${schemaPath}${(0, codegen_1$q.getProperty)(keyword2)}`;
1076
+ return (0, codegen_1$v._)`${topSchemaRef}${schemaPath}${(0, codegen_1$v.getProperty)(keyword2)}`;
1077
1077
  }
1078
1078
  util$7.schemaRefOrVal = schemaRefOrVal;
1079
1079
  function unescapeFragment$1(str) {
@@ -1105,20 +1105,20 @@ function eachItem(xs, f) {
1105
1105
  util$7.eachItem = eachItem;
1106
1106
  function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues: mergeValues2, resultToName }) {
1107
1107
  return (gen, from, to, toName) => {
1108
- const res = to === void 0 ? from : to instanceof codegen_1$q.Name ? (from instanceof codegen_1$q.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1$q.Name ? (mergeToName(gen, to, from), from) : mergeValues2(from, to);
1109
- return toName === codegen_1$q.Name && !(res instanceof codegen_1$q.Name) ? resultToName(gen, res) : res;
1108
+ const res = to === void 0 ? from : to instanceof codegen_1$v.Name ? (from instanceof codegen_1$v.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1$v.Name ? (mergeToName(gen, to, from), from) : mergeValues2(from, to);
1109
+ return toName === codegen_1$v.Name && !(res instanceof codegen_1$v.Name) ? resultToName(gen, res) : res;
1110
1110
  };
1111
1111
  }
1112
1112
  util$7.mergeEvaluated = {
1113
1113
  props: makeMergeEvaluated({
1114
- mergeNames: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true && ${from} !== undefined`, () => {
1115
- gen.if((0, codegen_1$q._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1$q._)`${to} || {}`).code((0, codegen_1$q._)`Object.assign(${to}, ${from})`));
1114
+ mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => {
1115
+ gen.if((0, codegen_1$v._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1$v._)`${to} || {}`).code((0, codegen_1$v._)`Object.assign(${to}, ${from})`));
1116
1116
  }),
1117
- mergeToName: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true`, () => {
1117
+ mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => {
1118
1118
  if (from === true) {
1119
1119
  gen.assign(to, true);
1120
1120
  } else {
1121
- gen.assign(to, (0, codegen_1$q._)`${to} || {}`);
1121
+ gen.assign(to, (0, codegen_1$v._)`${to} || {}`);
1122
1122
  setEvaluated(gen, to, from);
1123
1123
  }
1124
1124
  }),
@@ -1126,8 +1126,8 @@ util$7.mergeEvaluated = {
1126
1126
  resultToName: evaluatedPropsToName
1127
1127
  }),
1128
1128
  items: makeMergeEvaluated({
1129
- mergeNames: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1$q._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
1130
- mergeToName: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1$q._)`${to} > ${from} ? ${to} : ${from}`)),
1129
+ mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1$v._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
1130
+ mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1$v._)`${to} > ${from} ? ${to} : ${from}`)),
1131
1131
  mergeValues: (from, to) => from === true ? true : Math.max(from, to),
1132
1132
  resultToName: (gen, items2) => gen.var("items", items2)
1133
1133
  })
@@ -1135,21 +1135,21 @@ util$7.mergeEvaluated = {
1135
1135
  function evaluatedPropsToName(gen, ps) {
1136
1136
  if (ps === true)
1137
1137
  return gen.var("props", true);
1138
- const props = gen.var("props", (0, codegen_1$q._)`{}`);
1138
+ const props = gen.var("props", (0, codegen_1$v._)`{}`);
1139
1139
  if (ps !== void 0)
1140
1140
  setEvaluated(gen, props, ps);
1141
1141
  return props;
1142
1142
  }
1143
1143
  util$7.evaluatedPropsToName = evaluatedPropsToName;
1144
1144
  function setEvaluated(gen, props, ps) {
1145
- Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$q._)`${props}${(0, codegen_1$q.getProperty)(p)}`, true));
1145
+ Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$v._)`${props}${(0, codegen_1$v.getProperty)(p)}`, true));
1146
1146
  }
1147
1147
  util$7.setEvaluated = setEvaluated;
1148
1148
  const snippets = {};
1149
1149
  function useFunc(gen, f) {
1150
1150
  return gen.scopeValue("func", {
1151
1151
  ref: f,
1152
- code: snippets[f.code] || (snippets[f.code] = new code_1$9._Code(f.code))
1152
+ code: snippets[f.code] || (snippets[f.code] = new code_1$a._Code(f.code))
1153
1153
  });
1154
1154
  }
1155
1155
  util$7.useFunc = useFunc;
@@ -1159,11 +1159,11 @@ var Type;
1159
1159
  Type2[Type2["Str"] = 1] = "Str";
1160
1160
  })(Type || (util$7.Type = Type = {}));
1161
1161
  function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
1162
- if (dataProp instanceof codegen_1$q.Name) {
1162
+ if (dataProp instanceof codegen_1$v.Name) {
1163
1163
  const isNumber = dataPropType === Type.Num;
1164
- return jsPropertySyntax ? isNumber ? (0, codegen_1$q._)`"[" + ${dataProp} + "]"` : (0, codegen_1$q._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1$q._)`"/" + ${dataProp}` : (0, codegen_1$q._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
1164
+ return jsPropertySyntax ? isNumber ? (0, codegen_1$v._)`"[" + ${dataProp} + "]"` : (0, codegen_1$v._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1$v._)`"/" + ${dataProp}` : (0, codegen_1$v._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
1165
1165
  }
1166
- return jsPropertySyntax ? (0, codegen_1$q.getProperty)(dataProp).toString() : "/" + escapeJsonPointer$1(dataProp);
1166
+ return jsPropertySyntax ? (0, codegen_1$v.getProperty)(dataProp).toString() : "/" + escapeJsonPointer$1(dataProp);
1167
1167
  }
1168
1168
  util$7.getErrorPath = getErrorPath;
1169
1169
  function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
@@ -1177,35 +1177,35 @@ function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
1177
1177
  util$7.checkStrictMode = checkStrictMode;
1178
1178
  var names$1 = {};
1179
1179
  Object.defineProperty(names$1, "__esModule", { value: true });
1180
- const codegen_1$p = codegen;
1180
+ const codegen_1$u = codegen;
1181
1181
  const names = {
1182
1182
  // validation function arguments
1183
- data: new codegen_1$p.Name("data"),
1183
+ data: new codegen_1$u.Name("data"),
1184
1184
  // data passed to validation function
1185
1185
  // args passed from referencing schema
1186
- valCxt: new codegen_1$p.Name("valCxt"),
1186
+ valCxt: new codegen_1$u.Name("valCxt"),
1187
1187
  // validation/data context - should not be used directly, it is destructured to the names below
1188
- instancePath: new codegen_1$p.Name("instancePath"),
1189
- parentData: new codegen_1$p.Name("parentData"),
1190
- parentDataProperty: new codegen_1$p.Name("parentDataProperty"),
1191
- rootData: new codegen_1$p.Name("rootData"),
1188
+ instancePath: new codegen_1$u.Name("instancePath"),
1189
+ parentData: new codegen_1$u.Name("parentData"),
1190
+ parentDataProperty: new codegen_1$u.Name("parentDataProperty"),
1191
+ rootData: new codegen_1$u.Name("rootData"),
1192
1192
  // root data - same as the data passed to the first/top validation function
1193
- dynamicAnchors: new codegen_1$p.Name("dynamicAnchors"),
1193
+ dynamicAnchors: new codegen_1$u.Name("dynamicAnchors"),
1194
1194
  // used to support recursiveRef and dynamicRef
1195
1195
  // function scoped variables
1196
- vErrors: new codegen_1$p.Name("vErrors"),
1196
+ vErrors: new codegen_1$u.Name("vErrors"),
1197
1197
  // null or array of validation errors
1198
- errors: new codegen_1$p.Name("errors"),
1198
+ errors: new codegen_1$u.Name("errors"),
1199
1199
  // counter of validation errors
1200
- this: new codegen_1$p.Name("this"),
1200
+ this: new codegen_1$u.Name("this"),
1201
1201
  // "globals"
1202
- self: new codegen_1$p.Name("self"),
1203
- scope: new codegen_1$p.Name("scope"),
1202
+ self: new codegen_1$u.Name("self"),
1203
+ scope: new codegen_1$u.Name("scope"),
1204
1204
  // JTD serialize/parse name for JSON string and position
1205
- json: new codegen_1$p.Name("json"),
1206
- jsonPos: new codegen_1$p.Name("jsonPos"),
1207
- jsonLen: new codegen_1$p.Name("jsonLen"),
1208
- jsonPart: new codegen_1$p.Name("jsonPart")
1205
+ json: new codegen_1$u.Name("json"),
1206
+ jsonPos: new codegen_1$u.Name("jsonPos"),
1207
+ jsonLen: new codegen_1$u.Name("jsonLen"),
1208
+ jsonPart: new codegen_1$u.Name("jsonPart")
1209
1209
  };
1210
1210
  names$1.default = names;
1211
1211
  (function(exports) {
@@ -1325,55 +1325,49 @@ names$1.default = names;
1325
1325
  keyValues.push([E.propertyName, propertyName]);
1326
1326
  }
1327
1327
  })(errors);
1328
- var hasRequiredBoolSchema;
1329
- function requireBoolSchema() {
1330
- if (hasRequiredBoolSchema) return boolSchema;
1331
- hasRequiredBoolSchema = 1;
1332
- Object.defineProperty(boolSchema, "__esModule", { value: true });
1333
- boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
1334
- const errors_12 = errors;
1335
- const codegen_12 = codegen;
1336
- const names_12 = names$1;
1337
- const boolError = {
1338
- message: "boolean schema is false"
1339
- };
1340
- function topBoolOrEmptySchema(it) {
1341
- const { gen, schema, validateName } = it;
1342
- if (schema === false) {
1343
- falseSchemaError(it, false);
1344
- } else if (typeof schema == "object" && schema.$async === true) {
1345
- gen.return(names_12.default.data);
1346
- } else {
1347
- gen.assign((0, codegen_12._)`${validateName}.errors`, null);
1348
- gen.return(true);
1349
- }
1350
- }
1351
- boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
1352
- function boolOrEmptySchema(it, valid) {
1353
- const { gen, schema } = it;
1354
- if (schema === false) {
1355
- gen.var(valid, false);
1356
- falseSchemaError(it);
1357
- } else {
1358
- gen.var(valid, true);
1359
- }
1328
+ Object.defineProperty(boolSchema, "__esModule", { value: true });
1329
+ boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
1330
+ const errors_1$3 = errors;
1331
+ const codegen_1$t = codegen;
1332
+ const names_1$6 = names$1;
1333
+ const boolError = {
1334
+ message: "boolean schema is false"
1335
+ };
1336
+ function topBoolOrEmptySchema(it) {
1337
+ const { gen, schema, validateName } = it;
1338
+ if (schema === false) {
1339
+ falseSchemaError(it, false);
1340
+ } else if (typeof schema == "object" && schema.$async === true) {
1341
+ gen.return(names_1$6.default.data);
1342
+ } else {
1343
+ gen.assign((0, codegen_1$t._)`${validateName}.errors`, null);
1344
+ gen.return(true);
1360
1345
  }
1361
- boolSchema.boolOrEmptySchema = boolOrEmptySchema;
1362
- function falseSchemaError(it, overrideAllErrors) {
1363
- const { gen, data: data2 } = it;
1364
- const cxt = {
1365
- gen,
1366
- keyword: "false schema",
1367
- data: data2,
1368
- schema: false,
1369
- schemaCode: false,
1370
- schemaValue: false,
1371
- params: {},
1372
- it
1373
- };
1374
- (0, errors_12.reportError)(cxt, boolError, void 0, overrideAllErrors);
1346
+ }
1347
+ boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
1348
+ function boolOrEmptySchema(it, valid) {
1349
+ const { gen, schema } = it;
1350
+ if (schema === false) {
1351
+ gen.var(valid, false);
1352
+ falseSchemaError(it);
1353
+ } else {
1354
+ gen.var(valid, true);
1375
1355
  }
1376
- return boolSchema;
1356
+ }
1357
+ boolSchema.boolOrEmptySchema = boolOrEmptySchema;
1358
+ function falseSchemaError(it, overrideAllErrors) {
1359
+ const { gen, data: data2 } = it;
1360
+ const cxt = {
1361
+ gen,
1362
+ keyword: "false schema",
1363
+ data: data2,
1364
+ schema: false,
1365
+ schemaCode: false,
1366
+ schemaValue: false,
1367
+ params: {},
1368
+ it
1369
+ };
1370
+ (0, errors_1$3.reportError)(cxt, boolError, void 0, overrideAllErrors);
1377
1371
  }
1378
1372
  var dataType = {};
1379
1373
  var rules$2 = {};
@@ -1421,10 +1415,10 @@ applicability.shouldUseRule = shouldUseRule;
1421
1415
  Object.defineProperty(dataType, "__esModule", { value: true });
1422
1416
  dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
1423
1417
  const rules_1 = rules$2;
1424
- const applicability_1 = applicability;
1425
- const errors_1 = errors;
1426
- const codegen_1$o = codegen;
1427
- const util_1$n = util$7;
1418
+ const applicability_1$1 = applicability;
1419
+ const errors_1$2 = errors;
1420
+ const codegen_1$s = codegen;
1421
+ const util_1$q = util$7;
1428
1422
  var DataType;
1429
1423
  (function(DataType2) {
1430
1424
  DataType2[DataType2["Correct"] = 0] = "Correct";
@@ -1456,7 +1450,7 @@ dataType.getJSONTypes = getJSONTypes;
1456
1450
  function coerceAndCheckDataType(it, types2) {
1457
1451
  const { gen, data: data2, opts } = it;
1458
1452
  const coerceTo = coerceToTypes$1(types2, opts.coerceTypes);
1459
- const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types2[0]));
1453
+ const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1$1.schemaHasRulesForType)(it, types2[0]));
1460
1454
  if (checkTypes) {
1461
1455
  const wrongType = checkDataTypes$1(types2, data2, opts.strictNumbers, DataType.Wrong);
1462
1456
  gen.if(wrongType, () => {
@@ -1475,12 +1469,12 @@ function coerceToTypes$1(types2, coerceTypes) {
1475
1469
  }
1476
1470
  function coerceData(it, types2, coerceTo) {
1477
1471
  const { gen, data: data2, opts } = it;
1478
- const dataType2 = gen.let("dataType", (0, codegen_1$o._)`typeof ${data2}`);
1479
- const coerced = gen.let("coerced", (0, codegen_1$o._)`undefined`);
1472
+ const dataType2 = gen.let("dataType", (0, codegen_1$s._)`typeof ${data2}`);
1473
+ const coerced = gen.let("coerced", (0, codegen_1$s._)`undefined`);
1480
1474
  if (opts.coerceTypes === "array") {
1481
- gen.if((0, codegen_1$o._)`${dataType2} == 'object' && Array.isArray(${data2}) && ${data2}.length == 1`, () => gen.assign(data2, (0, codegen_1$o._)`${data2}[0]`).assign(dataType2, (0, codegen_1$o._)`typeof ${data2}`).if(checkDataTypes$1(types2, data2, opts.strictNumbers), () => gen.assign(coerced, data2)));
1475
+ gen.if((0, codegen_1$s._)`${dataType2} == 'object' && Array.isArray(${data2}) && ${data2}.length == 1`, () => gen.assign(data2, (0, codegen_1$s._)`${data2}[0]`).assign(dataType2, (0, codegen_1$s._)`typeof ${data2}`).if(checkDataTypes$1(types2, data2, opts.strictNumbers), () => gen.assign(coerced, data2)));
1482
1476
  }
1483
- gen.if((0, codegen_1$o._)`${coerced} !== undefined`);
1477
+ gen.if((0, codegen_1$s._)`${coerced} !== undefined`);
1484
1478
  for (const t of coerceTo) {
1485
1479
  if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") {
1486
1480
  coerceSpecificType(t);
@@ -1489,63 +1483,63 @@ function coerceData(it, types2, coerceTo) {
1489
1483
  gen.else();
1490
1484
  reportTypeError(it);
1491
1485
  gen.endIf();
1492
- gen.if((0, codegen_1$o._)`${coerced} !== undefined`, () => {
1486
+ gen.if((0, codegen_1$s._)`${coerced} !== undefined`, () => {
1493
1487
  gen.assign(data2, coerced);
1494
1488
  assignParentData(it, coerced);
1495
1489
  });
1496
1490
  function coerceSpecificType(t) {
1497
1491
  switch (t) {
1498
1492
  case "string":
1499
- gen.elseIf((0, codegen_1$o._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_1$o._)`"" + ${data2}`).elseIf((0, codegen_1$o._)`${data2} === null`).assign(coerced, (0, codegen_1$o._)`""`);
1493
+ gen.elseIf((0, codegen_1$s._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_1$s._)`"" + ${data2}`).elseIf((0, codegen_1$s._)`${data2} === null`).assign(coerced, (0, codegen_1$s._)`""`);
1500
1494
  return;
1501
1495
  case "number":
1502
- gen.elseIf((0, codegen_1$o._)`${dataType2} == "boolean" || ${data2} === null
1503
- || (${dataType2} == "string" && ${data2} && ${data2} == +${data2})`).assign(coerced, (0, codegen_1$o._)`+${data2}`);
1496
+ gen.elseIf((0, codegen_1$s._)`${dataType2} == "boolean" || ${data2} === null
1497
+ || (${dataType2} == "string" && ${data2} && ${data2} == +${data2})`).assign(coerced, (0, codegen_1$s._)`+${data2}`);
1504
1498
  return;
1505
1499
  case "integer":
1506
- gen.elseIf((0, codegen_1$o._)`${dataType2} === "boolean" || ${data2} === null
1507
- || (${dataType2} === "string" && ${data2} && ${data2} == +${data2} && !(${data2} % 1))`).assign(coerced, (0, codegen_1$o._)`+${data2}`);
1500
+ gen.elseIf((0, codegen_1$s._)`${dataType2} === "boolean" || ${data2} === null
1501
+ || (${dataType2} === "string" && ${data2} && ${data2} == +${data2} && !(${data2} % 1))`).assign(coerced, (0, codegen_1$s._)`+${data2}`);
1508
1502
  return;
1509
1503
  case "boolean":
1510
- gen.elseIf((0, codegen_1$o._)`${data2} === "false" || ${data2} === 0 || ${data2} === null`).assign(coerced, false).elseIf((0, codegen_1$o._)`${data2} === "true" || ${data2} === 1`).assign(coerced, true);
1504
+ gen.elseIf((0, codegen_1$s._)`${data2} === "false" || ${data2} === 0 || ${data2} === null`).assign(coerced, false).elseIf((0, codegen_1$s._)`${data2} === "true" || ${data2} === 1`).assign(coerced, true);
1511
1505
  return;
1512
1506
  case "null":
1513
- gen.elseIf((0, codegen_1$o._)`${data2} === "" || ${data2} === 0 || ${data2} === false`);
1507
+ gen.elseIf((0, codegen_1$s._)`${data2} === "" || ${data2} === 0 || ${data2} === false`);
1514
1508
  gen.assign(coerced, null);
1515
1509
  return;
1516
1510
  case "array":
1517
- gen.elseIf((0, codegen_1$o._)`${dataType2} === "string" || ${dataType2} === "number"
1518
- || ${dataType2} === "boolean" || ${data2} === null`).assign(coerced, (0, codegen_1$o._)`[${data2}]`);
1511
+ gen.elseIf((0, codegen_1$s._)`${dataType2} === "string" || ${dataType2} === "number"
1512
+ || ${dataType2} === "boolean" || ${data2} === null`).assign(coerced, (0, codegen_1$s._)`[${data2}]`);
1519
1513
  }
1520
1514
  }
1521
1515
  }
1522
1516
  function assignParentData({ gen, parentData, parentDataProperty }, expr) {
1523
- gen.if((0, codegen_1$o._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$o._)`${parentData}[${parentDataProperty}]`, expr));
1517
+ gen.if((0, codegen_1$s._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$s._)`${parentData}[${parentDataProperty}]`, expr));
1524
1518
  }
1525
1519
  function checkDataType$1(dataType2, data2, strictNums, correct = DataType.Correct) {
1526
- const EQ = correct === DataType.Correct ? codegen_1$o.operators.EQ : codegen_1$o.operators.NEQ;
1520
+ const EQ = correct === DataType.Correct ? codegen_1$s.operators.EQ : codegen_1$s.operators.NEQ;
1527
1521
  let cond;
1528
1522
  switch (dataType2) {
1529
1523
  case "null":
1530
- return (0, codegen_1$o._)`${data2} ${EQ} null`;
1524
+ return (0, codegen_1$s._)`${data2} ${EQ} null`;
1531
1525
  case "array":
1532
- cond = (0, codegen_1$o._)`Array.isArray(${data2})`;
1526
+ cond = (0, codegen_1$s._)`Array.isArray(${data2})`;
1533
1527
  break;
1534
1528
  case "object":
1535
- cond = (0, codegen_1$o._)`${data2} && typeof ${data2} == "object" && !Array.isArray(${data2})`;
1529
+ cond = (0, codegen_1$s._)`${data2} && typeof ${data2} == "object" && !Array.isArray(${data2})`;
1536
1530
  break;
1537
1531
  case "integer":
1538
- cond = numCond((0, codegen_1$o._)`!(${data2} % 1) && !isNaN(${data2})`);
1532
+ cond = numCond((0, codegen_1$s._)`!(${data2} % 1) && !isNaN(${data2})`);
1539
1533
  break;
1540
1534
  case "number":
1541
1535
  cond = numCond();
1542
1536
  break;
1543
1537
  default:
1544
- return (0, codegen_1$o._)`typeof ${data2} ${EQ} ${dataType2}`;
1538
+ return (0, codegen_1$s._)`typeof ${data2} ${EQ} ${dataType2}`;
1545
1539
  }
1546
- return correct === DataType.Correct ? cond : (0, codegen_1$o.not)(cond);
1547
- function numCond(_cond = codegen_1$o.nil) {
1548
- return (0, codegen_1$o.and)((0, codegen_1$o._)`typeof ${data2} == "number"`, _cond, strictNums ? (0, codegen_1$o._)`isFinite(${data2})` : codegen_1$o.nil);
1540
+ return correct === DataType.Correct ? cond : (0, codegen_1$s.not)(cond);
1541
+ function numCond(_cond = codegen_1$s.nil) {
1542
+ return (0, codegen_1$s.and)((0, codegen_1$s._)`typeof ${data2} == "number"`, _cond, strictNums ? (0, codegen_1$s._)`isFinite(${data2})` : codegen_1$s.nil);
1549
1543
  }
1550
1544
  }
1551
1545
  dataType.checkDataType = checkDataType$1;
@@ -1554,35 +1548,35 @@ function checkDataTypes$1(dataTypes, data2, strictNums, correct) {
1554
1548
  return checkDataType$1(dataTypes[0], data2, strictNums, correct);
1555
1549
  }
1556
1550
  let cond;
1557
- const types2 = (0, util_1$n.toHash)(dataTypes);
1551
+ const types2 = (0, util_1$q.toHash)(dataTypes);
1558
1552
  if (types2.array && types2.object) {
1559
- const notObj = (0, codegen_1$o._)`typeof ${data2} != "object"`;
1560
- cond = types2.null ? notObj : (0, codegen_1$o._)`!${data2} || ${notObj}`;
1553
+ const notObj = (0, codegen_1$s._)`typeof ${data2} != "object"`;
1554
+ cond = types2.null ? notObj : (0, codegen_1$s._)`!${data2} || ${notObj}`;
1561
1555
  delete types2.null;
1562
1556
  delete types2.array;
1563
1557
  delete types2.object;
1564
1558
  } else {
1565
- cond = codegen_1$o.nil;
1559
+ cond = codegen_1$s.nil;
1566
1560
  }
1567
1561
  if (types2.number)
1568
1562
  delete types2.integer;
1569
1563
  for (const t in types2)
1570
- cond = (0, codegen_1$o.and)(cond, checkDataType$1(t, data2, strictNums, correct));
1564
+ cond = (0, codegen_1$s.and)(cond, checkDataType$1(t, data2, strictNums, correct));
1571
1565
  return cond;
1572
1566
  }
1573
1567
  dataType.checkDataTypes = checkDataTypes$1;
1574
1568
  const typeError = {
1575
1569
  message: ({ schema }) => `must be ${schema}`,
1576
- params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$o._)`{type: ${schema}}` : (0, codegen_1$o._)`{type: ${schemaValue}}`
1570
+ params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$s._)`{type: ${schema}}` : (0, codegen_1$s._)`{type: ${schemaValue}}`
1577
1571
  };
1578
1572
  function reportTypeError(it) {
1579
1573
  const cxt = getTypeErrorContext(it);
1580
- (0, errors_1.reportError)(cxt, typeError);
1574
+ (0, errors_1$2.reportError)(cxt, typeError);
1581
1575
  }
1582
1576
  dataType.reportTypeError = reportTypeError;
1583
1577
  function getTypeErrorContext(it) {
1584
1578
  const { gen, data: data2, schema } = it;
1585
- const schemaCode = (0, util_1$n.schemaRefOrVal)(it, schema, "type");
1579
+ const schemaCode = (0, util_1$q.schemaRefOrVal)(it, schema, "type");
1586
1580
  return {
1587
1581
  gen,
1588
1582
  keyword: "type",
@@ -1596,60 +1590,54 @@ function getTypeErrorContext(it) {
1596
1590
  };
1597
1591
  }
1598
1592
  var defaults = {};
1599
- var hasRequiredDefaults;
1600
- function requireDefaults() {
1601
- if (hasRequiredDefaults) return defaults;
1602
- hasRequiredDefaults = 1;
1603
- Object.defineProperty(defaults, "__esModule", { value: true });
1604
- defaults.assignDefaults = void 0;
1605
- const codegen_12 = codegen;
1606
- const util_12 = util$7;
1607
- function assignDefaults(it, ty) {
1608
- const { properties: properties2, items: items2 } = it.schema;
1609
- if (ty === "object" && properties2) {
1610
- for (const key in properties2) {
1611
- assignDefault(it, key, properties2[key].default);
1612
- }
1613
- } else if (ty === "array" && Array.isArray(items2)) {
1614
- items2.forEach((sch, i) => assignDefault(it, i, sch.default));
1615
- }
1593
+ Object.defineProperty(defaults, "__esModule", { value: true });
1594
+ defaults.assignDefaults = void 0;
1595
+ const codegen_1$r = codegen;
1596
+ const util_1$p = util$7;
1597
+ function assignDefaults(it, ty) {
1598
+ const { properties: properties2, items: items2 } = it.schema;
1599
+ if (ty === "object" && properties2) {
1600
+ for (const key in properties2) {
1601
+ assignDefault(it, key, properties2[key].default);
1602
+ }
1603
+ } else if (ty === "array" && Array.isArray(items2)) {
1604
+ items2.forEach((sch, i) => assignDefault(it, i, sch.default));
1605
+ }
1606
+ }
1607
+ defaults.assignDefaults = assignDefaults;
1608
+ function assignDefault(it, prop, defaultValue) {
1609
+ const { gen, compositeRule, data: data2, opts } = it;
1610
+ if (defaultValue === void 0)
1611
+ return;
1612
+ const childData = (0, codegen_1$r._)`${data2}${(0, codegen_1$r.getProperty)(prop)}`;
1613
+ if (compositeRule) {
1614
+ (0, util_1$p.checkStrictMode)(it, `default is ignored for: ${childData}`);
1615
+ return;
1616
1616
  }
1617
- defaults.assignDefaults = assignDefaults;
1618
- function assignDefault(it, prop, defaultValue) {
1619
- const { gen, compositeRule, data: data2, opts } = it;
1620
- if (defaultValue === void 0)
1621
- return;
1622
- const childData = (0, codegen_12._)`${data2}${(0, codegen_12.getProperty)(prop)}`;
1623
- if (compositeRule) {
1624
- (0, util_12.checkStrictMode)(it, `default is ignored for: ${childData}`);
1625
- return;
1626
- }
1627
- let condition = (0, codegen_12._)`${childData} === undefined`;
1628
- if (opts.useDefaults === "empty") {
1629
- condition = (0, codegen_12._)`${condition} || ${childData} === null || ${childData} === ""`;
1630
- }
1631
- gen.if(condition, (0, codegen_12._)`${childData} = ${(0, codegen_12.stringify)(defaultValue)}`);
1617
+ let condition = (0, codegen_1$r._)`${childData} === undefined`;
1618
+ if (opts.useDefaults === "empty") {
1619
+ condition = (0, codegen_1$r._)`${condition} || ${childData} === null || ${childData} === ""`;
1632
1620
  }
1633
- return defaults;
1621
+ gen.if(condition, (0, codegen_1$r._)`${childData} = ${(0, codegen_1$r.stringify)(defaultValue)}`);
1634
1622
  }
1635
1623
  var keyword$1 = {};
1636
1624
  var code = {};
1637
1625
  Object.defineProperty(code, "__esModule", { value: true });
1638
1626
  code.validateUnion = code.validateArray = code.usePattern = code.callValidateCode = code.schemaProperties = code.allSchemaProperties = code.noPropertyInData = code.propertyInData = code.isOwnProperty = code.hasPropFunc = code.reportMissingProp = code.checkMissingProp = code.checkReportMissingProp = void 0;
1639
- const codegen_1$n = codegen;
1640
- const util_1$m = util$7;
1641
- const names_1$3 = names$1;
1627
+ const codegen_1$q = codegen;
1628
+ const util_1$o = util$7;
1629
+ const names_1$5 = names$1;
1642
1630
  const util_2$1 = util$7;
1643
1631
  function checkReportMissingProp(cxt, prop) {
1644
1632
  const { gen, data: data2, it } = cxt;
1645
1633
  gen.if(noPropertyInData(gen, data2, prop, it.opts.ownProperties), () => {
1646
- cxt.setParams({ missingProperty: (0, codegen_1$n._)`${prop}` }, true);
1634
+ cxt.setParams({ missingProperty: (0, codegen_1$q._)`${prop}` }, true);
1647
1635
  cxt.error();
1648
1636
  });
1649
1637
  }
1650
1638
  code.checkReportMissingProp = checkReportMissingProp;
1651
1639
  function checkMissingProp({ gen, data: data2, it: { opts } }, properties2, missing) {
1652
- return (0, codegen_1$n.or)(...properties2.map((prop) => (0, codegen_1$n.and)(noPropertyInData(gen, data2, prop, opts.ownProperties), (0, codegen_1$n._)`${missing} = ${prop}`)));
1640
+ return (0, codegen_1$q.or)(...properties2.map((prop) => (0, codegen_1$q.and)(noPropertyInData(gen, data2, prop, opts.ownProperties), (0, codegen_1$q._)`${missing} = ${prop}`)));
1653
1641
  }
1654
1642
  code.checkMissingProp = checkMissingProp;
1655
1643
  function reportMissingProp(cxt, missing) {
@@ -1661,22 +1649,22 @@ function hasPropFunc(gen) {
1661
1649
  return gen.scopeValue("func", {
1662
1650
  // eslint-disable-next-line @typescript-eslint/unbound-method
1663
1651
  ref: Object.prototype.hasOwnProperty,
1664
- code: (0, codegen_1$n._)`Object.prototype.hasOwnProperty`
1652
+ code: (0, codegen_1$q._)`Object.prototype.hasOwnProperty`
1665
1653
  });
1666
1654
  }
1667
1655
  code.hasPropFunc = hasPropFunc;
1668
1656
  function isOwnProperty(gen, data2, property) {
1669
- return (0, codegen_1$n._)`${hasPropFunc(gen)}.call(${data2}, ${property})`;
1657
+ return (0, codegen_1$q._)`${hasPropFunc(gen)}.call(${data2}, ${property})`;
1670
1658
  }
1671
1659
  code.isOwnProperty = isOwnProperty;
1672
1660
  function propertyInData(gen, data2, property, ownProperties) {
1673
- const cond = (0, codegen_1$n._)`${data2}${(0, codegen_1$n.getProperty)(property)} !== undefined`;
1674
- return ownProperties ? (0, codegen_1$n._)`${cond} && ${isOwnProperty(gen, data2, property)}` : cond;
1661
+ const cond = (0, codegen_1$q._)`${data2}${(0, codegen_1$q.getProperty)(property)} !== undefined`;
1662
+ return ownProperties ? (0, codegen_1$q._)`${cond} && ${isOwnProperty(gen, data2, property)}` : cond;
1675
1663
  }
1676
1664
  code.propertyInData = propertyInData;
1677
1665
  function noPropertyInData(gen, data2, property, ownProperties) {
1678
- const cond = (0, codegen_1$n._)`${data2}${(0, codegen_1$n.getProperty)(property)} === undefined`;
1679
- return ownProperties ? (0, codegen_1$n.or)(cond, (0, codegen_1$n.not)(isOwnProperty(gen, data2, property))) : cond;
1666
+ const cond = (0, codegen_1$q._)`${data2}${(0, codegen_1$q.getProperty)(property)} === undefined`;
1667
+ return ownProperties ? (0, codegen_1$q.or)(cond, (0, codegen_1$q.not)(isOwnProperty(gen, data2, property))) : cond;
1680
1668
  }
1681
1669
  code.noPropertyInData = noPropertyInData;
1682
1670
  function allSchemaProperties(schemaMap) {
@@ -1684,24 +1672,24 @@ function allSchemaProperties(schemaMap) {
1684
1672
  }
1685
1673
  code.allSchemaProperties = allSchemaProperties;
1686
1674
  function schemaProperties(it, schemaMap) {
1687
- return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$m.alwaysValidSchema)(it, schemaMap[p]));
1675
+ return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$o.alwaysValidSchema)(it, schemaMap[p]));
1688
1676
  }
1689
1677
  code.schemaProperties = schemaProperties;
1690
1678
  function callValidateCode({ schemaCode, data: data2, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
1691
- const dataAndSchema = passSchema ? (0, codegen_1$n._)`${schemaCode}, ${data2}, ${topSchemaRef}${schemaPath}` : data2;
1679
+ const dataAndSchema = passSchema ? (0, codegen_1$q._)`${schemaCode}, ${data2}, ${topSchemaRef}${schemaPath}` : data2;
1692
1680
  const valCxt = [
1693
- [names_1$3.default.instancePath, (0, codegen_1$n.strConcat)(names_1$3.default.instancePath, errorPath)],
1694
- [names_1$3.default.parentData, it.parentData],
1695
- [names_1$3.default.parentDataProperty, it.parentDataProperty],
1696
- [names_1$3.default.rootData, names_1$3.default.rootData]
1681
+ [names_1$5.default.instancePath, (0, codegen_1$q.strConcat)(names_1$5.default.instancePath, errorPath)],
1682
+ [names_1$5.default.parentData, it.parentData],
1683
+ [names_1$5.default.parentDataProperty, it.parentDataProperty],
1684
+ [names_1$5.default.rootData, names_1$5.default.rootData]
1697
1685
  ];
1698
1686
  if (it.opts.dynamicRef)
1699
- valCxt.push([names_1$3.default.dynamicAnchors, names_1$3.default.dynamicAnchors]);
1700
- const args = (0, codegen_1$n._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
1701
- return context !== codegen_1$n.nil ? (0, codegen_1$n._)`${func}.call(${context}, ${args})` : (0, codegen_1$n._)`${func}(${args})`;
1687
+ valCxt.push([names_1$5.default.dynamicAnchors, names_1$5.default.dynamicAnchors]);
1688
+ const args = (0, codegen_1$q._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
1689
+ return context !== codegen_1$q.nil ? (0, codegen_1$q._)`${func}.call(${context}, ${args})` : (0, codegen_1$q._)`${func}(${args})`;
1702
1690
  }
1703
1691
  code.callValidateCode = callValidateCode;
1704
- const newRegExp = (0, codegen_1$n._)`new RegExp`;
1692
+ const newRegExp = (0, codegen_1$q._)`new RegExp`;
1705
1693
  function usePattern({ gen, it: { opts } }, pattern2) {
1706
1694
  const u = opts.unicodeRegExp ? "u" : "";
1707
1695
  const { regExp } = opts.code;
@@ -1709,7 +1697,7 @@ function usePattern({ gen, it: { opts } }, pattern2) {
1709
1697
  return gen.scopeValue("pattern", {
1710
1698
  key: rx.toString(),
1711
1699
  ref: rx,
1712
- code: (0, codegen_1$n._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
1700
+ code: (0, codegen_1$q._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
1713
1701
  });
1714
1702
  }
1715
1703
  code.usePattern = usePattern;
@@ -1725,14 +1713,14 @@ function validateArray(cxt) {
1725
1713
  validateItems(() => gen.break());
1726
1714
  return valid;
1727
1715
  function validateItems(notValid) {
1728
- const len = gen.const("len", (0, codegen_1$n._)`${data2}.length`);
1716
+ const len = gen.const("len", (0, codegen_1$q._)`${data2}.length`);
1729
1717
  gen.forRange("i", 0, len, (i) => {
1730
1718
  cxt.subschema({
1731
1719
  keyword: keyword2,
1732
1720
  dataProp: i,
1733
- dataPropType: util_1$m.Type.Num
1721
+ dataPropType: util_1$o.Type.Num
1734
1722
  }, valid);
1735
- gen.if((0, codegen_1$n.not)(valid), notValid);
1723
+ gen.if((0, codegen_1$q.not)(valid), notValid);
1736
1724
  });
1737
1725
  }
1738
1726
  }
@@ -1741,7 +1729,7 @@ function validateUnion(cxt) {
1741
1729
  const { gen, schema, keyword: keyword2, it } = cxt;
1742
1730
  if (!Array.isArray(schema))
1743
1731
  throw new Error("ajv implementation error");
1744
- const alwaysValid = schema.some((sch) => (0, util_1$m.alwaysValidSchema)(it, sch));
1732
+ const alwaysValid = schema.some((sch) => (0, util_1$o.alwaysValidSchema)(it, sch));
1745
1733
  if (alwaysValid && !it.opts.unevaluated)
1746
1734
  return;
1747
1735
  const valid = gen.let("valid", false);
@@ -1752,214 +1740,202 @@ function validateUnion(cxt) {
1752
1740
  schemaProp: i,
1753
1741
  compositeRule: true
1754
1742
  }, schValid);
1755
- gen.assign(valid, (0, codegen_1$n._)`${valid} || ${schValid}`);
1743
+ gen.assign(valid, (0, codegen_1$q._)`${valid} || ${schValid}`);
1756
1744
  const merged = cxt.mergeValidEvaluated(schCxt, schValid);
1757
1745
  if (!merged)
1758
- gen.if((0, codegen_1$n.not)(valid));
1746
+ gen.if((0, codegen_1$q.not)(valid));
1759
1747
  }));
1760
1748
  cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
1761
1749
  }
1762
1750
  code.validateUnion = validateUnion;
1763
- var hasRequiredKeyword;
1764
- function requireKeyword() {
1765
- if (hasRequiredKeyword) return keyword$1;
1766
- hasRequiredKeyword = 1;
1767
- Object.defineProperty(keyword$1, "__esModule", { value: true });
1768
- keyword$1.validateKeywordUsage = keyword$1.validSchemaType = keyword$1.funcKeywordCode = keyword$1.macroKeywordCode = void 0;
1769
- const codegen_12 = codegen;
1770
- const names_12 = names$1;
1771
- const code_12 = code;
1772
- const errors_12 = errors;
1773
- function macroKeywordCode(cxt, def2) {
1774
- const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
1775
- const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
1776
- const schemaRef = useKeyword(gen, keyword2, macroSchema);
1777
- if (it.opts.validateSchema !== false)
1778
- it.self.validateSchema(macroSchema, true);
1779
- const valid = gen.name("valid");
1780
- cxt.subschema({
1781
- schema: macroSchema,
1782
- schemaPath: codegen_12.nil,
1783
- errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
1784
- topSchemaRef: schemaRef,
1785
- compositeRule: true
1786
- }, valid);
1787
- cxt.pass(valid, () => cxt.error(true));
1788
- }
1789
- keyword$1.macroKeywordCode = macroKeywordCode;
1790
- function funcKeywordCode(cxt, def2) {
1791
- var _a;
1792
- const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
1793
- checkAsyncKeyword(it, def2);
1794
- const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
1795
- const validateRef = useKeyword(gen, keyword2, validate2);
1796
- const valid = gen.let("valid");
1797
- cxt.block$data(valid, validateKeyword2);
1798
- cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
1799
- function validateKeyword2() {
1800
- if (def2.errors === false) {
1801
- assignValid();
1802
- if (def2.modifying)
1803
- modifyData(cxt);
1804
- reportErrs(() => cxt.error());
1805
- } else {
1806
- const ruleErrs = def2.async ? validateAsync() : validateSync();
1807
- if (def2.modifying)
1808
- modifyData(cxt);
1809
- reportErrs(() => addErrs(cxt, ruleErrs));
1810
- }
1811
- }
1812
- function validateAsync() {
1813
- const ruleErrs = gen.let("ruleErrs", null);
1814
- gen.try(() => assignValid((0, codegen_12._)`await `), (e) => gen.assign(valid, false).if((0, codegen_12._)`${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_12._)`${e}.errors`), () => gen.throw(e)));
1815
- return ruleErrs;
1816
- }
1817
- function validateSync() {
1818
- const validateErrs = (0, codegen_12._)`${validateRef}.errors`;
1819
- gen.assign(validateErrs, null);
1820
- assignValid(codegen_12.nil);
1821
- return validateErrs;
1822
- }
1823
- function assignValid(_await = def2.async ? (0, codegen_12._)`await ` : codegen_12.nil) {
1824
- const passCxt = it.opts.passContext ? names_12.default.this : names_12.default.self;
1825
- const passSchema = !("compile" in def2 && !$data || def2.schema === false);
1826
- gen.assign(valid, (0, codegen_12._)`${_await}${(0, code_12.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
1827
- }
1828
- function reportErrs(errors2) {
1829
- var _a2;
1830
- gen.if((0, codegen_12.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
1751
+ Object.defineProperty(keyword$1, "__esModule", { value: true });
1752
+ keyword$1.validateKeywordUsage = keyword$1.validSchemaType = keyword$1.funcKeywordCode = keyword$1.macroKeywordCode = void 0;
1753
+ const codegen_1$p = codegen;
1754
+ const names_1$4 = names$1;
1755
+ const code_1$9 = code;
1756
+ const errors_1$1 = errors;
1757
+ function macroKeywordCode(cxt, def2) {
1758
+ const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
1759
+ const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
1760
+ const schemaRef = useKeyword(gen, keyword2, macroSchema);
1761
+ if (it.opts.validateSchema !== false)
1762
+ it.self.validateSchema(macroSchema, true);
1763
+ const valid = gen.name("valid");
1764
+ cxt.subschema({
1765
+ schema: macroSchema,
1766
+ schemaPath: codegen_1$p.nil,
1767
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
1768
+ topSchemaRef: schemaRef,
1769
+ compositeRule: true
1770
+ }, valid);
1771
+ cxt.pass(valid, () => cxt.error(true));
1772
+ }
1773
+ keyword$1.macroKeywordCode = macroKeywordCode;
1774
+ function funcKeywordCode(cxt, def2) {
1775
+ var _a;
1776
+ const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
1777
+ checkAsyncKeyword(it, def2);
1778
+ const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
1779
+ const validateRef = useKeyword(gen, keyword2, validate2);
1780
+ const valid = gen.let("valid");
1781
+ cxt.block$data(valid, validateKeyword2);
1782
+ cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
1783
+ function validateKeyword2() {
1784
+ if (def2.errors === false) {
1785
+ assignValid();
1786
+ if (def2.modifying)
1787
+ modifyData(cxt);
1788
+ reportErrs(() => cxt.error());
1789
+ } else {
1790
+ const ruleErrs = def2.async ? validateAsync() : validateSync();
1791
+ if (def2.modifying)
1792
+ modifyData(cxt);
1793
+ reportErrs(() => addErrs(cxt, ruleErrs));
1831
1794
  }
1832
1795
  }
1833
- keyword$1.funcKeywordCode = funcKeywordCode;
1834
- function modifyData(cxt) {
1835
- const { gen, data: data2, it } = cxt;
1836
- gen.if(it.parentData, () => gen.assign(data2, (0, codegen_12._)`${it.parentData}[${it.parentDataProperty}]`));
1837
- }
1838
- function addErrs(cxt, errs) {
1839
- const { gen } = cxt;
1840
- gen.if((0, codegen_12._)`Array.isArray(${errs})`, () => {
1841
- gen.assign(names_12.default.vErrors, (0, codegen_12._)`${names_12.default.vErrors} === null ? ${errs} : ${names_12.default.vErrors}.concat(${errs})`).assign(names_12.default.errors, (0, codegen_12._)`${names_12.default.vErrors}.length`);
1842
- (0, errors_12.extendErrors)(cxt);
1843
- }, () => cxt.error());
1844
- }
1845
- function checkAsyncKeyword({ schemaEnv }, def2) {
1846
- if (def2.async && !schemaEnv.$async)
1847
- throw new Error("async keyword in sync schema");
1848
- }
1849
- function useKeyword(gen, keyword2, result) {
1850
- if (result === void 0)
1851
- throw new Error(`keyword "${keyword2}" failed to compile`);
1852
- return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_12.stringify)(result) });
1853
- }
1854
- function validSchemaType(schema, schemaType, allowUndefined = false) {
1855
- return !schemaType.length || schemaType.some((st) => st === "array" ? Array.isArray(schema) : st === "object" ? schema && typeof schema == "object" && !Array.isArray(schema) : typeof schema == st || allowUndefined && typeof schema == "undefined");
1856
- }
1857
- keyword$1.validSchemaType = validSchemaType;
1858
- function validateKeywordUsage({ schema, opts, self: self2, errSchemaPath }, def2, keyword2) {
1859
- if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
1860
- throw new Error("ajv implementation error");
1861
- }
1862
- const deps = def2.dependencies;
1863
- if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
1864
- throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
1865
- }
1866
- if (def2.validateSchema) {
1867
- const valid = def2.validateSchema(schema[keyword2]);
1868
- if (!valid) {
1869
- const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self2.errorsText(def2.validateSchema.errors);
1870
- if (opts.validateSchema === "log")
1871
- self2.logger.error(msg);
1872
- else
1873
- throw new Error(msg);
1874
- }
1796
+ function validateAsync() {
1797
+ const ruleErrs = gen.let("ruleErrs", null);
1798
+ gen.try(() => assignValid((0, codegen_1$p._)`await `), (e) => gen.assign(valid, false).if((0, codegen_1$p._)`${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_1$p._)`${e}.errors`), () => gen.throw(e)));
1799
+ return ruleErrs;
1800
+ }
1801
+ function validateSync() {
1802
+ const validateErrs = (0, codegen_1$p._)`${validateRef}.errors`;
1803
+ gen.assign(validateErrs, null);
1804
+ assignValid(codegen_1$p.nil);
1805
+ return validateErrs;
1806
+ }
1807
+ function assignValid(_await = def2.async ? (0, codegen_1$p._)`await ` : codegen_1$p.nil) {
1808
+ const passCxt = it.opts.passContext ? names_1$4.default.this : names_1$4.default.self;
1809
+ const passSchema = !("compile" in def2 && !$data || def2.schema === false);
1810
+ gen.assign(valid, (0, codegen_1$p._)`${_await}${(0, code_1$9.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
1811
+ }
1812
+ function reportErrs(errors2) {
1813
+ var _a2;
1814
+ gen.if((0, codegen_1$p.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
1815
+ }
1816
+ }
1817
+ keyword$1.funcKeywordCode = funcKeywordCode;
1818
+ function modifyData(cxt) {
1819
+ const { gen, data: data2, it } = cxt;
1820
+ gen.if(it.parentData, () => gen.assign(data2, (0, codegen_1$p._)`${it.parentData}[${it.parentDataProperty}]`));
1821
+ }
1822
+ function addErrs(cxt, errs) {
1823
+ const { gen } = cxt;
1824
+ gen.if((0, codegen_1$p._)`Array.isArray(${errs})`, () => {
1825
+ gen.assign(names_1$4.default.vErrors, (0, codegen_1$p._)`${names_1$4.default.vErrors} === null ? ${errs} : ${names_1$4.default.vErrors}.concat(${errs})`).assign(names_1$4.default.errors, (0, codegen_1$p._)`${names_1$4.default.vErrors}.length`);
1826
+ (0, errors_1$1.extendErrors)(cxt);
1827
+ }, () => cxt.error());
1828
+ }
1829
+ function checkAsyncKeyword({ schemaEnv }, def2) {
1830
+ if (def2.async && !schemaEnv.$async)
1831
+ throw new Error("async keyword in sync schema");
1832
+ }
1833
+ function useKeyword(gen, keyword2, result) {
1834
+ if (result === void 0)
1835
+ throw new Error(`keyword "${keyword2}" failed to compile`);
1836
+ return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1$p.stringify)(result) });
1837
+ }
1838
+ function validSchemaType(schema, schemaType, allowUndefined = false) {
1839
+ return !schemaType.length || schemaType.some((st) => st === "array" ? Array.isArray(schema) : st === "object" ? schema && typeof schema == "object" && !Array.isArray(schema) : typeof schema == st || allowUndefined && typeof schema == "undefined");
1840
+ }
1841
+ keyword$1.validSchemaType = validSchemaType;
1842
+ function validateKeywordUsage({ schema, opts, self: self2, errSchemaPath }, def2, keyword2) {
1843
+ if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
1844
+ throw new Error("ajv implementation error");
1845
+ }
1846
+ const deps = def2.dependencies;
1847
+ if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
1848
+ throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
1849
+ }
1850
+ if (def2.validateSchema) {
1851
+ const valid = def2.validateSchema(schema[keyword2]);
1852
+ if (!valid) {
1853
+ const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self2.errorsText(def2.validateSchema.errors);
1854
+ if (opts.validateSchema === "log")
1855
+ self2.logger.error(msg);
1856
+ else
1857
+ throw new Error(msg);
1875
1858
  }
1876
1859
  }
1877
- keyword$1.validateKeywordUsage = validateKeywordUsage;
1878
- return keyword$1;
1879
1860
  }
1861
+ keyword$1.validateKeywordUsage = validateKeywordUsage;
1880
1862
  var subschema = {};
1881
- var hasRequiredSubschema;
1882
- function requireSubschema() {
1883
- if (hasRequiredSubschema) return subschema;
1884
- hasRequiredSubschema = 1;
1885
- Object.defineProperty(subschema, "__esModule", { value: true });
1886
- subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
1887
- const codegen_12 = codegen;
1888
- const util_12 = util$7;
1889
- function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
1890
- if (keyword2 !== void 0 && schema !== void 0) {
1891
- throw new Error('both "keyword" and "schema" passed, only one allowed');
1892
- }
1893
- if (keyword2 !== void 0) {
1894
- const sch = it.schema[keyword2];
1895
- return schemaProp === void 0 ? {
1896
- schema: sch,
1897
- schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}`,
1898
- errSchemaPath: `${it.errSchemaPath}/${keyword2}`
1899
- } : {
1900
- schema: sch[schemaProp],
1901
- schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}${(0, codegen_12.getProperty)(schemaProp)}`,
1902
- errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_12.escapeFragment)(schemaProp)}`
1903
- };
1904
- }
1905
- if (schema !== void 0) {
1906
- if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
1907
- throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
1908
- }
1909
- return {
1910
- schema,
1911
- schemaPath,
1912
- topSchemaRef,
1913
- errSchemaPath
1914
- };
1863
+ Object.defineProperty(subschema, "__esModule", { value: true });
1864
+ subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
1865
+ const codegen_1$o = codegen;
1866
+ const util_1$n = util$7;
1867
+ function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
1868
+ if (keyword2 !== void 0 && schema !== void 0) {
1869
+ throw new Error('both "keyword" and "schema" passed, only one allowed');
1870
+ }
1871
+ if (keyword2 !== void 0) {
1872
+ const sch = it.schema[keyword2];
1873
+ return schemaProp === void 0 ? {
1874
+ schema: sch,
1875
+ schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}`,
1876
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}`
1877
+ } : {
1878
+ schema: sch[schemaProp],
1879
+ schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}${(0, codegen_1$o.getProperty)(schemaProp)}`,
1880
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_1$n.escapeFragment)(schemaProp)}`
1881
+ };
1882
+ }
1883
+ if (schema !== void 0) {
1884
+ if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
1885
+ throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
1915
1886
  }
1916
- throw new Error('either "keyword" or "schema" must be passed');
1917
- }
1918
- subschema.getSubschema = getSubschema;
1919
- function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data: data2, dataTypes, propertyName }) {
1920
- if (data2 !== void 0 && dataProp !== void 0) {
1921
- throw new Error('both "data" and "dataProp" passed, only one allowed');
1922
- }
1923
- const { gen } = it;
1924
- if (dataProp !== void 0) {
1925
- const { errorPath, dataPathArr, opts } = it;
1926
- const nextData = gen.let("data", (0, codegen_12._)`${it.data}${(0, codegen_12.getProperty)(dataProp)}`, true);
1927
- dataContextProps(nextData);
1928
- subschema2.errorPath = (0, codegen_12.str)`${errorPath}${(0, util_12.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
1929
- subschema2.parentDataProperty = (0, codegen_12._)`${dataProp}`;
1930
- subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
1931
- }
1932
- if (data2 !== void 0) {
1933
- const nextData = data2 instanceof codegen_12.Name ? data2 : gen.let("data", data2, true);
1934
- dataContextProps(nextData);
1935
- if (propertyName !== void 0)
1936
- subschema2.propertyName = propertyName;
1937
- }
1938
- if (dataTypes)
1939
- subschema2.dataTypes = dataTypes;
1940
- function dataContextProps(_nextData) {
1941
- subschema2.data = _nextData;
1942
- subschema2.dataLevel = it.dataLevel + 1;
1943
- subschema2.dataTypes = [];
1944
- it.definedProperties = /* @__PURE__ */ new Set();
1945
- subschema2.parentData = it.data;
1946
- subschema2.dataNames = [...it.dataNames, _nextData];
1947
- }
1948
- }
1949
- subschema.extendSubschemaData = extendSubschemaData;
1950
- function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
1951
- if (compositeRule !== void 0)
1952
- subschema2.compositeRule = compositeRule;
1953
- if (createErrors !== void 0)
1954
- subschema2.createErrors = createErrors;
1955
- if (allErrors !== void 0)
1956
- subschema2.allErrors = allErrors;
1957
- subschema2.jtdDiscriminator = jtdDiscriminator;
1958
- subschema2.jtdMetadata = jtdMetadata;
1959
- }
1960
- subschema.extendSubschemaMode = extendSubschemaMode;
1961
- return subschema;
1962
- }
1887
+ return {
1888
+ schema,
1889
+ schemaPath,
1890
+ topSchemaRef,
1891
+ errSchemaPath
1892
+ };
1893
+ }
1894
+ throw new Error('either "keyword" or "schema" must be passed');
1895
+ }
1896
+ subschema.getSubschema = getSubschema;
1897
+ function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data: data2, dataTypes, propertyName }) {
1898
+ if (data2 !== void 0 && dataProp !== void 0) {
1899
+ throw new Error('both "data" and "dataProp" passed, only one allowed');
1900
+ }
1901
+ const { gen } = it;
1902
+ if (dataProp !== void 0) {
1903
+ const { errorPath, dataPathArr, opts } = it;
1904
+ const nextData = gen.let("data", (0, codegen_1$o._)`${it.data}${(0, codegen_1$o.getProperty)(dataProp)}`, true);
1905
+ dataContextProps(nextData);
1906
+ subschema2.errorPath = (0, codegen_1$o.str)`${errorPath}${(0, util_1$n.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
1907
+ subschema2.parentDataProperty = (0, codegen_1$o._)`${dataProp}`;
1908
+ subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
1909
+ }
1910
+ if (data2 !== void 0) {
1911
+ const nextData = data2 instanceof codegen_1$o.Name ? data2 : gen.let("data", data2, true);
1912
+ dataContextProps(nextData);
1913
+ if (propertyName !== void 0)
1914
+ subschema2.propertyName = propertyName;
1915
+ }
1916
+ if (dataTypes)
1917
+ subschema2.dataTypes = dataTypes;
1918
+ function dataContextProps(_nextData) {
1919
+ subschema2.data = _nextData;
1920
+ subschema2.dataLevel = it.dataLevel + 1;
1921
+ subschema2.dataTypes = [];
1922
+ it.definedProperties = /* @__PURE__ */ new Set();
1923
+ subschema2.parentData = it.data;
1924
+ subschema2.dataNames = [...it.dataNames, _nextData];
1925
+ }
1926
+ }
1927
+ subschema.extendSubschemaData = extendSubschemaData;
1928
+ function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
1929
+ if (compositeRule !== void 0)
1930
+ subschema2.compositeRule = compositeRule;
1931
+ if (createErrors !== void 0)
1932
+ subschema2.createErrors = createErrors;
1933
+ if (allErrors !== void 0)
1934
+ subschema2.allErrors = allErrors;
1935
+ subschema2.jtdDiscriminator = jtdDiscriminator;
1936
+ subschema2.jtdMetadata = jtdMetadata;
1937
+ }
1938
+ subschema.extendSubschemaMode = extendSubschemaMode;
1963
1939
  var resolve$6 = {};
1964
1940
  var fastDeepEqual = function equal(a, b) {
1965
1941
  if (a === b) return true;
@@ -2074,7 +2050,7 @@ function escapeJsonPtr$1(str) {
2074
2050
  var jsonSchemaTraverseExports$1 = jsonSchemaTraverse$1.exports;
2075
2051
  Object.defineProperty(resolve$6, "__esModule", { value: true });
2076
2052
  resolve$6.getSchemaRefs = resolve$6.resolveUrl = resolve$6.normalizeId = resolve$6._getFullPath = resolve$6.getFullPath = resolve$6.inlineRef = void 0;
2077
- const util_1$l = util$7;
2053
+ const util_1$m = util$7;
2078
2054
  const equal$5 = fastDeepEqual;
2079
2055
  const traverse$2 = jsonSchemaTraverseExports$1;
2080
2056
  const SIMPLE_INLINED$1 = /* @__PURE__ */ new Set([
@@ -2133,7 +2109,7 @@ function countKeys$1(schema) {
2133
2109
  if (SIMPLE_INLINED$1.has(key))
2134
2110
  continue;
2135
2111
  if (typeof schema[key] == "object") {
2136
- (0, util_1$l.eachItem)(schema[key], (sch) => count += countKeys$1(sch));
2112
+ (0, util_1$m.eachItem)(schema[key], (sch) => count += countKeys$1(sch));
2137
2113
  }
2138
2114
  if (count === Infinity)
2139
2115
  return Infinity;
@@ -2221,528 +2197,516 @@ function getSchemaRefs(schema, baseId) {
2221
2197
  }
2222
2198
  }
2223
2199
  resolve$6.getSchemaRefs = getSchemaRefs;
2224
- var hasRequiredValidate;
2225
- function requireValidate() {
2226
- if (hasRequiredValidate) return validate$2;
2227
- hasRequiredValidate = 1;
2228
- Object.defineProperty(validate$2, "__esModule", { value: true });
2229
- validate$2.getData = validate$2.KeywordCxt = validate$2.validateFunctionCode = void 0;
2230
- const boolSchema_1 = requireBoolSchema();
2231
- const dataType_12 = dataType;
2232
- const applicability_12 = applicability;
2233
- const dataType_2 = dataType;
2234
- const defaults_1 = requireDefaults();
2235
- const keyword_1 = requireKeyword();
2236
- const subschema_1 = requireSubschema();
2237
- const codegen_12 = codegen;
2238
- const names_12 = names$1;
2239
- const resolve_12 = resolve$6;
2240
- const util_12 = util$7;
2241
- const errors_12 = errors;
2242
- function validateFunctionCode(it) {
2243
- if (isSchemaObj(it)) {
2244
- checkKeywords(it);
2245
- if (schemaCxtHasRules(it)) {
2246
- topSchemaObjCode(it);
2247
- return;
2248
- }
2200
+ Object.defineProperty(validate$2, "__esModule", { value: true });
2201
+ validate$2.getData = validate$2.KeywordCxt = validate$2.validateFunctionCode = void 0;
2202
+ const boolSchema_1 = boolSchema;
2203
+ const dataType_1$1 = dataType;
2204
+ const applicability_1 = applicability;
2205
+ const dataType_2 = dataType;
2206
+ const defaults_1 = defaults;
2207
+ const keyword_1 = keyword$1;
2208
+ const subschema_1 = subschema;
2209
+ const codegen_1$n = codegen;
2210
+ const names_1$3 = names$1;
2211
+ const resolve_1$3 = resolve$6;
2212
+ const util_1$l = util$7;
2213
+ const errors_1 = errors;
2214
+ function validateFunctionCode(it) {
2215
+ if (isSchemaObj(it)) {
2216
+ checkKeywords(it);
2217
+ if (schemaCxtHasRules(it)) {
2218
+ topSchemaObjCode(it);
2219
+ return;
2249
2220
  }
2250
- validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
2251
- }
2252
- validate$2.validateFunctionCode = validateFunctionCode;
2253
- function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
2254
- if (opts.code.es5) {
2255
- gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${names_12.default.valCxt}`, schemaEnv.$async, () => {
2256
- gen.code((0, codegen_12._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
2257
- destructureValCxtES5(gen, opts);
2258
- gen.code(body);
2259
- });
2260
- } else {
2261
- gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
2262
- }
2263
- }
2264
- function destructureValCxt(opts) {
2265
- return (0, codegen_12._)`{${names_12.default.instancePath}="", ${names_12.default.parentData}, ${names_12.default.parentDataProperty}, ${names_12.default.rootData}=${names_12.default.data}${opts.dynamicRef ? (0, codegen_12._)`, ${names_12.default.dynamicAnchors}={}` : codegen_12.nil}}={}`;
2266
- }
2267
- function destructureValCxtES5(gen, opts) {
2268
- gen.if(names_12.default.valCxt, () => {
2269
- gen.var(names_12.default.instancePath, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.instancePath}`);
2270
- gen.var(names_12.default.parentData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentData}`);
2271
- gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentDataProperty}`);
2272
- gen.var(names_12.default.rootData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.rootData}`);
2273
- if (opts.dynamicRef)
2274
- gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.dynamicAnchors}`);
2275
- }, () => {
2276
- gen.var(names_12.default.instancePath, (0, codegen_12._)`""`);
2277
- gen.var(names_12.default.parentData, (0, codegen_12._)`undefined`);
2278
- gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`undefined`);
2279
- gen.var(names_12.default.rootData, names_12.default.data);
2280
- if (opts.dynamicRef)
2281
- gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`{}`);
2282
- });
2283
2221
  }
2284
- function topSchemaObjCode(it) {
2285
- const { schema, opts, gen } = it;
2286
- validateFunction(it, () => {
2287
- if (opts.$comment && schema.$comment)
2288
- commentKeyword(it);
2289
- checkNoDefault(it);
2290
- gen.let(names_12.default.vErrors, null);
2291
- gen.let(names_12.default.errors, 0);
2292
- if (opts.unevaluated)
2293
- resetEvaluated(it);
2294
- typeAndKeywords(it);
2295
- returnResults(it);
2222
+ validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
2223
+ }
2224
+ validate$2.validateFunctionCode = validateFunctionCode;
2225
+ function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
2226
+ if (opts.code.es5) {
2227
+ gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${names_1$3.default.valCxt}`, schemaEnv.$async, () => {
2228
+ gen.code((0, codegen_1$n._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
2229
+ destructureValCxtES5(gen, opts);
2230
+ gen.code(body);
2296
2231
  });
2297
- return;
2298
- }
2299
- function resetEvaluated(it) {
2300
- const { gen, validateName } = it;
2301
- it.evaluated = gen.const("evaluated", (0, codegen_12._)`${validateName}.evaluated`);
2302
- gen.if((0, codegen_12._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_12._)`${it.evaluated}.props`, (0, codegen_12._)`undefined`));
2303
- gen.if((0, codegen_12._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_12._)`${it.evaluated}.items`, (0, codegen_12._)`undefined`));
2304
- }
2305
- function funcSourceUrl(schema, opts) {
2306
- const schId = typeof schema == "object" && schema[opts.schemaId];
2307
- return schId && (opts.code.source || opts.code.process) ? (0, codegen_12._)`/*# sourceURL=${schId} */` : codegen_12.nil;
2308
- }
2309
- function subschemaCode(it, valid) {
2310
- if (isSchemaObj(it)) {
2311
- checkKeywords(it);
2312
- if (schemaCxtHasRules(it)) {
2313
- subSchemaObjCode(it, valid);
2314
- return;
2315
- }
2316
- }
2317
- (0, boolSchema_1.boolOrEmptySchema)(it, valid);
2318
- }
2319
- function schemaCxtHasRules({ schema, self: self2 }) {
2320
- if (typeof schema == "boolean")
2321
- return !schema;
2322
- for (const key in schema)
2323
- if (self2.RULES.all[key])
2324
- return true;
2325
- return false;
2326
- }
2327
- function isSchemaObj(it) {
2328
- return typeof it.schema != "boolean";
2329
- }
2330
- function subSchemaObjCode(it, valid) {
2331
- const { schema, gen, opts } = it;
2232
+ } else {
2233
+ gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
2234
+ }
2235
+ }
2236
+ function destructureValCxt(opts) {
2237
+ return (0, codegen_1$n._)`{${names_1$3.default.instancePath}="", ${names_1$3.default.parentData}, ${names_1$3.default.parentDataProperty}, ${names_1$3.default.rootData}=${names_1$3.default.data}${opts.dynamicRef ? (0, codegen_1$n._)`, ${names_1$3.default.dynamicAnchors}={}` : codegen_1$n.nil}}={}`;
2238
+ }
2239
+ function destructureValCxtES5(gen, opts) {
2240
+ gen.if(names_1$3.default.valCxt, () => {
2241
+ gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.instancePath}`);
2242
+ gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentData}`);
2243
+ gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentDataProperty}`);
2244
+ gen.var(names_1$3.default.rootData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.rootData}`);
2245
+ if (opts.dynamicRef)
2246
+ gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.dynamicAnchors}`);
2247
+ }, () => {
2248
+ gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`""`);
2249
+ gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`undefined`);
2250
+ gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`undefined`);
2251
+ gen.var(names_1$3.default.rootData, names_1$3.default.data);
2252
+ if (opts.dynamicRef)
2253
+ gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`{}`);
2254
+ });
2255
+ }
2256
+ function topSchemaObjCode(it) {
2257
+ const { schema, opts, gen } = it;
2258
+ validateFunction(it, () => {
2332
2259
  if (opts.$comment && schema.$comment)
2333
2260
  commentKeyword(it);
2334
- updateContext(it);
2335
- checkAsyncSchema(it);
2336
- const errsCount = gen.const("_errs", names_12.default.errors);
2337
- typeAndKeywords(it, errsCount);
2338
- gen.var(valid, (0, codegen_12._)`${errsCount} === ${names_12.default.errors}`);
2339
- }
2340
- function checkKeywords(it) {
2341
- (0, util_12.checkUnknownRules)(it);
2342
- checkRefsAndKeywords(it);
2343
- }
2344
- function typeAndKeywords(it, errsCount) {
2345
- if (it.opts.jtd)
2346
- return schemaKeywords(it, [], false, errsCount);
2347
- const types2 = (0, dataType_12.getSchemaTypes)(it.schema);
2348
- const checkedTypes = (0, dataType_12.coerceAndCheckDataType)(it, types2);
2349
- schemaKeywords(it, types2, !checkedTypes, errsCount);
2350
- }
2351
- function checkRefsAndKeywords(it) {
2352
- const { schema, errSchemaPath, opts, self: self2 } = it;
2353
- if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_12.schemaHasRulesButRef)(schema, self2.RULES)) {
2354
- self2.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
2355
- }
2356
- }
2357
- function checkNoDefault(it) {
2358
- const { schema, opts } = it;
2359
- if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
2360
- (0, util_12.checkStrictMode)(it, "default is ignored in the schema root");
2261
+ checkNoDefault(it);
2262
+ gen.let(names_1$3.default.vErrors, null);
2263
+ gen.let(names_1$3.default.errors, 0);
2264
+ if (opts.unevaluated)
2265
+ resetEvaluated(it);
2266
+ typeAndKeywords(it);
2267
+ returnResults(it);
2268
+ });
2269
+ return;
2270
+ }
2271
+ function resetEvaluated(it) {
2272
+ const { gen, validateName } = it;
2273
+ it.evaluated = gen.const("evaluated", (0, codegen_1$n._)`${validateName}.evaluated`);
2274
+ gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.props`, (0, codegen_1$n._)`undefined`));
2275
+ gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.items`, (0, codegen_1$n._)`undefined`));
2276
+ }
2277
+ function funcSourceUrl(schema, opts) {
2278
+ const schId = typeof schema == "object" && schema[opts.schemaId];
2279
+ return schId && (opts.code.source || opts.code.process) ? (0, codegen_1$n._)`/*# sourceURL=${schId} */` : codegen_1$n.nil;
2280
+ }
2281
+ function subschemaCode(it, valid) {
2282
+ if (isSchemaObj(it)) {
2283
+ checkKeywords(it);
2284
+ if (schemaCxtHasRules(it)) {
2285
+ subSchemaObjCode(it, valid);
2286
+ return;
2361
2287
  }
2362
2288
  }
2363
- function updateContext(it) {
2364
- const schId = it.schema[it.opts.schemaId];
2365
- if (schId)
2366
- it.baseId = (0, resolve_12.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
2367
- }
2368
- function checkAsyncSchema(it) {
2369
- if (it.schema.$async && !it.schemaEnv.$async)
2370
- throw new Error("async schema in sync schema");
2371
- }
2372
- function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
2373
- const msg = schema.$comment;
2374
- if (opts.$comment === true) {
2375
- gen.code((0, codegen_12._)`${names_12.default.self}.logger.log(${msg})`);
2376
- } else if (typeof opts.$comment == "function") {
2377
- const schemaPath = (0, codegen_12.str)`${errSchemaPath}/$comment`;
2378
- const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
2379
- gen.code((0, codegen_12._)`${names_12.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
2380
- }
2289
+ (0, boolSchema_1.boolOrEmptySchema)(it, valid);
2290
+ }
2291
+ function schemaCxtHasRules({ schema, self: self2 }) {
2292
+ if (typeof schema == "boolean")
2293
+ return !schema;
2294
+ for (const key in schema)
2295
+ if (self2.RULES.all[key])
2296
+ return true;
2297
+ return false;
2298
+ }
2299
+ function isSchemaObj(it) {
2300
+ return typeof it.schema != "boolean";
2301
+ }
2302
+ function subSchemaObjCode(it, valid) {
2303
+ const { schema, gen, opts } = it;
2304
+ if (opts.$comment && schema.$comment)
2305
+ commentKeyword(it);
2306
+ updateContext(it);
2307
+ checkAsyncSchema(it);
2308
+ const errsCount = gen.const("_errs", names_1$3.default.errors);
2309
+ typeAndKeywords(it, errsCount);
2310
+ gen.var(valid, (0, codegen_1$n._)`${errsCount} === ${names_1$3.default.errors}`);
2311
+ }
2312
+ function checkKeywords(it) {
2313
+ (0, util_1$l.checkUnknownRules)(it);
2314
+ checkRefsAndKeywords(it);
2315
+ }
2316
+ function typeAndKeywords(it, errsCount) {
2317
+ if (it.opts.jtd)
2318
+ return schemaKeywords(it, [], false, errsCount);
2319
+ const types2 = (0, dataType_1$1.getSchemaTypes)(it.schema);
2320
+ const checkedTypes = (0, dataType_1$1.coerceAndCheckDataType)(it, types2);
2321
+ schemaKeywords(it, types2, !checkedTypes, errsCount);
2322
+ }
2323
+ function checkRefsAndKeywords(it) {
2324
+ const { schema, errSchemaPath, opts, self: self2 } = it;
2325
+ if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$l.schemaHasRulesButRef)(schema, self2.RULES)) {
2326
+ self2.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
2327
+ }
2328
+ }
2329
+ function checkNoDefault(it) {
2330
+ const { schema, opts } = it;
2331
+ if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
2332
+ (0, util_1$l.checkStrictMode)(it, "default is ignored in the schema root");
2333
+ }
2334
+ }
2335
+ function updateContext(it) {
2336
+ const schId = it.schema[it.opts.schemaId];
2337
+ if (schId)
2338
+ it.baseId = (0, resolve_1$3.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
2339
+ }
2340
+ function checkAsyncSchema(it) {
2341
+ if (it.schema.$async && !it.schemaEnv.$async)
2342
+ throw new Error("async schema in sync schema");
2343
+ }
2344
+ function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
2345
+ const msg = schema.$comment;
2346
+ if (opts.$comment === true) {
2347
+ gen.code((0, codegen_1$n._)`${names_1$3.default.self}.logger.log(${msg})`);
2348
+ } else if (typeof opts.$comment == "function") {
2349
+ const schemaPath = (0, codegen_1$n.str)`${errSchemaPath}/$comment`;
2350
+ const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
2351
+ gen.code((0, codegen_1$n._)`${names_1$3.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
2352
+ }
2353
+ }
2354
+ function returnResults(it) {
2355
+ const { gen, schemaEnv, validateName, ValidationError: ValidationError3, opts } = it;
2356
+ if (schemaEnv.$async) {
2357
+ gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === 0`, () => gen.return(names_1$3.default.data), () => gen.throw((0, codegen_1$n._)`new ${ValidationError3}(${names_1$3.default.vErrors})`));
2358
+ } else {
2359
+ gen.assign((0, codegen_1$n._)`${validateName}.errors`, names_1$3.default.vErrors);
2360
+ if (opts.unevaluated)
2361
+ assignEvaluated(it);
2362
+ gen.return((0, codegen_1$n._)`${names_1$3.default.errors} === 0`);
2363
+ }
2364
+ }
2365
+ function assignEvaluated({ gen, evaluated, props, items: items2 }) {
2366
+ if (props instanceof codegen_1$n.Name)
2367
+ gen.assign((0, codegen_1$n._)`${evaluated}.props`, props);
2368
+ if (items2 instanceof codegen_1$n.Name)
2369
+ gen.assign((0, codegen_1$n._)`${evaluated}.items`, items2);
2370
+ }
2371
+ function schemaKeywords(it, types2, typeErrors, errsCount) {
2372
+ const { gen, schema, data: data2, allErrors, opts, self: self2 } = it;
2373
+ const { RULES } = self2;
2374
+ if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$l.schemaHasRulesButRef)(schema, RULES))) {
2375
+ gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
2376
+ return;
2381
2377
  }
2382
- function returnResults(it) {
2383
- const { gen, schemaEnv, validateName, ValidationError: ValidationError2, opts } = it;
2384
- if (schemaEnv.$async) {
2385
- gen.if((0, codegen_12._)`${names_12.default.errors} === 0`, () => gen.return(names_12.default.data), () => gen.throw((0, codegen_12._)`new ${ValidationError2}(${names_12.default.vErrors})`));
2386
- } else {
2387
- gen.assign((0, codegen_12._)`${validateName}.errors`, names_12.default.vErrors);
2388
- if (opts.unevaluated)
2389
- assignEvaluated(it);
2390
- gen.return((0, codegen_12._)`${names_12.default.errors} === 0`);
2391
- }
2392
- }
2393
- function assignEvaluated({ gen, evaluated, props, items: items2 }) {
2394
- if (props instanceof codegen_12.Name)
2395
- gen.assign((0, codegen_12._)`${evaluated}.props`, props);
2396
- if (items2 instanceof codegen_12.Name)
2397
- gen.assign((0, codegen_12._)`${evaluated}.items`, items2);
2398
- }
2399
- function schemaKeywords(it, types2, typeErrors, errsCount) {
2400
- const { gen, schema, data: data2, allErrors, opts, self: self2 } = it;
2401
- const { RULES } = self2;
2402
- if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_12.schemaHasRulesButRef)(schema, RULES))) {
2403
- gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
2378
+ if (!opts.jtd)
2379
+ checkStrictTypes(it, types2);
2380
+ gen.block(() => {
2381
+ for (const group of RULES.rules)
2382
+ groupKeywords(group);
2383
+ groupKeywords(RULES.post);
2384
+ });
2385
+ function groupKeywords(group) {
2386
+ if (!(0, applicability_1.shouldUseGroup)(schema, group))
2404
2387
  return;
2405
- }
2406
- if (!opts.jtd)
2407
- checkStrictTypes(it, types2);
2408
- gen.block(() => {
2409
- for (const group of RULES.rules)
2410
- groupKeywords(group);
2411
- groupKeywords(RULES.post);
2412
- });
2413
- function groupKeywords(group) {
2414
- if (!(0, applicability_12.shouldUseGroup)(schema, group))
2415
- return;
2416
- if (group.type) {
2417
- gen.if((0, dataType_2.checkDataType)(group.type, data2, opts.strictNumbers));
2418
- iterateKeywords(it, group);
2419
- if (types2.length === 1 && types2[0] === group.type && typeErrors) {
2420
- gen.else();
2421
- (0, dataType_2.reportTypeError)(it);
2422
- }
2423
- gen.endIf();
2424
- } else {
2425
- iterateKeywords(it, group);
2388
+ if (group.type) {
2389
+ gen.if((0, dataType_2.checkDataType)(group.type, data2, opts.strictNumbers));
2390
+ iterateKeywords(it, group);
2391
+ if (types2.length === 1 && types2[0] === group.type && typeErrors) {
2392
+ gen.else();
2393
+ (0, dataType_2.reportTypeError)(it);
2426
2394
  }
2427
- if (!allErrors)
2428
- gen.if((0, codegen_12._)`${names_12.default.errors} === ${errsCount || 0}`);
2395
+ gen.endIf();
2396
+ } else {
2397
+ iterateKeywords(it, group);
2429
2398
  }
2399
+ if (!allErrors)
2400
+ gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === ${errsCount || 0}`);
2430
2401
  }
2431
- function iterateKeywords(it, group) {
2432
- const { gen, schema, opts: { useDefaults } } = it;
2433
- if (useDefaults)
2434
- (0, defaults_1.assignDefaults)(it, group.type);
2435
- gen.block(() => {
2436
- for (const rule of group.rules) {
2437
- if ((0, applicability_12.shouldUseRule)(schema, rule)) {
2438
- keywordCode(it, rule.keyword, rule.definition, group.type);
2439
- }
2440
- }
2441
- });
2442
- }
2443
- function checkStrictTypes(it, types2) {
2444
- if (it.schemaEnv.meta || !it.opts.strictTypes)
2445
- return;
2446
- checkContextTypes(it, types2);
2447
- if (!it.opts.allowUnionTypes)
2448
- checkMultipleTypes(it, types2);
2449
- checkKeywordTypes(it, it.dataTypes);
2450
- }
2451
- function checkContextTypes(it, types2) {
2452
- if (!types2.length)
2453
- return;
2454
- if (!it.dataTypes.length) {
2455
- it.dataTypes = types2;
2456
- return;
2457
- }
2458
- types2.forEach((t) => {
2459
- if (!includesType(it.dataTypes, t)) {
2460
- strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
2461
- }
2462
- });
2463
- narrowSchemaTypes(it, types2);
2464
- }
2465
- function checkMultipleTypes(it, ts) {
2466
- if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
2467
- strictTypesError(it, "use allowUnionTypes to allow union type keyword");
2468
- }
2469
- }
2470
- function checkKeywordTypes(it, ts) {
2471
- const rules3 = it.self.RULES.all;
2472
- for (const keyword2 in rules3) {
2473
- const rule = rules3[keyword2];
2474
- if (typeof rule == "object" && (0, applicability_12.shouldUseRule)(it.schema, rule)) {
2475
- const { type: type2 } = rule.definition;
2476
- if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
2477
- strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
2478
- }
2479
- }
2480
- }
2481
- }
2482
- function hasApplicableType(schTs, kwdT) {
2483
- return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
2484
- }
2485
- function includesType(ts, t) {
2486
- return ts.includes(t) || t === "integer" && ts.includes("number");
2487
- }
2488
- function narrowSchemaTypes(it, withTypes) {
2489
- const ts = [];
2490
- for (const t of it.dataTypes) {
2491
- if (includesType(withTypes, t))
2492
- ts.push(t);
2493
- else if (withTypes.includes("integer") && t === "number")
2494
- ts.push("integer");
2495
- }
2496
- it.dataTypes = ts;
2497
- }
2498
- function strictTypesError(it, msg) {
2499
- const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
2500
- msg += ` at "${schemaPath}" (strictTypes)`;
2501
- (0, util_12.checkStrictMode)(it, msg, it.opts.strictTypes);
2502
- }
2503
- class KeywordCxt {
2504
- constructor(it, def2, keyword2) {
2505
- (0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
2506
- this.gen = it.gen;
2507
- this.allErrors = it.allErrors;
2508
- this.keyword = keyword2;
2509
- this.data = it.data;
2510
- this.schema = it.schema[keyword2];
2511
- this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
2512
- this.schemaValue = (0, util_12.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
2513
- this.schemaType = def2.schemaType;
2514
- this.parentSchema = it.schema;
2515
- this.params = {};
2516
- this.it = it;
2517
- this.def = def2;
2518
- if (this.$data) {
2519
- this.schemaCode = it.gen.const("vSchema", getData2(this.$data, it));
2520
- } else {
2521
- this.schemaCode = this.schemaValue;
2522
- if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
2523
- throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
2524
- }
2525
- }
2526
- if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
2527
- this.errsCount = it.gen.const("_errs", names_12.default.errors);
2402
+ }
2403
+ function iterateKeywords(it, group) {
2404
+ const { gen, schema, opts: { useDefaults } } = it;
2405
+ if (useDefaults)
2406
+ (0, defaults_1.assignDefaults)(it, group.type);
2407
+ gen.block(() => {
2408
+ for (const rule of group.rules) {
2409
+ if ((0, applicability_1.shouldUseRule)(schema, rule)) {
2410
+ keywordCode(it, rule.keyword, rule.definition, group.type);
2528
2411
  }
2529
2412
  }
2530
- result(condition, successAction, failAction) {
2531
- this.failResult((0, codegen_12.not)(condition), successAction, failAction);
2413
+ });
2414
+ }
2415
+ function checkStrictTypes(it, types2) {
2416
+ if (it.schemaEnv.meta || !it.opts.strictTypes)
2417
+ return;
2418
+ checkContextTypes(it, types2);
2419
+ if (!it.opts.allowUnionTypes)
2420
+ checkMultipleTypes(it, types2);
2421
+ checkKeywordTypes(it, it.dataTypes);
2422
+ }
2423
+ function checkContextTypes(it, types2) {
2424
+ if (!types2.length)
2425
+ return;
2426
+ if (!it.dataTypes.length) {
2427
+ it.dataTypes = types2;
2428
+ return;
2429
+ }
2430
+ types2.forEach((t) => {
2431
+ if (!includesType(it.dataTypes, t)) {
2432
+ strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
2532
2433
  }
2533
- failResult(condition, successAction, failAction) {
2534
- this.gen.if(condition);
2535
- if (failAction)
2536
- failAction();
2537
- else
2538
- this.error();
2539
- if (successAction) {
2540
- this.gen.else();
2541
- successAction();
2542
- if (this.allErrors)
2543
- this.gen.endIf();
2544
- } else {
2545
- if (this.allErrors)
2546
- this.gen.endIf();
2547
- else
2548
- this.gen.else();
2434
+ });
2435
+ narrowSchemaTypes(it, types2);
2436
+ }
2437
+ function checkMultipleTypes(it, ts) {
2438
+ if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
2439
+ strictTypesError(it, "use allowUnionTypes to allow union type keyword");
2440
+ }
2441
+ }
2442
+ function checkKeywordTypes(it, ts) {
2443
+ const rules3 = it.self.RULES.all;
2444
+ for (const keyword2 in rules3) {
2445
+ const rule = rules3[keyword2];
2446
+ if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) {
2447
+ const { type: type2 } = rule.definition;
2448
+ if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
2449
+ strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
2450
+ }
2451
+ }
2452
+ }
2453
+ }
2454
+ function hasApplicableType(schTs, kwdT) {
2455
+ return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
2456
+ }
2457
+ function includesType(ts, t) {
2458
+ return ts.includes(t) || t === "integer" && ts.includes("number");
2459
+ }
2460
+ function narrowSchemaTypes(it, withTypes) {
2461
+ const ts = [];
2462
+ for (const t of it.dataTypes) {
2463
+ if (includesType(withTypes, t))
2464
+ ts.push(t);
2465
+ else if (withTypes.includes("integer") && t === "number")
2466
+ ts.push("integer");
2467
+ }
2468
+ it.dataTypes = ts;
2469
+ }
2470
+ function strictTypesError(it, msg) {
2471
+ const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
2472
+ msg += ` at "${schemaPath}" (strictTypes)`;
2473
+ (0, util_1$l.checkStrictMode)(it, msg, it.opts.strictTypes);
2474
+ }
2475
+ class KeywordCxt {
2476
+ constructor(it, def2, keyword2) {
2477
+ (0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
2478
+ this.gen = it.gen;
2479
+ this.allErrors = it.allErrors;
2480
+ this.keyword = keyword2;
2481
+ this.data = it.data;
2482
+ this.schema = it.schema[keyword2];
2483
+ this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
2484
+ this.schemaValue = (0, util_1$l.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
2485
+ this.schemaType = def2.schemaType;
2486
+ this.parentSchema = it.schema;
2487
+ this.params = {};
2488
+ this.it = it;
2489
+ this.def = def2;
2490
+ if (this.$data) {
2491
+ this.schemaCode = it.gen.const("vSchema", getData$1(this.$data, it));
2492
+ } else {
2493
+ this.schemaCode = this.schemaValue;
2494
+ if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
2495
+ throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
2549
2496
  }
2550
2497
  }
2551
- pass(condition, failAction) {
2552
- this.failResult((0, codegen_12.not)(condition), void 0, failAction);
2498
+ if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
2499
+ this.errsCount = it.gen.const("_errs", names_1$3.default.errors);
2553
2500
  }
2554
- fail(condition) {
2555
- if (condition === void 0) {
2556
- this.error();
2557
- if (!this.allErrors)
2558
- this.gen.if(false);
2559
- return;
2560
- }
2561
- this.gen.if(condition);
2501
+ }
2502
+ result(condition, successAction, failAction) {
2503
+ this.failResult((0, codegen_1$n.not)(condition), successAction, failAction);
2504
+ }
2505
+ failResult(condition, successAction, failAction) {
2506
+ this.gen.if(condition);
2507
+ if (failAction)
2508
+ failAction();
2509
+ else
2562
2510
  this.error();
2511
+ if (successAction) {
2512
+ this.gen.else();
2513
+ successAction();
2514
+ if (this.allErrors)
2515
+ this.gen.endIf();
2516
+ } else {
2563
2517
  if (this.allErrors)
2564
2518
  this.gen.endIf();
2565
2519
  else
2566
2520
  this.gen.else();
2567
2521
  }
2568
- fail$data(condition) {
2569
- if (!this.$data)
2570
- return this.fail(condition);
2571
- const { schemaCode } = this;
2572
- this.fail((0, codegen_12._)`${schemaCode} !== undefined && (${(0, codegen_12.or)(this.invalid$data(), condition)})`);
2573
- }
2574
- error(append, errorParams, errorPaths) {
2575
- if (errorParams) {
2576
- this.setParams(errorParams);
2577
- this._error(append, errorPaths);
2578
- this.setParams({});
2579
- return;
2580
- }
2581
- this._error(append, errorPaths);
2582
- }
2583
- _error(append, errorPaths) {
2584
- (append ? errors_12.reportExtraError : errors_12.reportError)(this, this.def.error, errorPaths);
2585
- }
2586
- $dataError() {
2587
- (0, errors_12.reportError)(this, this.def.$dataError || errors_12.keyword$DataError);
2588
- }
2589
- reset() {
2590
- if (this.errsCount === void 0)
2591
- throw new Error('add "trackErrors" to keyword definition');
2592
- (0, errors_12.resetErrorsCount)(this.gen, this.errsCount);
2593
- }
2594
- ok(cond) {
2522
+ }
2523
+ pass(condition, failAction) {
2524
+ this.failResult((0, codegen_1$n.not)(condition), void 0, failAction);
2525
+ }
2526
+ fail(condition) {
2527
+ if (condition === void 0) {
2528
+ this.error();
2595
2529
  if (!this.allErrors)
2596
- this.gen.if(cond);
2530
+ this.gen.if(false);
2531
+ return;
2597
2532
  }
2598
- setParams(obj, assign) {
2599
- if (assign)
2600
- Object.assign(this.params, obj);
2601
- else
2602
- this.params = obj;
2533
+ this.gen.if(condition);
2534
+ this.error();
2535
+ if (this.allErrors)
2536
+ this.gen.endIf();
2537
+ else
2538
+ this.gen.else();
2539
+ }
2540
+ fail$data(condition) {
2541
+ if (!this.$data)
2542
+ return this.fail(condition);
2543
+ const { schemaCode } = this;
2544
+ this.fail((0, codegen_1$n._)`${schemaCode} !== undefined && (${(0, codegen_1$n.or)(this.invalid$data(), condition)})`);
2545
+ }
2546
+ error(append, errorParams, errorPaths) {
2547
+ if (errorParams) {
2548
+ this.setParams(errorParams);
2549
+ this._error(append, errorPaths);
2550
+ this.setParams({});
2551
+ return;
2603
2552
  }
2604
- block$data(valid, codeBlock, $dataValid = codegen_12.nil) {
2605
- this.gen.block(() => {
2606
- this.check$data(valid, $dataValid);
2607
- codeBlock();
2608
- });
2553
+ this._error(append, errorPaths);
2554
+ }
2555
+ _error(append, errorPaths) {
2556
+ (append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
2557
+ }
2558
+ $dataError() {
2559
+ (0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
2560
+ }
2561
+ reset() {
2562
+ if (this.errsCount === void 0)
2563
+ throw new Error('add "trackErrors" to keyword definition');
2564
+ (0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
2565
+ }
2566
+ ok(cond) {
2567
+ if (!this.allErrors)
2568
+ this.gen.if(cond);
2569
+ }
2570
+ setParams(obj, assign) {
2571
+ if (assign)
2572
+ Object.assign(this.params, obj);
2573
+ else
2574
+ this.params = obj;
2575
+ }
2576
+ block$data(valid, codeBlock, $dataValid = codegen_1$n.nil) {
2577
+ this.gen.block(() => {
2578
+ this.check$data(valid, $dataValid);
2579
+ codeBlock();
2580
+ });
2581
+ }
2582
+ check$data(valid = codegen_1$n.nil, $dataValid = codegen_1$n.nil) {
2583
+ if (!this.$data)
2584
+ return;
2585
+ const { gen, schemaCode, schemaType, def: def2 } = this;
2586
+ gen.if((0, codegen_1$n.or)((0, codegen_1$n._)`${schemaCode} === undefined`, $dataValid));
2587
+ if (valid !== codegen_1$n.nil)
2588
+ gen.assign(valid, true);
2589
+ if (schemaType.length || def2.validateSchema) {
2590
+ gen.elseIf(this.invalid$data());
2591
+ this.$dataError();
2592
+ if (valid !== codegen_1$n.nil)
2593
+ gen.assign(valid, false);
2609
2594
  }
2610
- check$data(valid = codegen_12.nil, $dataValid = codegen_12.nil) {
2611
- if (!this.$data)
2612
- return;
2613
- const { gen, schemaCode, schemaType, def: def2 } = this;
2614
- gen.if((0, codegen_12.or)((0, codegen_12._)`${schemaCode} === undefined`, $dataValid));
2615
- if (valid !== codegen_12.nil)
2616
- gen.assign(valid, true);
2617
- if (schemaType.length || def2.validateSchema) {
2618
- gen.elseIf(this.invalid$data());
2619
- this.$dataError();
2620
- if (valid !== codegen_12.nil)
2621
- gen.assign(valid, false);
2595
+ gen.else();
2596
+ }
2597
+ invalid$data() {
2598
+ const { gen, schemaCode, schemaType, def: def2, it } = this;
2599
+ return (0, codegen_1$n.or)(wrong$DataType(), invalid$DataSchema());
2600
+ function wrong$DataType() {
2601
+ if (schemaType.length) {
2602
+ if (!(schemaCode instanceof codegen_1$n.Name))
2603
+ throw new Error("ajv implementation error");
2604
+ const st = Array.isArray(schemaType) ? schemaType : [schemaType];
2605
+ return (0, codegen_1$n._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
2622
2606
  }
2623
- gen.else();
2607
+ return codegen_1$n.nil;
2624
2608
  }
2625
- invalid$data() {
2626
- const { gen, schemaCode, schemaType, def: def2, it } = this;
2627
- return (0, codegen_12.or)(wrong$DataType(), invalid$DataSchema());
2628
- function wrong$DataType() {
2629
- if (schemaType.length) {
2630
- if (!(schemaCode instanceof codegen_12.Name))
2631
- throw new Error("ajv implementation error");
2632
- const st = Array.isArray(schemaType) ? schemaType : [schemaType];
2633
- return (0, codegen_12._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
2634
- }
2635
- return codegen_12.nil;
2636
- }
2637
- function invalid$DataSchema() {
2638
- if (def2.validateSchema) {
2639
- const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
2640
- return (0, codegen_12._)`!${validateSchemaRef}(${schemaCode})`;
2641
- }
2642
- return codegen_12.nil;
2643
- }
2644
- }
2645
- subschema(appl, valid) {
2646
- const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
2647
- (0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
2648
- (0, subschema_1.extendSubschemaMode)(subschema2, appl);
2649
- const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
2650
- subschemaCode(nextContext, valid);
2651
- return nextContext;
2652
- }
2653
- mergeEvaluated(schemaCxt, toName) {
2654
- const { it, gen } = this;
2655
- if (!it.opts.unevaluated)
2656
- return;
2657
- if (it.props !== true && schemaCxt.props !== void 0) {
2658
- it.props = util_12.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
2659
- }
2660
- if (it.items !== true && schemaCxt.items !== void 0) {
2661
- it.items = util_12.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
2609
+ function invalid$DataSchema() {
2610
+ if (def2.validateSchema) {
2611
+ const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
2612
+ return (0, codegen_1$n._)`!${validateSchemaRef}(${schemaCode})`;
2662
2613
  }
2614
+ return codegen_1$n.nil;
2663
2615
  }
2664
- mergeValidEvaluated(schemaCxt, valid) {
2665
- const { it, gen } = this;
2666
- if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
2667
- gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_12.Name));
2668
- return true;
2669
- }
2616
+ }
2617
+ subschema(appl, valid) {
2618
+ const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
2619
+ (0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
2620
+ (0, subschema_1.extendSubschemaMode)(subschema2, appl);
2621
+ const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
2622
+ subschemaCode(nextContext, valid);
2623
+ return nextContext;
2624
+ }
2625
+ mergeEvaluated(schemaCxt, toName) {
2626
+ const { it, gen } = this;
2627
+ if (!it.opts.unevaluated)
2628
+ return;
2629
+ if (it.props !== true && schemaCxt.props !== void 0) {
2630
+ it.props = util_1$l.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
2631
+ }
2632
+ if (it.items !== true && schemaCxt.items !== void 0) {
2633
+ it.items = util_1$l.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
2634
+ }
2635
+ }
2636
+ mergeValidEvaluated(schemaCxt, valid) {
2637
+ const { it, gen } = this;
2638
+ if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
2639
+ gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1$n.Name));
2640
+ return true;
2670
2641
  }
2671
2642
  }
2672
- validate$2.KeywordCxt = KeywordCxt;
2673
- function keywordCode(it, keyword2, def2, ruleType) {
2674
- const cxt = new KeywordCxt(it, def2, keyword2);
2675
- if ("code" in def2) {
2676
- def2.code(cxt, ruleType);
2677
- } else if (cxt.$data && def2.validate) {
2678
- (0, keyword_1.funcKeywordCode)(cxt, def2);
2679
- } else if ("macro" in def2) {
2680
- (0, keyword_1.macroKeywordCode)(cxt, def2);
2681
- } else if (def2.compile || def2.validate) {
2682
- (0, keyword_1.funcKeywordCode)(cxt, def2);
2683
- }
2684
- }
2685
- const JSON_POINTER2 = /^\/(?:[^~]|~0|~1)*$/;
2686
- const RELATIVE_JSON_POINTER2 = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
2687
- function getData2($data, { dataLevel, dataNames, dataPathArr }) {
2688
- let jsonPointer;
2689
- let data2;
2690
- if ($data === "")
2691
- return names_12.default.rootData;
2692
- if ($data[0] === "/") {
2693
- if (!JSON_POINTER2.test($data))
2694
- throw new Error(`Invalid JSON-pointer: ${$data}`);
2695
- jsonPointer = $data;
2696
- data2 = names_12.default.rootData;
2697
- } else {
2698
- const matches = RELATIVE_JSON_POINTER2.exec($data);
2699
- if (!matches)
2700
- throw new Error(`Invalid JSON-pointer: ${$data}`);
2701
- const up = +matches[1];
2702
- jsonPointer = matches[2];
2703
- if (jsonPointer === "#") {
2704
- if (up >= dataLevel)
2705
- throw new Error(errorMsg("property/index", up));
2706
- return dataPathArr[dataLevel - up];
2707
- }
2708
- if (up > dataLevel)
2709
- throw new Error(errorMsg("data", up));
2710
- data2 = dataNames[dataLevel - up];
2711
- if (!jsonPointer)
2712
- return data2;
2713
- }
2714
- let expr = data2;
2715
- const segments = jsonPointer.split("/");
2716
- for (const segment of segments) {
2717
- if (segment) {
2718
- data2 = (0, codegen_12._)`${data2}${(0, codegen_12.getProperty)((0, util_12.unescapeJsonPointer)(segment))}`;
2719
- expr = (0, codegen_12._)`${expr} && ${data2}`;
2720
- }
2721
- }
2722
- return expr;
2723
- function errorMsg(pointerType, up) {
2724
- return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
2725
- }
2726
- }
2727
- validate$2.getData = getData2;
2728
- return validate$2;
2729
2643
  }
2730
- var validation_error = {};
2731
- var hasRequiredValidation_error;
2732
- function requireValidation_error() {
2733
- if (hasRequiredValidation_error) return validation_error;
2734
- hasRequiredValidation_error = 1;
2735
- Object.defineProperty(validation_error, "__esModule", { value: true });
2736
- class ValidationError2 extends Error {
2737
- constructor(errors2) {
2738
- super("validation failed");
2739
- this.errors = errors2;
2740
- this.ajv = this.validation = true;
2644
+ validate$2.KeywordCxt = KeywordCxt;
2645
+ function keywordCode(it, keyword2, def2, ruleType) {
2646
+ const cxt = new KeywordCxt(it, def2, keyword2);
2647
+ if ("code" in def2) {
2648
+ def2.code(cxt, ruleType);
2649
+ } else if (cxt.$data && def2.validate) {
2650
+ (0, keyword_1.funcKeywordCode)(cxt, def2);
2651
+ } else if ("macro" in def2) {
2652
+ (0, keyword_1.macroKeywordCode)(cxt, def2);
2653
+ } else if (def2.compile || def2.validate) {
2654
+ (0, keyword_1.funcKeywordCode)(cxt, def2);
2655
+ }
2656
+ }
2657
+ const JSON_POINTER$2 = /^\/(?:[^~]|~0|~1)*$/;
2658
+ const RELATIVE_JSON_POINTER$2 = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
2659
+ function getData$1($data, { dataLevel, dataNames, dataPathArr }) {
2660
+ let jsonPointer;
2661
+ let data2;
2662
+ if ($data === "")
2663
+ return names_1$3.default.rootData;
2664
+ if ($data[0] === "/") {
2665
+ if (!JSON_POINTER$2.test($data))
2666
+ throw new Error(`Invalid JSON-pointer: ${$data}`);
2667
+ jsonPointer = $data;
2668
+ data2 = names_1$3.default.rootData;
2669
+ } else {
2670
+ const matches = RELATIVE_JSON_POINTER$2.exec($data);
2671
+ if (!matches)
2672
+ throw new Error(`Invalid JSON-pointer: ${$data}`);
2673
+ const up = +matches[1];
2674
+ jsonPointer = matches[2];
2675
+ if (jsonPointer === "#") {
2676
+ if (up >= dataLevel)
2677
+ throw new Error(errorMsg("property/index", up));
2678
+ return dataPathArr[dataLevel - up];
2679
+ }
2680
+ if (up > dataLevel)
2681
+ throw new Error(errorMsg("data", up));
2682
+ data2 = dataNames[dataLevel - up];
2683
+ if (!jsonPointer)
2684
+ return data2;
2685
+ }
2686
+ let expr = data2;
2687
+ const segments = jsonPointer.split("/");
2688
+ for (const segment of segments) {
2689
+ if (segment) {
2690
+ data2 = (0, codegen_1$n._)`${data2}${(0, codegen_1$n.getProperty)((0, util_1$l.unescapeJsonPointer)(segment))}`;
2691
+ expr = (0, codegen_1$n._)`${expr} && ${data2}`;
2741
2692
  }
2742
2693
  }
2743
- validation_error.default = ValidationError2;
2744
- return validation_error;
2694
+ return expr;
2695
+ function errorMsg(pointerType, up) {
2696
+ return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
2697
+ }
2745
2698
  }
2699
+ validate$2.getData = getData$1;
2700
+ var validation_error = {};
2701
+ Object.defineProperty(validation_error, "__esModule", { value: true });
2702
+ let ValidationError$2 = class ValidationError extends Error {
2703
+ constructor(errors2) {
2704
+ super("validation failed");
2705
+ this.errors = errors2;
2706
+ this.ajv = this.validation = true;
2707
+ }
2708
+ };
2709
+ validation_error.default = ValidationError$2;
2746
2710
  var ref_error = {};
2747
2711
  Object.defineProperty(ref_error, "__esModule", { value: true });
2748
2712
  const resolve_1$2 = resolve$6;
@@ -2758,11 +2722,11 @@ var compile$2 = {};
2758
2722
  Object.defineProperty(compile$2, "__esModule", { value: true });
2759
2723
  compile$2.resolveSchema = compile$2.getCompilingSchema = compile$2.resolveRef = compile$2.compileSchema = compile$2.SchemaEnv = void 0;
2760
2724
  const codegen_1$m = codegen;
2761
- const validation_error_1 = requireValidation_error();
2725
+ const validation_error_1 = validation_error;
2762
2726
  const names_1$2 = names$1;
2763
2727
  const resolve_1$1 = resolve$6;
2764
2728
  const util_1$k = util$7;
2765
- const validate_1$1 = requireValidate();
2729
+ const validate_1$1 = validate$2;
2766
2730
  class SchemaEnv {
2767
2731
  constructor(env) {
2768
2732
  var _a;
@@ -3649,7 +3613,7 @@ uri$2.default = uri$1;
3649
3613
  (function(exports) {
3650
3614
  Object.defineProperty(exports, "__esModule", { value: true });
3651
3615
  exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
3652
- var validate_12 = requireValidate();
3616
+ var validate_12 = validate$2;
3653
3617
  Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
3654
3618
  return validate_12.KeywordCxt;
3655
3619
  } });
@@ -3672,7 +3636,7 @@ uri$2.default = uri$1;
3672
3636
  Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function() {
3673
3637
  return codegen_12.CodeGen;
3674
3638
  } });
3675
- const validation_error_12 = requireValidation_error();
3639
+ const validation_error_12 = validation_error;
3676
3640
  const ref_error_12 = ref_error;
3677
3641
  const rules_12 = rules$2;
3678
3642
  const compile_12 = compile$2;
@@ -5251,7 +5215,7 @@ const def$a = {
5251
5215
  additionalProperties$1.default = def$a;
5252
5216
  var properties$4 = {};
5253
5217
  Object.defineProperty(properties$4, "__esModule", { value: true });
5254
- const validate_1 = requireValidate();
5218
+ const validate_1 = validate$2;
5255
5219
  const code_1$2 = code;
5256
5220
  const util_1$7 = util$7;
5257
5221
  const additionalProperties_1$1 = additionalProperties$1;
@@ -6102,7 +6066,7 @@ const require$$3 = {
6102
6066
  module.exports.Ajv = Ajv2;
6103
6067
  Object.defineProperty(exports, "__esModule", { value: true });
6104
6068
  exports.default = Ajv2;
6105
- var validate_12 = requireValidate();
6069
+ var validate_12 = validate$2;
6106
6070
  Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
6107
6071
  return validate_12.KeywordCxt;
6108
6072
  } });
@@ -6125,7 +6089,7 @@ const require$$3 = {
6125
6089
  Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function() {
6126
6090
  return codegen_12.CodeGen;
6127
6091
  } });
6128
- var validation_error_12 = requireValidation_error();
6092
+ var validation_error_12 = validation_error;
6129
6093
  Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function() {
6130
6094
  return validation_error_12.default;
6131
6095
  } });
@@ -13525,7 +13489,7 @@ var resolve$1 = resolve_1, util$2 = util$5, errorClasses$1 = error_classes, stab
13525
13489
  var validateGenerator = validate$1;
13526
13490
  var ucs2length2 = util$2.ucs2length;
13527
13491
  var equal2 = fastDeepEqual;
13528
- var ValidationError = errorClasses$1.Validation;
13492
+ var ValidationError2 = errorClasses$1.Validation;
13529
13493
  var compile_1 = compile$1;
13530
13494
  function compile$1(schema, root, localRefs, baseId) {
13531
13495
  var self2 = this, opts = this._opts, refVal = [void 0], refs = {}, patterns = [], patternsHash = {}, defaults2 = [], defaultsHash = {}, customRules = [];
@@ -13613,7 +13577,7 @@ function compile$1(schema, root, localRefs, baseId) {
13613
13577
  customRules,
13614
13578
  equal2,
13615
13579
  ucs2length2,
13616
- ValidationError
13580
+ ValidationError2
13617
13581
  );
13618
13582
  refVal[0] = validate2;
13619
13583
  } catch (e) {