@opentiny/next-sdk 0.1.6 → 0.1.8

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.
@@ -1021,8 +1021,8 @@
1021
1021
  var util$7 = {};
1022
1022
  Object.defineProperty(util$7, "__esModule", { value: true });
1023
1023
  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;
1024
- const codegen_1$v = codegen;
1025
- const code_1$a = code$1;
1024
+ const codegen_1$p = codegen;
1025
+ const code_1$9 = code$1;
1026
1026
  function toHash$2(arr) {
1027
1027
  const hash = {};
1028
1028
  for (const item of arr)
@@ -1075,9 +1075,9 @@
1075
1075
  if (typeof schema == "number" || typeof schema == "boolean")
1076
1076
  return schema;
1077
1077
  if (typeof schema == "string")
1078
- return (0, codegen_1$v._)`${schema}`;
1078
+ return (0, codegen_1$p._)`${schema}`;
1079
1079
  }
1080
- return (0, codegen_1$v._)`${topSchemaRef}${schemaPath}${(0, codegen_1$v.getProperty)(keyword2)}`;
1080
+ return (0, codegen_1$p._)`${topSchemaRef}${schemaPath}${(0, codegen_1$p.getProperty)(keyword2)}`;
1081
1081
  }
1082
1082
  util$7.schemaRefOrVal = schemaRefOrVal;
1083
1083
  function unescapeFragment$1(str) {
@@ -1109,20 +1109,20 @@
1109
1109
  util$7.eachItem = eachItem;
1110
1110
  function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues: mergeValues2, resultToName }) {
1111
1111
  return (gen, from, to, toName) => {
1112
- 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);
1113
- return toName === codegen_1$v.Name && !(res instanceof codegen_1$v.Name) ? resultToName(gen, res) : res;
1112
+ const res = to === void 0 ? from : to instanceof codegen_1$p.Name ? (from instanceof codegen_1$p.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1$p.Name ? (mergeToName(gen, to, from), from) : mergeValues2(from, to);
1113
+ return toName === codegen_1$p.Name && !(res instanceof codegen_1$p.Name) ? resultToName(gen, res) : res;
1114
1114
  };
1115
1115
  }
1116
1116
  util$7.mergeEvaluated = {
1117
1117
  props: makeMergeEvaluated({
1118
- mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => {
1119
- 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})`));
1118
+ mergeNames: (gen, from, to) => gen.if((0, codegen_1$p._)`${to} !== true && ${from} !== undefined`, () => {
1119
+ gen.if((0, codegen_1$p._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1$p._)`${to} || {}`).code((0, codegen_1$p._)`Object.assign(${to}, ${from})`));
1120
1120
  }),
1121
- mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => {
1121
+ mergeToName: (gen, from, to) => gen.if((0, codegen_1$p._)`${to} !== true`, () => {
1122
1122
  if (from === true) {
1123
1123
  gen.assign(to, true);
1124
1124
  } else {
1125
- gen.assign(to, (0, codegen_1$v._)`${to} || {}`);
1125
+ gen.assign(to, (0, codegen_1$p._)`${to} || {}`);
1126
1126
  setEvaluated(gen, to, from);
1127
1127
  }
1128
1128
  }),
@@ -1130,8 +1130,8 @@
1130
1130
  resultToName: evaluatedPropsToName
1131
1131
  }),
1132
1132
  items: makeMergeEvaluated({
1133
- 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}`)),
1134
- 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}`)),
1133
+ mergeNames: (gen, from, to) => gen.if((0, codegen_1$p._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1$p._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
1134
+ mergeToName: (gen, from, to) => gen.if((0, codegen_1$p._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1$p._)`${to} > ${from} ? ${to} : ${from}`)),
1135
1135
  mergeValues: (from, to) => from === true ? true : Math.max(from, to),
1136
1136
  resultToName: (gen, items2) => gen.var("items", items2)
1137
1137
  })
@@ -1139,21 +1139,21 @@
1139
1139
  function evaluatedPropsToName(gen, ps) {
1140
1140
  if (ps === true)
1141
1141
  return gen.var("props", true);
1142
- const props = gen.var("props", (0, codegen_1$v._)`{}`);
1142
+ const props = gen.var("props", (0, codegen_1$p._)`{}`);
1143
1143
  if (ps !== void 0)
1144
1144
  setEvaluated(gen, props, ps);
1145
1145
  return props;
1146
1146
  }
1147
1147
  util$7.evaluatedPropsToName = evaluatedPropsToName;
1148
1148
  function setEvaluated(gen, props, ps) {
1149
- Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$v._)`${props}${(0, codegen_1$v.getProperty)(p)}`, true));
1149
+ Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$p._)`${props}${(0, codegen_1$p.getProperty)(p)}`, true));
1150
1150
  }
1151
1151
  util$7.setEvaluated = setEvaluated;
1152
1152
  const snippets = {};
1153
1153
  function useFunc(gen, f) {
1154
1154
  return gen.scopeValue("func", {
1155
1155
  ref: f,
1156
- code: snippets[f.code] || (snippets[f.code] = new code_1$a._Code(f.code))
1156
+ code: snippets[f.code] || (snippets[f.code] = new code_1$9._Code(f.code))
1157
1157
  });
1158
1158
  }
1159
1159
  util$7.useFunc = useFunc;
@@ -1163,11 +1163,11 @@
1163
1163
  Type2[Type2["Str"] = 1] = "Str";
1164
1164
  })(Type || (util$7.Type = Type = {}));
1165
1165
  function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
1166
- if (dataProp instanceof codegen_1$v.Name) {
1166
+ if (dataProp instanceof codegen_1$p.Name) {
1167
1167
  const isNumber = dataPropType === Type.Num;
1168
- 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")`;
1168
+ return jsPropertySyntax ? isNumber ? (0, codegen_1$p._)`"[" + ${dataProp} + "]"` : (0, codegen_1$p._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1$p._)`"/" + ${dataProp}` : (0, codegen_1$p._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
1169
1169
  }
1170
- return jsPropertySyntax ? (0, codegen_1$v.getProperty)(dataProp).toString() : "/" + escapeJsonPointer$1(dataProp);
1170
+ return jsPropertySyntax ? (0, codegen_1$p.getProperty)(dataProp).toString() : "/" + escapeJsonPointer$1(dataProp);
1171
1171
  }
1172
1172
  util$7.getErrorPath = getErrorPath;
1173
1173
  function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
@@ -1181,35 +1181,35 @@
1181
1181
  util$7.checkStrictMode = checkStrictMode;
1182
1182
  var names$1 = {};
1183
1183
  Object.defineProperty(names$1, "__esModule", { value: true });
1184
- const codegen_1$u = codegen;
1184
+ const codegen_1$o = codegen;
1185
1185
  const names = {
1186
1186
  // validation function arguments
1187
- data: new codegen_1$u.Name("data"),
1187
+ data: new codegen_1$o.Name("data"),
1188
1188
  // data passed to validation function
1189
1189
  // args passed from referencing schema
1190
- valCxt: new codegen_1$u.Name("valCxt"),
1190
+ valCxt: new codegen_1$o.Name("valCxt"),
1191
1191
  // validation/data context - should not be used directly, it is destructured to the names below
1192
- instancePath: new codegen_1$u.Name("instancePath"),
1193
- parentData: new codegen_1$u.Name("parentData"),
1194
- parentDataProperty: new codegen_1$u.Name("parentDataProperty"),
1195
- rootData: new codegen_1$u.Name("rootData"),
1192
+ instancePath: new codegen_1$o.Name("instancePath"),
1193
+ parentData: new codegen_1$o.Name("parentData"),
1194
+ parentDataProperty: new codegen_1$o.Name("parentDataProperty"),
1195
+ rootData: new codegen_1$o.Name("rootData"),
1196
1196
  // root data - same as the data passed to the first/top validation function
1197
- dynamicAnchors: new codegen_1$u.Name("dynamicAnchors"),
1197
+ dynamicAnchors: new codegen_1$o.Name("dynamicAnchors"),
1198
1198
  // used to support recursiveRef and dynamicRef
1199
1199
  // function scoped variables
1200
- vErrors: new codegen_1$u.Name("vErrors"),
1200
+ vErrors: new codegen_1$o.Name("vErrors"),
1201
1201
  // null or array of validation errors
1202
- errors: new codegen_1$u.Name("errors"),
1202
+ errors: new codegen_1$o.Name("errors"),
1203
1203
  // counter of validation errors
1204
- this: new codegen_1$u.Name("this"),
1204
+ this: new codegen_1$o.Name("this"),
1205
1205
  // "globals"
1206
- self: new codegen_1$u.Name("self"),
1207
- scope: new codegen_1$u.Name("scope"),
1206
+ self: new codegen_1$o.Name("self"),
1207
+ scope: new codegen_1$o.Name("scope"),
1208
1208
  // JTD serialize/parse name for JSON string and position
1209
- json: new codegen_1$u.Name("json"),
1210
- jsonPos: new codegen_1$u.Name("jsonPos"),
1211
- jsonLen: new codegen_1$u.Name("jsonLen"),
1212
- jsonPart: new codegen_1$u.Name("jsonPart")
1209
+ json: new codegen_1$o.Name("json"),
1210
+ jsonPos: new codegen_1$o.Name("jsonPos"),
1211
+ jsonLen: new codegen_1$o.Name("jsonLen"),
1212
+ jsonPart: new codegen_1$o.Name("jsonPart")
1213
1213
  };
1214
1214
  names$1.default = names;
1215
1215
  (function(exports3) {
@@ -1329,49 +1329,55 @@
1329
1329
  keyValues.push([E.propertyName, propertyName]);
1330
1330
  }
1331
1331
  })(errors);
1332
- Object.defineProperty(boolSchema, "__esModule", { value: true });
1333
- boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
1334
- const errors_1$3 = errors;
1335
- const codegen_1$t = codegen;
1336
- const names_1$6 = 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_1$6.default.data);
1346
- } else {
1347
- gen.assign((0, codegen_1$t._)`${validateName}.errors`, null);
1348
- gen.return(true);
1332
+ var hasRequiredBoolSchema;
1333
+ function requireBoolSchema() {
1334
+ if (hasRequiredBoolSchema) return boolSchema;
1335
+ hasRequiredBoolSchema = 1;
1336
+ Object.defineProperty(boolSchema, "__esModule", { value: true });
1337
+ boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
1338
+ const errors_12 = errors;
1339
+ const codegen_12 = codegen;
1340
+ const names_12 = names$1;
1341
+ const boolError = {
1342
+ message: "boolean schema is false"
1343
+ };
1344
+ function topBoolOrEmptySchema(it) {
1345
+ const { gen, schema, validateName } = it;
1346
+ if (schema === false) {
1347
+ falseSchemaError(it, false);
1348
+ } else if (typeof schema == "object" && schema.$async === true) {
1349
+ gen.return(names_12.default.data);
1350
+ } else {
1351
+ gen.assign((0, codegen_12._)`${validateName}.errors`, null);
1352
+ gen.return(true);
1353
+ }
1349
1354
  }
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);
1355
+ boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
1356
+ function boolOrEmptySchema(it, valid) {
1357
+ const { gen, schema } = it;
1358
+ if (schema === false) {
1359
+ gen.var(valid, false);
1360
+ falseSchemaError(it);
1361
+ } else {
1362
+ gen.var(valid, true);
1363
+ }
1359
1364
  }
1360
- }
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_1$3.reportError)(cxt, boolError, void 0, overrideAllErrors);
1365
+ boolSchema.boolOrEmptySchema = boolOrEmptySchema;
1366
+ function falseSchemaError(it, overrideAllErrors) {
1367
+ const { gen, data: data2 } = it;
1368
+ const cxt = {
1369
+ gen,
1370
+ keyword: "false schema",
1371
+ data: data2,
1372
+ schema: false,
1373
+ schemaCode: false,
1374
+ schemaValue: false,
1375
+ params: {},
1376
+ it
1377
+ };
1378
+ (0, errors_12.reportError)(cxt, boolError, void 0, overrideAllErrors);
1379
+ }
1380
+ return boolSchema;
1375
1381
  }
1376
1382
  var dataType = {};
1377
1383
  var rules$2 = {};
@@ -1419,10 +1425,10 @@
1419
1425
  Object.defineProperty(dataType, "__esModule", { value: true });
1420
1426
  dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
1421
1427
  const rules_1 = rules$2;
1422
- const applicability_1$1 = applicability;
1423
- const errors_1$2 = errors;
1424
- const codegen_1$s = codegen;
1425
- const util_1$q = util$7;
1428
+ const applicability_1 = applicability;
1429
+ const errors_1 = errors;
1430
+ const codegen_1$n = codegen;
1431
+ const util_1$m = util$7;
1426
1432
  var DataType;
1427
1433
  (function(DataType2) {
1428
1434
  DataType2[DataType2["Correct"] = 0] = "Correct";
@@ -1454,7 +1460,7 @@
1454
1460
  function coerceAndCheckDataType(it, types2) {
1455
1461
  const { gen, data: data2, opts } = it;
1456
1462
  const coerceTo = coerceToTypes$1(types2, opts.coerceTypes);
1457
- const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1$1.schemaHasRulesForType)(it, types2[0]));
1463
+ const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types2[0]));
1458
1464
  if (checkTypes) {
1459
1465
  const wrongType = checkDataTypes$1(types2, data2, opts.strictNumbers, DataType.Wrong);
1460
1466
  gen.if(wrongType, () => {
@@ -1473,12 +1479,12 @@
1473
1479
  }
1474
1480
  function coerceData(it, types2, coerceTo) {
1475
1481
  const { gen, data: data2, opts } = it;
1476
- const dataType2 = gen.let("dataType", (0, codegen_1$s._)`typeof ${data2}`);
1477
- const coerced = gen.let("coerced", (0, codegen_1$s._)`undefined`);
1482
+ const dataType2 = gen.let("dataType", (0, codegen_1$n._)`typeof ${data2}`);
1483
+ const coerced = gen.let("coerced", (0, codegen_1$n._)`undefined`);
1478
1484
  if (opts.coerceTypes === "array") {
1479
- 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)));
1485
+ gen.if((0, codegen_1$n._)`${dataType2} == 'object' && Array.isArray(${data2}) && ${data2}.length == 1`, () => gen.assign(data2, (0, codegen_1$n._)`${data2}[0]`).assign(dataType2, (0, codegen_1$n._)`typeof ${data2}`).if(checkDataTypes$1(types2, data2, opts.strictNumbers), () => gen.assign(coerced, data2)));
1480
1486
  }
