z-schema 3.22.0 → 3.23.0

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.
@@ -3022,6 +3022,10 @@ var _isIP = require('./lib/isIP');
3022
3022
 
3023
3023
  var _isIP2 = _interopRequireDefault(_isIP);
3024
3024
 
3025
+ var _isIPRange = require('./lib/isIPRange');
3026
+
3027
+ var _isIPRange2 = _interopRequireDefault(_isIPRange);
3028
+
3025
3029
  var _isFQDN = require('./lib/isFQDN');
3026
3030
 
3027
3031
  var _isFQDN2 = _interopRequireDefault(_isFQDN);
@@ -3256,7 +3260,7 @@ var _toString2 = _interopRequireDefault(_toString);
3256
3260
 
3257
3261
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3258
3262
 
3259
- var version = '10.2.0';
3263
+ var version = '10.5.0';
3260
3264
 
3261
3265
  var validator = {
3262
3266
  version: version,
@@ -3271,6 +3275,7 @@ var validator = {
3271
3275
  isURL: _isURL2.default,
3272
3276
  isMACAddress: _isMACAddress2.default,
3273
3277
  isIP: _isIP2.default,
3278
+ isIPRange: _isIPRange2.default,
3274
3279
  isFQDN: _isFQDN2.default,
3275
3280
  isBoolean: _isBoolean2.default,
3276
3281
  isAlpha: _isAlpha2.default,
@@ -3334,7 +3339,7 @@ var validator = {
3334
3339
 
3335
3340
  exports.default = validator;
3336
3341
  module.exports = exports['default'];
3337
- },{"./lib/blacklist":6,"./lib/contains":7,"./lib/equals":8,"./lib/escape":9,"./lib/isAfter":10,"./lib/isAlpha":11,"./lib/isAlphanumeric":12,"./lib/isAscii":13,"./lib/isBase64":14,"./lib/isBefore":15,"./lib/isBoolean":16,"./lib/isByteLength":17,"./lib/isCreditCard":18,"./lib/isCurrency":19,"./lib/isDataURI":20,"./lib/isDecimal":21,"./lib/isDivisibleBy":22,"./lib/isEmail":23,"./lib/isEmpty":24,"./lib/isFQDN":25,"./lib/isFloat":26,"./lib/isFullWidth":27,"./lib/isHalfWidth":28,"./lib/isHash":29,"./lib/isHexColor":30,"./lib/isHexadecimal":31,"./lib/isIP":32,"./lib/isISBN":33,"./lib/isISIN":34,"./lib/isISO31661Alpha2":35,"./lib/isISO31661Alpha3":36,"./lib/isISO8601":37,"./lib/isISRC":38,"./lib/isISSN":39,"./lib/isIn":40,"./lib/isInt":41,"./lib/isJSON":42,"./lib/isLatLong":43,"./lib/isLength":44,"./lib/isLowercase":45,"./lib/isMACAddress":46,"./lib/isMD5":47,"./lib/isMimeType":48,"./lib/isMobilePhone":49,"./lib/isMongoId":50,"./lib/isMultibyte":51,"./lib/isNumeric":52,"./lib/isPort":53,"./lib/isPostalCode":54,"./lib/isRFC3339":55,"./lib/isSurrogatePair":56,"./lib/isURL":57,"./lib/isUUID":58,"./lib/isUppercase":59,"./lib/isVariableWidth":60,"./lib/isWhitelisted":61,"./lib/ltrim":62,"./lib/matches":63,"./lib/normalizeEmail":64,"./lib/rtrim":65,"./lib/stripLow":66,"./lib/toBoolean":67,"./lib/toDate":68,"./lib/toFloat":69,"./lib/toInt":70,"./lib/trim":71,"./lib/unescape":72,"./lib/util/toString":75,"./lib/whitelist":76}],5:[function(require,module,exports){
3342
+ },{"./lib/blacklist":6,"./lib/contains":7,"./lib/equals":8,"./lib/escape":9,"./lib/isAfter":10,"./lib/isAlpha":11,"./lib/isAlphanumeric":12,"./lib/isAscii":13,"./lib/isBase64":14,"./lib/isBefore":15,"./lib/isBoolean":16,"./lib/isByteLength":17,"./lib/isCreditCard":18,"./lib/isCurrency":19,"./lib/isDataURI":20,"./lib/isDecimal":21,"./lib/isDivisibleBy":22,"./lib/isEmail":23,"./lib/isEmpty":24,"./lib/isFQDN":25,"./lib/isFloat":26,"./lib/isFullWidth":27,"./lib/isHalfWidth":28,"./lib/isHash":29,"./lib/isHexColor":30,"./lib/isHexadecimal":31,"./lib/isIP":32,"./lib/isIPRange":33,"./lib/isISBN":34,"./lib/isISIN":35,"./lib/isISO31661Alpha2":36,"./lib/isISO31661Alpha3":37,"./lib/isISO8601":38,"./lib/isISRC":39,"./lib/isISSN":40,"./lib/isIn":41,"./lib/isInt":42,"./lib/isJSON":43,"./lib/isLatLong":44,"./lib/isLength":45,"./lib/isLowercase":46,"./lib/isMACAddress":47,"./lib/isMD5":48,"./lib/isMimeType":49,"./lib/isMobilePhone":50,"./lib/isMongoId":51,"./lib/isMultibyte":52,"./lib/isNumeric":53,"./lib/isPort":54,"./lib/isPostalCode":55,"./lib/isRFC3339":56,"./lib/isSurrogatePair":57,"./lib/isURL":58,"./lib/isUUID":59,"./lib/isUppercase":60,"./lib/isVariableWidth":61,"./lib/isWhitelisted":62,"./lib/ltrim":63,"./lib/matches":64,"./lib/normalizeEmail":65,"./lib/rtrim":66,"./lib/stripLow":67,"./lib/toBoolean":68,"./lib/toDate":69,"./lib/toFloat":70,"./lib/toInt":71,"./lib/trim":72,"./lib/unescape":73,"./lib/util/toString":77,"./lib/whitelist":78}],5:[function(require,module,exports){
3338
3343
  'use strict';
3339
3344
 
3340
3345
  Object.defineProperty(exports, "__esModule", {
@@ -3363,6 +3368,7 @@ var alpha = exports.alpha = {
3363
3368
  'sv-SE': /^[A-ZÅÄÖ]+$/i,
3364
3369
  'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i,
3365
3370
  'uk-UA': /^[А-ЩЬЮЯЄIЇҐі]+$/i,
3371
+ 'ku-IQ': /^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
3366
3372
  ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/
3367
3373
  };
3368
3374
 
@@ -3389,6 +3395,7 @@ var alphanumeric = exports.alphanumeric = {
3389
3395
  'sv-SE': /^[0-9A-ZÅÄÖ]+$/i,
3390
3396
  'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i,
3391
3397
  'uk-UA': /^[0-9А-ЩЬЮЯЄIЇҐі]+$/i,
3398
+ 'ku-IQ': /^[٠١٢٣٤٥٦٧٨٩0-9ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
3392
3399
  ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/
3393
3400
  };
3394
3401
 
@@ -3418,7 +3425,7 @@ for (var _locale, _i = 0; _i < arabicLocales.length; _i++) {
3418
3425
 
3419
3426
  // Source: https://en.wikipedia.org/wiki/Decimal_mark
3420
3427
  var dotDecimal = exports.dotDecimal = [];
3421
- var commaDecimal = exports.commaDecimal = ['bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'es-ES', 'fr-FR', 'it-IT', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-Pl', 'pt-PT', 'ru-RU', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA'];
3428
+ var commaDecimal = exports.commaDecimal = ['bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'es-ES', 'fr-FR', 'it-IT', 'ku-IQ', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-PL', 'pt-PT', 'ru-RU', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA'];
3422
3429
 
3423
3430
  for (var _i2 = 0; _i2 < dotDecimal.length; _i2++) {
3424
3431
  decimal[dotDecimal[_i2]] = decimal['en-US'];
@@ -3431,6 +3438,11 @@ for (var _i3 = 0; _i3 < commaDecimal.length; _i3++) {
3431
3438
  alpha['pt-BR'] = alpha['pt-PT'];
3432
3439
  alphanumeric['pt-BR'] = alphanumeric['pt-PT'];
3433
3440
  decimal['pt-BR'] = decimal['pt-PT'];
3441
+
3442
+ // see #862
3443
+ alpha['pl-Pl'] = alpha['pl-PL'];
3444
+ alphanumeric['pl-Pl'] = alphanumeric['pl-PL'];
3445
+ decimal['pl-Pl'] = decimal['pl-PL'];
3434
3446
  },{}],6:[function(require,module,exports){
3435
3447
  'use strict';
3436
3448
 
@@ -3450,7 +3462,7 @@ function blacklist(str, chars) {
3450
3462
  return str.replace(new RegExp('[' + chars + ']+', 'g'), '');
3451
3463
  }
3452
3464
  module.exports = exports['default'];
3453
- },{"./util/assertString":73}],7:[function(require,module,exports){
3465
+ },{"./util/assertString":74}],7:[function(require,module,exports){
3454
3466
  'use strict';
3455
3467
 
3456
3468
  Object.defineProperty(exports, "__esModule", {
@@ -3473,7 +3485,7 @@ function contains(str, elem) {
3473
3485
  return str.indexOf((0, _toString2.default)(elem)) >= 0;
3474
3486
  }
3475
3487
  module.exports = exports['default'];
3476
- },{"./util/assertString":73,"./util/toString":75}],8:[function(require,module,exports){
3488
+ },{"./util/assertString":74,"./util/toString":77}],8:[function(require,module,exports){
3477
3489
  'use strict';
3478
3490
 
3479
3491
  Object.defineProperty(exports, "__esModule", {
@@ -3492,7 +3504,7 @@ function equals(str, comparison) {
3492
3504
  return str === comparison;
3493
3505
  }
3494
3506
  module.exports = exports['default'];
3495
- },{"./util/assertString":73}],9:[function(require,module,exports){
3507
+ },{"./util/assertString":74}],9:[function(require,module,exports){
3496
3508
  'use strict';
3497
3509
 
3498
3510
  Object.defineProperty(exports, "__esModule", {
@@ -3511,7 +3523,7 @@ function escape(str) {
3511
3523
  return str.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\//g, '&#x2F;').replace(/\\/g, '&#x5C;').replace(/`/g, '&#96;');
3512
3524
  }
3513
3525
  module.exports = exports['default'];
3514
- },{"./util/assertString":73}],10:[function(require,module,exports){
3526
+ },{"./util/assertString":74}],10:[function(require,module,exports){
3515
3527
  'use strict';
3516
3528
 
3517
3529
  Object.defineProperty(exports, "__esModule", {
@@ -3538,7 +3550,7 @@ function isAfter(str) {
3538
3550
  return !!(original && comparison && original > comparison);
3539
3551
  }
3540
3552
  module.exports = exports['default'];
3541
- },{"./toDate":68,"./util/assertString":73}],11:[function(require,module,exports){
3553
+ },{"./toDate":69,"./util/assertString":74}],11:[function(require,module,exports){
3542
3554
  'use strict';
3543
3555
 
3544
3556
  Object.defineProperty(exports, "__esModule", {
@@ -3564,7 +3576,7 @@ function isAlpha(str) {
3564
3576
  throw new Error('Invalid locale \'' + locale + '\'');
3565
3577
  }
3566
3578
  module.exports = exports['default'];
3567
- },{"./alpha":5,"./util/assertString":73}],12:[function(require,module,exports){
3579
+ },{"./alpha":5,"./util/assertString":74}],12:[function(require,module,exports){
3568
3580
  'use strict';
3569
3581
 
3570
3582
  Object.defineProperty(exports, "__esModule", {
@@ -3590,7 +3602,7 @@ function isAlphanumeric(str) {
3590
3602
  throw new Error('Invalid locale \'' + locale + '\'');
3591
3603
  }
3592
3604
  module.exports = exports['default'];
3593
- },{"./alpha":5,"./util/assertString":73}],13:[function(require,module,exports){
3605
+ },{"./alpha":5,"./util/assertString":74}],13:[function(require,module,exports){
3594
3606
  'use strict';
3595
3607
 
3596
3608
  Object.defineProperty(exports, "__esModule", {
@@ -3613,7 +3625,7 @@ function isAscii(str) {
3613
3625
  return ascii.test(str);
3614
3626
  }
3615
3627
  module.exports = exports['default'];
3616
- },{"./util/assertString":73}],14:[function(require,module,exports){
3628
+ },{"./util/assertString":74}],14:[function(require,module,exports){
3617
3629
  'use strict';
3618
3630
 
3619
3631
  Object.defineProperty(exports, "__esModule", {
@@ -3639,7 +3651,7 @@ function isBase64(str) {
3639
3651
  return firstPaddingChar === -1 || firstPaddingChar === len - 1 || firstPaddingChar === len - 2 && str[len - 1] === '=';
3640
3652
  }
3641
3653
  module.exports = exports['default'];
3642
- },{"./util/assertString":73}],15:[function(require,module,exports){
3654
+ },{"./util/assertString":74}],15:[function(require,module,exports){
3643
3655
  'use strict';
3644
3656
 
3645
3657
  Object.defineProperty(exports, "__esModule", {
@@ -3666,7 +3678,7 @@ function isBefore(str) {
3666
3678
  return !!(original && comparison && original < comparison);
3667
3679
  }
3668
3680
  module.exports = exports['default'];
3669
- },{"./toDate":68,"./util/assertString":73}],16:[function(require,module,exports){
3681
+ },{"./toDate":69,"./util/assertString":74}],16:[function(require,module,exports){
3670
3682
  'use strict';
3671
3683
 
3672
3684
  Object.defineProperty(exports, "__esModule", {
@@ -3685,7 +3697,7 @@ function isBoolean(str) {
3685
3697
  return ['true', 'false', '1', '0'].indexOf(str) >= 0;
3686
3698
  }
3687
3699
  module.exports = exports['default'];
3688
- },{"./util/assertString":73}],17:[function(require,module,exports){
3700
+ },{"./util/assertString":74}],17:[function(require,module,exports){
3689
3701
  'use strict';
3690
3702
 
3691
3703
  Object.defineProperty(exports, "__esModule", {
@@ -3719,7 +3731,7 @@ function isByteLength(str, options) {
3719
3731
  return len >= min && (typeof max === 'undefined' || len <= max);
3720
3732
  }
3721
3733
  module.exports = exports['default'];
3722
- },{"./util/assertString":73}],18:[function(require,module,exports){
3734
+ },{"./util/assertString":74}],18:[function(require,module,exports){
3723
3735
  'use strict';
3724
3736
 
3725
3737
  Object.defineProperty(exports, "__esModule", {
@@ -3765,7 +3777,7 @@ function isCreditCard(str) {
3765
3777
  return !!(sum % 10 === 0 ? sanitized : false);
3766
3778
  }
3767
3779
  module.exports = exports['default'];
3768
- },{"./util/assertString":73}],19:[function(require,module,exports){
3780
+ },{"./util/assertString":74}],19:[function(require,module,exports){
3769
3781
  'use strict';
3770
3782
 
3771
3783
  Object.defineProperty(exports, "__esModule", {
@@ -3858,7 +3870,7 @@ function isCurrency(str, options) {
3858
3870
  return currencyRegex(options).test(str);
3859
3871
  }
3860
3872
  module.exports = exports['default'];
3861
- },{"./util/assertString":73,"./util/merge":74}],20:[function(require,module,exports){
3873
+ },{"./util/assertString":74,"./util/merge":76}],20:[function(require,module,exports){
3862
3874
  'use strict';
3863
3875
 
3864
3876
  Object.defineProperty(exports, "__esModule", {
@@ -3908,7 +3920,7 @@ function isDataURI(str) {
3908
3920
  return true;
3909
3921
  }
3910
3922
  module.exports = exports['default'];
3911
- },{"./util/assertString":73}],21:[function(require,module,exports){
3923
+ },{"./util/assertString":74}],21:[function(require,module,exports){
3912
3924
  'use strict';
3913
3925
 
3914
3926
  Object.defineProperty(exports, "__esModule", {
@@ -3924,6 +3936,10 @@ var _assertString = require('./util/assertString');
3924
3936
 
3925
3937
  var _assertString2 = _interopRequireDefault(_assertString);
3926
3938
 
3939
+ var _includes = require('./util/includes');
3940
+
3941
+ var _includes2 = _interopRequireDefault(_includes);
3942
+
3927
3943
  var _alpha = require('./alpha');
3928
3944
 
3929
3945
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -3945,12 +3961,12 @@ function isDecimal(str, options) {
3945
3961
  (0, _assertString2.default)(str);
3946
3962
  options = (0, _merge2.default)(options, default_decimal_options);
3947
3963
  if (options.locale in _alpha.decimal) {
3948
- return !blacklist.includes(str.replace(/ /g, '')) && decimalRegExp(options).test(str);
3964
+ return !(0, _includes2.default)(blacklist, str.replace(/ /g, '')) && decimalRegExp(options).test(str);
3949
3965
  }
3950
3966
  throw new Error('Invalid locale \'' + options.locale + '\'');
3951
3967
  }
3952
3968
  module.exports = exports['default'];
3953
- },{"./alpha":5,"./util/assertString":73,"./util/merge":74}],22:[function(require,module,exports){
3969
+ },{"./alpha":5,"./util/assertString":74,"./util/includes":75,"./util/merge":76}],22:[function(require,module,exports){
3954
3970
  'use strict';
3955
3971
 
3956
3972
  Object.defineProperty(exports, "__esModule", {
@@ -3973,7 +3989,7 @@ function isDivisibleBy(str, num) {
3973
3989
  return (0, _toFloat2.default)(str) % parseInt(num, 10) === 0;
3974
3990
  }
3975
3991
  module.exports = exports['default'];
3976
- },{"./toFloat":69,"./util/assertString":73}],23:[function(require,module,exports){
3992
+ },{"./toFloat":70,"./util/assertString":74}],23:[function(require,module,exports){
3977
3993
  'use strict';
3978
3994
 
3979
3995
  Object.defineProperty(exports, "__esModule", {
@@ -3997,6 +4013,10 @@ var _isFQDN = require('./isFQDN');
3997
4013
 
3998
4014
  var _isFQDN2 = _interopRequireDefault(_isFQDN);
3999
4015
 
4016
+ var _isIP = require('./isIP');
4017
+
4018
+ var _isIP2 = _interopRequireDefault(_isIP);
4019
+
4000
4020
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4001
4021
 
4002
4022
  var default_email_options = {
@@ -4010,6 +4030,7 @@ var default_email_options = {
4010
4030
  /* eslint-disable no-control-regex */
4011
4031
  var displayName = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\,\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i;
4012
4032
  var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i;
4033
+ var gmailUserPart = /^[a-z\d]+$/;
4013
4034
  var quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i;
4014
4035
  var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i;
4015
4036
  var quotedEmailUserUtf8 = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i;
@@ -4035,7 +4056,7 @@ function isEmail(str, options) {
4035
4056
 
4036
4057
  var lower_domain = domain.toLowerCase();
4037
4058
 
4038
- if (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com') {
4059
+ if (options.domain_specific_validation && (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com')) {
4039
4060
  /*
4040
4061
  Previously we removed dots for gmail addresses before validating.
4041
4062
  This was removed because it allows `multiple..dots@gmail.com`
@@ -4044,6 +4065,21 @@ function isEmail(str, options) {
4044
4065
  should be done in normalizeEmail
4045
4066
  */
4046
4067
  user = user.toLowerCase();
4068
+
4069
+ // Removing sub-address from username before gmail validation
4070
+ var username = user.split('+')[0];
4071
+
4072
+ // Dots are not included in gmail length restriction
4073
+ if (!(0, _isByteLength2.default)(username.replace('.', ''), { min: 6, max: 30 })) {
4074
+ return false;
4075
+ }
4076
+
4077
+ var _user_parts = username.split('.');
4078
+ for (var i = 0; i < _user_parts.length; i++) {
4079
+ if (!gmailUserPart.test(_user_parts[i])) {
4080
+ return false;
4081
+ }
4082
+ }
4047
4083
  }
4048
4084
 
4049
4085
  if (!(0, _isByteLength2.default)(user, { max: 64 }) || !(0, _isByteLength2.default)(domain, { max: 254 })) {
@@ -4051,7 +4087,21 @@ function isEmail(str, options) {
4051
4087
  }
4052
4088
 
4053
4089
  if (!(0, _isFQDN2.default)(domain, { require_tld: options.require_tld })) {
4054
- return false;
4090
+ if (!options.allow_ip_domain) {
4091
+ return false;
4092
+ }
4093
+
4094
+ if (!(0, _isIP2.default)(domain)) {
4095
+ if (!domain.startsWith('[') || !domain.endsWith(']')) {
4096
+ return false;
4097
+ }
4098
+
4099
+ var noBracketdomain = domain.substr(1, domain.length - 2);
4100
+
4101
+ if (noBracketdomain.length === 0 || !(0, _isIP2.default)(noBracketdomain)) {
4102
+ return false;
4103
+ }
4104
+ }
4055
4105
  }
4056
4106
 
4057
4107
  if (user[0] === '"') {
@@ -4062,8 +4112,8 @@ function isEmail(str, options) {
4062
4112
  var pattern = options.allow_utf8_local_part ? emailUserUtf8Part : emailUserPart;
4063
4113
 
4064
4114
  var user_parts = user.split('.');
4065
- for (var i = 0; i < user_parts.length; i++) {
4066
- if (!pattern.test(user_parts[i])) {
4115
+ for (var _i = 0; _i < user_parts.length; _i++) {
4116
+ if (!pattern.test(user_parts[_i])) {
4067
4117
  return false;
4068
4118
  }
4069
4119
  }
@@ -4071,7 +4121,7 @@ function isEmail(str, options) {
4071
4121
  return true;
4072
4122
  }
4073
4123
  module.exports = exports['default'];
4074
- },{"./isByteLength":17,"./isFQDN":25,"./util/assertString":73,"./util/merge":74}],24:[function(require,module,exports){
4124
+ },{"./isByteLength":17,"./isFQDN":25,"./isIP":32,"./util/assertString":74,"./util/merge":76}],24:[function(require,module,exports){
4075
4125
  'use strict';
4076
4126
 
4077
4127
  Object.defineProperty(exports, "__esModule", {
@@ -4090,7 +4140,7 @@ function isEmpty(str) {
4090
4140
  return str.length === 0;
4091
4141
  }
4092
4142
  module.exports = exports['default'];
4093
- },{"./util/assertString":73}],25:[function(require,module,exports){
4143
+ },{"./util/assertString":74}],25:[function(require,module,exports){
4094
4144
  'use strict';
4095
4145
 
4096
4146
  Object.defineProperty(exports, "__esModule", {
@@ -4157,7 +4207,7 @@ function isFQDN(str, options) {
4157
4207
  return true;
4158
4208
  }
4159
4209
  module.exports = exports['default'];
4160
- },{"./util/assertString":73,"./util/merge":74}],26:[function(require,module,exports){
4210
+ },{"./util/assertString":74,"./util/merge":76}],26:[function(require,module,exports){
4161
4211
  'use strict';
4162
4212
 
4163
4213
  Object.defineProperty(exports, "__esModule", {
@@ -4184,7 +4234,7 @@ function isFloat(str, options) {
4184
4234
  return float.test(str) && (!options.hasOwnProperty('min') || value >= options.min) && (!options.hasOwnProperty('max') || value <= options.max) && (!options.hasOwnProperty('lt') || value < options.lt) && (!options.hasOwnProperty('gt') || value > options.gt);
4185
4235
  }
4186
4236
  module.exports = exports['default'];
4187
- },{"./alpha":5,"./util/assertString":73}],27:[function(require,module,exports){
4237
+ },{"./alpha":5,"./util/assertString":74}],27:[function(require,module,exports){
4188
4238
  'use strict';
4189
4239
 
4190
4240
  Object.defineProperty(exports, "__esModule", {
@@ -4205,7 +4255,7 @@ function isFullWidth(str) {
4205
4255
  (0, _assertString2.default)(str);
4206
4256
  return fullWidth.test(str);
4207
4257
  }
4208
- },{"./util/assertString":73}],28:[function(require,module,exports){
4258
+ },{"./util/assertString":74}],28:[function(require,module,exports){
4209
4259
  'use strict';
4210
4260
 
4211
4261
  Object.defineProperty(exports, "__esModule", {
@@ -4226,7 +4276,7 @@ function isHalfWidth(str) {
4226
4276
  (0, _assertString2.default)(str);
4227
4277
  return halfWidth.test(str);
4228
4278
  }
4229
- },{"./util/assertString":73}],29:[function(require,module,exports){
4279
+ },{"./util/assertString":74}],29:[function(require,module,exports){
4230
4280
  'use strict';
4231
4281
 
4232
4282
  Object.defineProperty(exports, "__esModule", {
@@ -4262,7 +4312,7 @@ function isHash(str, algorithm) {
4262
4312
  return hash.test(str);
4263
4313
  }
4264
4314
  module.exports = exports['default'];
4265
- },{"./util/assertString":73}],30:[function(require,module,exports){
4315
+ },{"./util/assertString":74}],30:[function(require,module,exports){
4266
4316
  'use strict';
4267
4317
 
4268
4318
  Object.defineProperty(exports, "__esModule", {
@@ -4283,7 +4333,7 @@ function isHexColor(str) {
4283
4333
  return hexcolor.test(str);
4284
4334
  }
4285
4335
  module.exports = exports['default'];
4286
- },{"./util/assertString":73}],31:[function(require,module,exports){
4336
+ },{"./util/assertString":74}],31:[function(require,module,exports){
4287
4337
  'use strict';
4288
4338
 
4289
4339
  Object.defineProperty(exports, "__esModule", {
@@ -4304,7 +4354,7 @@ function isHexadecimal(str) {
4304
4354
  return hexadecimal.test(str);
4305
4355
  }
4306
4356
  module.exports = exports['default'];
4307
- },{"./util/assertString":73}],32:[function(require,module,exports){
4357
+ },{"./util/assertString":74}],32:[function(require,module,exports){
4308
4358
  'use strict';
4309
4359
 
4310
4360
  Object.defineProperty(exports, "__esModule", {
@@ -4386,7 +4436,48 @@ function isIP(str) {
4386
4436
  return false;
4387
4437
  }
4388
4438
  module.exports = exports['default'];
4389
- },{"./util/assertString":73}],33:[function(require,module,exports){
4439
+ },{"./util/assertString":74}],33:[function(require,module,exports){
4440
+ 'use strict';
4441
+
4442
+ Object.defineProperty(exports, "__esModule", {
4443
+ value: true
4444
+ });
4445
+ exports.default = isIPRange;
4446
+
4447
+ var _assertString = require('./util/assertString');
4448
+
4449
+ var _assertString2 = _interopRequireDefault(_assertString);
4450
+
4451
+ var _isIP = require('./isIP');
4452
+
4453
+ var _isIP2 = _interopRequireDefault(_isIP);
4454
+
4455
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4456
+
4457
+ var subnetMaybe = /^\d{1,2}$/;
4458
+
4459
+ function isIPRange(str) {
4460
+ (0, _assertString2.default)(str);
4461
+ var parts = str.split('/');
4462
+
4463
+ // parts[0] -> ip, parts[1] -> subnet
4464
+ if (parts.length !== 2) {
4465
+ return false;
4466
+ }
4467
+
4468
+ if (!subnetMaybe.test(parts[1])) {
4469
+ return false;
4470
+ }
4471
+
4472
+ // Disallow preceding 0 i.e. 01, 02, ...
4473
+ if (parts[1].length > 1 && parts[1].startsWith('0')) {
4474
+ return false;
4475
+ }
4476
+
4477
+ return (0, _isIP2.default)(parts[0], 4) && parts[1] <= 32 && parts[1] >= 0;
4478
+ }
4479
+ module.exports = exports['default'];
4480
+ },{"./isIP":32,"./util/assertString":74}],34:[function(require,module,exports){
4390
4481
  'use strict';
4391
4482
 
4392
4483
  Object.defineProperty(exports, "__esModule", {
@@ -4444,7 +4535,7 @@ function isISBN(str) {
4444
4535
  return false;
4445
4536
  }
4446
4537
  module.exports = exports['default'];
4447
- },{"./util/assertString":73}],34:[function(require,module,exports){
4538
+ },{"./util/assertString":74}],35:[function(require,module,exports){
4448
4539
  'use strict';
4449
4540
 
4450
4541
  Object.defineProperty(exports, "__esModule", {
@@ -4493,7 +4584,7 @@ function isISIN(str) {
4493
4584
  return parseInt(str.substr(str.length - 1), 10) === (10000 - sum) % 10;
4494
4585
  }
4495
4586
  module.exports = exports['default'];
4496
- },{"./util/assertString":73}],35:[function(require,module,exports){
4587
+ },{"./util/assertString":74}],36:[function(require,module,exports){
4497
4588
  'use strict';
4498
4589
 
4499
4590
  Object.defineProperty(exports, "__esModule", {
@@ -4505,6 +4596,10 @@ var _assertString = require('./util/assertString');
4505
4596
 
4506
4597
  var _assertString2 = _interopRequireDefault(_assertString);
4507
4598
 
4599
+ var _includes = require('./util/includes');
4600
+
4601
+ var _includes2 = _interopRequireDefault(_includes);
4602
+
4508
4603
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4509
4604
 
4510
4605
  // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
@@ -4512,10 +4607,10 @@ var validISO31661Alpha2CountriesCodes = ['AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM
4512
4607
 
4513
4608
  function isISO31661Alpha2(str) {
4514
4609
  (0, _assertString2.default)(str);
4515
- return validISO31661Alpha2CountriesCodes.includes(str.toUpperCase());
4610
+ return (0, _includes2.default)(validISO31661Alpha2CountriesCodes, str.toUpperCase());
4516
4611
  }
4517
4612
  module.exports = exports['default'];
4518
- },{"./util/assertString":73}],36:[function(require,module,exports){
4613
+ },{"./util/assertString":74,"./util/includes":75}],37:[function(require,module,exports){
4519
4614
  'use strict';
4520
4615
 
4521
4616
  Object.defineProperty(exports, "__esModule", {
@@ -4527,6 +4622,10 @@ var _assertString = require('./util/assertString');
4527
4622
 
4528
4623
  var _assertString2 = _interopRequireDefault(_assertString);
4529
4624
 
4625
+ var _includes = require('./util/includes');
4626
+
4627
+ var _includes2 = _interopRequireDefault(_includes);
4628
+
4530
4629
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4531
4630
 
4532
4631
  // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
@@ -4534,10 +4633,10 @@ var validISO31661Alpha3CountriesCodes = ['AFG', 'ALA', 'ALB', 'DZA', 'ASM', 'AND
4534
4633
 
4535
4634
  function isISO31661Alpha3(str) {
4536
4635
  (0, _assertString2.default)(str);
4537
- return validISO31661Alpha3CountriesCodes.includes(str.toUpperCase());
4636
+ return (0, _includes2.default)(validISO31661Alpha3CountriesCodes, str.toUpperCase());
4538
4637
  }
4539
4638
  module.exports = exports['default'];
4540
- },{"./util/assertString":73}],37:[function(require,module,exports){
4639
+ },{"./util/assertString":74,"./util/includes":75}],38:[function(require,module,exports){
4541
4640
  'use strict';
4542
4641
 
4543
4642
  Object.defineProperty(exports, "__esModule", {
@@ -4561,7 +4660,7 @@ function isISO8601(str) {
4561
4660
  return iso8601.test(str);
4562
4661
  }
4563
4662
  module.exports = exports['default'];
4564
- },{"./util/assertString":73}],38:[function(require,module,exports){
4663
+ },{"./util/assertString":74}],39:[function(require,module,exports){
4565
4664
  'use strict';
4566
4665
 
4567
4666
  Object.defineProperty(exports, "__esModule", {
@@ -4583,7 +4682,7 @@ function isISRC(str) {
4583
4682
  return isrc.test(str);
4584
4683
  }
4585
4684
  module.exports = exports['default'];
4586
- },{"./util/assertString":73}],39:[function(require,module,exports){
4685
+ },{"./util/assertString":74}],40:[function(require,module,exports){
4587
4686
  'use strict';
4588
4687
 
4589
4688
  Object.defineProperty(exports, "__esModule", {
@@ -4609,40 +4708,16 @@ function isISSN(str) {
4609
4708
  if (!testIssn.test(str)) {
4610
4709
  return false;
4611
4710
  }
4612
- var issnDigits = str.replace('-', '');
4613
- var position = 8;
4711
+ var digits = str.replace('-', '').toUpperCase();
4614
4712
  var checksum = 0;
4615
- var _iteratorNormalCompletion = true;
4616
- var _didIteratorError = false;
4617
- var _iteratorError = undefined;
4618
-
4619
- try {
4620
- for (var _iterator = issnDigits[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
4621
- var digit = _step.value;
4622
-
4623
- var digitValue = digit.toUpperCase() === 'X' ? 10 : +digit;
4624
- checksum += digitValue * position;
4625
- --position;
4626
- }
4627
- } catch (err) {
4628
- _didIteratorError = true;
4629
- _iteratorError = err;
4630
- } finally {
4631
- try {
4632
- if (!_iteratorNormalCompletion && _iterator.return) {
4633
- _iterator.return();
4634
- }
4635
- } finally {
4636
- if (_didIteratorError) {
4637
- throw _iteratorError;
4638
- }
4639
- }
4713
+ for (var i = 0; i < digits.length; i++) {
4714
+ var digit = digits[i];
4715
+ checksum += (digit === 'X' ? 10 : +digit) * (8 - i);
4640
4716
  }
4641
-
4642
4717
  return checksum % 11 === 0;
4643
4718
  }
4644
4719
  module.exports = exports['default'];
4645
- },{"./util/assertString":73}],40:[function(require,module,exports){
4720
+ },{"./util/assertString":74}],41:[function(require,module,exports){
4646
4721
  'use strict';
4647
4722
 
4648
4723
  Object.defineProperty(exports, "__esModule", {
@@ -4682,7 +4757,7 @@ function isIn(str, options) {
4682
4757
  return false;
4683
4758
  }
4684
4759
  module.exports = exports['default'];
4685
- },{"./util/assertString":73,"./util/toString":75}],41:[function(require,module,exports){
4760
+ },{"./util/assertString":74,"./util/toString":77}],42:[function(require,module,exports){
4686
4761
  'use strict';
4687
4762
 
4688
4763
  Object.defineProperty(exports, "__esModule", {
@@ -4716,7 +4791,7 @@ function isInt(str, options) {
4716
4791
  return regex.test(str) && minCheckPassed && maxCheckPassed && ltCheckPassed && gtCheckPassed;
4717
4792
  }
4718
4793
  module.exports = exports['default'];
4719
- },{"./util/assertString":73}],42:[function(require,module,exports){
4794
+ },{"./util/assertString":74}],43:[function(require,module,exports){
4720
4795
  'use strict';
4721
4796
 
4722
4797
  Object.defineProperty(exports, "__esModule", {
@@ -4742,7 +4817,7 @@ function isJSON(str) {
4742
4817
  return false;
4743
4818
  }
4744
4819
  module.exports = exports['default'];
4745
- },{"./util/assertString":73}],43:[function(require,module,exports){
4820
+ },{"./util/assertString":74}],44:[function(require,module,exports){
4746
4821
  'use strict';
4747
4822
 
4748
4823
  Object.defineProperty(exports, "__esModule", {
@@ -4766,7 +4841,7 @@ var lat = /^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/;
4766
4841
  var long = /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/;
4767
4842
 
4768
4843
  module.exports = exports['default'];
4769
- },{"./util/assertString":73}],44:[function(require,module,exports){
4844
+ },{"./util/assertString":74}],45:[function(require,module,exports){
4770
4845
  'use strict';
4771
4846
 
4772
4847
  Object.defineProperty(exports, "__esModule", {
@@ -4801,7 +4876,7 @@ function isLength(str, options) {
4801
4876
  return len >= min && (typeof max === 'undefined' || len <= max);
4802
4877
  }
4803
4878
  module.exports = exports['default'];
4804
- },{"./util/assertString":73}],45:[function(require,module,exports){
4879
+ },{"./util/assertString":74}],46:[function(require,module,exports){
4805
4880
  'use strict';
4806
4881
 
4807
4882
  Object.defineProperty(exports, "__esModule", {
@@ -4820,7 +4895,7 @@ function isLowercase(str) {
4820
4895
  return str === str.toLowerCase();
4821
4896
  }
4822
4897
  module.exports = exports['default'];
4823
- },{"./util/assertString":73}],46:[function(require,module,exports){
4898
+ },{"./util/assertString":74}],47:[function(require,module,exports){
4824
4899
  'use strict';
4825
4900
 
4826
4901
  Object.defineProperty(exports, "__esModule", {
@@ -4835,13 +4910,17 @@ var _assertString2 = _interopRequireDefault(_assertString);
4835
4910
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4836
4911
 
4837
4912
  var macAddress = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/;
4913
+ var macAddressNoColons = /^([0-9a-fA-F]){12}$/;
4838
4914
 
4839
- function isMACAddress(str) {
4915
+ function isMACAddress(str, options) {
4840
4916
  (0, _assertString2.default)(str);
4917
+ if (options && options.no_colons) {
4918
+ return macAddressNoColons.test(str);
4919
+ }
4841
4920
  return macAddress.test(str);
4842
4921
  }
4843
4922
  module.exports = exports['default'];
4844
- },{"./util/assertString":73}],47:[function(require,module,exports){
4923
+ },{"./util/assertString":74}],48:[function(require,module,exports){
4845
4924
  'use strict';
4846
4925
 
4847
4926
  Object.defineProperty(exports, "__esModule", {
@@ -4862,7 +4941,7 @@ function isMD5(str) {
4862
4941
  return md5.test(str);
4863
4942
  }
4864
4943
  module.exports = exports['default'];
4865
- },{"./util/assertString":73}],48:[function(require,module,exports){
4944
+ },{"./util/assertString":74}],49:[function(require,module,exports){
4866
4945
  'use strict';
4867
4946
 
4868
4947
  Object.defineProperty(exports, "__esModule", {
@@ -4915,7 +4994,7 @@ function isMimeType(str) {
4915
4994
  return mimeTypeSimple.test(str) || mimeTypeText.test(str) || mimeTypeMultipart.test(str);
4916
4995
  }
4917
4996
  module.exports = exports['default'];
4918
- },{"./util/assertString":73}],49:[function(require,module,exports){
4997
+ },{"./util/assertString":74}],50:[function(require,module,exports){
4919
4998
  'use strict';
4920
4999
 
4921
5000
  Object.defineProperty(exports, "__esModule", {
@@ -4934,14 +5013,18 @@ var phones = {
4934
5013
  'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/,
4935
5014
  'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/,
4936
5015
  'ar-EG': /^((\+?20)|0)?1[012]\d{8}$/,
5016
+ 'ar-IQ': /^(\+?964|0)?7[0-9]\d{8}$/,
4937
5017
  'ar-JO': /^(\+?962|0)?7[789]\d{7}$/,
5018
+ 'ar-KW': /^(\+?965)[569]\d{7}$/,
4938
5019
  'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/,
4939
5020
  'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/,
5021
+ 'ar-TN': /^(\+?216)?[2459]\d{7}$/,
4940
5022
  'be-BY': /^(\+?375)?(24|25|29|33|44)\d{7}$/,
4941
5023
  'bg-BG': /^(\+?359|0)?8[789]\d{7}$/,
5024
+ 'bn-BD': /\+?(88)?0?1[156789][0-9]{8}\b/,
4942
5025
  'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
4943
5026
  'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,
4944
- 'de-DE': /^(\+?49[ \.\-])?([\(]{1}[0-9]{1,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/,
5027
+ 'de-DE': /^(\+?49[ \.\-]?)?([\(]{1}[0-9]{1,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/,
4945
5028
  'el-GR': /^(\+?30|0)?(69\d{8})$/,
4946
5029
  'en-AU': /^(\+?61|0)4\d{8}$/,
4947
5030
  'en-GB': /^(\+?44|0)7\d{9}$/,
@@ -4949,13 +5032,13 @@ var phones = {
4949
5032
  'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
4950
5033
  'en-KE': /^(\+?254|0)?[7]\d{8}$/,
4951
5034
  'en-NG': /^(\+?234|0)?[789]\d{9}$/,
4952
- 'en-NZ': /^(\+?64|0)2\d{7,9}$/,
5035
+ 'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
4953
5036
  'en-PK': /^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/,
4954
5037
  'en-RW': /^(\+?250|0)?[7]\d{8}$/,
4955
5038
  'en-SG': /^(\+65)?[89]\d{7}$/,
4956
5039
  'en-TZ': /^(\+?255|0)?[67]\d{8}$/,
4957
5040
  'en-UG': /^(\+?256|0)?[7]\d{8}$/,
4958
- 'en-US': /^(\+?1)?[2-9]\d{2}[2-9](?!11)\d{6}$/,
5041
+ 'en-US': /^(\+?1?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/,
4959
5042
  'en-ZA': /^(\+?27|0)\d{9}$/,
4960
5043
  'en-ZM': /^(\+?26)?09[567]\d{7}$/,
4961
5044
  'es-ES': /^(\+?34)?(6\d{1}|7[1234])\d{7}$/,
@@ -4966,7 +5049,7 @@ var phones = {
4966
5049
  'fr-FR': /^(\+?33|0)[67]\d{8}$/,
4967
5050
  'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}/,
4968
5051
  'hu-HU': /^(\+?36)(20|30|70)\d{7}$/,
4969
- 'id-ID': /^(\+?62|0[1-9])[\s|\d]+$/,
5052
+ 'id-ID': /^(\+?62|0)(0?8?\d\d\s?\d?)([\s?|\d]{7,12})$/,
4970
5053
  'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/,
4971
5054
  'ja-JP': /^(\+?81|0)[789]0[ \-]?[1-9]\d{2}[ \-]?\d{5}$/,
4972
5055
  'kk-KZ': /^(\+?7|8)?7\d{9}$/,
@@ -4984,11 +5067,12 @@ var phones = {
4984
5067
  'ru-RU': /^(\+?7|8)?9\d{9}$/,
4985
5068
  'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
4986
5069
  'sr-RS': /^(\+3816|06)[- \d]{5,9}$/,
5070
+ 'sv-SE': /^(\+?46|0)[\s\-]?7[\s\-]?[02369]([\s\-]?\d){7}$/,
4987
5071
  'th-TH': /^(\+66|66|0)\d{9}$/,
4988
5072
  'tr-TR': /^(\+?90|0)?5\d{9}$/,
4989
5073
  'uk-UA': /^(\+?38|8)?0\d{9}$/,
4990
5074
  'vi-VN': /^(\+?84|0)?((1(2([0-9])|6([2-9])|88|99))|(9((?!5)[0-9])))([0-9]{7})$/,
4991
- 'zh-CN': /^(\+?0?86\-?)?1[3456789]\d{9}$/,
5075
+ 'zh-CN': /^((\+|00)86)?1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/,
4992
5076
  'zh-TW': /^(\+?886\-?|0)?9\d{8}$/
4993
5077
  };
4994
5078
  /* eslint-enable max-len */
@@ -5003,9 +5087,20 @@ function isMobilePhone(str, locale, options) {
5003
5087
  if (options && options.strictMode && !str.startsWith('+')) {
5004
5088
  return false;
5005
5089
  }
5006
- if (locale in phones) {
5090
+ if (Array.isArray(locale)) {
5091
+ return locale.some(function (key) {
5092
+ if (phones.hasOwnProperty(key)) {
5093
+ var phone = phones[key];
5094
+ if (phone.test(str)) {
5095
+ return true;
5096
+ }
5097
+ }
5098
+ return false;
5099
+ });
5100
+ } else if (locale in phones) {
5007
5101
  return phones[locale].test(str);
5008
- } else if (locale === 'any') {
5102
+ // alias falsey locale as 'any'
5103
+ } else if (!locale || locale === 'any') {
5009
5104
  for (var key in phones) {
5010
5105
  if (phones.hasOwnProperty(key)) {
5011
5106
  var phone = phones[key];
@@ -5019,7 +5114,7 @@ function isMobilePhone(str, locale, options) {
5019
5114
  throw new Error('Invalid locale \'' + locale + '\'');
5020
5115
  }
5021
5116
  module.exports = exports['default'];
5022
- },{"./util/assertString":73}],50:[function(require,module,exports){
5117
+ },{"./util/assertString":74}],51:[function(require,module,exports){
5023
5118
  'use strict';
5024
5119
 
5025
5120
  Object.defineProperty(exports, "__esModule", {
@@ -5042,7 +5137,7 @@ function isMongoId(str) {
5042
5137
  return (0, _isHexadecimal2.default)(str) && str.length === 24;
5043
5138
  }
5044
5139
  module.exports = exports['default'];
5045
- },{"./isHexadecimal":31,"./util/assertString":73}],51:[function(require,module,exports){
5140
+ },{"./isHexadecimal":31,"./util/assertString":74}],52:[function(require,module,exports){
5046
5141
  'use strict';
5047
5142
 
5048
5143
  Object.defineProperty(exports, "__esModule", {
@@ -5065,7 +5160,7 @@ function isMultibyte(str) {
5065
5160
  return multibyte.test(str);
5066
5161
  }
5067
5162
  module.exports = exports['default'];
5068
- },{"./util/assertString":73}],52:[function(require,module,exports){
5163
+ },{"./util/assertString":74}],53:[function(require,module,exports){
5069
5164
  'use strict';
5070
5165
 
5071
5166
  Object.defineProperty(exports, "__esModule", {
@@ -5080,13 +5175,17 @@ var _assertString2 = _interopRequireDefault(_assertString);
5080
5175
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5081
5176
 
5082
5177
  var numeric = /^[+-]?([0-9]*[.])?[0-9]+$/;
5178
+ var numericNoSymbols = /^[0-9]+$/;
5083
5179
 
5084
- function isNumeric(str) {
5180
+ function isNumeric(str, options) {
5085
5181
  (0, _assertString2.default)(str);
5182
+ if (options && options.no_symbols) {
5183
+ return numericNoSymbols.test(str);
5184
+ }
5086
5185
  return numeric.test(str);
5087
5186
  }
5088
5187
  module.exports = exports['default'];
5089
- },{"./util/assertString":73}],53:[function(require,module,exports){
5188
+ },{"./util/assertString":74}],54:[function(require,module,exports){
5090
5189
  'use strict';
5091
5190
 
5092
5191
  Object.defineProperty(exports, "__esModule", {
@@ -5104,7 +5203,7 @@ function isPort(str) {
5104
5203
  return (0, _isInt2.default)(str, { min: 0, max: 65535 });
5105
5204
  }
5106
5205
  module.exports = exports['default'];
5107
- },{"./isInt":41}],54:[function(require,module,exports){
5206
+ },{"./isInt":42}],55:[function(require,module,exports){
5108
5207
  'use strict';
5109
5208
 
5110
5209
  Object.defineProperty(exports, "__esModule", {
@@ -5143,6 +5242,7 @@ var fiveDigit = /^\d{5}$/;
5143
5242
  var sixDigit = /^\d{6}$/;
5144
5243
 
5145
5244
  var patterns = {
5245
+ AD: /^AD\d{3}$/,
5146
5246
  AT: fourDigit,
5147
5247
  AU: fourDigit,
5148
5248
  BE: fourDigit,
@@ -5153,11 +5253,14 @@ var patterns = {
5153
5253
  DE: fiveDigit,
5154
5254
  DK: fourDigit,
5155
5255
  DZ: fiveDigit,
5256
+ EE: fiveDigit,
5156
5257
  ES: fiveDigit,
5157
5258
  FI: fiveDigit,
5158
5259
  FR: /^\d{2}\s?\d{3}$/,
5159
5260
  GB: /^(gir\s?0aa|[a-z]{1,2}\d[\da-z]?\s?(\d[a-z]{2})?)$/i,
5160
5261
  GR: /^\d{3}\s?\d{2}$/,
5262
+ HR: /^([1-5]\d{4}$)/,
5263
+ HU: fourDigit,
5161
5264
  IL: fiveDigit,
5162
5265
  IN: sixDigit,
5163
5266
  IS: threeDigit,
@@ -5165,6 +5268,9 @@ var patterns = {
5165
5268
  JP: /^\d{3}\-\d{4}$/,
5166
5269
  KE: fiveDigit,
5167
5270
  LI: /^(948[5-9]|949[0-7])$/,
5271
+ LT: /^LT\-\d{5}$/,
5272
+ LU: fourDigit,
5273
+ LV: /^LV\-\d{4}$/,
5168
5274
  MX: fiveDigit,
5169
5275
  NL: /^\d{4}\s?[a-z]{2}$/i,
5170
5276
  NO: fourDigit,
@@ -5174,7 +5280,9 @@ var patterns = {
5174
5280
  RU: sixDigit,
5175
5281
  SA: fiveDigit,
5176
5282
  SE: /^\d{3}\s?\d{2}$/,
5283
+ SI: fourDigit,
5177
5284
  SK: /^\d{3}\s?\d{2}$/,
5285
+ TN: fourDigit,
5178
5286
  TW: /^\d{3}(\d{2})?$/,
5179
5287
  US: /^\d{5}(-\d{4})?$/,
5180
5288
  ZA: fourDigit,
@@ -5182,7 +5290,7 @@ var patterns = {
5182
5290
  };
5183
5291
 
5184
5292
  var locales = exports.locales = Object.keys(patterns);
5185
- },{"./util/assertString":73}],55:[function(require,module,exports){
5293
+ },{"./util/assertString":74}],56:[function(require,module,exports){
5186
5294
  'use strict';
5187
5295
 
5188
5296
  Object.defineProperty(exports, "__esModule", {
@@ -5222,7 +5330,7 @@ function isRFC3339(str) {
5222
5330
  return rfc3339.test(str);
5223
5331
  }
5224
5332
  module.exports = exports['default'];
5225
- },{"./util/assertString":73}],56:[function(require,module,exports){
5333
+ },{"./util/assertString":74}],57:[function(require,module,exports){
5226
5334
  'use strict';
5227
5335
 
5228
5336
  Object.defineProperty(exports, "__esModule", {
@@ -5243,7 +5351,7 @@ function isSurrogatePair(str) {
5243
5351
  return surrogatePair.test(str);
5244
5352
  }
5245
5353
  module.exports = exports['default'];
5246
- },{"./util/assertString":73}],57:[function(require,module,exports){
5354
+ },{"./util/assertString":74}],58:[function(require,module,exports){
5247
5355
  'use strict';
5248
5356
 
5249
5357
  Object.defineProperty(exports, "__esModule", {
@@ -5328,7 +5436,10 @@ function isURL(url, options) {
5328
5436
  }
5329
5437
  } else if (options.require_protocol) {
5330
5438
  return false;
5331
- } else if (options.allow_protocol_relative_urls && url.substr(0, 2) === '//') {
5439
+ } else if (url.substr(0, 2) === '//') {
5440
+ if (!options.allow_protocol_relative_urls) {
5441
+ return false;
5442
+ }
5332
5443
  split[0] = url.substr(2);
5333
5444
  }
5334
5445
  url = split.join('://');
@@ -5391,7 +5502,7 @@ function isURL(url, options) {
5391
5502
  return true;
5392
5503
  }
5393
5504
  module.exports = exports['default'];
5394
- },{"./isFQDN":25,"./isIP":32,"./util/assertString":73,"./util/merge":74}],58:[function(require,module,exports){
5505
+ },{"./isFQDN":25,"./isIP":32,"./util/assertString":74,"./util/merge":76}],59:[function(require,module,exports){
5395
5506
  'use strict';
5396
5507
 
5397
5508
  Object.defineProperty(exports, "__esModule", {
@@ -5420,7 +5531,7 @@ function isUUID(str) {
5420
5531
  return pattern && pattern.test(str);
5421
5532
  }
5422
5533
  module.exports = exports['default'];
5423
- },{"./util/assertString":73}],59:[function(require,module,exports){
5534
+ },{"./util/assertString":74}],60:[function(require,module,exports){
5424
5535
  'use strict';
5425
5536
 
5426
5537
  Object.defineProperty(exports, "__esModule", {
@@ -5439,7 +5550,7 @@ function isUppercase(str) {
5439
5550
  return str === str.toUpperCase();
5440
5551
  }
5441
5552
  module.exports = exports['default'];
5442
- },{"./util/assertString":73}],60:[function(require,module,exports){
5553
+ },{"./util/assertString":74}],61:[function(require,module,exports){
5443
5554
  'use strict';
5444
5555
 
5445
5556
  Object.defineProperty(exports, "__esModule", {
@@ -5462,7 +5573,7 @@ function isVariableWidth(str) {
5462
5573
  return _isFullWidth.fullWidth.test(str) && _isHalfWidth.halfWidth.test(str);
5463
5574
  }
5464
5575
  module.exports = exports['default'];
5465
- },{"./isFullWidth":27,"./isHalfWidth":28,"./util/assertString":73}],61:[function(require,module,exports){
5576
+ },{"./isFullWidth":27,"./isHalfWidth":28,"./util/assertString":74}],62:[function(require,module,exports){
5466
5577
  'use strict';
5467
5578
 
5468
5579
  Object.defineProperty(exports, "__esModule", {
@@ -5486,7 +5597,7 @@ function isWhitelisted(str, chars) {
5486
5597
  return true;
5487
5598
  }
5488
5599
  module.exports = exports['default'];
5489
- },{"./util/assertString":73}],62:[function(require,module,exports){
5600
+ },{"./util/assertString":74}],63:[function(require,module,exports){
5490
5601
  'use strict';
5491
5602
 
5492
5603
  Object.defineProperty(exports, "__esModule", {
@@ -5506,7 +5617,7 @@ function ltrim(str, chars) {
5506
5617
  return str.replace(pattern, '');
5507
5618
  }
5508
5619
  module.exports = exports['default'];
5509
- },{"./util/assertString":73}],63:[function(require,module,exports){
5620
+ },{"./util/assertString":74}],64:[function(require,module,exports){
5510
5621
  'use strict';
5511
5622
 
5512
5623
  Object.defineProperty(exports, "__esModule", {
@@ -5528,7 +5639,7 @@ function matches(str, pattern, modifiers) {
5528
5639
  return pattern.test(str);
5529
5640
  }
5530
5641
  module.exports = exports['default'];
5531
- },{"./util/assertString":73}],64:[function(require,module,exports){
5642
+ },{"./util/assertString":74}],65:[function(require,module,exports){
5532
5643
  'use strict';
5533
5644
 
5534
5645
  Object.defineProperty(exports, "__esModule", {
@@ -5633,7 +5744,7 @@ function normalizeEmail(email, options) {
5633
5744
  parts[0] = parts[0].toLowerCase();
5634
5745
  }
5635
5746
  parts[1] = options.gmail_convert_googlemaildotcom ? 'gmail.com' : parts[1];
5636
- } else if (~icloud_domains.indexOf(parts[1])) {
5747
+ } else if (icloud_domains.indexOf(parts[1]) >= 0) {
5637
5748
  // Address is iCloud
5638
5749
  if (options.icloud_remove_subaddress) {
5639
5750
  parts[0] = parts[0].split('+')[0];
@@ -5644,7 +5755,7 @@ function normalizeEmail(email, options) {
5644
5755
  if (options.all_lowercase || options.icloud_lowercase) {
5645
5756
  parts[0] = parts[0].toLowerCase();
5646
5757
  }
5647
- } else if (~outlookdotcom_domains.indexOf(parts[1])) {
5758
+ } else if (outlookdotcom_domains.indexOf(parts[1]) >= 0) {
5648
5759
  // Address is Outlook.com
5649
5760
  if (options.outlookdotcom_remove_subaddress) {
5650
5761
  parts[0] = parts[0].split('+')[0];
@@ -5655,7 +5766,7 @@ function normalizeEmail(email, options) {
5655
5766
  if (options.all_lowercase || options.outlookdotcom_lowercase) {
5656
5767
  parts[0] = parts[0].toLowerCase();
5657
5768
  }
5658
- } else if (~yahoo_domains.indexOf(parts[1])) {
5769
+ } else if (yahoo_domains.indexOf(parts[1]) >= 0) {
5659
5770
  // Address is Yahoo
5660
5771
  if (options.yahoo_remove_subaddress) {
5661
5772
  var components = parts[0].split('-');
@@ -5667,7 +5778,7 @@ function normalizeEmail(email, options) {
5667
5778
  if (options.all_lowercase || options.yahoo_lowercase) {
5668
5779
  parts[0] = parts[0].toLowerCase();
5669
5780
  }
5670
- } else if (~yandex_domains.indexOf(parts[1])) {
5781
+ } else if (yandex_domains.indexOf(parts[1]) >= 0) {
5671
5782
  if (options.all_lowercase || options.yandex_lowercase) {
5672
5783
  parts[0] = parts[0].toLowerCase();
5673
5784
  }
@@ -5679,7 +5790,7 @@ function normalizeEmail(email, options) {
5679
5790
  return parts.join('@');
5680
5791
  }
5681
5792
  module.exports = exports['default'];
5682
- },{"./util/merge":74}],65:[function(require,module,exports){
5793
+ },{"./util/merge":76}],66:[function(require,module,exports){
5683
5794
  'use strict';
5684
5795
 
5685
5796
  Object.defineProperty(exports, "__esModule", {
@@ -5698,14 +5809,12 @@ function rtrim(str, chars) {
5698
5809
  var pattern = chars ? new RegExp('[' + chars + ']') : /\s/;
5699
5810
 
5700
5811
  var idx = str.length - 1;
5701
- while (idx >= 0 && pattern.test(str[idx])) {
5702
- idx--;
5703
- }
5812
+ for (; idx >= 0 && pattern.test(str[idx]); idx--) {}
5704
5813
 
5705
5814
  return idx < str.length ? str.substr(0, idx + 1) : str;
5706
5815
  }
5707
5816
  module.exports = exports['default'];
5708
- },{"./util/assertString":73}],66:[function(require,module,exports){
5817
+ },{"./util/assertString":74}],67:[function(require,module,exports){
5709
5818
  'use strict';
5710
5819
 
5711
5820
  Object.defineProperty(exports, "__esModule", {
@@ -5729,7 +5838,7 @@ function stripLow(str, keep_new_lines) {
5729
5838
  return (0, _blacklist2.default)(str, chars);
5730
5839
  }
5731
5840
  module.exports = exports['default'];
5732
- },{"./blacklist":6,"./util/assertString":73}],67:[function(require,module,exports){
5841
+ },{"./blacklist":6,"./util/assertString":74}],68:[function(require,module,exports){
5733
5842
  'use strict';
5734
5843
 
5735
5844
  Object.defineProperty(exports, "__esModule", {
@@ -5751,7 +5860,7 @@ function toBoolean(str, strict) {
5751
5860
  return str !== '0' && str !== 'false' && str !== '';
5752
5861
  }
5753
5862
  module.exports = exports['default'];
5754
- },{"./util/assertString":73}],68:[function(require,module,exports){
5863
+ },{"./util/assertString":74}],69:[function(require,module,exports){
5755
5864
  'use strict';
5756
5865
 
5757
5866
  Object.defineProperty(exports, "__esModule", {
@@ -5771,7 +5880,7 @@ function toDate(date) {
5771
5880
  return !isNaN(date) ? new Date(date) : null;
5772
5881
  }
5773
5882
  module.exports = exports['default'];
5774
- },{"./util/assertString":73}],69:[function(require,module,exports){
5883
+ },{"./util/assertString":74}],70:[function(require,module,exports){
5775
5884
  'use strict';
5776
5885
 
5777
5886
  Object.defineProperty(exports, "__esModule", {
@@ -5790,7 +5899,7 @@ function toFloat(str) {
5790
5899
  return parseFloat(str);
5791
5900
  }
5792
5901
  module.exports = exports['default'];
5793
- },{"./util/assertString":73}],70:[function(require,module,exports){
5902
+ },{"./util/assertString":74}],71:[function(require,module,exports){
5794
5903
  'use strict';
5795
5904
 
5796
5905
  Object.defineProperty(exports, "__esModule", {
@@ -5809,7 +5918,7 @@ function toInt(str, radix) {
5809
5918
  return parseInt(str, radix || 10);
5810
5919
  }
5811
5920
  module.exports = exports['default'];
5812
- },{"./util/assertString":73}],71:[function(require,module,exports){
5921
+ },{"./util/assertString":74}],72:[function(require,module,exports){
5813
5922
  'use strict';
5814
5923
 
5815
5924
  Object.defineProperty(exports, "__esModule", {
@@ -5831,7 +5940,7 @@ function trim(str, chars) {
5831
5940
  return (0, _rtrim2.default)((0, _ltrim2.default)(str, chars), chars);
5832
5941
  }
5833
5942
  module.exports = exports['default'];
5834
- },{"./ltrim":62,"./rtrim":65}],72:[function(require,module,exports){
5943
+ },{"./ltrim":63,"./rtrim":66}],73:[function(require,module,exports){
5835
5944
  'use strict';
5836
5945
 
5837
5946
  Object.defineProperty(exports, "__esModule", {
@@ -5850,7 +5959,7 @@ function unescape(str) {
5850
5959
  return str.replace(/&amp;/g, '&').replace(/&quot;/g, '"').replace(/&#x27;/g, "'").replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&#x2F;/g, '/').replace(/&#x5C;/g, '\\').replace(/&#96;/g, '`');
5851
5960
  }
5852
5961
  module.exports = exports['default'];
5853
- },{"./util/assertString":73}],73:[function(require,module,exports){
5962
+ },{"./util/assertString":74}],74:[function(require,module,exports){
5854
5963
  'use strict';
5855
5964
 
5856
5965
  Object.defineProperty(exports, "__esModule", {
@@ -5865,7 +5974,21 @@ function assertString(input) {
5865
5974
  }
5866
5975
  }
5867
5976
  module.exports = exports['default'];
5868
- },{}],74:[function(require,module,exports){
5977
+ },{}],75:[function(require,module,exports){
5978
+ "use strict";
5979
+
5980
+ Object.defineProperty(exports, "__esModule", {
5981
+ value: true
5982
+ });
5983
+ var includes = function includes(arr, val) {
5984
+ return arr.some(function (arrVal) {
5985
+ return val === arrVal;
5986
+ });
5987
+ };
5988
+
5989
+ exports.default = includes;
5990
+ module.exports = exports["default"];
5991
+ },{}],76:[function(require,module,exports){
5869
5992
  'use strict';
5870
5993
 
5871
5994
  Object.defineProperty(exports, "__esModule", {
@@ -5884,7 +6007,7 @@ function merge() {
5884
6007
  return obj;
5885
6008
  }
5886
6009
  module.exports = exports['default'];
5887
- },{}],75:[function(require,module,exports){
6010
+ },{}],77:[function(require,module,exports){
5888
6011
  'use strict';
5889
6012
 
5890
6013
  Object.defineProperty(exports, "__esModule", {
@@ -5907,7 +6030,7 @@ function toString(input) {
5907
6030
  return String(input);
5908
6031
  }
5909
6032
  module.exports = exports['default'];
5910
- },{}],76:[function(require,module,exports){
6033
+ },{}],78:[function(require,module,exports){
5911
6034
  'use strict';
5912
6035
 
5913
6036
  Object.defineProperty(exports, "__esModule", {
@@ -5926,7 +6049,7 @@ function whitelist(str, chars) {
5926
6049
  return str.replace(new RegExp('[^' + chars + ']+', 'g'), '');
5927
6050
  }
5928
6051
  module.exports = exports['default'];
5929
- },{"./util/assertString":73}],77:[function(require,module,exports){
6052
+ },{"./util/assertString":74}],79:[function(require,module,exports){
5930
6053
  "use strict";
5931
6054
 
5932
6055
  module.exports = {
@@ -5988,7 +6111,7 @@ module.exports = {
5988
6111
 
5989
6112
  };
5990
6113
 
5991
- },{}],78:[function(require,module,exports){
6114
+ },{}],80:[function(require,module,exports){
5992
6115
  /*jshint maxlen: false*/
5993
6116
 
5994
6117
  var validator = require("validator");
@@ -6119,12 +6242,12 @@ var FormatValidators = {
6119
6242
 
6120
6243
  module.exports = FormatValidators;
6121
6244
 
6122
- },{"validator":4}],79:[function(require,module,exports){
6245
+ },{"validator":4}],81:[function(require,module,exports){
6123
6246
  "use strict";
6124
6247
 
6125
- var FormatValidators = require("./FormatValidators"),
6126
- Report = require("./Report"),
6127
- Utils = require("./Utils");
6248
+ var FormatValidators = require("./FormatValidators"),
6249
+ Report = require("./Report"),
6250
+ Utils = require("./Utils");
6128
6251
 
6129
6252
  var JsonValidators = {
6130
6253
  multipleOf: function (report, schema, json) {
@@ -6133,7 +6256,7 @@ var JsonValidators = {
6133
6256
  return;
6134
6257
  }
6135
6258
  if (Utils.whatIs(json / schema.multipleOf) !== "integer") {
6136
- report.addError("MULTIPLE_OF", [json, schema.multipleOf], null, schema.description);
6259
+ report.addError("MULTIPLE_OF", [json, schema.multipleOf], null, schema);
6137
6260
  }
6138
6261
  },
6139
6262
  maximum: function (report, schema, json) {
@@ -6143,11 +6266,11 @@ var JsonValidators = {
6143
6266
  }
6144
6267
  if (schema.exclusiveMaximum !== true) {
6145
6268
  if (json > schema.maximum) {
6146
- report.addError("MAXIMUM", [json, schema.maximum], null, schema.description);
6269
+ report.addError("MAXIMUM", [json, schema.maximum], null, schema);
6147
6270
  }
6148
6271
  } else {
6149
6272
  if (json >= schema.maximum) {
6150
- report.addError("MAXIMUM_EXCLUSIVE", [json, schema.maximum], null, schema.description);
6273
+ report.addError("MAXIMUM_EXCLUSIVE", [json, schema.maximum], null, schema);
6151
6274
  }
6152
6275
  }
6153
6276
  },
@@ -6161,11 +6284,11 @@ var JsonValidators = {
6161
6284
  }
6162
6285
  if (schema.exclusiveMinimum !== true) {
6163
6286
  if (json < schema.minimum) {
6164
- report.addError("MINIMUM", [json, schema.minimum], null, schema.description);
6287
+ report.addError("MINIMUM", [json, schema.minimum], null, schema);
6165
6288
  }
6166
6289
  } else {
6167
6290
  if (json <= schema.minimum) {
6168
- report.addError("MINIMUM_EXCLUSIVE", [json, schema.minimum], null, schema.description);
6291
+ report.addError("MINIMUM_EXCLUSIVE", [json, schema.minimum], null, schema);
6169
6292
  }
6170
6293
  }
6171
6294
  },
@@ -6178,7 +6301,7 @@ var JsonValidators = {
6178
6301
  return;
6179
6302
  }
6180
6303
  if (Utils.ucs2decode(json).length > schema.maxLength) {
6181
- report.addError("MAX_LENGTH", [json.length, schema.maxLength], null, schema.description);
6304
+ report.addError("MAX_LENGTH", [json.length, schema.maxLength], null, schema);
6182
6305
  }
6183
6306
  },
6184
6307
  minLength: function (report, schema, json) {
@@ -6187,7 +6310,7 @@ var JsonValidators = {
6187
6310
  return;
6188
6311
  }
6189
6312
  if (Utils.ucs2decode(json).length < schema.minLength) {
6190
- report.addError("MIN_LENGTH", [json.length, schema.minLength], null, schema.description);
6313
+ report.addError("MIN_LENGTH", [json.length, schema.minLength], null, schema);
6191
6314
  }
6192
6315
  },
6193
6316
  pattern: function (report, schema, json) {
@@ -6196,7 +6319,7 @@ var JsonValidators = {
6196
6319
  return;
6197
6320
  }
6198
6321
  if (RegExp(schema.pattern).test(json) === false) {
6199
- report.addError("PATTERN", [schema.pattern, json], null, schema.description);
6322
+ report.addError("PATTERN", [schema.pattern, json], null, schema);
6200
6323
  }
6201
6324
  },
6202
6325
  additionalItems: function (report, schema, json) {
@@ -6208,7 +6331,7 @@ var JsonValidators = {
6208
6331
  // the json is valid if its size is less than, or equal to, the size of "items".
6209
6332
  if (schema.additionalItems === false && Array.isArray(schema.items)) {
6210
6333
  if (json.length > schema.items.length) {
6211
- report.addError("ARRAY_ADDITIONAL_ITEMS", null, null, schema.description);
6334
+ report.addError("ARRAY_ADDITIONAL_ITEMS", null, null, schema);
6212
6335
  }
6213
6336
  }
6214
6337
  },
@@ -6221,7 +6344,7 @@ var JsonValidators = {
6221
6344
  return;
6222
6345
  }
6223
6346
  if (json.length > schema.maxItems) {
6224
- report.addError("ARRAY_LENGTH_LONG", [json.length, schema.maxItems], null, schema.description);
6347
+ report.addError("ARRAY_LENGTH_LONG", [json.length, schema.maxItems], null, schema);
6225
6348
  }
6226
6349
  },
6227
6350
  minItems: function (report, schema, json) {
@@ -6230,7 +6353,7 @@ var JsonValidators = {
6230
6353
  return;
6231
6354
  }
6232
6355
  if (json.length < schema.minItems) {
6233
- report.addError("ARRAY_LENGTH_SHORT", [json.length, schema.minItems], null, schema.description);
6356
+ report.addError("ARRAY_LENGTH_SHORT", [json.length, schema.minItems], null, schema);
6234
6357
  }
6235
6358
  },
6236
6359
  uniqueItems: function (report, schema, json) {
@@ -6241,7 +6364,7 @@ var JsonValidators = {
6241
6364
  if (schema.uniqueItems === true) {
6242
6365
  var matches = [];
6243
6366
  if (Utils.isUniqueArray(json, matches) === false) {
6244
- report.addError("ARRAY_UNIQUE", matches, null, schema.description);
6367
+ report.addError("ARRAY_UNIQUE", matches, null, schema);
6245
6368
  }
6246
6369
  }
6247
6370
  },
@@ -6252,7 +6375,7 @@ var JsonValidators = {
6252
6375
  }
6253
6376
  var keysCount = Object.keys(json).length;
6254
6377
  if (keysCount > schema.maxProperties) {
6255
- report.addError("OBJECT_PROPERTIES_MAXIMUM", [keysCount, schema.maxProperties], null, schema.description);
6378
+ report.addError("OBJECT_PROPERTIES_MAXIMUM", [keysCount, schema.maxProperties], null, schema);
6256
6379
  }
6257
6380
  },
6258
6381
  minProperties: function (report, schema, json) {
@@ -6262,7 +6385,7 @@ var JsonValidators = {
6262
6385
  }
6263
6386
  var keysCount = Object.keys(json).length;
6264
6387
  if (keysCount < schema.minProperties) {
6265
- report.addError("OBJECT_PROPERTIES_MINIMUM", [keysCount, schema.minProperties], null, schema.description);
6388
+ report.addError("OBJECT_PROPERTIES_MINIMUM", [keysCount, schema.minProperties], null, schema);
6266
6389
  }
6267
6390
  },
6268
6391
  required: function (report, schema, json) {
@@ -6274,7 +6397,7 @@ var JsonValidators = {
6274
6397
  while (idx--) {
6275
6398
  var requiredPropertyName = schema.required[idx];
6276
6399
  if (json[requiredPropertyName] === undefined) {
6277
- report.addError("OBJECT_MISSING_REQUIRED_PROPERTY", [requiredPropertyName], null, schema.description);
6400
+ report.addError("OBJECT_MISSING_REQUIRED_PROPERTY", [requiredPropertyName], null, schema);
6278
6401
  }
6279
6402
  }
6280
6403
  },
@@ -6330,7 +6453,7 @@ var JsonValidators = {
6330
6453
  }
6331
6454
  }
6332
6455
  if (s.length > 0) {
6333
- report.addError("OBJECT_ADDITIONAL_PROPERTIES", [s], null, schema.description);
6456
+ report.addError("OBJECT_ADDITIONAL_PROPERTIES", [s], null, schema);
6334
6457
  }
6335
6458
  }
6336
6459
  }
@@ -6358,7 +6481,7 @@ var JsonValidators = {
6358
6481
  while (idx2--) {
6359
6482
  var requiredPropertyName = dependencyDefinition[idx2];
6360
6483
  if (json[requiredPropertyName] === undefined) {
6361
- report.addError("OBJECT_DEPENDENCY_KEY", [requiredPropertyName, dependencyName], null, schema.description);
6484
+ report.addError("OBJECT_DEPENDENCY_KEY", [requiredPropertyName, dependencyName], null, schema);
6362
6485
  }
6363
6486
  }
6364
6487
  }
@@ -6381,7 +6504,7 @@ var JsonValidators = {
6381
6504
 
6382
6505
  if (match === false) {
6383
6506
  var error = caseInsensitiveMatch && this.options.enumCaseInsensitiveComparison ? "ENUM_CASE_MISMATCH" : "ENUM_MISMATCH";
6384
- report.addError(error, [json], null, schema.description);
6507
+ report.addError(error, [json], null, schema);
6385
6508
  }
6386
6509
  },
6387
6510
  type: function (report, schema, json) {
@@ -6389,11 +6512,11 @@ var JsonValidators = {
6389
6512
  var jsonType = Utils.whatIs(json);
6390
6513
  if (typeof schema.type === "string") {
6391
6514
  if (jsonType !== schema.type && (jsonType !== "integer" || schema.type !== "number")) {
6392
- report.addError("INVALID_TYPE", [schema.type, jsonType], null, schema.description);
6515
+ report.addError("INVALID_TYPE", [schema.type, jsonType], null, schema);
6393
6516
  }
6394
6517
  } else {
6395
6518
  if (schema.type.indexOf(jsonType) === -1 && (jsonType !== "integer" || schema.type.indexOf("number") === -1)) {
6396
- report.addError("INVALID_TYPE", [schema.type, jsonType], null, schema.description);
6519
+ report.addError("INVALID_TYPE", [schema.type, jsonType], null, schema);
6397
6520
  }
6398
6521
  }
6399
6522
  },
@@ -6420,7 +6543,7 @@ var JsonValidators = {
6420
6543
  }
6421
6544
 
6422
6545
  if (passed === false) {
6423
- report.addError("ANY_OF_MISSING", undefined, subReports, schema.description);
6546
+ report.addError("ANY_OF_MISSING", undefined, subReports, schema);
6424
6547
  }
6425
6548
  },
6426
6549
  oneOf: function (report, schema, json) {
@@ -6438,16 +6561,16 @@ var JsonValidators = {
6438
6561
  }
6439
6562
 
6440
6563
  if (passes === 0) {
6441
- report.addError("ONE_OF_MISSING", undefined, subReports, schema.description);
6564
+ report.addError("ONE_OF_MISSING", undefined, subReports, schema);
6442
6565
  } else if (passes > 1) {
6443
- report.addError("ONE_OF_MULTIPLE", null, null, schema.description);
6566
+ report.addError("ONE_OF_MULTIPLE", null, null, schema);
6444
6567
  }
6445
6568
  },
6446
6569
  not: function (report, schema, json) {
6447
6570
  // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.6.2
6448
6571
  var subReport = new Report(report);
6449
6572
  if (exports.validate.call(this, subReport, schema.not, json) === true) {
6450
- report.addError("NOT_PASSED", null, null, schema.description);
6573
+ report.addError("NOT_PASSED", null, null, schema);
6451
6574
  }
6452
6575
  },
6453
6576
  definitions: function () { /*report, schema, json*/
@@ -6462,17 +6585,17 @@ var JsonValidators = {
6462
6585
  // async
6463
6586
  report.addAsyncTask(formatValidatorFn, [json], function (result) {
6464
6587
  if (result !== true) {
6465
- report.addError("INVALID_FORMAT", [schema.format, json], null, schema.description);
6588
+ report.addError("INVALID_FORMAT", [schema.format, json], null, schema);
6466
6589
  }
6467
6590
  });
6468
6591
  } else {
6469
6592
  // sync
6470
6593
  if (formatValidatorFn.call(this, json) !== true) {
6471
- report.addError("INVALID_FORMAT", [schema.format, json], null, schema.description);
6594
+ report.addError("INVALID_FORMAT", [schema.format, json], null, schema);
6472
6595
  }
6473
6596
  }
6474
6597
  } else if (this.options.ignoreUnknownFormats !== true) {
6475
- report.addError("UNKNOWN_FORMAT", [schema.format], null, schema.description);
6598
+ report.addError("UNKNOWN_FORMAT", [schema.format], null, schema);
6476
6599
  }
6477
6600
  }
6478
6601
  };
@@ -6584,7 +6707,7 @@ exports.validate = function (report, schema, json) {
6584
6707
  // check if schema is an object
6585
6708
  var to = Utils.whatIs(schema);
6586
6709
  if (to !== "object") {
6587
- report.addError("SCHEMA_NOT_AN_OBJECT", [to], null, schema.description);
6710
+ report.addError("SCHEMA_NOT_AN_OBJECT", [to], null, schema);
6588
6711
  return false;
6589
6712
  }
6590
6713
 
@@ -6607,7 +6730,7 @@ exports.validate = function (report, schema, json) {
6607
6730
  var maxRefs = 99;
6608
6731
  while (schema.$ref && maxRefs > 0) {
6609
6732
  if (!schema.__$refResolved) {
6610
- report.addError("REF_UNRESOLVED", [schema.$ref], null, schema.description);
6733
+ report.addError("REF_UNRESOLVED", [schema.$ref], null, schema);
6611
6734
  break;
6612
6735
  } else if (schema.__$refResolved === schema) {
6613
6736
  break;
@@ -6663,7 +6786,7 @@ exports.validate = function (report, schema, json) {
6663
6786
 
6664
6787
  };
6665
6788
 
6666
- },{"./FormatValidators":78,"./Report":81,"./Utils":85}],80:[function(require,module,exports){
6789
+ },{"./FormatValidators":80,"./Report":83,"./Utils":87}],82:[function(require,module,exports){
6667
6790
  // Number.isFinite polyfill
6668
6791
  // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite
6669
6792
  if (typeof Number.isFinite !== "function") {
@@ -6681,7 +6804,7 @@ if (typeof Number.isFinite !== "function") {
6681
6804
  };
6682
6805
  }
6683
6806
 
6684
- },{}],81:[function(require,module,exports){
6807
+ },{}],83:[function(require,module,exports){
6685
6808
  (function (process){
6686
6809
  "use strict";
6687
6810
 
@@ -6727,7 +6850,7 @@ Report.prototype.processAsyncTasks = function (timeout, callback) {
6727
6850
  function finish() {
6728
6851
  process.nextTick(function () {
6729
6852
  var valid = self.errors.length === 0,
6730
- err = valid ? undefined : self.errors;
6853
+ err = valid ? undefined : self.errors;
6731
6854
  callback(err, valid);
6732
6855
  });
6733
6856
  }
@@ -6830,13 +6953,13 @@ Report.prototype.hasError = function (errorCode, params) {
6830
6953
  return false;
6831
6954
  };
6832
6955
 
6833
- Report.prototype.addError = function (errorCode, params, subReports, schemaDescription) {
6956
+ Report.prototype.addError = function (errorCode, params, subReports, schema) {
6834
6957
  if (!errorCode) { throw new Error("No errorCode passed into addError()"); }
6835
6958
 
6836
- this.addCustomError(errorCode, Errors[errorCode], params, subReports, schemaDescription);
6959
+ this.addCustomError(errorCode, Errors[errorCode], params, subReports, schema);
6837
6960
  };
6838
6961
 
6839
- Report.prototype.addCustomError = function (errorCode, errorMessage, params, subReports, schemaDescription) {
6962
+ Report.prototype.addCustomError = function (errorCode, errorMessage, params, subReports, schema) {
6840
6963
  if (this.errors.length >= this.reportOptions.maxErrors) {
6841
6964
  return;
6842
6965
  }
@@ -6860,8 +6983,15 @@ Report.prototype.addCustomError = function (errorCode, errorMessage, params, sub
6860
6983
  schemaId: this.getSchemaId()
6861
6984
  };
6862
6985
 
6863
- if (schemaDescription) {
6864
- err.description = schemaDescription;
6986
+ if (schema && typeof schema === "string") {
6987
+ err.description = schema;
6988
+ } else if (schema && typeof schema === "object") {
6989
+ if (schema.title) {
6990
+ err.title = schema.title;
6991
+ }
6992
+ if (schema.description) {
6993
+ err.description = schema.description;
6994
+ }
6865
6995
  }
6866
6996
 
6867
6997
  if (subReports != null) {
@@ -6888,7 +7018,7 @@ Report.prototype.addCustomError = function (errorCode, errorMessage, params, sub
6888
7018
  module.exports = Report;
6889
7019
 
6890
7020
  }).call(this,require('_process'))
6891
- },{"./Errors":77,"./Utils":85,"_process":3,"lodash.get":1}],82:[function(require,module,exports){
7021
+ },{"./Errors":79,"./Utils":87,"_process":3,"lodash.get":1}],84:[function(require,module,exports){
6892
7022
  "use strict";
6893
7023
 
6894
7024
  var isequal = require("lodash.isequal");
@@ -7052,7 +7182,7 @@ exports.getSchemaByUri = function (report, uri, root) {
7052
7182
 
7053
7183
  exports.getRemotePath = getRemotePath;
7054
7184
 
7055
- },{"./Report":81,"./SchemaCompilation":83,"./SchemaValidation":84,"./Utils":85,"lodash.isequal":2}],83:[function(require,module,exports){
7185
+ },{"./Report":83,"./SchemaCompilation":85,"./SchemaValidation":86,"./Utils":87,"lodash.isequal":2}],85:[function(require,module,exports){
7056
7186
  "use strict";
7057
7187
 
7058
7188
  var Report = require("./Report");
@@ -7353,7 +7483,7 @@ exports.compileSchema = function (report, schema) {
7353
7483
 
7354
7484
  };
7355
7485
 
7356
- },{"./Report":81,"./SchemaCache":82,"./Utils":85}],84:[function(require,module,exports){
7486
+ },{"./Report":83,"./SchemaCache":84,"./Utils":87}],86:[function(require,module,exports){
7357
7487
  "use strict";
7358
7488
 
7359
7489
  var FormatValidators = require("./FormatValidators"),
@@ -7962,7 +8092,7 @@ exports.validateSchema = function (report, schema) {
7962
8092
  return isValid;
7963
8093
  };
7964
8094
 
7965
- },{"./FormatValidators":78,"./JsonValidation":79,"./Report":81,"./Utils":85}],85:[function(require,module,exports){
8095
+ },{"./FormatValidators":80,"./JsonValidation":81,"./Report":83,"./Utils":87}],87:[function(require,module,exports){
7966
8096
  "use strict";
7967
8097
 
7968
8098
  exports.isAbsoluteUri = function (uri) {
@@ -8191,7 +8321,7 @@ exports.ucs2decode = function (string) {
8191
8321
  };
8192
8322
  /*jshint +W016*/
8193
8323
 
8194
- },{}],86:[function(require,module,exports){
8324
+ },{}],88:[function(require,module,exports){
8195
8325
  (function (process){
8196
8326
  "use strict";
8197
8327
 
@@ -8567,7 +8697,7 @@ ZSchema.getDefaultOptions = function () {
8567
8697
  module.exports = ZSchema;
8568
8698
 
8569
8699
  }).call(this,require('_process'))
8570
- },{"./FormatValidators":78,"./JsonValidation":79,"./Polyfills":80,"./Report":81,"./SchemaCache":82,"./SchemaCompilation":83,"./SchemaValidation":84,"./Utils":85,"./schemas/hyper-schema.json":87,"./schemas/schema.json":88,"_process":3,"lodash.get":1}],87:[function(require,module,exports){
8700
+ },{"./FormatValidators":80,"./JsonValidation":81,"./Polyfills":82,"./Report":83,"./SchemaCache":84,"./SchemaCompilation":85,"./SchemaValidation":86,"./Utils":87,"./schemas/hyper-schema.json":89,"./schemas/schema.json":90,"_process":3,"lodash.get":1}],89:[function(require,module,exports){
8571
8701
  module.exports={
8572
8702
  "$schema": "http://json-schema.org/draft-04/hyper-schema#",
8573
8703
  "id": "http://json-schema.org/draft-04/hyper-schema#",
@@ -8727,7 +8857,7 @@ module.exports={
8727
8857
  }
8728
8858
 
8729
8859
 
8730
- },{}],88:[function(require,module,exports){
8860
+ },{}],90:[function(require,module,exports){
8731
8861
  module.exports={
8732
8862
  "id": "http://json-schema.org/draft-04/schema#",
8733
8863
  "$schema": "http://json-schema.org/draft-04/schema#",
@@ -8880,5 +9010,5 @@ module.exports={
8880
9010
  "default": {}
8881
9011
  }
8882
9012
 
8883
- },{}]},{},[77,78,79,80,81,82,83,84,85,86])(86)
9013
+ },{}]},{},[79,80,81,82,83,84,85,86,87,88])(88)
8884
9014
  });