@hpcc-js/ddl-shim 2.17.23 → 2.17.24

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.
package/dist/index.js CHANGED
@@ -5,8 +5,8 @@
5
5
  }(this, (function (exports) { 'use strict';
6
6
 
7
7
  var PKG_NAME = "@hpcc-js/ddl-shim";
8
- var PKG_VERSION = "2.17.23";
9
- var BUILD_VERSION = "2.99.0";
8
+ var PKG_VERSION = "2.17.24";
9
+ var BUILD_VERSION = "2.100.0";
10
10
 
11
11
  function isWorkunitDatasource(ref) {
12
12
  return ref.WUID !== undefined;
@@ -2506,21 +2506,18 @@
2506
2506
 
2507
2507
  unwrapExports(uri_all);
2508
2508
 
2509
- var isArray = Array.isArray;
2510
- var keyList = Object.keys;
2511
- var hasProp = Object.prototype.hasOwnProperty;
2509
+ // do not edit .js files directly - edit src/index.jst
2510
+
2511
+
2512
2512
 
2513
2513
  var fastDeepEqual = function equal(a, b) {
2514
2514
  if (a === b) return true;
2515
2515
 
2516
2516
  if (a && b && typeof a == 'object' && typeof b == 'object') {
2517
- var arrA = isArray(a)
2518
- , arrB = isArray(b)
2519
- , i
2520
- , length
2521
- , key;
2517
+ if (a.constructor !== b.constructor) return false;
2522
2518
 
2523
- if (arrA && arrB) {
2519
+ var length, i, keys;
2520
+ if (Array.isArray(a)) {
2524
2521
  length = a.length;
2525
2522
  if (length != b.length) return false;
2526
2523
  for (i = length; i-- !== 0;)
@@ -2528,35 +2525,29 @@
2528
2525
  return true;
2529
2526
  }
2530
2527
 
2531
- if (arrA != arrB) return false;
2532
2528
 
2533
- var dateA = a instanceof Date
2534
- , dateB = b instanceof Date;
2535
- if (dateA != dateB) return false;
2536
- if (dateA && dateB) return a.getTime() == b.getTime();
2537
2529
 
2538
- var regexpA = a instanceof RegExp
2539
- , regexpB = b instanceof RegExp;
2540
- if (regexpA != regexpB) return false;
2541
- if (regexpA && regexpB) return a.toString() == b.toString();
2530
+ if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
2531
+ if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
2532
+ if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
2542
2533
 
2543
- var keys = keyList(a);
2534
+ keys = Object.keys(a);
2544
2535
  length = keys.length;
2545
-
2546
- if (length !== keyList(b).length)
2547
- return false;
2536
+ if (length !== Object.keys(b).length) return false;
2548
2537
 
2549
2538
  for (i = length; i-- !== 0;)
2550
- if (!hasProp.call(b, keys[i])) return false;
2539
+ if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
2551
2540
 
2552
2541
  for (i = length; i-- !== 0;) {
2553
- key = keys[i];
2542
+ var key = keys[i];
2543
+
2554
2544
  if (!equal(a[key], b[key])) return false;
2555
2545
  }
2556
2546
 
2557
2547
  return true;
2558
2548
  }
2559
2549
 
2550
+ // true if both NaN, false otherwise
2560
2551
  return a!==a && b!==b;
2561
2552
  };
2562
2553
 
@@ -2591,8 +2582,6 @@
2591
2582
  ucs2length: ucs2length,
2592
2583
  varOccurences: varOccurences,
2593
2584
  varReplace: varReplace,
2594
- cleanUpCode: cleanUpCode,
2595
- finalCleanUpCode: finalCleanUpCode,
2596
2585
  schemaHasRules: schemaHasRules,
2597
2586
  schemaHasRulesExcept: schemaHasRulesExcept,
2598
2587
  schemaUnknownRules: schemaUnknownRules,
@@ -2614,7 +2603,7 @@
2614
2603
  }
2615
2604
 
2616
2605
 
2617
- function checkDataType(dataType, data, negate) {
2606
+ function checkDataType(dataType, data, strictNumbers, negate) {
2618
2607
  var EQUAL = negate ? ' !== ' : ' === '
2619
2608
  , AND = negate ? ' || ' : ' && '
2620
2609
  , OK = negate ? '!' : ''
@@ -2627,15 +2616,18 @@
2627
2616
  NOT + 'Array.isArray(' + data + '))';
2628
2617
  case 'integer': return '(typeof ' + data + EQUAL + '"number"' + AND +
2629
2618
  NOT + '(' + data + ' % 1)' +
2630
- AND + data + EQUAL + data + ')';
2619
+ AND + data + EQUAL + data +
2620
+ (strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
2621
+ case 'number': return '(typeof ' + data + EQUAL + '"' + dataType + '"' +
2622
+ (strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
2631
2623
  default: return 'typeof ' + data + EQUAL + '"' + dataType + '"';
2632
2624
  }
2633
2625
  }
2634
2626
 
2635
2627
 
2636
- function checkDataTypes(dataTypes, data) {
2628
+ function checkDataTypes(dataTypes, data, strictNumbers) {
2637
2629
  switch (dataTypes.length) {
2638
- case 1: return checkDataType(dataTypes[0], data, true);
2630
+ case 1: return checkDataType(dataTypes[0], data, strictNumbers, true);
2639
2631
  default:
2640
2632
  var code = '';
2641
2633
  var types = toHash(dataTypes);
@@ -2648,7 +2640,7 @@
2648
2640
  }
2649
2641
  if (types.number) delete types.integer;
2650
2642
  for (var t in types)
2651
- code += (code ? ' && ' : '' ) + checkDataType(t, data, true);
2643
+ code += (code ? ' && ' : '' ) + checkDataType(t, data, strictNumbers, true);
2652
2644
 
2653
2645
  return code;
2654
2646
  }
@@ -2714,42 +2706,6 @@
2714
2706
  }
2715
2707
 
2716
2708
 
2717
- var EMPTY_ELSE = /else\s*{\s*}/g
2718
- , EMPTY_IF_NO_ELSE = /if\s*\([^)]+\)\s*\{\s*\}(?!\s*else)/g
2719
- , EMPTY_IF_WITH_ELSE = /if\s*\(([^)]+)\)\s*\{\s*\}\s*else(?!\s*if)/g;
2720
- function cleanUpCode(out) {
2721
- return out.replace(EMPTY_ELSE, '')
2722
- .replace(EMPTY_IF_NO_ELSE, '')
2723
- .replace(EMPTY_IF_WITH_ELSE, 'if (!($1))');
2724
- }
2725
-
2726
-
2727
- var ERRORS_REGEXP = /[^v.]errors/g
2728
- , REMOVE_ERRORS = /var errors = 0;|var vErrors = null;|validate.errors = vErrors;/g
2729
- , REMOVE_ERRORS_ASYNC = /var errors = 0;|var vErrors = null;/g
2730
- , RETURN_VALID = 'return errors === 0;'
2731
- , RETURN_TRUE = 'validate.errors = null; return true;'
2732
- , RETURN_ASYNC = /if \(errors === 0\) return data;\s*else throw new ValidationError\(vErrors\);/
2733
- , RETURN_DATA_ASYNC = 'return data;'
2734
- , ROOTDATA_REGEXP = /[^A-Za-z_$]rootData[^A-Za-z0-9_$]/g
2735
- , REMOVE_ROOTDATA = /if \(rootData === undefined\) rootData = data;/;
2736
-
2737
- function finalCleanUpCode(out, async) {
2738
- var matches = out.match(ERRORS_REGEXP);
2739
- if (matches && matches.length == 2) {
2740
- out = async
2741
- ? out.replace(REMOVE_ERRORS_ASYNC, '')
2742
- .replace(RETURN_ASYNC, RETURN_DATA_ASYNC)
2743
- : out.replace(REMOVE_ERRORS, '')
2744
- .replace(RETURN_VALID, RETURN_TRUE);
2745
- }
2746
-
2747
- matches = out.match(ROOTDATA_REGEXP);
2748
- if (!matches || matches.length !== 3) return out;
2749
- return out.replace(REMOVE_ROOTDATA, '');
2750
- }
2751
-
2752
-
2753
2709
  function schemaHasRules(schema, rules) {
2754
2710
  if (typeof schema == 'boolean') return !schema;
2755
2711
  for (var key in schema) if (rules[key]) return true;
@@ -2828,7 +2784,7 @@
2828
2784
 
2829
2785
  function joinPaths (a, b) {
2830
2786
  if (a == '""') return b;
2831
- return (a + ' + ' + b).replace(/' \+ '/g, '');
2787
+ return (a + ' + ' + b).replace(/([^\\])' \+ '/g, '$1');
2832
2788
  }
2833
2789
 
2834
2790
 
@@ -3392,7 +3348,7 @@
3392
3348
  it.rootId = it.resolve.fullPath(it.self._getId(it.root.schema));
3393
3349
  it.baseId = it.baseId || it.rootId;
3394
3350
  delete it.isTop;
3395
- it.dataPathArr = [undefined];
3351
+ it.dataPathArr = [""];
3396
3352
  if (it.schema.default !== undefined && it.opts.useDefaults && it.opts.strictDefaults) {
3397
3353
  var $defaultMsg = 'default is ignored in the schema root';
3398
3354
  if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);
@@ -3450,47 +3406,39 @@
3450
3406
  var $schemaPath = it.schemaPath + '.type',
3451
3407
  $errSchemaPath = it.errSchemaPath + '/type',
3452
3408
  $method = $typeIsArray ? 'checkDataTypes' : 'checkDataType';
3453
- out += ' if (' + (it.util[$method]($typeSchema, $data, true)) + ') { ';
3409
+ out += ' if (' + (it.util[$method]($typeSchema, $data, it.opts.strictNumbers, true)) + ') { ';
3454
3410
  if ($coerceToTypes) {
3455
3411
  var $dataType = 'dataType' + $lvl,
3456
3412
  $coerced = 'coerced' + $lvl;
3457
- out += ' var ' + ($dataType) + ' = typeof ' + ($data) + '; ';
3413
+ out += ' var ' + ($dataType) + ' = typeof ' + ($data) + '; var ' + ($coerced) + ' = undefined; ';
3458
3414
  if (it.opts.coerceTypes == 'array') {
3459
- out += ' if (' + ($dataType) + ' == \'object\' && Array.isArray(' + ($data) + ')) ' + ($dataType) + ' = \'array\'; ';
3415
+ out += ' if (' + ($dataType) + ' == \'object\' && Array.isArray(' + ($data) + ') && ' + ($data) + '.length == 1) { ' + ($data) + ' = ' + ($data) + '[0]; ' + ($dataType) + ' = typeof ' + ($data) + '; if (' + (it.util.checkDataType(it.schema.type, $data, it.opts.strictNumbers)) + ') ' + ($coerced) + ' = ' + ($data) + '; } ';
3460
3416
  }
3461
- out += ' var ' + ($coerced) + ' = undefined; ';
3462
- var $bracesCoercion = '';
3417
+ out += ' if (' + ($coerced) + ' !== undefined) ; ';
3463
3418
  var arr1 = $coerceToTypes;
3464
3419
  if (arr1) {
3465
3420
  var $type, $i = -1,
3466
3421
  l1 = arr1.length - 1;
3467
3422
  while ($i < l1) {
3468
3423
  $type = arr1[$i += 1];
3469
- if ($i) {
3470
- out += ' if (' + ($coerced) + ' === undefined) { ';
3471
- $bracesCoercion += '}';
3472
- }
3473
- if (it.opts.coerceTypes == 'array' && $type != 'array') {
3474
- out += ' if (' + ($dataType) + ' == \'array\' && ' + ($data) + '.length == 1) { ' + ($coerced) + ' = ' + ($data) + ' = ' + ($data) + '[0]; ' + ($dataType) + ' = typeof ' + ($data) + '; } ';
3475
- }
3476
3424
  if ($type == 'string') {
3477
- out += ' if (' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\') ' + ($coerced) + ' = \'\' + ' + ($data) + '; else if (' + ($data) + ' === null) ' + ($coerced) + ' = \'\'; ';
3425
+ out += ' else if (' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\') ' + ($coerced) + ' = \'\' + ' + ($data) + '; else if (' + ($data) + ' === null) ' + ($coerced) + ' = \'\'; ';
3478
3426
  } else if ($type == 'number' || $type == 'integer') {
3479
- out += ' if (' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' === null || (' + ($dataType) + ' == \'string\' && ' + ($data) + ' && ' + ($data) + ' == +' + ($data) + ' ';
3427
+ out += ' else if (' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' === null || (' + ($dataType) + ' == \'string\' && ' + ($data) + ' && ' + ($data) + ' == +' + ($data) + ' ';
3480
3428
  if ($type == 'integer') {
3481
3429
  out += ' && !(' + ($data) + ' % 1)';
3482
3430
  }
3483
3431
  out += ')) ' + ($coerced) + ' = +' + ($data) + '; ';
3484
3432
  } else if ($type == 'boolean') {
3485
- out += ' if (' + ($data) + ' === \'false\' || ' + ($data) + ' === 0 || ' + ($data) + ' === null) ' + ($coerced) + ' = false; else if (' + ($data) + ' === \'true\' || ' + ($data) + ' === 1) ' + ($coerced) + ' = true; ';
3433
+ out += ' else if (' + ($data) + ' === \'false\' || ' + ($data) + ' === 0 || ' + ($data) + ' === null) ' + ($coerced) + ' = false; else if (' + ($data) + ' === \'true\' || ' + ($data) + ' === 1) ' + ($coerced) + ' = true; ';
3486
3434
  } else if ($type == 'null') {
3487
- out += ' if (' + ($data) + ' === \'\' || ' + ($data) + ' === 0 || ' + ($data) + ' === false) ' + ($coerced) + ' = null; ';
3435
+ out += ' else if (' + ($data) + ' === \'\' || ' + ($data) + ' === 0 || ' + ($data) + ' === false) ' + ($coerced) + ' = null; ';
3488
3436
  } else if (it.opts.coerceTypes == 'array' && $type == 'array') {
3489
- out += ' if (' + ($dataType) + ' == \'string\' || ' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' == null) ' + ($coerced) + ' = [' + ($data) + ']; ';
3437
+ out += ' else if (' + ($dataType) + ' == \'string\' || ' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' == null) ' + ($coerced) + ' = [' + ($data) + ']; ';
3490
3438
  }
3491
3439
  }
3492
3440
  }
3493
- out += ' ' + ($bracesCoercion) + ' if (' + ($coerced) + ' === undefined) { ';
3441
+ out += ' else { ';
3494
3442
  var $$outStack = $$outStack || [];
3495
3443
  $$outStack.push(out);
3496
3444
  out = ''; /* istanbul ignore else */
@@ -3530,7 +3478,7 @@
3530
3478
  } else {
3531
3479
  out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3532
3480
  }
3533
- out += ' } else { ';
3481
+ out += ' } if (' + ($coerced) + ' !== undefined) { ';
3534
3482
  var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData',
3535
3483
  $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
3536
3484
  out += ' ' + ($data) + ' = ' + ($coerced) + '; ';
@@ -3603,7 +3551,7 @@
3603
3551
  $rulesGroup = arr2[i2 += 1];
3604
3552
  if ($shouldUseGroup($rulesGroup)) {
3605
3553
  if ($rulesGroup.type) {
3606
- out += ' if (' + (it.util.checkDataType($rulesGroup.type, $data)) + ') { ';
3554
+ out += ' if (' + (it.util.checkDataType($rulesGroup.type, $data, it.opts.strictNumbers)) + ') { ';
3607
3555
  }
3608
3556
  if (it.opts.useDefaults) {
3609
3557
  if ($rulesGroup.type == 'object' && it.schema.properties) {
@@ -3771,10 +3719,6 @@
3771
3719
  } else {
3772
3720
  out += ' var ' + ($valid) + ' = errors === errs_' + ($lvl) + ';';
3773
3721
  }
3774
- out = it.util.cleanUpCode(out);
3775
- if ($top) {
3776
- out = it.util.finalCleanUpCode(out, $async);
3777
- }
3778
3722
 
3779
3723
  function $shouldUseGroup($rulesGroup) {
3780
3724
  var rules = $rulesGroup.rules;
@@ -3900,7 +3844,7 @@
3900
3844
  + vars(defaults, defaultCode) + vars(customRules, customRuleCode)
3901
3845
  + sourceCode;
3902
3846
 
3903
- if (opts.processCode) sourceCode = opts.processCode(sourceCode);
3847
+ if (opts.processCode) sourceCode = opts.processCode(sourceCode, _schema);
3904
3848
  // console.log('\n\n\n *** \n', JSON.stringify(sourceCode));
3905
3849
  var validate$1;
3906
3850
  try {
@@ -4203,8 +4147,8 @@
4203
4147
 
4204
4148
  var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
4205
4149
  var DAYS = [0,31,28,31,30,31,30,31,31,30,31,30,31];
4206
- var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d:\d\d)?$/i;
4207
- var HOSTNAME = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*$/i;
4150
+ var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
4151
+ var HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i;
4208
4152
  var URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
4209
4153
  var URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
4210
4154
  // uri-template: https://tools.ietf.org/html/rfc6570
@@ -4212,8 +4156,8 @@
4212
4156
  // For the source: https://gist.github.com/dperini/729294
4213
4157
  // For test cases: https://mathiasbynens.be/demo/url-regex
4214
4158
  // @todo Delete current URL in favour of the commented out URL rule when this issue is fixed https://github.com/eslint/eslint/issues/7983.
4215
- // var URL = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
4216
- var URL = /^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i;
4159
+ // var URL = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
4160
+ var URL = /^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i;
4217
4161
  var UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
4218
4162
  var JSON_POINTER$1 = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
4219
4163
  var JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
@@ -4232,11 +4176,11 @@
4232
4176
  // date: http://tools.ietf.org/html/rfc3339#section-5.6
4233
4177
  date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/,
4234
4178
  // date-time: http://tools.ietf.org/html/rfc3339#section-5.6
4235
- time: /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d:\d\d)?$/i,
4236
- 'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d:\d\d)$/i,
4179
+ time: /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,
4180
+ 'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,
4237
4181
  // uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
4238
- uri: /^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i,
4239
- 'uri-reference': /^(?:(?:[a-z][a-z0-9+-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,
4182
+ uri: /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,
4183
+ 'uri-reference': /^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,
4240
4184
  'uri-template': URITEMPLATE,
4241
4185
  url: URL,
4242
4186
  // email (sources from jsen validator):
@@ -4269,7 +4213,7 @@
4269
4213
  'uri-template': URITEMPLATE,
4270
4214
  url: URL,
4271
4215
  email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
4272
- hostname: hostname,
4216
+ hostname: HOSTNAME,
4273
4217
  ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
4274
4218
  ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
4275
4219
  regex: regex,
@@ -4322,13 +4266,6 @@
4322
4266
  }
4323
4267
 
4324
4268
 
4325
- function hostname(str) {
4326
- // https://tools.ietf.org/html/rfc1034#section-3.5
4327
- // https://tools.ietf.org/html/rfc1123#section-2
4328
- return str.length <= 255 && HOSTNAME.test(str);
4329
- }
4330
-
4331
-
4332
4269
  var NOT_URI_FRAGMENT = /\/|:/;
4333
4270
  function uri(str) {
4334
4271
  // http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
@@ -4489,7 +4426,7 @@
4489
4426
  l1 = arr1.length - 1;
4490
4427
  while ($i < l1) {
4491
4428
  $sch = arr1[$i += 1];
4492
- if (it.util.schemaHasRules($sch, it.RULES.all)) {
4429
+ if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
4493
4430
  $allSchemasEmpty = false;
4494
4431
  $it.schema = $sch;
4495
4432
  $it.schemaPath = $schemaPath + '[' + $i + ']';
@@ -4510,7 +4447,6 @@
4510
4447
  out += ' ' + ($closingBraces.slice(0, -1)) + ' ';
4511
4448
  }
4512
4449
  }
4513
- out = it.util.cleanUpCode(out);
4514
4450
  return out;
4515
4451
  };
4516
4452
 
@@ -4530,7 +4466,7 @@
4530
4466
  $it.level++;
4531
4467
  var $nextValid = 'valid' + $it.level;
4532
4468
  var $noEmptySchema = $schema.every(function($sch) {
4533
- return it.util.schemaHasRules($sch, it.RULES.all);
4469
+ return (it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all));
4534
4470
  });
4535
4471
  if ($noEmptySchema) {
4536
4472
  var $currentBaseId = $it.baseId;
@@ -4579,7 +4515,6 @@
4579
4515
  if (it.opts.allErrors) {
4580
4516
  out += ' } ';
4581
4517
  }
4582
- out = it.util.cleanUpCode(out);
4583
4518
  } else {
4584
4519
  if ($breakOnError) {
4585
4520
  out += ' if (true) { ';
@@ -4673,7 +4608,7 @@
4673
4608
  $dataNxt = $it.dataLevel = it.dataLevel + 1,
4674
4609
  $nextData = 'data' + $dataNxt,
4675
4610
  $currentBaseId = it.baseId,
4676
- $nonEmptySchema = it.util.schemaHasRules($schema, it.RULES.all);
4611
+ $nonEmptySchema = (it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all));
4677
4612
  out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';';
4678
4613
  if ($nonEmptySchema) {
4679
4614
  var $wasComposite = it.compositeRule;
@@ -4732,7 +4667,6 @@
4732
4667
  if (it.opts.allErrors) {
4733
4668
  out += ' } ';
4734
4669
  }
4735
- out = it.util.cleanUpCode(out);
4736
4670
  return out;
4737
4671
  };
4738
4672
 
@@ -4754,6 +4688,7 @@
4754
4688
  $propertyDeps = {},
4755
4689
  $ownProperties = it.opts.ownProperties;
4756
4690
  for ($property in $schema) {
4691
+ if ($property == '__proto__') continue;
4757
4692
  var $sch = $schema[$property];
4758
4693
  var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
4759
4694
  $deps[$property] = $sch;
@@ -4879,7 +4814,7 @@
4879
4814
  var $currentBaseId = $it.baseId;
4880
4815
  for (var $property in $schemaDeps) {
4881
4816
  var $sch = $schemaDeps[$property];
4882
- if (it.util.schemaHasRules($sch, it.RULES.all)) {
4817
+ if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
4883
4818
  out += ' ' + ($nextValid) + ' = true; if ( ' + ($data) + (it.util.getProperty($property)) + ' !== undefined ';
4884
4819
  if ($ownProperties) {
4885
4820
  out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($property)) + '\') ';
@@ -4900,7 +4835,6 @@
4900
4835
  if ($breakOnError) {
4901
4836
  out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
4902
4837
  }
4903
- out = it.util.cleanUpCode(out);
4904
4838
  return out;
4905
4839
  };
4906
4840
 
@@ -5132,8 +5066,8 @@
5132
5066
  var $nextValid = 'valid' + $it.level;
5133
5067
  var $thenSch = it.schema['then'],
5134
5068
  $elseSch = it.schema['else'],
5135
- $thenPresent = $thenSch !== undefined && it.util.schemaHasRules($thenSch, it.RULES.all),
5136
- $elsePresent = $elseSch !== undefined && it.util.schemaHasRules($elseSch, it.RULES.all),
5069
+ $thenPresent = $thenSch !== undefined && (it.opts.strictKeywords ? (typeof $thenSch == 'object' && Object.keys($thenSch).length > 0) || $thenSch === false : it.util.schemaHasRules($thenSch, it.RULES.all)),
5070
+ $elsePresent = $elseSch !== undefined && (it.opts.strictKeywords ? (typeof $elseSch == 'object' && Object.keys($elseSch).length > 0) || $elseSch === false : it.util.schemaHasRules($elseSch, it.RULES.all)),
5137
5071
  $currentBaseId = $it.baseId;
5138
5072
  if ($thenPresent || $elsePresent) {
5139
5073
  var $ifClause;
@@ -5211,7 +5145,6 @@
5211
5145
  if ($breakOnError) {
5212
5146
  out += ' else { ';
5213
5147
  }
5214
- out = it.util.cleanUpCode(out);
5215
5148
  } else {
5216
5149
  if ($breakOnError) {
5217
5150
  out += ' if (true) { ';
@@ -5287,7 +5220,7 @@
5287
5220
  l1 = arr1.length - 1;
5288
5221
  while ($i < l1) {
5289
5222
  $sch = arr1[$i += 1];
5290
- if (it.util.schemaHasRules($sch, it.RULES.all)) {
5223
+ if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
5291
5224
  out += ' ' + ($nextValid) + ' = true; if (' + ($data) + '.length > ' + ($i) + ') { ';
5292
5225
  var $passData = $data + '[' + $i + ']';
5293
5226
  $it.schema = $sch;
@@ -5310,7 +5243,7 @@
5310
5243
  }
5311
5244
  }
5312
5245
  }
5313
- if (typeof $additionalItems == 'object' && it.util.schemaHasRules($additionalItems, it.RULES.all)) {
5246
+ if (typeof $additionalItems == 'object' && (it.opts.strictKeywords ? (typeof $additionalItems == 'object' && Object.keys($additionalItems).length > 0) || $additionalItems === false : it.util.schemaHasRules($additionalItems, it.RULES.all))) {
5314
5247
  $it.schema = $additionalItems;
5315
5248
  $it.schemaPath = it.schemaPath + '.additionalItems';
5316
5249
  $it.errSchemaPath = it.errSchemaPath + '/additionalItems';
@@ -5334,7 +5267,7 @@
5334
5267
  $closingBraces += '}';
5335
5268
  }
5336
5269
  }
5337
- } else if (it.util.schemaHasRules($schema, it.RULES.all)) {
5270
+ } else if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) {
5338
5271
  $it.schema = $schema;
5339
5272
  $it.schemaPath = $schemaPath;
5340
5273
  $it.errSchemaPath = $errSchemaPath;
@@ -5357,7 +5290,6 @@
5357
5290
  if ($breakOnError) {
5358
5291
  out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
5359
5292
  }
5360
- out = it.util.cleanUpCode(out);
5361
5293
  return out;
5362
5294
  };
5363
5295
 
@@ -5386,6 +5318,12 @@
5386
5318
  $op = $isMax ? '<' : '>',
5387
5319
  $notOp = $isMax ? '>' : '<',
5388
5320
  $errorKeyword = undefined;
5321
+ if (!($isData || typeof $schema == 'number' || $schema === undefined)) {
5322
+ throw new Error($keyword + ' must be number');
5323
+ }
5324
+ if (!($isDataExcl || $schemaExcl === undefined || typeof $schemaExcl == 'number' || typeof $schemaExcl == 'boolean')) {
5325
+ throw new Error($exclusiveKeyword + ' must be number or boolean');
5326
+ }
5389
5327
  if ($isDataExcl) {
5390
5328
  var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr),
5391
5329
  $exclusive = 'exclusive' + $lvl,
@@ -5536,6 +5474,9 @@
5536
5474
  } else {
5537
5475
  $schemaValue = $schema;
5538
5476
  }
5477
+ if (!($isData || typeof $schema == 'number')) {
5478
+ throw new Error($keyword + ' must be number');
5479
+ }
5539
5480
  var $op = $keyword == 'maxItems' ? '>' : '<';
5540
5481
  out += 'if ( ';
5541
5482
  if ($isData) {
@@ -5613,6 +5554,9 @@
5613
5554
  } else {
5614
5555
  $schemaValue = $schema;
5615
5556
  }
5557
+ if (!($isData || typeof $schema == 'number')) {
5558
+ throw new Error($keyword + ' must be number');
5559
+ }
5616
5560
  var $op = $keyword == 'maxLength' ? '>' : '<';
5617
5561
  out += 'if ( ';
5618
5562
  if ($isData) {
@@ -5695,6 +5639,9 @@
5695
5639
  } else {
5696
5640
  $schemaValue = $schema;
5697
5641
  }
5642
+ if (!($isData || typeof $schema == 'number')) {
5643
+ throw new Error($keyword + ' must be number');
5644
+ }
5698
5645
  var $op = $keyword == 'maxProperties' ? '>' : '<';
5699
5646
  out += 'if ( ';
5700
5647
  if ($isData) {
@@ -5771,6 +5718,9 @@
5771
5718
  } else {
5772
5719
  $schemaValue = $schema;
5773
5720
  }
5721
+ if (!($isData || typeof $schema == 'number')) {
5722
+ throw new Error($keyword + ' must be number');
5723
+ }
5774
5724
  out += 'var division' + ($lvl) + ';if (';
5775
5725
  if ($isData) {
5776
5726
  out += ' ' + ($schemaValue) + ' !== undefined && ( typeof ' + ($schemaValue) + ' != \'number\' || ';
@@ -5844,7 +5794,7 @@
5844
5794
  var $it = it.util.copy(it);
5845
5795
  $it.level++;
5846
5796
  var $nextValid = 'valid' + $it.level;
5847
- if (it.util.schemaHasRules($schema, it.RULES.all)) {
5797
+ if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) {
5848
5798
  $it.schema = $schema;
5849
5799
  $it.schemaPath = $schemaPath;
5850
5800
  $it.errSchemaPath = $errSchemaPath;
@@ -5942,7 +5892,7 @@
5942
5892
  l1 = arr1.length - 1;
5943
5893
  while ($i < l1) {
5944
5894
  $sch = arr1[$i += 1];
5945
- if (it.util.schemaHasRules($sch, it.RULES.all)) {
5895
+ if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
5946
5896
  $it.schema = $sch;
5947
5897
  $it.schemaPath = $schemaPath + '[' + $i + ']';
5948
5898
  $it.errSchemaPath = $errSchemaPath + '/' + $i;
@@ -6082,9 +6032,9 @@
6082
6032
  $dataNxt = $it.dataLevel = it.dataLevel + 1,
6083
6033
  $nextData = 'data' + $dataNxt,
6084
6034
  $dataProperties = 'dataProperties' + $lvl;
6085
- var $schemaKeys = Object.keys($schema || {}),
6035
+ var $schemaKeys = Object.keys($schema || {}).filter(notProto),
6086
6036
  $pProperties = it.schema.patternProperties || {},
6087
- $pPropertyKeys = Object.keys($pProperties),
6037
+ $pPropertyKeys = Object.keys($pProperties).filter(notProto),
6088
6038
  $aProperties = it.schema.additionalProperties,
6089
6039
  $someProperties = $schemaKeys.length || $pPropertyKeys.length,
6090
6040
  $noAdditional = $aProperties === false,
@@ -6094,7 +6044,13 @@
6094
6044
  $ownProperties = it.opts.ownProperties,
6095
6045
  $currentBaseId = it.baseId;
6096
6046
  var $required = it.schema.required;
6097
- if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) var $requiredHash = it.util.toHash($required);
6047
+ if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) {
6048
+ var $requiredHash = it.util.toHash($required);
6049
+ }
6050
+
6051
+ function notProto(p) {
6052
+ return p !== '__proto__';
6053
+ }
6098
6054
  out += 'var ' + ($errs) + ' = errors;var ' + ($nextValid) + ' = true;';
6099
6055
  if ($ownProperties) {
6100
6056
  out += ' var ' + ($dataProperties) + ' = undefined;';
@@ -6247,7 +6203,7 @@
6247
6203
  while (i3 < l3) {
6248
6204
  $propertyKey = arr3[i3 += 1];
6249
6205
  var $sch = $schema[$propertyKey];
6250
- if (it.util.schemaHasRules($sch, it.RULES.all)) {
6206
+ if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
6251
6207
  var $prop = it.util.getProperty($propertyKey),
6252
6208
  $passData = $data + $prop,
6253
6209
  $hasDefault = $useDefaults && $sch.default !== undefined;
@@ -6350,7 +6306,7 @@
6350
6306
  while (i4 < l4) {
6351
6307
  $pProperty = arr4[i4 += 1];
6352
6308
  var $sch = $pProperties[$pProperty];
6353
- if (it.util.schemaHasRules($sch, it.RULES.all)) {
6309
+ if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
6354
6310
  $it.schema = $sch;
6355
6311
  $it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty);
6356
6312
  $it.errSchemaPath = it.errSchemaPath + '/patternProperties/' + it.util.escapeFragment($pProperty);
@@ -6389,7 +6345,6 @@
6389
6345
  if ($breakOnError) {
6390
6346
  out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
6391
6347
  }
6392
- out = it.util.cleanUpCode(out);
6393
6348
  return out;
6394
6349
  };
6395
6350
 
@@ -6408,7 +6363,7 @@
6408
6363
  $it.level++;
6409
6364
  var $nextValid = 'valid' + $it.level;
6410
6365
  out += 'var ' + ($errs) + ' = errors;';
6411
- if (it.util.schemaHasRules($schema, it.RULES.all)) {
6366
+ if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) {
6412
6367
  $it.schema = $schema;
6413
6368
  $it.schemaPath = $schemaPath;
6414
6369
  $it.errSchemaPath = $errSchemaPath;
@@ -6471,7 +6426,6 @@
6471
6426
  if ($breakOnError) {
6472
6427
  out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
6473
6428
  }
6474
- out = it.util.cleanUpCode(out);
6475
6429
  return out;
6476
6430
  };
6477
6431
 
@@ -6500,7 +6454,7 @@
6500
6454
  while (i1 < l1) {
6501
6455
  $property = arr1[i1 += 1];
6502
6456
  var $propertySch = it.schema.properties[$property];
6503
- if (!($propertySch && it.util.schemaHasRules($propertySch, it.RULES.all))) {
6457
+ if (!($propertySch && (it.opts.strictKeywords ? (typeof $propertySch == 'object' && Object.keys($propertySch).length > 0) || $propertySch === false : it.util.schemaHasRules($propertySch, it.RULES.all)))) {
6504
6458
  $required[$required.length] = $property;
6505
6459
  }
6506
6460
  }
@@ -6771,7 +6725,7 @@
6771
6725
  } else {
6772
6726
  out += ' var itemIndices = {}, item; for (;i--;) { var item = ' + ($data) + '[i]; ';
6773
6727
  var $method = 'checkDataType' + ($typeIsArray ? 's' : '');
6774
- out += ' if (' + (it.util[$method]($itemType, 'item', true)) + ') continue; ';
6728
+ out += ' if (' + (it.util[$method]($itemType, 'item', it.opts.strictNumbers, true)) + ') continue; ';
6775
6729
  if ($typeIsArray) {
6776
6730
  out += ' if (typeof item == \'string\') item = \'"\' + item; ';
6777
6731
  }
@@ -6961,7 +6915,7 @@
6961
6915
  keywords[key] = {
6962
6916
  anyOf: [
6963
6917
  schema,
6964
- { $ref: 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#' }
6918
+ { $ref: 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' }
6965
6919
  ]
6966
6920
  };
6967
6921
  }
@@ -7553,20 +7507,10 @@
7553
7507
 
7554
7508
  var require$$2 = getCjsExportFromNamespace(jsonSchemaDraft07$1);
7555
7509
 
7556
- var IDENTIFIER$1 = /^[a-z_$][a-z0-9_$-]*$/i;
7557
-
7558
- var metaSchema = require$$2;
7559
-
7560
- var keyword = {
7561
- add: addKeyword,
7562
- get: getKeyword,
7563
- remove: removeKeyword,
7564
- validate: validateKeyword
7565
- };
7566
-
7567
- var definitionSchema = {
7510
+ var definition_schema = {
7511
+ $id: 'https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js',
7568
7512
  definitions: {
7569
- simpleTypes: metaSchema.definitions.simpleTypes
7513
+ simpleTypes: require$$2.definitions.simpleTypes
7570
7514
  },
7571
7515
  type: 'object',
7572
7516
  dependencies: {
@@ -7576,7 +7520,7 @@
7576
7520
  valid: {not: {required: ['macro']}}
7577
7521
  },
7578
7522
  properties: {
7579
- type: metaSchema.properties.type,
7523
+ type: require$$2.properties.type,
7580
7524
  schema: {type: 'boolean'},
7581
7525
  statements: {type: 'boolean'},
7582
7526
  dependencies: {
@@ -7597,6 +7541,18 @@
7597
7541
  }
7598
7542
  };
7599
7543
 
7544
+ var IDENTIFIER$1 = /^[a-z_$][a-z0-9_$-]*$/i;
7545
+
7546
+
7547
+
7548
+ var keyword = {
7549
+ add: addKeyword,
7550
+ get: getKeyword,
7551
+ remove: removeKeyword,
7552
+ validate: validateKeyword
7553
+ };
7554
+
7555
+
7600
7556
  /**
7601
7557
  * Define custom keyword
7602
7558
  * @this Ajv
@@ -7631,7 +7587,7 @@
7631
7587
  metaSchema = {
7632
7588
  anyOf: [
7633
7589
  metaSchema,
7634
- { '$ref': 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#' }
7590
+ { '$ref': 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' }
7635
7591
  ]
7636
7592
  };
7637
7593
  }
@@ -7720,7 +7676,7 @@
7720
7676
  function validateKeyword(definition, throwError) {
7721
7677
  validateKeyword.errors = null;
7722
7678
  var v = this._validateKeyword = this._validateKeyword
7723
- || this.compile(definitionSchema, true);
7679
+ || this.compile(definition_schema, true);
7724
7680
 
7725
7681
  if (v(definition)) return true;
7726
7682
  validateKeyword.errors = v.errors;
@@ -7731,7 +7687,7 @@
7731
7687
  }
7732
7688
 
7733
7689
  var $schema$1 = "http://json-schema.org/draft-07/schema#";
7734
- var $id$1 = "https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#";
7690
+ var $id$1 = "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#";
7735
7691
  var description = "Meta-schema for $data reference (JSON Schema extension proposal)";
7736
7692
  var type$1 = "object";
7737
7693
  var required$1 = [
@@ -7834,6 +7790,7 @@
7834
7790
  this._metaOpts = getMetaSchemaOptions(this);
7835
7791
 
7836
7792
  if (opts.formats) addInitialFormats(this);
7793
+ if (opts.keywords) addInitialKeywords(this);
7837
7794
  addDefaultMetaSchema(this);
7838
7795
  if (typeof opts.meta == 'object') this.addMetaSchema(opts.meta);
7839
7796
  if (opts.nullable) this.addKeyword('nullable', {metaSchema: {type: 'boolean'}});
@@ -8232,6 +8189,14 @@
8232
8189
  }
8233
8190
 
8234
8191
 
8192
+ function addInitialKeywords(self) {
8193
+ for (var name in self._opts.keywords) {
8194
+ var keyword = self._opts.keywords[name];
8195
+ self.addKeyword(name, keyword);
8196
+ }
8197
+ }
8198
+
8199
+
8235
8200
  function checkUnique(self, id) {
8236
8201
  if (self._schemas[id] || self._refs[id])
8237
8202
  throw new Error('schema with key or id "' + id + '" already exists');