1481
- gen.if((0, codegen_1$s._)`${coerced} !== undefined`);
1487
+ gen.if((0, codegen_1$n._)`${coerced} !== undefined`);
1482
1488
  for (const t of coerceTo) {
1483
1489
  if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") {
1484
1490
  coerceSpecificType(t);
@@ -1487,63 +1493,63 @@
1487
1493
  gen.else();
1488
1494
  reportTypeError(it);
1489
1495
  gen.endIf();
1490
- gen.if((0, codegen_1$s._)`${coerced} !== undefined`, () => {
1496
+ gen.if((0, codegen_1$n._)`${coerced} !== undefined`, () => {
1491
1497
  gen.assign(data2, coerced);
1492
1498
  assignParentData(it, coerced);
1493
1499
  });
1494
1500
  function coerceSpecificType(t) {
1495
1501
  switch (t) {
1496
1502
  case "string":
1497
- 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._)`""`);
1503
+ gen.elseIf((0, codegen_1$n._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_1$n._)`"" + ${data2}`).elseIf((0, codegen_1$n._)`${data2} === null`).assign(coerced, (0, codegen_1$n._)`""`);
1498
1504
  return;
1499
1505
  case "number":
1500
- gen.elseIf((0, codegen_1$s._)`${dataType2} == "boolean" || ${data2} === null
1501
- || (${dataType2} == "string" && ${data2} && ${data2} == +${data2})`).assign(coerced, (0, codegen_1$s._)`+${data2}`);
1506
+ gen.elseIf((0, codegen_1$n._)`${dataType2} == "boolean" || ${data2} === null
1507
+ || (${dataType2} == "string" && ${data2} && ${data2} == +${data2})`).assign(coerced, (0, codegen_1$n._)`+${data2}`);
1502
1508
  return;
1503
1509
  case "integer":
1504
- gen.elseIf((0, codegen_1$s._)`${dataType2} === "boolean" || ${data2} === null
1505
- || (${dataType2} === "string" && ${data2} && ${data2} == +${data2} && !(${data2} % 1))`).assign(coerced, (0, codegen_1$s._)`+${data2}`);
1510
+ gen.elseIf((0, codegen_1$n._)`${dataType2} === "boolean" || ${data2} === null
1511
+ || (${dataType2} === "string" && ${data2} && ${data2} == +${data2} && !(${data2} % 1))`).assign(coerced, (0, codegen_1$n._)`+${data2}`);
1506
1512
  return;
1507
1513
  case "boolean":
1508
- 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);
1514
+ gen.elseIf((0, codegen_1$n._)`${data2} === "false" || ${data2} === 0 || ${data2} === null`).assign(coerced, false).elseIf((0, codegen_1$n._)`${data2} === "true" || ${data2} === 1`).assign(coerced, true);
1509
1515
  return;
1510
1516
  case "null":
1511
- gen.elseIf((0, codegen_1$s._)`${data2} === "" || ${data2} === 0 || ${data2} === false`);
1517
+ gen.elseIf((0, codegen_1$n._)`${data2} === "" || ${data2} === 0 || ${data2} === false`);
1512
1518
  gen.assign(coerced, null);
1513
1519
  return;
1514
1520
  case "array":
1515
- gen.elseIf((0, codegen_1$s._)`${dataType2} === "string" || ${dataType2} === "number"
1516
- || ${dataType2} === "boolean" || ${data2} === null`).assign(coerced, (0, codegen_1$s._)`[${data2}]`);
1521
+ gen.elseIf((0, codegen_1$n._)`${dataType2} === "string" || ${dataType2} === "number"
1522
+ || ${dataType2} === "boolean" || ${data2} === null`).assign(coerced, (0, codegen_1$n._)`[${data2}]`);
1517
1523
  }
1518
1524
  }
1519
1525
  }
1520
1526
  function assignParentData({ gen, parentData, parentDataProperty }, expr) {
1521
- gen.if((0, codegen_1$s._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$s._)`${parentData}[${parentDataProperty}]`, expr));
1527
+ gen.if((0, codegen_1$n._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$n._)`${parentData}[${parentDataProperty}]`, expr));
1522
1528
  }
1523
1529
  function checkDataType$1(dataType2, data2, strictNums, correct = DataType.Correct) {
1524
- const EQ = correct === DataType.Correct ? codegen_1$s.operators.EQ : codegen_1$s.operators.NEQ;
1530
+ const EQ = correct === DataType.Correct ? codegen_1$n.operators.EQ : codegen_1$n.operators.NEQ;
1525
1531
  let cond;
1526
1532
  switch (dataType2) {
1527
1533
  case "null":
1528
- return (0, codegen_1$s._)`${data2} ${EQ} null`;
1534
+ return (0, codegen_1$n._)`${data2} ${EQ} null`;
1529
1535
  case "array":
1530
- cond = (0, codegen_1$s._)`Array.isArray(${data2})`;
1536
+ cond = (0, codegen_1$n._)`Array.isArray(${data2})`;
1531
1537
  break;
1532
1538
  case "object":
1533
- cond = (0, codegen_1$s._)`${data2} && typeof ${data2} == "object" && !Array.isArray(${data2})`;
1539
+ cond = (0, codegen_1$n._)`${data2} && typeof ${data2} == "object" && !Array.isArray(${data2})`;
1534
1540
  break;
1535
1541
  case "integer":
1536
- cond = numCond((0, codegen_1$s._)`!(${data2} % 1) && !isNaN(${data2})`);
1542
+ cond = numCond((0, codegen_1$n._)`!(${data2} % 1) && !isNaN(${data2})`);
1537
1543
  break;
1538
1544
  case "number":
1539
1545
  cond = numCond();
1540
1546
  break;
1541
1547
  default:
1542
- return (0, codegen_1$s._)`typeof ${data2} ${EQ} ${dataType2}`;
1548
+ return (0, codegen_1$n._)`typeof ${data2} ${EQ} ${dataType2}`;
1543
1549
  }
1544
- return correct === DataType.Correct ? cond : (0, codegen_1$s.not)(cond);
1545
- function numCond(_cond = codegen_1$s.nil) {
1546
- 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);
1550
+ return correct === DataType.Correct ? cond : (0, codegen_1$n.not)(cond);
1551
+ function numCond(_cond = codegen_1$n.nil) {
1552
+ return (0, codegen_1$n.and)((0, codegen_1$n._)`typeof ${data2} == "number"`, _cond, strictNums ? (0, codegen_1$n._)`isFinite(${data2})` : codegen_1$n.nil);
1547
1553
  }
1548
1554
  }
1549
1555
  dataType.checkDataType = checkDataType$1;
@@ -1552,35 +1558,35 @@
1552
1558
  return checkDataType$1(dataTypes[0], data2, strictNums, correct);
1553
1559
  }
1554
1560
  let cond;
1555
- const types2 = (0, util_1$q.toHash)(dataTypes);
1561
+ const types2 = (0, util_1$m.toHash)(dataTypes);
1556
1562
  if (types2.array && types2.object) {
1557
- const notObj = (0, codegen_1$s._)`typeof ${data2} != "object"`;
1558
- cond = types2.null ? notObj : (0, codegen_1$s._)`!${data2} || ${notObj}`;
1563
+ const notObj = (0, codegen_1$n._)`typeof ${data2} != "object"`;
1564
+ cond = types2.null ? notObj : (0, codegen_1$n._)`!${data2} || ${notObj}`;
1559
1565
  delete types2.null;
1560
1566
  delete types2.array;
1561
1567
  delete types2.object;
1562
1568
  } else {
1563
- cond = codegen_1$s.nil;
1569
+ cond = codegen_1$n.nil;
1564
1570
  }
1565
1571
  if (types2.number)
1566
1572
  delete types2.integer;
1567
1573
  for (const t in types2)
1568
- cond = (0, codegen_1$s.and)(cond, checkDataType$1(t, data2, strictNums, correct));
1574
+ cond = (0, codegen_1$n.and)(cond, checkDataType$1(t, data2, strictNums, correct));
1569
1575
  return cond;
1570
1576
  }
1571
1577
  dataType.checkDataTypes = checkDataTypes$1;
1572
1578
  const typeError = {
1573
1579
  message: ({ schema }) => `must be ${schema}`,
1574
- params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$s._)`{type: ${schema}}` : (0, codegen_1$s._)`{type: ${schemaValue}}`
1580
+ params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$n._)`{type: ${schema}}` : (0, codegen_1$n._)`{type: ${schemaValue}}`
1575
1581
  };
1576
1582
  function reportTypeError(it) {
1577
1583
  const cxt = getTypeErrorContext(it);
1578
- (0, errors_1$2.reportError)(cxt, typeError);
1584
+ (0, errors_1.reportError)(cxt, typeError);
1579
1585
  }
1580
1586
  dataType.reportTypeError = reportTypeError;
1581
1587
  function getTypeErrorContext(it) {
1582
1588
  const { gen, data: data2, schema } = it;
1583
- const schemaCode = (0, util_1$q.schemaRefOrVal)(it, schema, "type");
1589
+ const schemaCode = (0, util_1$m.schemaRefOrVal)(it, schema, "type");
1584
1590
  return {
1585
1591
  gen,
1586
1592
  keyword: "type",
@@ -1594,352 +1600,376 @@
1594
1600
  };
1595
1601
  }
1596
1602
  var defaults = {};
1597
- Object.defineProperty(defaults, "__esModule", { value: true });
1598
- defaults.assignDefaults = void 0;
1599
- const codegen_1$r = codegen;
1600
- const util_1$p = util$7;
1601
- function assignDefaults(it, ty) {
1602
- const { properties: properties2, items: items2 } = it.schema;
1603
- if (ty === "object" && properties2) {
1604
- for (const key in properties2) {
1605
- assignDefault(it, key, properties2[key].default);
1606
- }
1607
- } else if (ty === "array" && Array.isArray(items2)) {
1608
- items2.forEach((sch, i) => assignDefault(it, i, sch.default));
1609
- }
1610
- }
1611
- defaults.assignDefaults = assignDefaults;
1612
- function assignDefault(it, prop, defaultValue) {
1613
- const { gen, compositeRule, data: data2, opts } = it;
1614
- if (defaultValue === void 0)
1615
- return;
1616
- const childData = (0, codegen_1$r._)`${data2}${(0, codegen_1$r.getProperty)(prop)}`;
1617
- if (compositeRule) {
1618
- (0, util_1$p.checkStrictMode)(it, `default is ignored for: ${childData}`);
1619
- return;
1603
+ var hasRequiredDefaults;
1604
+ function requireDefaults() {
1605
+ if (hasRequiredDefaults) return defaults;
1606
+ hasRequiredDefaults = 1;
1607
+ Object.defineProperty(defaults, "__esModule", { value: true });
1608
+ defaults.assignDefaults = void 0;
1609
+ const codegen_12 = codegen;
1610
+ const util_12 = util$7;
1611
+ function assignDefaults(it, ty) {
1612
+ const { properties: properties2, items: items2 } = it.schema;
1613
+ if (ty === "object" && properties2) {
1614
+ for (const key in properties2) {
1615
+ assignDefault(it, key, properties2[key].default);
1616
+ }
1617
+ } else if (ty === "array" && Array.isArray(items2)) {
1618
+ items2.forEach((sch, i) => assignDefault(it, i, sch.default));
1619
+ }
1620
1620
  }
1621
- let condition = (0, codegen_1$r._)`${childData} === undefined`;
1622
- if (opts.useDefaults === "empty") {
1623
- condition = (0, codegen_1$r._)`${condition} || ${childData} === null || ${childData} === ""`;
1621
+ defaults.assignDefaults = assignDefaults;
1622
+ function assignDefault(it, prop, defaultValue) {
1623
+ const { gen, compositeRule, data: data2, opts } = it;
1624
+ if (defaultValue === void 0)
1625
+ return;
1626
+ const childData = (0, codegen_12._)`${data2}${(0, codegen_12.getProperty)(prop)}`;
1627
+ if (compositeRule) {
1628
+ (0, util_12.checkStrictMode)(it, `default is ignored for: ${childData}`);
1629
+ return;
1630
+ }
1631
+ let condition = (0, codegen_12._)`${childData} === undefined`;
1632
+ if (opts.useDefaults === "empty") {
1633
+ condition = (0, codegen_12._)`${condition} || ${childData} === null || ${childData} === ""`;
1634
+ }
1635
+ gen.if(condition, (0, codegen_12._)`${childData} = ${(0, codegen_12.stringify)(defaultValue)}`);
1624
1636
  }
1625
- gen.if(condition, (0, codegen_1$r._)`${childData} = ${(0, codegen_1$r.stringify)(defaultValue)}`);
1637
+ return defaults;
1626
1638
  }
1627
1639
  var keyword$1 = {};
1628
1640
  var code = {};
1629
- Object.defineProperty(code, "__esModule", { value: true });
1630
- 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;
1631
- const codegen_1$q = codegen;
1632
- const util_1$o = util$7;
1633
- const names_1$5 = names$1;
1634
- const util_2$1 = util$7;
1635
- function checkReportMissingProp(cxt, prop) {
1636
- const { gen, data: data2, it } = cxt;
1637
- gen.if(noPropertyInData(gen, data2, prop, it.opts.ownProperties), () => {
1638
- cxt.setParams({ missingProperty: (0, codegen_1$q._)`${prop}` }, true);
1641
+ var hasRequiredCode;
1642
+ function requireCode() {
1643
+ if (hasRequiredCode) return code;
1644
+ hasRequiredCode = 1;
1645
+ Object.defineProperty(code, "__esModule", { value: true });
1646
+ 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;
1647
+ const codegen_12 = codegen;
1648
+ const util_12 = util$7;
1649
+ const names_12 = names$1;
1650
+ const util_22 = util$7;
1651
+ function checkReportMissingProp(cxt, prop) {
1652
+ const { gen, data: data2, it } = cxt;
1653
+ gen.if(noPropertyInData(gen, data2, prop, it.opts.ownProperties), () => {
1654
+ cxt.setParams({ missingProperty: (0, codegen_12._)`${prop}` }, true);
1655
+ cxt.error();
1656
+ });
1657
+ }
1658
+ code.checkReportMissingProp = checkReportMissingProp;
1659
+ function checkMissingProp({ gen, data: data2, it: { opts } }, properties2, missing) {
1660
+ return (0, codegen_12.or)(...properties2.map((prop) => (0, codegen_12.and)(noPropertyInData(gen, data2, prop, opts.ownProperties), (0, codegen_12._)`${missing} = ${prop}`)));
1661
+ }
1662
+ code.checkMissingProp = checkMissingProp;
1663
+ function reportMissingProp(cxt, missing) {
1664
+ cxt.setParams({ missingProperty: missing }, true);
1639
1665
  cxt.error();
1640
- });
1641
- }
1642
- code.checkReportMissingProp = checkReportMissingProp;
1643
- function checkMissingProp({ gen, data: data2, it: { opts } }, properties2, missing) {
1644
- 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}`)));
1645
- }
1646
- code.checkMissingProp = checkMissingProp;
1647
- function reportMissingProp(cxt, missing) {
1648
- cxt.setParams({ missingProperty: missing }, true);
1649
- cxt.error();
1650
- }
1651
- code.reportMissingProp = reportMissingProp;
1652
- function hasPropFunc(gen) {
1653
- return gen.scopeValue("func", {
1654
- // eslint-disable-next-line @typescript-eslint/unbound-method
1655
- ref: Object.prototype.hasOwnProperty,
1656
- code: (0, codegen_1$q._)`Object.prototype.hasOwnProperty`
1657
- });
1658
- }
1659
- code.hasPropFunc = hasPropFunc;
1660
- function isOwnProperty(gen, data2, property) {
1661
- return (0, codegen_1$q._)`${hasPropFunc(gen)}.call(${data2}, ${property})`;
1662
- }
1663
- code.isOwnProperty = isOwnProperty;
1664
- function propertyInData(gen, data2, property, ownProperties) {
1665
- const cond = (0, codegen_1$q._)`${data2}${(0, codegen_1$q.getProperty)(property)} !== undefined`;
1666
- return ownProperties ? (0, codegen_1$q._)`${cond} && ${isOwnProperty(gen, data2, property)}` : cond;
1667
- }
1668
- code.propertyInData = propertyInData;
1669
- function noPropertyInData(gen, data2, property, ownProperties) {
1670
- const cond = (0, codegen_1$q._)`${data2}${(0, codegen_1$q.getProperty)(property)} === undefined`;
1671
- return ownProperties ? (0, codegen_1$q.or)(cond, (0, codegen_1$q.not)(isOwnProperty(gen, data2, property))) : cond;
1672
- }
1673
- code.noPropertyInData = noPropertyInData;
1674
- function allSchemaProperties(schemaMap) {
1675
- return schemaMap ? Object.keys(schemaMap).filter((p) => p !== "__proto__") : [];
1676
- }
1677
- code.allSchemaProperties = allSchemaProperties;
1678
- function schemaProperties(it, schemaMap) {
1679
- return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$o.alwaysValidSchema)(it, schemaMap[p]));
1680
- }
1681
- code.schemaProperties = schemaProperties;
1682
- function callValidateCode({ schemaCode, data: data2, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
1683
- const dataAndSchema = passSchema ? (0, codegen_1$q._)`${schemaCode}, ${data2}, ${topSchemaRef}${schemaPath}` : data2;
1684
- const valCxt = [
1685
- [names_1$5.default.instancePath, (0, codegen_1$q.strConcat)(names_1$5.default.instancePath, errorPath)],
1686
- [names_1$5.default.parentData, it.parentData],
1687
- [names_1$5.default.parentDataProperty, it.parentDataProperty],
1688
- [names_1$5.default.rootData, names_1$5.default.rootData]
1689
- ];
1690
- if (it.opts.dynamicRef)
1691
- valCxt.push([names_1$5.default.dynamicAnchors, names_1$5.default.dynamicAnchors]);
1692
- const args = (0, codegen_1$q._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
1693
- return context !== codegen_1$q.nil ? (0, codegen_1$q._)`${func}.call(${context}, ${args})` : (0, codegen_1$q._)`${func}(${args})`;
1694
- }
1695
- code.callValidateCode = callValidateCode;
1696
- const newRegExp = (0, codegen_1$q._)`new RegExp`;
1697
- function usePattern({ gen, it: { opts } }, pattern2) {
1698
- const u = opts.unicodeRegExp ? "u" : "";
1699
- const { regExp } = opts.code;
1700
- const rx = regExp(pattern2, u);
1701
- return gen.scopeValue("pattern", {
1702
- key: rx.toString(),
1703
- ref: rx,
1704
- code: (0, codegen_1$q._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
1705
- });
1706
- }
1707
- code.usePattern = usePattern;
1708
- function validateArray(cxt) {
1709
- const { gen, data: data2, keyword: keyword2, it } = cxt;
1710
- const valid = gen.name("valid");
1711
- if (it.allErrors) {
1712
- const validArr = gen.let("valid", true);
1713
- validateItems(() => gen.assign(validArr, false));
1714
- return validArr;
1715
1666
  }
1716
- gen.var(valid, true);
1717
- validateItems(() => gen.break());
1718
- return valid;
1719
- function validateItems(notValid) {
1720
- const len = gen.const("len", (0, codegen_1$q._)`${data2}.length`);
1721
- gen.forRange("i", 0, len, (i) => {
1722
- cxt.subschema({
1723
- keyword: keyword2,
1724
- dataProp: i,
1725
- dataPropType: util_1$o.Type.Num
1726
- }, valid);
1727
- gen.if((0, codegen_1$q.not)(valid), notValid);
1667
+ code.reportMissingProp = reportMissingProp;
1668
+ function hasPropFunc(gen) {
1669
+ return gen.scopeValue("func", {
1670
+ // eslint-disable-next-line @typescript-eslint/unbound-method
1671
+ ref: Object.prototype.hasOwnProperty,
1672
+ code: (0, codegen_12._)`Object.prototype.hasOwnProperty`
1728
1673
  });
1729
1674
  }
1730
- }
1731
- code.validateArray = validateArray;
1732
- function validateUnion(cxt) {
1733
- const { gen, schema, keyword: keyword2, it } = cxt;
1734
- if (!Array.isArray(schema))
1735
- throw new Error("ajv implementation error");
1736
- const alwaysValid = schema.some((sch) => (0, util_1$o.alwaysValidSchema)(it, sch));
1737
- if (alwaysValid && !it.opts.unevaluated)
1738
- return;
1739
- const valid = gen.let("valid", false);
1740
- const schValid = gen.name("_valid");
1741
- gen.block(() => schema.forEach((_sch, i) => {
1742
- const schCxt = cxt.subschema({
1743
- keyword: keyword2,
1744
- schemaProp: i,
1745
- compositeRule: true
1746
- }, schValid);
1747
- gen.assign(valid, (0, codegen_1$q._)`${valid} || ${schValid}`);
1748
- const merged = cxt.mergeValidEvaluated(schCxt, schValid);
1749
- if (!merged)
1750
- gen.if((0, codegen_1$q.not)(valid));
1751
- }));
1752
- cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
1753
- }
1754
- code.validateUnion = validateUnion;
1755
- Object.defineProperty(keyword$1, "__esModule", { value: true });
1756
- keyword$1.validateKeywordUsage = keyword$1.validSchemaType = keyword$1.funcKeywordCode = keyword$1.macroKeywordCode = void 0;
1757
- const codegen_1$p = codegen;
1758
- const names_1$4 = names$1;
1759
- const code_1$9 = code;
1760
- const errors_1$1 = errors;
1761
- function macroKeywordCode(cxt, def2) {
1762
- const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
1763
- const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
1764
- const schemaRef = useKeyword(gen, keyword2, macroSchema);
1765
- if (it.opts.validateSchema !== false)
1766
- it.self.validateSchema(macroSchema, true);
1767
- const valid = gen.name("valid");
1768
- cxt.subschema({
1769
- schema: macroSchema,
1770
- schemaPath: codegen_1$p.nil,
1771
- errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
1772
- topSchemaRef: schemaRef,
1773
- compositeRule: true
1774
- }, valid);
1775
- cxt.pass(valid, () => cxt.error(true));
1776
- }
1777
- keyword$1.macroKeywordCode = macroKeywordCode;
1778
- function funcKeywordCode(cxt, def2) {
1779
- var _a;
1780
- const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
1781
- checkAsyncKeyword(it, def2);
1782
- const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
1783
- const validateRef = useKeyword(gen, keyword2, validate2);
1784
- const valid = gen.let("valid");
1785
- cxt.block$data(valid, validateKeyword2);
1786
- cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
1787
- function validateKeyword2() {
1788
- if (def2.errors === false) {
1789
- assignValid();
1790
- if (def2.modifying)
1791
- modifyData(cxt);
1792
- reportErrs(() => cxt.error());
1793
- } else {
1794
- const ruleErrs = def2.async ? validateAsync() : validateSync();
1795
- if (def2.modifying)
1796
- modifyData(cxt);
1797
- reportErrs(() => addErrs(cxt, ruleErrs));
1798
- }
1675
+ code.hasPropFunc = hasPropFunc;
1676
+ function isOwnProperty(gen, data2, property) {
1677
+ return (0, codegen_12._)`${hasPropFunc(gen)}.call(${data2}, ${property})`;
1678
+ }
1679
+ code.isOwnProperty = isOwnProperty;
1680
+ function propertyInData(gen, data2, property, ownProperties) {
1681
+ const cond = (0, codegen_12._)`${data2}${(0, codegen_12.getProperty)(property)} !== undefined`;
1682
+ return ownProperties ? (0, codegen_12._)`${cond} && ${isOwnProperty(gen, data2, property)}` : cond;
1683
+ }
1684
+ code.propertyInData = propertyInData;
1685
+ function noPropertyInData(gen, data2, property, ownProperties) {
1686
+ const cond = (0, codegen_12._)`${data2}${(0, codegen_12.getProperty)(property)} === undefined`;
1687
+ return ownProperties ? (0, codegen_12.or)(cond, (0, codegen_12.not)(isOwnProperty(gen, data2, property))) : cond;
1688
+ }
1689
+ code.noPropertyInData = noPropertyInData;
1690
+ function allSchemaProperties(schemaMap) {
1691
+ return schemaMap ? Object.keys(schemaMap).filter((p) => p !== "__proto__") : [];
1692
+ }
1693
+ code.allSchemaProperties = allSchemaProperties;
1694
+ function schemaProperties(it, schemaMap) {
1695
+ return allSchemaProperties(schemaMap).filter((p) => !(0, util_12.alwaysValidSchema)(it, schemaMap[p]));
1696
+ }
1697
+ code.schemaProperties = schemaProperties;
1698
+ function callValidateCode({ schemaCode, data: data2, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
1699
+ const dataAndSchema = passSchema ? (0, codegen_12._)`${schemaCode}, ${data2}, ${topSchemaRef}${schemaPath}` : data2;
1700
+ const valCxt = [
1701
+ [names_12.default.instancePath, (0, codegen_12.strConcat)(names_12.default.instancePath, errorPath)],
1702
+ [names_12.default.parentData, it.parentData],
1703
+ [names_12.default.parentDataProperty, it.parentDataProperty],
1704
+ [names_12.default.rootData, names_12.default.rootData]
1705
+ ];
1706
+ if (it.opts.dynamicRef)
1707
+ valCxt.push([names_12.default.dynamicAnchors, names_12.default.dynamicAnchors]);
1708
+ const args = (0, codegen_12._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
1709
+ return context !== codegen_12.nil ? (0, codegen_12._)`${func}.call(${context}, ${args})` : (0, codegen_12._)`${func}(${args})`;
1710
+ }
1711
+ code.callValidateCode = callValidateCode;
1712
+ const newRegExp = (0, codegen_12._)`new RegExp`;
1713
+ function usePattern({ gen, it: { opts } }, pattern2) {
1714
+ const u = opts.unicodeRegExp ? "u" : "";
1715
+ const { regExp } = opts.code;
1716
+ const rx = regExp(pattern2, u);
1717
+ return gen.scopeValue("pattern", {
1718
+ key: rx.toString(),
1719
+ ref: rx,
1720
+ code: (0, codegen_12._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_22.useFunc)(gen, regExp)}(${pattern2}, ${u})`
1721
+ });
1799
1722
  }
1800
- function validateAsync() {
1801
- const ruleErrs = gen.let("ruleErrs", null);
1802
- 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)));
1803
- return ruleErrs;
1723
+ code.usePattern = usePattern;
1724
+ function validateArray(cxt) {
1725
+ const { gen, data: data2, keyword: keyword2, it } = cxt;
1726
+ const valid = gen.name("valid");
1727
+ if (it.allErrors) {
1728
+ const validArr = gen.let("valid", true);
1729
+ validateItems(() => gen.assign(validArr, false));
1730
+ return validArr;
1731
+ }
1732
+ gen.var(valid, true);
1733
+ validateItems(() => gen.break());
1734
+ return valid;
1735
+ function validateItems(notValid) {
1736
+ const len = gen.const("len", (0, codegen_12._)`${data2}.length`);
1737
+ gen.forRange("i", 0, len, (i) => {
1738
+ cxt.subschema({
1739
+ keyword: keyword2,
1740
+ dataProp: i,
1741
+ dataPropType: util_12.Type.Num
1742
+ }, valid);
1743
+ gen.if((0, codegen_12.not)(valid), notValid);
1744
+ });
1745
+ }
1804
1746
  }
1805
- function validateSync() {
1806
- const validateErrs = (0, codegen_1$p._)`${validateRef}.errors`;
1807
- gen.assign(validateErrs, null);
1808
- assignValid(codegen_1$p.nil);
1809
- return validateErrs;
1747
+ code.validateArray = validateArray;
1748
+ function validateUnion(cxt) {
1749
+ const { gen, schema, keyword: keyword2, it } = cxt;
1750
+ if (!Array.isArray(schema))
1751
+ throw new Error("ajv implementation error");
1752
+ const alwaysValid = schema.some((sch) => (0, util_12.alwaysValidSchema)(it, sch));
1753
+ if (alwaysValid && !it.opts.unevaluated)
1754
+ return;
1755
+ const valid = gen.let("valid", false);
1756
+ const schValid = gen.name("_valid");
1757
+ gen.block(() => schema.forEach((_sch, i) => {
1758
+ const schCxt = cxt.subschema({
1759
+ keyword: keyword2,
1760
+ schemaProp: i,
1761
+ compositeRule: true
1762
+ }, schValid);
1763
+ gen.assign(valid, (0, codegen_12._)`${valid} || ${schValid}`);
1764
+ const merged = cxt.mergeValidEvaluated(schCxt, schValid);
1765
+ if (!merged)
1766
+ gen.if((0, codegen_12.not)(valid));
1767
+ }));
1768
+ cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
1810
1769
  }
1811
- function assignValid(_await = def2.async ? (0, codegen_1$p._)`await ` : codegen_1$p.nil) {
1812
- const passCxt = it.opts.passContext ? names_1$4.default.this : names_1$4.default.self;
1813
- const passSchema = !("compile" in def2 && !$data || def2.schema === false);
1814
- gen.assign(valid, (0, codegen_1$p._)`${_await}${(0, code_1$9.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
1770
+ code.validateUnion = validateUnion;
1771
+ return code;
1772
+ }
1773
+ var hasRequiredKeyword;
1774
+ function requireKeyword() {
1775
+ if (hasRequiredKeyword) return keyword$1;
1776
+ hasRequiredKeyword = 1;
1777
+ Object.defineProperty(keyword$1, "__esModule", { value: true });
1778
+ keyword$1.validateKeywordUsage = keyword$1.validSchemaType = keyword$1.funcKeywordCode = keyword$1.macroKeywordCode = void 0;
1779
+ const codegen_12 = codegen;
1780
+ const names_12 = names$1;
1781
+ const code_12 = requireCode();
1782
+ const errors_12 = errors;
1783
+ function macroKeywordCode(cxt, def2) {
1784
+ const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
1785
+ const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
1786
+ const schemaRef = useKeyword(gen, keyword2, macroSchema);
1787
+ if (it.opts.validateSchema !== false)
1788
+ it.self.validateSchema(macroSchema, true);
1789
+ const valid = gen.name("valid");
1790
+ cxt.subschema({
1791
+ schema: macroSchema,
1792
+ schemaPath: codegen_12.nil,
1793
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
1794
+ topSchemaRef: schemaRef,
1795
+ compositeRule: true
1796
+ }, valid);
1797
+ cxt.pass(valid, () => cxt.error(true));
1815
1798
  }
1816
- function reportErrs(errors2) {
1817
- var _a2;
1818
- gen.if((0, codegen_1$p.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
1799
+ keyword$1.macroKeywordCode = macroKeywordCode;
1800
+ function funcKeywordCode(cxt, def2) {
1801
+ var _a;
1802
+ const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
1803
+ checkAsyncKeyword(it, def2);
1804
+ const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
1805
+ const validateRef = useKeyword(gen, keyword2, validate2);
1806
+ const valid = gen.let("valid");
1807
+ cxt.block$data(valid, validateKeyword2);
1808
+ cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
1809
+ function validateKeyword2() {
1810
+ if (def2.errors === false) {
1811
+ assignValid();
1812
+ if (def2.modifying)
1813
+ modifyData(cxt);
1814
+ reportErrs(() => cxt.error());
1815
+ } else {
1816
+ const ruleErrs = def2.async ? validateAsync() : validateSync();
1817
+ if (def2.modifying)
1818
+ modifyData(cxt);
1819
+ reportErrs(() => addErrs(cxt, ruleErrs));
1820
+ }
1821
+ }
1822
+ function validateAsync() {
1823
+ const ruleErrs = gen.let("ruleErrs", null);
1824
+ 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)));
1825
+ return ruleErrs;
1826
+ }
1827
+ function validateSync() {
1828
+ const validateErrs = (0, codegen_12._)`${validateRef}.errors`;
1829
+ gen.assign(validateErrs, null);
1830
+ assignValid(codegen_12.nil);
1831
+ return validateErrs;
1832
+ }
1833
+ function assignValid(_await = def2.async ? (0, codegen_12._)`await ` : codegen_12.nil) {
1834
+ const passCxt = it.opts.passContext ? names_12.default.this : names_12.default.self;
1835
+ const passSchema = !("compile" in def2 && !$data || def2.schema === false);
1836
+ gen.assign(valid, (0, codegen_12._)`${_await}${(0, code_12.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
1837
+ }
1838
+ function reportErrs(errors2) {
1839
+ var _a2;
1840
+ gen.if((0, codegen_12.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
1841
+ }
1819
1842
  }
1820
- }
1821
- keyword$1.funcKeywordCode = funcKeywordCode;
1822
- function modifyData(cxt) {
1823
- const { gen, data: data2, it } = cxt;
1824
- gen.if(it.parentData, () => gen.assign(data2, (0, codegen_1$p._)`${it.parentData}[${it.parentDataProperty}]`));
1825
- }
1826
- function addErrs(cxt, errs) {
1827
- const { gen } = cxt;
1828
- gen.if((0, codegen_1$p._)`Array.isArray(${errs})`, () => {
1829
- 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`);
1830
- (0, errors_1$1.extendErrors)(cxt);
1831
- }, () => cxt.error());
1832
- }
1833
- function checkAsyncKeyword({ schemaEnv }, def2) {
1834
- if (def2.async && !schemaEnv.$async)
1835
- throw new Error("async keyword in sync schema");
1836
- }
1837
- function useKeyword(gen, keyword2, result) {
1838
- if (result === void 0)
1839
- throw new Error(`keyword "${keyword2}" failed to compile`);
1840
- return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1$p.stringify)(result) });
1841
- }
1842
- function validSchemaType(schema, schemaType, allowUndefined = false) {
1843
- 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");
1844
- }
1845
- keyword$1.validSchemaType = validSchemaType;
1846
- function validateKeywordUsage({ schema, opts, self: self2, errSchemaPath }, def2, keyword2) {
1847
- if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
1848
- throw new Error("ajv implementation error");
1849
- }
1850
- const deps = def2.dependencies;
1851
- if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
1852
- throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
1853
- }
1854
- if (def2.validateSchema) {
1855
- const valid = def2.validateSchema(schema[keyword2]);
1856
- if (!valid) {
1857
- const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self2.errorsText(def2.validateSchema.errors);
1858
- if (opts.validateSchema === "log")
1859
- self2.logger.error(msg);
1860
- else
1861
- throw new Error(msg);
1843
+ keyword$1.funcKeywordCode = funcKeywordCode;
1844
+ function modifyData(cxt) {
1845
+ const { gen, data: data2, it } = cxt;
1846
+ gen.if(it.parentData, () => gen.assign(data2, (0, codegen_12._)`${it.parentData}[${it.parentDataProperty}]`));
1847
+ }
1848
+ function addErrs(cxt, errs) {
1849
+ const { gen } = cxt;
1850
+ gen.if((0, codegen_12._)`Array.isArray(${errs})`, () => {
1851
+ 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`);
1852
+ (0, errors_12.extendErrors)(cxt);
1853
+ }, () => cxt.error());
1854
+ }
1855
+ function checkAsyncKeyword({ schemaEnv }, def2) {
1856
+ if (def2.async && !schemaEnv.$async)
1857
+ throw new Error("async keyword in sync schema");
1858
+ }
1859
+ function useKeyword(gen, keyword2, result) {
1860
+ if (result === void 0)
1861
+ throw new Error(`keyword "${keyword2}" failed to compile`);
1862
+ return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_12.stringify)(result) });
1863
+ }
1864
+ function validSchemaType(schema, schemaType, allowUndefined = false) {
1865
+ 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");
1866
+ }
1867
+ keyword$1.validSchemaType = validSchemaType;
1868
+ function validateKeywordUsage({ schema, opts, self: self2, errSchemaPath }, def2, keyword2) {
1869
+ if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
1870
+ throw new Error("ajv implementation error");
1871
+ }
1872
+ const deps = def2.dependencies;
1873
+ if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
1874
+ throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
1875
+ }
1876
+ if (def2.validateSchema) {
1877
+ const valid = def2.validateSchema(schema[keyword2]);
1878
+ if (!valid) {
1879
+ const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self2.errorsText(def2.validateSchema.errors);
1880
+ if (opts.validateSchema === "log")
1881
+ self2.logger.error(msg);
1882
+ else
1883
+ throw new Error(msg);
1884
+ }
1862
1885
  }
1863
1886
  }
1887
+ keyword$1.validateKeywordUsage = validateKeywordUsage;
1888
+ return keyword$1;
1864
1889
  }
1865
- keyword$1.validateKeywordUsage = validateKeywordUsage;
1866
1890
  var subschema = {};
1867
- Object.defineProperty(subschema, "__esModule", { value: true });
1868
- subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
1869
- const codegen_1$o = codegen;
1870
- const util_1$n = util$7;
1871
- function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
1872
- if (keyword2 !== void 0 && schema !== void 0) {
1873
- throw new Error('both "keyword" and "schema" passed, only one allowed');
1874
- }
1875
- if (keyword2 !== void 0) {
1876
- const sch = it.schema[keyword2];
1877
- return schemaProp === void 0 ? {
1878
- schema: sch,
1879
- schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}`,
1880
- errSchemaPath: `${it.errSchemaPath}/${keyword2}`
1881
- } : {
1882
- schema: sch[schemaProp],
1883
- schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}${(0, codegen_1$o.getProperty)(schemaProp)}`,
1884
- errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_1$n.escapeFragment)(schemaProp)}`
1885
- };
1886
- }
1887
- if (schema !== void 0) {
1888
- if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
1889
- throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
1891
+ var hasRequiredSubschema;
1892
+ function requireSubschema() {
1893
+ if (hasRequiredSubschema) return subschema;
1894
+ hasRequiredSubschema = 1;
1895
+ Object.defineProperty(subschema, "__esModule", { value: true });
1896
+ subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
1897
+ const codegen_12 = codegen;
1898
+ const util_12 = util$7;
1899
+ function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
1900
+ if (keyword2 !== void 0 && schema !== void 0) {
1901
+ throw new Error('both "keyword" and "schema" passed, only one allowed');
1890
1902
  }
1891
- return {
1892
- schema,
1893
- schemaPath,
1894
- topSchemaRef,
1895
- errSchemaPath
1896
- };
1897
- }
1898
- throw new Error('either "keyword" or "schema" must be passed');
1899
- }
1900
- subschema.getSubschema = getSubschema;
1901
- function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data: data2, dataTypes, propertyName }) {
1902
- if (data2 !== void 0 && dataProp !== void 0) {
1903
- throw new Error('both "data" and "dataProp" passed, only one allowed');
1904
- }
1905
- const { gen } = it;
1906
- if (dataProp !== void 0) {
1907
- const { errorPath, dataPathArr, opts } = it;
1908
- const nextData = gen.let("data", (0, codegen_1$o._)`${it.data}${(0, codegen_1$o.getProperty)(dataProp)}`, true);
1909
- dataContextProps(nextData);
1910
- subschema2.errorPath = (0, codegen_1$o.str)`${errorPath}${(0, util_1$n.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
1911
- subschema2.parentDataProperty = (0, codegen_1$o._)`${dataProp}`;
1912
- subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
1913
- }
1914
- if (data2 !== void 0) {
1915
- const nextData = data2 instanceof codegen_1$o.Name ? data2 : gen.let("data", data2, true);
1916
- dataContextProps(nextData);
1917
- if (propertyName !== void 0)
1918
- subschema2.propertyName = propertyName;
1919
- }
1920
- if (dataTypes)
1921
- subschema2.dataTypes = dataTypes;
1922
- function dataContextProps(_nextData) {
1923
- subschema2.data = _nextData;
1924
- subschema2.dataLevel = it.dataLevel + 1;
1925
- subschema2.dataTypes = [];
1926
- it.definedProperties = /* @__PURE__ */ new Set();
1927
- subschema2.parentData = it.data;
1928
- subschema2.dataNames = [...it.dataNames, _nextData];
1929
- }
1930
- }
1931
- subschema.extendSubschemaData = extendSubschemaData;
1932
- function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
1933
- if (compositeRule !== void 0)
1934
- subschema2.compositeRule = compositeRule;
1935
- if (createErrors !== void 0)
1936
- subschema2.createErrors = createErrors;
1937
- if (allErrors !== void 0)
1938
- subschema2.allErrors = allErrors;
1939
- subschema2.jtdDiscriminator = jtdDiscriminator;
1940
- subschema2.jtdMetadata = jtdMetadata;
1941
- }
1942
- subschema.extendSubschemaMode = extendSubschemaMode;
1903
+ if (keyword2 !== void 0) {
1904
+ const sch = it.schema[keyword2];
1905
+ return schemaProp === void 0 ? {
1906
+ schema: sch,
1907
+ schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}`,
1908
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}`
1909
+ } : {
1910
+ schema: sch[schemaProp],
1911
+ schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}${(0, codegen_12.getProperty)(schemaProp)}`,
1912
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_12.escapeFragment)(schemaProp)}`
1913
+ };
1914
+ }
1915
+ if (schema !== void 0) {
1916
+ if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
1917
+ throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
1918
+ }
1919
+ return {
1920
+ schema,
1921
+ schemaPath,
1922
+ topSchemaRef,
1923
+ errSchemaPath
1924
+ };
1925
+ }
1926
+ throw new Error('either "keyword" or "schema" must be passed');
1927
+ }
1928
+ subschema.getSubschema = getSubschema;
1929
+ function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data: data2, dataTypes, propertyName }) {
1930
+ if (data2 !== void 0 && dataProp !== void 0) {
1931
+ throw new Error('both "data" and "dataProp" passed, only one allowed');
1932
+ }
1933
+ const { gen } = it;
1934
+ if (dataProp !== void 0) {
1935
+ const { errorPath, dataPathArr, opts } = it;
1936
+ const nextData = gen.let("data", (0, codegen_12._)`${it.data}${(0, codegen_12.getProperty)(dataProp)}`, true);
1937
+ dataContextProps(nextData);
1938
+ subschema2.errorPath = (0, codegen_12.str)`${errorPath}${(0, util_12.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
1939
+ subschema2.parentDataProperty = (0, codegen_12._)`${dataProp}`;
1940
+ subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
1941
+ }
1942
+ if (data2 !== void 0) {
1943
+ const nextData = data2 instanceof codegen_12.Name ? data2 : gen.let("data", data2, true);
1944
+ dataContextProps(nextData);
1945
+ if (propertyName !== void 0)
1946
+ subschema2.propertyName = propertyName;
1947
+ }
1948
+ if (dataTypes)
1949
+ subschema2.dataTypes = dataTypes;
1950
+ function dataContextProps(_nextData) {
1951
+ subschema2.data = _nextData;
1952
+ subschema2.dataLevel = it.dataLevel + 1;
1953
+ subschema2.dataTypes = [];
1954
+ it.definedProperties = /* @__PURE__ */ new Set();
1955
+ subschema2.parentData = it.data;
1956
+ subschema2.dataNames = [...it.dataNames, _nextData];
1957
+ }
1958
+ }
1959
+ subschema.extendSubschemaData = extendSubschemaData;
1960
+ function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
1961
+ if (compositeRule !== void 0)
1962
+ subschema2.compositeRule = compositeRule;
1963
+ if (createErrors !== void 0)
1964
+ subschema2.createErrors = createErrors;
1965
+ if (allErrors !== void 0)
1966
+ subschema2.allErrors = allErrors;
1967
+ subschema2.jtdDiscriminator = jtdDiscriminator;
1968
+ subschema2.jtdMetadata = jtdMetadata;
1969
+ }
1970
+ subschema.extendSubschemaMode = extendSubschemaMode;
1971
+ return subschema;
1972
+ }
1943
1973
  var resolve$6 = {};
1944
1974
  var fastDeepEqual = function equal2(a, b) {
1945
1975
  if (a === b) return true;
@@ -2054,7 +2084,7 @@
2054
2084
  var jsonSchemaTraverseExports$1 = jsonSchemaTraverse$1.exports;
2055
2085
  Object.defineProperty(resolve$6, "__esModule", { value: true });
2056
2086
  resolve$6.getSchemaRefs = resolve$6.resolveUrl = resolve$6.normalizeId = resolve$6._getFullPath = resolve$6.getFullPath = resolve$6.inlineRef = void 0;
2057
- const util_1$m = util$7;
2087
+ const util_1$l = util$7;
2058
2088
  const equal$5 = fastDeepEqual;
2059
2089
  const traverse$2 = jsonSchemaTraverseExports$1;
2060
2090
  const SIMPLE_INLINED$1 = /* @__PURE__ */ new Set([
@@ -2113,7 +2143,7 @@
2113
2143
  if (SIMPLE_INLINED$1.has(key))
2114
2144
  continue;
2115
2145
  if (typeof schema[key] == "object") {
2116
- (0, util_1$m.eachItem)(schema[key], (sch) => count += countKeys$1(sch));
2146
+ (0, util_1$l.eachItem)(schema[key], (sch) => count += countKeys$1(sch));
2117
2147
  }
2118
2148
  if (count === Infinity)
2119
2149
  return Infinity;
@@ -2201,506 +2231,512 @@
2201
2231
  }
2202
2232
  }
2203
2233
  resolve$6.getSchemaRefs = getSchemaRefs;
2204
- Object.defineProperty(validate$2, "__esModule", { value: true });
2205
- validate$2.getData = validate$2.KeywordCxt = validate$2.validateFunctionCode = void 0;
2206
- const boolSchema_1 = boolSchema;
2207
- const dataType_1$1 = dataType;
2208
- const applicability_1 = applicability;
2209
- const dataType_2 = dataType;
2210
- const defaults_1 = defaults;
2211
- const keyword_1 = keyword$1;
2212
- const subschema_1 = subschema;
2213
- const codegen_1$n = codegen;
2214
- const names_1$3 = names$1;
2215
- const resolve_1$3 = resolve$6;
2216
- const util_1$l = util$7;
2217
- const errors_1 = errors;
2218
- function validateFunctionCode(it) {
2219
- if (isSchemaObj(it)) {
2220
- checkKeywords(it);
2221
- if (schemaCxtHasRules(it)) {
2222
- topSchemaObjCode(it);
2223
- return;
2234
+ var hasRequiredValidate;
2235
+ function requireValidate() {
2236
+ if (hasRequiredValidate) return validate$2;
2237
+ hasRequiredValidate = 1;
2238
+ Object.defineProperty(validate$2, "__esModule", { value: true });
2239
+ validate$2.getData = validate$2.KeywordCxt = validate$2.validateFunctionCode = void 0;
2240
+ const boolSchema_1 = requireBoolSchema();
2241
+ const dataType_12 = dataType;
2242
+ const applicability_12 = applicability;
2243
+ const dataType_2 = dataType;
2244
+ const defaults_1 = requireDefaults();
2245
+ const keyword_1 = requireKeyword();
2246
+ const subschema_1 = requireSubschema();
2247
+ const codegen_12 = codegen;
2248
+ const names_12 = names$1;
2249
+ const resolve_12 = resolve$6;
2250
+ const util_12 = util$7;
2251
+ const errors_12 = errors;
2252
+ function validateFunctionCode(it) {
2253
+ if (isSchemaObj(it)) {
2254
+ checkKeywords(it);
2255
+ if (schemaCxtHasRules(it)) {
2256
+ topSchemaObjCode(it);
2257
+ return;
2258
+ }
2224
2259
  }
2260
+ validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
2225
2261
  }
2226
- validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
2227
- }
2228
- validate$2.validateFunctionCode = validateFunctionCode;
2229
- function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
2230
- if (opts.code.es5) {
2231
- gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${names_1$3.default.valCxt}`, schemaEnv.$async, () => {
2232
- gen.code((0, codegen_1$n._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
2233
- destructureValCxtES5(gen, opts);
2234
- gen.code(body);
2262
+ validate$2.validateFunctionCode = validateFunctionCode;
2263
+ function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
2264
+ if (opts.code.es5) {
2265
+ gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${names_12.default.valCxt}`, schemaEnv.$async, () => {
2266
+ gen.code((0, codegen_12._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
2267
+ destructureValCxtES5(gen, opts);
2268
+ gen.code(body);
2269
+ });
2270
+ } else {
2271
+ gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
2272
+ }
2273
+ }
2274
+ function destructureValCxt(opts) {
2275
+ 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}}={}`;
2276
+ }
2277
+ function destructureValCxtES5(gen, opts) {
2278
+ gen.if(names_12.default.valCxt, () => {
2279
+ gen.var(names_12.default.instancePath, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.instancePath}`);
2280
+ gen.var(names_12.default.parentData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentData}`);
2281
+ gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentDataProperty}`);
2282
+ gen.var(names_12.default.rootData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.rootData}`);
2283
+ if (opts.dynamicRef)
2284
+ gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.dynamicAnchors}`);
2285
+ }, () => {
2286
+ gen.var(names_12.default.instancePath, (0, codegen_12._)`""`);
2287
+ gen.var(names_12.default.parentData, (0, codegen_12._)`undefined`);
2288
+ gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`undefined`);
2289
+ gen.var(names_12.default.rootData, names_12.default.data);
2290
+ if (opts.dynamicRef)
2291
+ gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`{}`);
2235
2292
  });
2236
- } else {
2237
- gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
2238
- }
2239
- }
2240
- function destructureValCxt(opts) {
2241
- 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}}={}`;
2242
- }
2243
- function destructureValCxtES5(gen, opts) {
2244
- gen.if(names_1$3.default.valCxt, () => {
2245
- gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.instancePath}`);
2246
- gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentData}`);
2247
- gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentDataProperty}`);
2248
- gen.var(names_1$3.default.rootData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.rootData}`);
2249
- if (opts.dynamicRef)
2250
- gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.dynamicAnchors}`);
2251
- }, () => {
2252
- gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`""`);
2253
- gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`undefined`);
2254
- gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`undefined`);
2255
- gen.var(names_1$3.default.rootData, names_1$3.default.data);
2256
- if (opts.dynamicRef)
2257
- gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`{}`);
2258
- });
2259
- }
2260
- function topSchemaObjCode(it) {
2261
- const { schema, opts, gen } = it;
2262
- validateFunction(it, () => {
2263
- if (opts.$comment && schema.$comment)
2264
- commentKeyword(it);
2265
- checkNoDefault(it);
2266
- gen.let(names_1$3.default.vErrors, null);
2267
- gen.let(names_1$3.default.errors, 0);
2268
- if (opts.unevaluated)
2269
- resetEvaluated(it);
2270
- typeAndKeywords(it);
2271
- returnResults(it);
2272
- });
2273
- return;
2274
- }
2275
- function resetEvaluated(it) {
2276
- const { gen, validateName } = it;
2277
- it.evaluated = gen.const("evaluated", (0, codegen_1$n._)`${validateName}.evaluated`);
2278
- gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.props`, (0, codegen_1$n._)`undefined`));
2279
- gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.items`, (0, codegen_1$n._)`undefined`));
2280
- }
2281
- function funcSourceUrl(schema, opts) {
2282
- const schId = typeof schema == "object" && schema[opts.schemaId];
2283
- return schId && (opts.code.source || opts.code.process) ? (0, codegen_1$n._)`/*# sourceURL=${schId} */` : codegen_1$n.nil;
2284
- }
2285
- function subschemaCode(it, valid) {
2286
- if (isSchemaObj(it)) {
2287
- checkKeywords(it);
2288
- if (schemaCxtHasRules(it)) {
2289
- subSchemaObjCode(it, valid);
2290
- return;
2291
- }
2292
2293
  }
2293
- (0, boolSchema_1.boolOrEmptySchema)(it, valid);
2294
- }
2295
- function schemaCxtHasRules({ schema, self: self2 }) {
2296
- if (typeof schema == "boolean")
2297
- return !schema;
2298
- for (const key in schema)
2299
- if (self2.RULES.all[key])
2300
- return true;
2301
- return false;
2302
- }
2303
- function isSchemaObj(it) {
2304
- return typeof it.schema != "boolean";
2305
- }
2306
- function subSchemaObjCode(it, valid) {
2307
- const { schema, gen, opts } = it;
2308
- if (opts.$comment && schema.$comment)
2309
- commentKeyword(it);
2310
- updateContext(it);
2311
- checkAsyncSchema(it);
2312
- const errsCount = gen.const("_errs", names_1$3.default.errors);
2313
- typeAndKeywords(it, errsCount);
2314
- gen.var(valid, (0, codegen_1$n._)`${errsCount} === ${names_1$3.default.errors}`);
2315
- }
2316
- function checkKeywords(it) {
2317
- (0, util_1$l.checkUnknownRules)(it);
2318
- checkRefsAndKeywords(it);
2319
- }
2320
- function typeAndKeywords(it, errsCount) {
2321
- if (it.opts.jtd)
2322
- return schemaKeywords(it, [], false, errsCount);
2323
- const types2 = (0, dataType_1$1.getSchemaTypes)(it.schema);
2324
- const checkedTypes = (0, dataType_1$1.coerceAndCheckDataType)(it, types2);
2325
- schemaKeywords(it, types2, !checkedTypes, errsCount);
2326
- }
2327
- function checkRefsAndKeywords(it) {
2328
- const { schema, errSchemaPath, opts, self: self2 } = it;
2329
- if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$l.schemaHasRulesButRef)(schema, self2.RULES)) {
2330
- self2.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
2331
- }
2332
- }
2333
- function checkNoDefault(it) {
2334
- const { schema, opts } = it;
2335
- if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
2336
- (0, util_1$l.checkStrictMode)(it, "default is ignored in the schema root");
2337
- }
2338
- }
2339
- function updateContext(it) {
2340
- const schId = it.schema[it.opts.schemaId];
2341
- if (schId)
2342
- it.baseId = (0, resolve_1$3.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
2343
- }
2344
- function checkAsyncSchema(it) {
2345
- if (it.schema.$async && !it.schemaEnv.$async)
2346
- throw new Error("async schema in sync schema");
2347
- }
2348
- function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
2349
- const msg = schema.$comment;
2350
- if (opts.$comment === true) {
2351
- gen.code((0, codegen_1$n._)`${names_1$3.default.self}.logger.log(${msg})`);
2352
- } else if (typeof opts.$comment == "function") {
2353
- const schemaPath = (0, codegen_1$n.str)`${errSchemaPath}/$comment`;
2354
- const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
2355
- gen.code((0, codegen_1$n._)`${names_1$3.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
2356
- }
2357
- }
2358
- function returnResults(it) {
2359
- const { gen, schemaEnv, validateName, ValidationError: ValidationError2, opts } = it;
2360
- if (schemaEnv.$async) {
2361
- 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 ${ValidationError2}(${names_1$3.default.vErrors})`));
2362
- } else {
2363
- gen.assign((0, codegen_1$n._)`${validateName}.errors`, names_1$3.default.vErrors);
2364
- if (opts.unevaluated)
2365
- assignEvaluated(it);
2366
- gen.return((0, codegen_1$n._)`${names_1$3.default.errors} === 0`);
2367
- }
2368
- }
2369
- function assignEvaluated({ gen, evaluated, props, items: items2 }) {
2370
- if (props instanceof codegen_1$n.Name)
2371
- gen.assign((0, codegen_1$n._)`${evaluated}.props`, props);
2372
- if (items2 instanceof codegen_1$n.Name)
2373
- gen.assign((0, codegen_1$n._)`${evaluated}.items`, items2);
2374
- }
2375
- function schemaKeywords(it, types2, typeErrors, errsCount) {
2376
- const { gen, schema, data: data2, allErrors, opts, self: self2 } = it;
2377
- const { RULES } = self2;
2378
- if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$l.schemaHasRulesButRef)(schema, RULES))) {
2379
- gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
2294
+ function topSchemaObjCode(it) {
2295
+ const { schema, opts, gen } = it;
2296
+ validateFunction(it, () => {
2297
+ if (opts.$comment && schema.$comment)
2298
+ commentKeyword(it);
2299
+ checkNoDefault(it);
2300
+ gen.let(names_12.default.vErrors, null);
2301
+ gen.let(names_12.default.errors, 0);
2302
+ if (opts.unevaluated)
2303
+ resetEvaluated(it);
2304
+ typeAndKeywords(it);
2305
+ returnResults(it);
2306
+ });
2380
2307
  return;
2381
2308
  }
2382
- if (!opts.jtd)
2383
- checkStrictTypes(it, types2);
2384
- gen.block(() => {
2385
- for (const group of RULES.rules)
2386
- groupKeywords(group);
2387
- groupKeywords(RULES.post);
2388
- });
2389
- function groupKeywords(group) {
2390
- if (!(0, applicability_1.shouldUseGroup)(schema, group))
2391
- return;
2392
- if (group.type) {
2393
- gen.if((0, dataType_2.checkDataType)(group.type, data2, opts.strictNumbers));
2394
- iterateKeywords(it, group);
2395
- if (types2.length === 1 && types2[0] === group.type && typeErrors) {
2396
- gen.else();
2397
- (0, dataType_2.reportTypeError)(it);
2309
+ function resetEvaluated(it) {
2310
+ const { gen, validateName } = it;
2311
+ it.evaluated = gen.const("evaluated", (0, codegen_12._)`${validateName}.evaluated`);
2312
+ gen.if((0, codegen_12._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_12._)`${it.evaluated}.props`, (0, codegen_12._)`undefined`));
2313
+ gen.if((0, codegen_12._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_12._)`${it.evaluated}.items`, (0, codegen_12._)`undefined`));
2314
+ }
2315
+ function funcSourceUrl(schema, opts) {
2316
+ const schId = typeof schema == "object" && schema[opts.schemaId];
2317
+ return schId && (opts.code.source || opts.code.process) ? (0, codegen_12._)`/*# sourceURL=${schId} */` : codegen_12.nil;
2318
+ }
2319
+ function subschemaCode(it, valid) {
2320
+ if (isSchemaObj(it)) {
2321
+ checkKeywords(it);
2322
+ if (schemaCxtHasRules(it)) {
2323
+ subSchemaObjCode(it, valid);
2324
+ return;
2398
2325
  }
2399
- gen.endIf();
2400
- } else {
2401
- iterateKeywords(it, group);
2402
2326
  }
2403
- if (!allErrors)
2404
- gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === ${errsCount || 0}`);
2327
+ (0, boolSchema_1.boolOrEmptySchema)(it, valid);
2405
2328
  }
2406
- }
2407
- function iterateKeywords(it, group) {
2408
- const { gen, schema, opts: { useDefaults } } = it;
2409
- if (useDefaults)
2410
- (0, defaults_1.assignDefaults)(it, group.type);
2411
- gen.block(() => {
2412
- for (const rule of group.rules) {
2413
- if ((0, applicability_1.shouldUseRule)(schema, rule)) {
2414
- keywordCode(it, rule.keyword, rule.definition, group.type);
2415
- }
2416
- }
2417
- });
2418
- }
2419
- function checkStrictTypes(it, types2) {
2420
- if (it.schemaEnv.meta || !it.opts.strictTypes)
2421
- return;
2422
- checkContextTypes(it, types2);
2423
- if (!it.opts.allowUnionTypes)
2424
- checkMultipleTypes(it, types2);
2425
- checkKeywordTypes(it, it.dataTypes);
2426
- }
2427
- function checkContextTypes(it, types2) {
2428
- if (!types2.length)
2429
- return;
2430
- if (!it.dataTypes.length) {
2431
- it.dataTypes = types2;
2432
- return;
2329
+ function schemaCxtHasRules({ schema, self: self2 }) {
2330
+ if (typeof schema == "boolean")
2331
+ return !schema;
2332
+ for (const key in schema)
2333
+ if (self2.RULES.all[key])
2334
+ return true;
2335
+ return false;
2433
2336
  }
2434
- types2.forEach((t) => {
2435
- if (!includesType(it.dataTypes, t)) {
2436
- strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
2437
- }
2438
- });
2439
- narrowSchemaTypes(it, types2);
2440
- }
2441
- function checkMultipleTypes(it, ts) {
2442
- if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
2443
- strictTypesError(it, "use allowUnionTypes to allow union type keyword");
2444
- }
2445
- }
2446
- function checkKeywordTypes(it, ts) {
2447
- const rules2 = it.self.RULES.all;
2448
- for (const keyword2 in rules2) {
2449
- const rule = rules2[keyword2];
2450
- if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) {
2451
- const { type: type2 } = rule.definition;
2452
- if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
2453
- strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
2454
- }
2455
- }
2456
- }
2457
- }
2458
- function hasApplicableType(schTs, kwdT) {
2459
- return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
2460
- }
2461
- function includesType(ts, t) {
2462
- return ts.includes(t) || t === "integer" && ts.includes("number");
2463
- }
2464
- function narrowSchemaTypes(it, withTypes) {
2465
- const ts = [];
2466
- for (const t of it.dataTypes) {
2467
- if (includesType(withTypes, t))
2468
- ts.push(t);
2469
- else if (withTypes.includes("integer") && t === "number")
2470
- ts.push("integer");
2471
- }
2472
- it.dataTypes = ts;
2473
- }
2474
- function strictTypesError(it, msg) {
2475
- const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
2476
- msg += ` at "${schemaPath}" (strictTypes)`;
2477
- (0, util_1$l.checkStrictMode)(it, msg, it.opts.strictTypes);
2478
- }
2479
- class KeywordCxt {
2480
- constructor(it, def2, keyword2) {
2481
- (0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
2482
- this.gen = it.gen;
2483
- this.allErrors = it.allErrors;
2484
- this.keyword = keyword2;
2485
- this.data = it.data;
2486
- this.schema = it.schema[keyword2];
2487
- this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
2488
- this.schemaValue = (0, util_1$l.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
2489
- this.schemaType = def2.schemaType;
2490
- this.parentSchema = it.schema;
2491
- this.params = {};
2492
- this.it = it;
2493
- this.def = def2;
2494
- if (this.$data) {
2495
- this.schemaCode = it.gen.const("vSchema", getData$1(this.$data, it));
2496
- } else {
2497
- this.schemaCode = this.schemaValue;
2498
- if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
2499
- throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
2500
- }
2501
- }
2502
- if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
2503
- this.errsCount = it.gen.const("_errs", names_1$3.default.errors);
2504
- }
2337
+ function isSchemaObj(it) {
2338
+ return typeof it.schema != "boolean";
2505
2339
  }
2506
- result(condition, successAction, failAction) {
2507
- this.failResult((0, codegen_1$n.not)(condition), successAction, failAction);
2340
+ function subSchemaObjCode(it, valid) {
2341
+ const { schema, gen, opts } = it;
2342
+ if (opts.$comment && schema.$comment)
2343
+ commentKeyword(it);
2344
+ updateContext(it);
2345
+ checkAsyncSchema(it);
2346
+ const errsCount = gen.const("_errs", names_12.default.errors);
2347
+ typeAndKeywords(it, errsCount);
2348
+ gen.var(valid, (0, codegen_12._)`${errsCount} === ${names_12.default.errors}`);
2508
2349
  }
2509
- failResult(condition, successAction, failAction) {
2510
- this.gen.if(condition);
2511
- if (failAction)
2512
- failAction();
2513
- else
2514
- this.error();
2515
- if (successAction) {
2516
- this.gen.else();
2517
- successAction();
2518
- if (this.allErrors)
2519
- this.gen.endIf();
2520
- } else {
2521
- if (this.allErrors)
2522
- this.gen.endIf();
2523
- else
2524
- this.gen.else();
2525
- }
2350
+ function checkKeywords(it) {
2351
+ (0, util_12.checkUnknownRules)(it);
2352
+ checkRefsAndKeywords(it);
2526
2353
  }
2527
- pass(condition, failAction) {
2528
- this.failResult((0, codegen_1$n.not)(condition), void 0, failAction);
2354
+ function typeAndKeywords(it, errsCount) {
2355
+ if (it.opts.jtd)
2356
+ return schemaKeywords(it, [], false, errsCount);
2357
+ const types2 = (0, dataType_12.getSchemaTypes)(it.schema);
2358
+ const checkedTypes = (0, dataType_12.coerceAndCheckDataType)(it, types2);
2359
+ schemaKeywords(it, types2, !checkedTypes, errsCount);
2529
2360
  }
2530
- fail(condition) {
2531
- if (condition === void 0) {
2532
- this.error();
2533
- if (!this.allErrors)
2534
- this.gen.if(false);
2535
- return;
2361
+ function checkRefsAndKeywords(it) {
2362
+ const { schema, errSchemaPath, opts, self: self2 } = it;
2363
+ if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_12.schemaHasRulesButRef)(schema, self2.RULES)) {
2364
+ self2.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
2536
2365
  }
2537
- this.gen.if(condition);
2538
- this.error();
2539
- if (this.allErrors)
2540
- this.gen.endIf();
2541
- else
2542
- this.gen.else();
2543
- }
2544
- fail$data(condition) {
2545
- if (!this.$data)
2546
- return this.fail(condition);
2547
- const { schemaCode } = this;
2548
- this.fail((0, codegen_1$n._)`${schemaCode} !== undefined && (${(0, codegen_1$n.or)(this.invalid$data(), condition)})`);
2549
2366
  }
2550
- error(append, errorParams, errorPaths) {
2551
- if (errorParams) {
2552
- this.setParams(errorParams);
2553
- this._error(append, errorPaths);
2554
- this.setParams({});
2555
- return;
2367
+ function checkNoDefault(it) {
2368
+ const { schema, opts } = it;
2369
+ if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
2370
+ (0, util_12.checkStrictMode)(it, "default is ignored in the schema root");
2556
2371
  }
2557
- this._error(append, errorPaths);
2558
- }
2559
- _error(append, errorPaths) {
2560
- (append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
2561
2372
  }
2562
- $dataError() {
2563
- (0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
2373
+ function updateContext(it) {
2374
+ const schId = it.schema[it.opts.schemaId];
2375
+ if (schId)
2376
+ it.baseId = (0, resolve_12.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
2564
2377
  }
2565
- reset() {
2566
- if (this.errsCount === void 0)
2567
- throw new Error('add "trackErrors" to keyword definition');
2568
- (0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
2378
+ function checkAsyncSchema(it) {
2379
+ if (it.schema.$async && !it.schemaEnv.$async)
2380
+ throw new Error("async schema in sync schema");
2569
2381
  }
2570
- ok(cond) {
2571
- if (!this.allErrors)
2572
- this.gen.if(cond);
2382
+ function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
2383
+ const msg = schema.$comment;
2384
+ if (opts.$comment === true) {
2385
+ gen.code((0, codegen_12._)`${names_12.default.self}.logger.log(${msg})`);
2386
+ } else if (typeof opts.$comment == "function") {
2387
+ const schemaPath = (0, codegen_12.str)`${errSchemaPath}/$comment`;
2388
+ const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
2389
+ gen.code((0, codegen_12._)`${names_12.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
2390
+ }
2573
2391
  }
2574
- setParams(obj, assign) {
2575
- if (assign)
2576
- Object.assign(this.params, obj);
2577
- else
2578
- this.params = obj;
2392
+ function returnResults(it) {
2393
+ const { gen, schemaEnv, validateName, ValidationError: ValidationError2, opts } = it;
2394
+ if (schemaEnv.$async) {
2395
+ 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})`));
2396
+ } else {
2397
+ gen.assign((0, codegen_12._)`${validateName}.errors`, names_12.default.vErrors);
2398
+ if (opts.unevaluated)
2399
+ assignEvaluated(it);
2400
+ gen.return((0, codegen_12._)`${names_12.default.errors} === 0`);
2401
+ }
2402
+ }
2403
+ function assignEvaluated({ gen, evaluated, props, items: items2 }) {
2404
+ if (props instanceof codegen_12.Name)
2405
+ gen.assign((0, codegen_12._)`${evaluated}.props`, props);
2406
+ if (items2 instanceof codegen_12.Name)
2407
+ gen.assign((0, codegen_12._)`${evaluated}.items`, items2);
2408
+ }
2409
+ function schemaKeywords(it, types2, typeErrors, errsCount) {
2410
+ const { gen, schema, data: data2, allErrors, opts, self: self2 } = it;
2411
+ const { RULES } = self2;
2412
+ if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_12.schemaHasRulesButRef)(schema, RULES))) {
2413
+ gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
2414
+ return;
2415
+ }
2416
+ if (!opts.jtd)
2417
+ checkStrictTypes(it, types2);
2418
+ gen.block(() => {
2419
+ for (const group of RULES.rules)
2420
+ groupKeywords(group);
2421
+ groupKeywords(RULES.post);
2422
+ });
2423
+ function groupKeywords(group) {
2424
+ if (!(0, applicability_12.shouldUseGroup)(schema, group))
2425
+ return;
2426
+ if (group.type) {
2427
+ gen.if((0, dataType_2.checkDataType)(group.type, data2, opts.strictNumbers));
2428
+ iterateKeywords(it, group);
2429
+ if (types2.length === 1 && types2[0] === group.type && typeErrors) {
2430
+ gen.else();
2431
+ (0, dataType_2.reportTypeError)(it);
2432
+ }
2433
+ gen.endIf();
2434
+ } else {
2435
+ iterateKeywords(it, group);
2436
+ }
2437
+ if (!allErrors)
2438
+ gen.if((0, codegen_12._)`${names_12.default.errors} === ${errsCount || 0}`);
2439
+ }
2579
2440
  }
2580
- block$data(valid, codeBlock, $dataValid = codegen_1$n.nil) {
2581
- this.gen.block(() => {
2582
- this.check$data(valid, $dataValid);
2583
- codeBlock();
2441
+ function iterateKeywords(it, group) {
2442
+ const { gen, schema, opts: { useDefaults } } = it;
2443
+ if (useDefaults)
2444
+ (0, defaults_1.assignDefaults)(it, group.type);
2445
+ gen.block(() => {
2446
+ for (const rule of group.rules) {
2447
+ if ((0, applicability_12.shouldUseRule)(schema, rule)) {
2448
+ keywordCode(it, rule.keyword, rule.definition, group.type);
2449
+ }
2450
+ }
2584
2451
  });
2585
2452
  }
2586
- check$data(valid = codegen_1$n.nil, $dataValid = codegen_1$n.nil) {
2587
- if (!this.$data)
2453
+ function checkStrictTypes(it, types2) {
2454
+ if (it.schemaEnv.meta || !it.opts.strictTypes)
2588
2455
  return;
2589
- const { gen, schemaCode, schemaType, def: def2 } = this;
2590
- gen.if((0, codegen_1$n.or)((0, codegen_1$n._)`${schemaCode} === undefined`, $dataValid));
2591
- if (valid !== codegen_1$n.nil)
2592
- gen.assign(valid, true);
2593
- if (schemaType.length || def2.validateSchema) {
2594
- gen.elseIf(this.invalid$data());
2595
- this.$dataError();
2596
- if (valid !== codegen_1$n.nil)
2597
- gen.assign(valid, false);
2598
- }
2599
- gen.else();
2456
+ checkContextTypes(it, types2);
2457
+ if (!it.opts.allowUnionTypes)
2458
+ checkMultipleTypes(it, types2);
2459
+ checkKeywordTypes(it, it.dataTypes);
2600
2460
  }
2601
- invalid$data() {
2602
- const { gen, schemaCode, schemaType, def: def2, it } = this;
2603
- return (0, codegen_1$n.or)(wrong$DataType(), invalid$DataSchema());
2604
- function wrong$DataType() {
2605
- if (schemaType.length) {
2606
- if (!(schemaCode instanceof codegen_1$n.Name))
2607
- throw new Error("ajv implementation error");
2608
- const st = Array.isArray(schemaType) ? schemaType : [schemaType];
2609
- return (0, codegen_1$n._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
2461
+ function checkContextTypes(it, types2) {
2462
+ if (!types2.length)
2463
+ return;
2464
+ if (!it.dataTypes.length) {
2465
+ it.dataTypes = types2;
2466
+ return;
2467
+ }
2468
+ types2.forEach((t) => {
2469
+ if (!includesType(it.dataTypes, t)) {
2470
+ strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
2471
+ }
2472
+ });
2473
+ narrowSchemaTypes(it, types2);
2474
+ }
2475
+ function checkMultipleTypes(it, ts) {
2476
+ if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
2477
+ strictTypesError(it, "use allowUnionTypes to allow union type keyword");
2478
+ }
2479
+ }
2480
+ function checkKeywordTypes(it, ts) {
2481
+ const rules2 = it.self.RULES.all;
2482
+ for (const keyword2 in rules2) {
2483
+ const rule = rules2[keyword2];
2484
+ if (typeof rule == "object" && (0, applicability_12.shouldUseRule)(it.schema, rule)) {
2485
+ const { type: type2 } = rule.definition;
2486
+ if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
2487
+ strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
2488
+ }
2489
+ }
2490
+ }
2491
+ }
2492
+ function hasApplicableType(schTs, kwdT) {
2493
+ return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
2494
+ }
2495
+ function includesType(ts, t) {
2496
+ return ts.includes(t) || t === "integer" && ts.includes("number");
2497
+ }
2498
+ function narrowSchemaTypes(it, withTypes) {
2499
+ const ts = [];
2500
+ for (const t of it.dataTypes) {
2501
+ if (includesType(withTypes, t))
2502
+ ts.push(t);
2503
+ else if (withTypes.includes("integer") && t === "number")
2504
+ ts.push("integer");
2505
+ }
2506
+ it.dataTypes = ts;
2507
+ }
2508
+ function strictTypesError(it, msg) {
2509
+ const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
2510
+ msg += ` at "${schemaPath}" (strictTypes)`;
2511
+ (0, util_12.checkStrictMode)(it, msg, it.opts.strictTypes);
2512
+ }
2513
+ class KeywordCxt {
2514
+ constructor(it, def2, keyword2) {
2515
+ (0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
2516
+ this.gen = it.gen;
2517
+ this.allErrors = it.allErrors;
2518
+ this.keyword = keyword2;
2519
+ this.data = it.data;
2520
+ this.schema = it.schema[keyword2];
2521
+ this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
2522
+ this.schemaValue = (0, util_12.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
2523
+ this.schemaType = def2.schemaType;
2524
+ this.parentSchema = it.schema;
2525
+ this.params = {};
2526
+ this.it = it;
2527
+ this.def = def2;
2528
+ if (this.$data) {
2529
+ this.schemaCode = it.gen.const("vSchema", getData2(this.$data, it));
2530
+ } else {
2531
+ this.schemaCode = this.schemaValue;
2532
+ if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
2533
+ throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
2534
+ }
2535
+ }
2536
+ if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
2537
+ this.errsCount = it.gen.const("_errs", names_12.default.errors);
2610
2538
  }
2611
- return codegen_1$n.nil;
2612
2539
  }
2613
- function invalid$DataSchema() {
2614
- if (def2.validateSchema) {
2615
- const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
2616
- return (0, codegen_1$n._)`!${validateSchemaRef}(${schemaCode})`;
2540
+ result(condition, successAction, failAction) {
2541
+ this.failResult((0, codegen_12.not)(condition), successAction, failAction);
2542
+ }
2543
+ failResult(condition, successAction, failAction) {
2544
+ this.gen.if(condition);
2545
+ if (failAction)
2546
+ failAction();
2547
+ else
2548
+ this.error();
2549
+ if (successAction) {
2550
+ this.gen.else();
2551
+ successAction();
2552
+ if (this.allErrors)
2553
+ this.gen.endIf();
2554
+ } else {
2555
+ if (this.allErrors)
2556
+ this.gen.endIf();
2557
+ else
2558
+ this.gen.else();
2617
2559
  }
2618
- return codegen_1$n.nil;
2619
2560
  }
2620
- }
2621
- subschema(appl, valid) {
2622
- const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
2623
- (0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
2624
- (0, subschema_1.extendSubschemaMode)(subschema2, appl);
2625
- const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
2626
- subschemaCode(nextContext, valid);
2627
- return nextContext;
2628
- }
2629
- mergeEvaluated(schemaCxt, toName) {
2630
- const { it, gen } = this;
2631
- if (!it.opts.unevaluated)
2632
- return;
2633
- if (it.props !== true && schemaCxt.props !== void 0) {
2634
- it.props = util_1$l.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
2561
+ pass(condition, failAction) {
2562
+ this.failResult((0, codegen_12.not)(condition), void 0, failAction);
2563
+ }
2564
+ fail(condition) {
2565
+ if (condition === void 0) {
2566
+ this.error();
2567
+ if (!this.allErrors)
2568
+ this.gen.if(false);
2569
+ return;
2570
+ }
2571
+ this.gen.if(condition);
2572
+ this.error();
2573
+ if (this.allErrors)
2574
+ this.gen.endIf();
2575
+ else
2576
+ this.gen.else();
2635
2577
  }
2636
- if (it.items !== true && schemaCxt.items !== void 0) {
2637
- it.items = util_1$l.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
2578
+ fail$data(condition) {
2579
+ if (!this.$data)
2580
+ return this.fail(condition);
2581
+ const { schemaCode } = this;
2582
+ this.fail((0, codegen_12._)`${schemaCode} !== undefined && (${(0, codegen_12.or)(this.invalid$data(), condition)})`);
2583
+ }
2584
+ error(append, errorParams, errorPaths) {
2585
+ if (errorParams) {
2586
+ this.setParams(errorParams);
2587
+ this._error(append, errorPaths);
2588
+ this.setParams({});
2589
+ return;
2590
+ }
2591
+ this._error(append, errorPaths);
2638
2592
  }
2639
- }
2640
- mergeValidEvaluated(schemaCxt, valid) {
2641
- const { it, gen } = this;
2642
- if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
2643
- gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1$n.Name));
2644
- return true;
2593
+ _error(append, errorPaths) {
2594
+ (append ? errors_12.reportExtraError : errors_12.reportError)(this, this.def.error, errorPaths);
2645
2595
  }
2646
- }
2647
- }
2648
- validate$2.KeywordCxt = KeywordCxt;
2649
- function keywordCode(it, keyword2, def2, ruleType) {
2650
- const cxt = new KeywordCxt(it, def2, keyword2);
2651
- if ("code" in def2) {
2652
- def2.code(cxt, ruleType);
2653
- } else if (cxt.$data && def2.validate) {
2654
- (0, keyword_1.funcKeywordCode)(cxt, def2);
2655
- } else if ("macro" in def2) {
2656
- (0, keyword_1.macroKeywordCode)(cxt, def2);
2657
- } else if (def2.compile || def2.validate) {
2658
- (0, keyword_1.funcKeywordCode)(cxt, def2);
2659
- }
2660
- }
2661
- const JSON_POINTER$2 = /^\/(?:[^~]|~0|~1)*$/;
2662
- const RELATIVE_JSON_POINTER$2 = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
2663
- function getData$1($data, { dataLevel, dataNames, dataPathArr }) {
2664
- let jsonPointer;
2665
- let data2;
2666
- if ($data === "")
2667
- return names_1$3.default.rootData;
2668
- if ($data[0] === "/") {
2669
- if (!JSON_POINTER$2.test($data))
2670
- throw new Error(`Invalid JSON-pointer: ${$data}`);
2671
- jsonPointer = $data;
2672
- data2 = names_1$3.default.rootData;
2673
- } else {
2674
- const matches = RELATIVE_JSON_POINTER$2.exec($data);
2675
- if (!matches)
2676
- throw new Error(`Invalid JSON-pointer: ${$data}`);
2677
- const up = +matches[1];
2678
- jsonPointer = matches[2];
2679
- if (jsonPointer === "#") {
2680
- if (up >= dataLevel)
2681
- throw new Error(errorMsg("property/index", up));
2682
- return dataPathArr[dataLevel - up];
2683
- }
2684
- if (up > dataLevel)
2685
- throw new Error(errorMsg("data", up));
2686
- data2 = dataNames[dataLevel - up];
2687
- if (!jsonPointer)
2688
- return data2;
2689
- }
2690
- let expr = data2;
2691
- const segments = jsonPointer.split("/");
2692
- for (const segment of segments) {
2693
- if (segment) {
2694
- data2 = (0, codegen_1$n._)`${data2}${(0, codegen_1$n.getProperty)((0, util_1$l.unescapeJsonPointer)(segment))}`;
2695
- expr = (0, codegen_1$n._)`${expr} && ${data2}`;
2596
+ $dataError() {
2597
+ (0, errors_12.reportError)(this, this.def.$dataError || errors_12.keyword$DataError);
2598
+ }
2599
+ reset() {
2600
+ if (this.errsCount === void 0)
2601
+ throw new Error('add "trackErrors" to keyword definition');
2602
+ (0, errors_12.resetErrorsCount)(this.gen, this.errsCount);
2603
+ }
2604
+ ok(cond) {
2605
+ if (!this.allErrors)
2606
+ this.gen.if(cond);
2607
+ }
2608
+ setParams(obj, assign) {
2609
+ if (assign)
2610
+ Object.assign(this.params, obj);
2611
+ else
2612
+ this.params = obj;
2613
+ }
2614
+ block$data(valid, codeBlock, $dataValid = codegen_12.nil) {
2615
+ this.gen.block(() => {
2616
+ this.check$data(valid, $dataValid);
2617
+ codeBlock();
2618
+ });
2619
+ }
2620
+ check$data(valid = codegen_12.nil, $dataValid = codegen_12.nil) {
2621
+ if (!this.$data)
2622
+ return;
2623
+ const { gen, schemaCode, schemaType, def: def2 } = this;
2624
+ gen.if((0, codegen_12.or)((0, codegen_12._)`${schemaCode} === undefined`, $dataValid));
2625
+ if (valid !== codegen_12.nil)
2626
+ gen.assign(valid, true);
2627
+ if (schemaType.length || def2.validateSchema) {
2628
+ gen.elseIf(this.invalid$data());
2629
+ this.$dataError();
2630
+ if (valid !== codegen_12.nil)
2631
+ gen.assign(valid, false);
2632
+ }
2633
+ gen.else();
2634
+ }
2635
+ invalid$data() {
2636
+ const { gen, schemaCode, schemaType, def: def2, it } = this;
2637
+ return (0, codegen_12.or)(wrong$DataType(), invalid$DataSchema());
2638
+ function wrong$DataType() {
2639
+ if (schemaType.length) {
2640
+ if (!(schemaCode instanceof codegen_12.Name))
2641
+ throw new Error("ajv implementation error");
2642
+ const st = Array.isArray(schemaType) ? schemaType : [schemaType];
2643
+ return (0, codegen_12._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
2644
+ }
2645
+ return codegen_12.nil;
2646
+ }
2647
+ function invalid$DataSchema() {
2648
+ if (def2.validateSchema) {
2649
+ const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
2650
+ return (0, codegen_12._)`!${validateSchemaRef}(${schemaCode})`;
2651
+ }
2652
+ return codegen_12.nil;
2653
+ }
2654
+ }
2655
+ subschema(appl, valid) {
2656
+ const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
2657
+ (0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
2658
+ (0, subschema_1.extendSubschemaMode)(subschema2, appl);
2659
+ const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
2660
+ subschemaCode(nextContext, valid);
2661
+ return nextContext;
2662
+ }
2663
+ mergeEvaluated(schemaCxt, toName) {
2664
+ const { it, gen } = this;
2665
+ if (!it.opts.unevaluated)
2666
+ return;
2667
+ if (it.props !== true && schemaCxt.props !== void 0) {
2668
+ it.props = util_12.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
2669
+ }
2670
+ if (it.items !== true && schemaCxt.items !== void 0) {
2671
+ it.items = util_12.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
2672
+ }
2673
+ }
2674
+ mergeValidEvaluated(schemaCxt, valid) {
2675
+ const { it, gen } = this;
2676
+ if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
2677
+ gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_12.Name));
2678
+ return true;
2679
+ }
2696
2680
  }
2697
2681
  }
2698
- return expr;
2699
- function errorMsg(pointerType, up) {
2700
- return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
2701
- }
2682
+ validate$2.KeywordCxt = KeywordCxt;
2683
+ function keywordCode(it, keyword2, def2, ruleType) {
2684
+ const cxt = new KeywordCxt(it, def2, keyword2);
2685
+ if ("code" in def2) {
2686
+ def2.code(cxt, ruleType);
2687
+ } else if (cxt.$data && def2.validate) {
2688
+ (0, keyword_1.funcKeywordCode)(cxt, def2);
2689
+ } else if ("macro" in def2) {
2690
+ (0, keyword_1.macroKeywordCode)(cxt, def2);
2691
+ } else if (def2.compile || def2.validate) {
2692
+ (0, keyword_1.funcKeywordCode)(cxt, def2);
2693
+ }
2694
+ }
2695
+ const JSON_POINTER2 = /^\/(?:[^~]|~0|~1)*$/;
2696
+ const RELATIVE_JSON_POINTER2 = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
2697
+ function getData2($data, { dataLevel, dataNames, dataPathArr }) {
2698
+ let jsonPointer;
2699
+ let data2;
2700
+ if ($data === "")
2701
+ return names_12.default.rootData;
2702
+ if ($data[0] === "/") {
2703
+ if (!JSON_POINTER2.test($data))
2704
+ throw new Error(`Invalid JSON-pointer: ${$data}`);
2705
+ jsonPointer = $data;
2706
+ data2 = names_12.default.rootData;
2707
+ } else {
2708
+ const matches = RELATIVE_JSON_POINTER2.exec($data);
2709
+ if (!matches)
2710
+ throw new Error(`Invalid JSON-pointer: ${$data}`);
2711
+ const up = +matches[1];
2712
+ jsonPointer = matches[2];
2713
+ if (jsonPointer === "#") {
2714
+ if (up >= dataLevel)
2715
+ throw new Error(errorMsg("property/index", up));
2716
+ return dataPathArr[dataLevel - up];
2717
+ }
2718
+ if (up > dataLevel)
2719
+ throw new Error(errorMsg("data", up));
2720
+ data2 = dataNames[dataLevel - up];
2721
+ if (!jsonPointer)
2722
+ return data2;
2723
+ }
2724
+ let expr = data2;
2725
+ const segments = jsonPointer.split("/");
2726
+ for (const segment of segments) {
2727
+ if (segment) {
2728
+ data2 = (0, codegen_12._)`${data2}${(0, codegen_12.getProperty)((0, util_12.unescapeJsonPointer)(segment))}`;
2729
+ expr = (0, codegen_12._)`${expr} && ${data2}`;
2730
+ }
2731
+ }
2732
+ return expr;
2733
+ function errorMsg(pointerType, up) {
2734
+ return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
2735
+ }
2736
+ }
2737
+ validate$2.getData = getData2;
2738
+ return validate$2;
2702
2739
  }
2703
- validate$2.getData = getData$1;
2704
2740
  var validation_error = {};
2705
2741
  Object.defineProperty(validation_error, "__esModule", { value: true });
2706
2742
  let ValidationError$2 = class ValidationError extends Error {
@@ -2730,7 +2766,7 @@
2730
2766
  const names_1$2 = names$1;
2731
2767
  const resolve_1$1 = resolve$6;
2732
2768
  const util_1$k = util$7;
2733
- const validate_1$1 = validate$2;
2769
+ const validate_1$1 = requireValidate();
2734
2770
  class SchemaEnv {
2735
2771
  constructor(env) {
2736
2772
  var _a;
@@ -3617,7 +3653,7 @@
3617
3653
  (function(exports3) {
3618
3654
  Object.defineProperty(exports3, "__esModule", { value: true });
3619
3655
  exports3.CodeGen = exports3.Name = exports3.nil = exports3.stringify = exports3.str = exports3._ = exports3.KeywordCxt = void 0;
3620
- var validate_12 = validate$2;
3656
+ var validate_12 = requireValidate();
3621
3657
  Object.defineProperty(exports3, "KeywordCxt", { enumerable: true, get: function() {
3622
3658
  return validate_12.KeywordCxt;
3623
3659
  } });
@@ -4235,7 +4271,7 @@
4235
4271
  Object.defineProperty(ref$1, "__esModule", { value: true });
4236
4272
  ref$1.callRef = ref$1.getValidate = void 0;
4237
4273
  const ref_error_1$1 = ref_error;
4238
- const code_1$8 = code;
4274
+ const code_1$8 = requireCode();
4239
4275
  const codegen_1$l = codegen;
4240
4276
  const names_1$1 = names$1;
4241
4277
  const compile_1$2 = compile$2;
@@ -4458,7 +4494,7 @@
4458
4494
  limitLength.default = def$o;
4459
4495
  var pattern$1 = {};
4460
4496
  Object.defineProperty(pattern$1, "__esModule", { value: true });
4461
- const code_1$7 = code;
4497
+ const code_1$7 = requireCode();
4462
4498
  const codegen_1$h = codegen;
4463
4499
  const error$f = {
4464
4500
  message: ({ schemaCode }) => (0, codegen_1$h.str)`must match pattern "${schemaCode}"`,
@@ -4503,7 +4539,7 @@
4503
4539
  limitProperties.default = def$m;
4504
4540
  var required$2 = {};
4505
4541
  Object.defineProperty(required$2, "__esModule", { value: true });
4506
- const code_1$6 = code;
4542
+ const code_1$6 = requireCode();
4507
4543
  const codegen_1$f = codegen;
4508
4544
  const util_1$h = util$7;
4509
4545
  const error$d = {
@@ -4817,7 +4853,7 @@
4817
4853
  items$1.validateTuple = void 0;
4818
4854
  const codegen_1$9 = codegen;
4819
4855
  const util_1$c = util$7;
4820
- const code_1$5 = code;
4856
+ const code_1$5 = requireCode();
4821
4857
  const def$f = {
4822
4858
  keyword: "items",
4823
4859
  type: "array",
@@ -4877,7 +4913,7 @@
4877
4913
  Object.defineProperty(items2020, "__esModule", { value: true });
4878
4914
  const codegen_1$8 = codegen;
4879
4915
  const util_1$b = util$7;
4880
- const code_1$4 = code;
4916
+ const code_1$4 = requireCode();
4881
4917
  const additionalItems_1$1 = additionalItems;
4882
4918
  const error$7 = {
4883
4919
  message: ({ params: { len } }) => (0, codegen_1$8.str)`must NOT have more than ${len} items`,
@@ -4996,7 +5032,7 @@
4996
5032
  exports3.validateSchemaDeps = exports3.validatePropertyDeps = exports3.error = void 0;
4997
5033
  const codegen_12 = codegen;
4998
5034
  const util_12 = util$7;
4999
- const code_12 = code;
5035
+ const code_12 = requireCode();
5000
5036
  exports3.error = {
5001
5037
  message: ({ params: { property, depsCount, deps } }) => {
5002
5038
  const property_ies = depsCount === 1 ? "property" : "properties";
@@ -5119,7 +5155,7 @@
5119
5155
  propertyNames$1.default = def$b;
5120
5156
  var additionalProperties$1 = {};
5121
5157
  Object.defineProperty(additionalProperties$1, "__esModule", { value: true });
5122
- const code_1$3 = code;
5158
+ const code_1$3 = requireCode();
5123
5159
  const codegen_1$5 = codegen;
5124
5160
  const names_1 = names$1;
5125
5161
  const util_1$8 = util$7;
@@ -5219,8 +5255,8 @@
5219
5255
  additionalProperties$1.default = def$a;
5220
5256
  var properties$4 = {};
5221
5257
  Object.defineProperty(properties$4, "__esModule", { value: true });
5222
- const validate_1 = validate$2;
5223
- const code_1$2 = code;
5258
+ const validate_1 = requireValidate();
5259
+ const code_1$2 = requireCode();
5224
5260
  const util_1$7 = util$7;
5225
5261
  const additionalProperties_1$1 = additionalProperties$1;
5226
5262
  const def$9 = {
@@ -5271,7 +5307,7 @@
5271
5307
  properties$4.default = def$9;
5272
5308
  var patternProperties = {};
5273
5309
  Object.defineProperty(patternProperties, "__esModule", { value: true });
5274
- const code_1$1 = code;
5310
+ const code_1$1 = requireCode();
5275
5311
  const codegen_1$4 = codegen;
5276
5312
  const util_1$6 = util$7;
5277
5313
  const util_2 = util$7;
@@ -5364,7 +5400,7 @@
5364
5400
  not$1.default = def$7;
5365
5401
  var anyOf$1 = {};
5366
5402
  Object.defineProperty(anyOf$1, "__esModule", { value: true });
5367
- const code_1 = code;
5403
+ const code_1 = requireCode();
5368
5404
  const def$6 = {
5369
5405
  keyword: "anyOf",
5370
5406
  schemaType: "array",
@@ -6070,7 +6106,7 @@
6070
6106
  module2.exports.Ajv = Ajv2;
6071
6107
  Object.defineProperty(exports3, "__esModule", { value: true });
6072
6108
  exports3.default = Ajv2;
6073
- var validate_12 = validate$2;
6109
+ var validate_12 = requireValidate();
6074
6110
  Object.defineProperty(exports3, "KeywordCxt", { enumerable: true, get: function() {
6075
6111
  return validate_12.KeywordCxt;
6076
6112
  } });
@@ -13546,7 +13582,7 @@
13546
13582
  util: util$2,
13547
13583
  resolve: resolve$1,
13548
13584
  resolveRef: resolveRef2,
13549
- usePattern: usePattern2,
13585
+ usePattern,
13550
13586
  useDefault,
13551
13587
  useCustomRule,
13552
13588
  opts,
@@ -13651,7 +13687,7 @@
13651
13687
  function resolvedRef(refVal2, code2) {
13652
13688
  return typeof refVal2 == "object" || typeof refVal2 == "boolean" ? { code: code2, schema: refVal2, inline: true } : { code: code2, $async: refVal2 && !!refVal2.$async };
13653
13689
  }
13654
- function usePattern2(regexStr) {
13690
+ function usePattern(regexStr) {
13655
13691
  var index = patternsHash[regexStr];
13656
13692
  if (index === void 0) {
13657
13693
  index = patternsHash[regexStr] = patterns.length;