z-schema 3.19.1 → 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.
@@ -1,4 +1,4 @@
1
- (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ZSchema = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
1
+ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ZSchema = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2
2
  (function (global){
3
3
  /**
4
4
  * lodash (Custom Build) <https://lodash.com/>
@@ -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);
@@ -3178,10 +3182,18 @@ var _isISO = require('./lib/isISO8601');
3178
3182
 
3179
3183
  var _isISO2 = _interopRequireDefault(_isISO);
3180
3184
 
3185
+ var _isRFC = require('./lib/isRFC3339');
3186
+
3187
+ var _isRFC2 = _interopRequireDefault(_isRFC);
3188
+
3181
3189
  var _isISO31661Alpha = require('./lib/isISO31661Alpha2');
3182
3190
 
3183
3191
  var _isISO31661Alpha2 = _interopRequireDefault(_isISO31661Alpha);
3184
3192
 
3193
+ var _isISO31661Alpha3 = require('./lib/isISO31661Alpha3');
3194
+
3195
+ var _isISO31661Alpha4 = _interopRequireDefault(_isISO31661Alpha3);
3196
+
3185
3197
  var _isBase = require('./lib/isBase64');
3186
3198
 
3187
3199
  var _isBase2 = _interopRequireDefault(_isBase);
@@ -3248,7 +3260,7 @@ var _toString2 = _interopRequireDefault(_toString);
3248
3260
 
3249
3261
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3250
3262
 
3251
- var version = '9.4.0';
3263
+ var version = '10.5.0';
3252
3264
 
3253
3265
  var validator = {
3254
3266
  version: version,
@@ -3263,6 +3275,7 @@ var validator = {
3263
3275
  isURL: _isURL2.default,
3264
3276
  isMACAddress: _isMACAddress2.default,
3265
3277
  isIP: _isIP2.default,
3278
+ isIPRange: _isIPRange2.default,
3266
3279
  isFQDN: _isFQDN2.default,
3267
3280
  isBoolean: _isBoolean2.default,
3268
3281
  isAlpha: _isAlpha2.default,
@@ -3301,9 +3314,12 @@ var validator = {
3301
3314
  isISSN: _isISSN2.default,
3302
3315
  isMobilePhone: _isMobilePhone2.default,
3303
3316
  isPostalCode: _isPostalCode2.default,
3317
+ isPostalCodeLocales: _isPostalCode.locales,
3304
3318
  isCurrency: _isCurrency2.default,
3305
3319
  isISO8601: _isISO2.default,
3320
+ isRFC3339: _isRFC2.default,
3306
3321
  isISO31661Alpha2: _isISO31661Alpha2.default,
3322
+ isISO31661Alpha3: _isISO31661Alpha4.default,
3307
3323
  isBase64: _isBase2.default,
3308
3324
  isDataURI: _isDataURI2.default,
3309
3325
  isMimeType: _isMimeType2.default,
@@ -3323,7 +3339,7 @@ var validator = {
3323
3339
 
3324
3340
  exports.default = validator;
3325
3341
  module.exports = exports['default'];
3326
- },{"./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/isISO8601":36,"./lib/isISRC":37,"./lib/isISSN":38,"./lib/isIn":39,"./lib/isInt":40,"./lib/isJSON":41,"./lib/isLatLong":42,"./lib/isLength":43,"./lib/isLowercase":44,"./lib/isMACAddress":45,"./lib/isMD5":46,"./lib/isMimeType":47,"./lib/isMobilePhone":48,"./lib/isMongoId":49,"./lib/isMultibyte":50,"./lib/isNumeric":51,"./lib/isPort":52,"./lib/isPostalCode":53,"./lib/isSurrogatePair":54,"./lib/isURL":55,"./lib/isUUID":56,"./lib/isUppercase":57,"./lib/isVariableWidth":58,"./lib/isWhitelisted":59,"./lib/ltrim":60,"./lib/matches":61,"./lib/normalizeEmail":62,"./lib/rtrim":63,"./lib/stripLow":64,"./lib/toBoolean":65,"./lib/toDate":66,"./lib/toFloat":67,"./lib/toInt":68,"./lib/trim":69,"./lib/unescape":70,"./lib/util/toString":73,"./lib/whitelist":74}],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){
3327
3343
  'use strict';
3328
3344
 
3329
3345
  Object.defineProperty(exports, "__esModule", {
@@ -3352,6 +3368,7 @@ var alpha = exports.alpha = {
3352
3368
  'sv-SE': /^[A-ZÅÄÖ]+$/i,
3353
3369
  'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i,
3354
3370
  'uk-UA': /^[А-ЩЬЮЯЄIЇҐі]+$/i,
3371
+ 'ku-IQ': /^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
3355
3372
  ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/
3356
3373
  };
3357
3374
 
@@ -3378,6 +3395,7 @@ var alphanumeric = exports.alphanumeric = {
3378
3395
  'sv-SE': /^[0-9A-ZÅÄÖ]+$/i,
3379
3396
  'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i,
3380
3397
  'uk-UA': /^[0-9А-ЩЬЮЯЄIЇҐі]+$/i,
3398
+ 'ku-IQ': /^[٠١٢٣٤٥٦٧٨٩0-9ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
3381
3399
  ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/
3382
3400
  };
3383
3401
 
@@ -3407,7 +3425,7 @@ for (var _locale, _i = 0; _i < arabicLocales.length; _i++) {
3407
3425
 
3408
3426
  // Source: https://en.wikipedia.org/wiki/Decimal_mark
3409
3427
  var dotDecimal = exports.dotDecimal = [];
3410
- 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'];
3411
3429
 
3412
3430
  for (var _i2 = 0; _i2 < dotDecimal.length; _i2++) {
3413
3431
  decimal[dotDecimal[_i2]] = decimal['en-US'];
@@ -3420,6 +3438,11 @@ for (var _i3 = 0; _i3 < commaDecimal.length; _i3++) {
3420
3438
  alpha['pt-BR'] = alpha['pt-PT'];
3421
3439
  alphanumeric['pt-BR'] = alphanumeric['pt-PT'];
3422
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'];
3423
3446
  },{}],6:[function(require,module,exports){
3424
3447
  'use strict';
3425
3448
 
@@ -3439,7 +3462,7 @@ function blacklist(str, chars) {
3439
3462
  return str.replace(new RegExp('[' + chars + ']+', 'g'), '');
3440
3463
  }
3441
3464
  module.exports = exports['default'];
3442
- },{"./util/assertString":71}],7:[function(require,module,exports){
3465
+ },{"./util/assertString":74}],7:[function(require,module,exports){
3443
3466
  'use strict';
3444
3467
 
3445
3468
  Object.defineProperty(exports, "__esModule", {
@@ -3462,7 +3485,7 @@ function contains(str, elem) {
3462
3485
  return str.indexOf((0, _toString2.default)(elem)) >= 0;
3463
3486
  }
3464
3487
  module.exports = exports['default'];
3465
- },{"./util/assertString":71,"./util/toString":73}],8:[function(require,module,exports){
3488
+ },{"./util/assertString":74,"./util/toString":77}],8:[function(require,module,exports){
3466
3489
  'use strict';
3467
3490
 
3468
3491
  Object.defineProperty(exports, "__esModule", {
@@ -3481,7 +3504,7 @@ function equals(str, comparison) {
3481
3504
  return str === comparison;
3482
3505
  }
3483
3506
  module.exports = exports['default'];
3484
- },{"./util/assertString":71}],9:[function(require,module,exports){
3507
+ },{"./util/assertString":74}],9:[function(require,module,exports){
3485
3508
  'use strict';
3486
3509
 
3487
3510
  Object.defineProperty(exports, "__esModule", {
@@ -3500,7 +3523,7 @@ function escape(str) {
3500
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;');
3501
3524
  }
3502
3525
  module.exports = exports['default'];
3503
- },{"./util/assertString":71}],10:[function(require,module,exports){
3526
+ },{"./util/assertString":74}],10:[function(require,module,exports){
3504
3527
  'use strict';
3505
3528
 
3506
3529
  Object.defineProperty(exports, "__esModule", {
@@ -3527,7 +3550,7 @@ function isAfter(str) {
3527
3550
  return !!(original && comparison && original > comparison);
3528
3551
  }
3529
3552
  module.exports = exports['default'];
3530
- },{"./toDate":66,"./util/assertString":71}],11:[function(require,module,exports){
3553
+ },{"./toDate":69,"./util/assertString":74}],11:[function(require,module,exports){
3531
3554
  'use strict';
3532
3555
 
3533
3556
  Object.defineProperty(exports, "__esModule", {
@@ -3553,7 +3576,7 @@ function isAlpha(str) {
3553
3576
  throw new Error('Invalid locale \'' + locale + '\'');
3554
3577
  }
3555
3578
  module.exports = exports['default'];
3556
- },{"./alpha":5,"./util/assertString":71}],12:[function(require,module,exports){
3579
+ },{"./alpha":5,"./util/assertString":74}],12:[function(require,module,exports){
3557
3580
  'use strict';
3558
3581
 
3559
3582
  Object.defineProperty(exports, "__esModule", {
@@ -3579,7 +3602,7 @@ function isAlphanumeric(str) {
3579
3602
  throw new Error('Invalid locale \'' + locale + '\'');
3580
3603
  }
3581
3604
  module.exports = exports['default'];
3582
- },{"./alpha":5,"./util/assertString":71}],13:[function(require,module,exports){
3605
+ },{"./alpha":5,"./util/assertString":74}],13:[function(require,module,exports){
3583
3606
  'use strict';
3584
3607
 
3585
3608
  Object.defineProperty(exports, "__esModule", {
@@ -3602,7 +3625,7 @@ function isAscii(str) {
3602
3625
  return ascii.test(str);
3603
3626
  }
3604
3627
  module.exports = exports['default'];
3605
- },{"./util/assertString":71}],14:[function(require,module,exports){
3628
+ },{"./util/assertString":74}],14:[function(require,module,exports){
3606
3629
  'use strict';
3607
3630
 
3608
3631
  Object.defineProperty(exports, "__esModule", {
@@ -3628,7 +3651,7 @@ function isBase64(str) {
3628
3651
  return firstPaddingChar === -1 || firstPaddingChar === len - 1 || firstPaddingChar === len - 2 && str[len - 1] === '=';
3629
3652
  }
3630
3653
  module.exports = exports['default'];
3631
- },{"./util/assertString":71}],15:[function(require,module,exports){
3654
+ },{"./util/assertString":74}],15:[function(require,module,exports){
3632
3655
  'use strict';
3633
3656
 
3634
3657
  Object.defineProperty(exports, "__esModule", {
@@ -3655,7 +3678,7 @@ function isBefore(str) {
3655
3678
  return !!(original && comparison && original < comparison);
3656
3679
  }
3657
3680
  module.exports = exports['default'];
3658
- },{"./toDate":66,"./util/assertString":71}],16:[function(require,module,exports){
3681
+ },{"./toDate":69,"./util/assertString":74}],16:[function(require,module,exports){
3659
3682
  'use strict';
3660
3683
 
3661
3684
  Object.defineProperty(exports, "__esModule", {
@@ -3674,7 +3697,7 @@ function isBoolean(str) {
3674
3697
  return ['true', 'false', '1', '0'].indexOf(str) >= 0;
3675
3698
  }
3676
3699
  module.exports = exports['default'];
3677
- },{"./util/assertString":71}],17:[function(require,module,exports){
3700
+ },{"./util/assertString":74}],17:[function(require,module,exports){
3678
3701
  'use strict';
3679
3702
 
3680
3703
  Object.defineProperty(exports, "__esModule", {
@@ -3708,7 +3731,7 @@ function isByteLength(str, options) {
3708
3731
  return len >= min && (typeof max === 'undefined' || len <= max);
3709
3732
  }
3710
3733
  module.exports = exports['default'];
3711
- },{"./util/assertString":71}],18:[function(require,module,exports){
3734
+ },{"./util/assertString":74}],18:[function(require,module,exports){
3712
3735
  'use strict';
3713
3736
 
3714
3737
  Object.defineProperty(exports, "__esModule", {
@@ -3723,7 +3746,7 @@ var _assertString2 = _interopRequireDefault(_assertString);
3723
3746
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3724
3747
 
3725
3748
  /* eslint-disable max-len */
3726
- var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|62[0-9]{14})$/;
3749
+ var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14})$/;
3727
3750
  /* eslint-enable max-len */
3728
3751
 
3729
3752
  function isCreditCard(str) {
@@ -3754,7 +3777,7 @@ function isCreditCard(str) {
3754
3777
  return !!(sum % 10 === 0 ? sanitized : false);
3755
3778
  }
3756
3779
  module.exports = exports['default'];
3757
- },{"./util/assertString":71}],19:[function(require,module,exports){
3780
+ },{"./util/assertString":74}],19:[function(require,module,exports){
3758
3781
  'use strict';
3759
3782
 
3760
3783
  Object.defineProperty(exports, "__esModule", {
@@ -3847,7 +3870,7 @@ function isCurrency(str, options) {
3847
3870
  return currencyRegex(options).test(str);
3848
3871
  }
3849
3872
  module.exports = exports['default'];
3850
- },{"./util/assertString":71,"./util/merge":72}],20:[function(require,module,exports){
3873
+ },{"./util/assertString":74,"./util/merge":76}],20:[function(require,module,exports){
3851
3874
  'use strict';
3852
3875
 
3853
3876
  Object.defineProperty(exports, "__esModule", {
@@ -3861,14 +3884,43 @@ var _assertString2 = _interopRequireDefault(_assertString);
3861
3884
 
3862
3885
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3863
3886
 
3864
- var dataURI = /^\s*data:([a-z]+\/[a-z0-9\-\+]+(;[a-z\-]+=[a-z0-9\-]+)?)?(;base64)?,[a-z0-9!\$&',\(\)\*\+,;=\-\._~:@\/\?%\s]*\s*$/i; // eslint-disable-line max-len
3887
+ var validMediaType = /^[a-z]+\/[a-z0-9\-\+]+$/i;
3888
+
3889
+ var validAttribute = /^[a-z\-]+=[a-z0-9\-]+$/i;
3890
+
3891
+ var validData = /^[a-z0-9!\$&'\(\)\*\+,;=\-\._~:@\/\?%\s]*$/i;
3865
3892
 
3866
3893
  function isDataURI(str) {
3867
3894
  (0, _assertString2.default)(str);
3868
- return dataURI.test(str);
3895
+ var data = str.split(',');
3896
+ if (data.length < 2) {
3897
+ return false;
3898
+ }
3899
+ var attributes = data.shift().trim().split(';');
3900
+ var schemeAndMediaType = attributes.shift();
3901
+ if (schemeAndMediaType.substr(0, 5) !== 'data:') {
3902
+ return false;
3903
+ }
3904
+ var mediaType = schemeAndMediaType.substr(5);
3905
+ if (mediaType !== '' && !validMediaType.test(mediaType)) {
3906
+ return false;
3907
+ }
3908
+ for (var i = 0; i < attributes.length; i++) {
3909
+ if (i === attributes.length - 1 && attributes[i].toLowerCase() === 'base64') {
3910
+ // ok
3911
+ } else if (!validAttribute.test(attributes[i])) {
3912
+ return false;
3913
+ }
3914
+ }
3915
+ for (var _i = 0; _i < data.length; _i++) {
3916
+ if (!validData.test(data[_i])) {
3917
+ return false;
3918
+ }
3919
+ }
3920
+ return true;
3869
3921
  }
3870
3922
  module.exports = exports['default'];
3871
- },{"./util/assertString":71}],21:[function(require,module,exports){
3923
+ },{"./util/assertString":74}],21:[function(require,module,exports){
3872
3924
  'use strict';
3873
3925
 
3874
3926
  Object.defineProperty(exports, "__esModule", {
@@ -3884,6 +3936,10 @@ var _assertString = require('./util/assertString');
3884
3936
 
3885
3937
  var _assertString2 = _interopRequireDefault(_assertString);
3886
3938
 
3939
+ var _includes = require('./util/includes');
3940
+
3941
+ var _includes2 = _interopRequireDefault(_includes);
3942
+
3887
3943
  var _alpha = require('./alpha');
3888
3944
 
3889
3945
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -3905,12 +3961,12 @@ function isDecimal(str, options) {
3905
3961
  (0, _assertString2.default)(str);
3906
3962
  options = (0, _merge2.default)(options, default_decimal_options);
3907
3963
  if (options.locale in _alpha.decimal) {
3908
- return !blacklist.includes(str.replace(/ /g, '')) && decimalRegExp(options).test(str);
3964
+ return !(0, _includes2.default)(blacklist, str.replace(/ /g, '')) && decimalRegExp(options).test(str);
3909
3965
  }
3910
3966
  throw new Error('Invalid locale \'' + options.locale + '\'');
3911
3967
  }
3912
3968
  module.exports = exports['default'];
3913
- },{"./alpha":5,"./util/assertString":71,"./util/merge":72}],22:[function(require,module,exports){
3969
+ },{"./alpha":5,"./util/assertString":74,"./util/includes":75,"./util/merge":76}],22:[function(require,module,exports){
3914
3970
  'use strict';
3915
3971
 
3916
3972
  Object.defineProperty(exports, "__esModule", {
@@ -3933,7 +3989,7 @@ function isDivisibleBy(str, num) {
3933
3989
  return (0, _toFloat2.default)(str) % parseInt(num, 10) === 0;
3934
3990
  }
3935
3991
  module.exports = exports['default'];
3936
- },{"./toFloat":67,"./util/assertString":71}],23:[function(require,module,exports){
3992
+ },{"./toFloat":70,"./util/assertString":74}],23:[function(require,module,exports){
3937
3993
  'use strict';
3938
3994
 
3939
3995
  Object.defineProperty(exports, "__esModule", {
@@ -3957,6 +4013,10 @@ var _isFQDN = require('./isFQDN');
3957
4013
 
3958
4014
  var _isFQDN2 = _interopRequireDefault(_isFQDN);
3959
4015
 
4016
+ var _isIP = require('./isIP');
4017
+
4018
+ var _isIP2 = _interopRequireDefault(_isIP);
4019
+
3960
4020
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3961
4021
 
3962
4022
  var default_email_options = {
@@ -3970,6 +4030,7 @@ var default_email_options = {
3970
4030
  /* eslint-disable no-control-regex */
3971
4031
  var displayName = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\,\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i;
3972
4032
  var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i;
4033
+ var gmailUserPart = /^[a-z\d]+$/;
3973
4034
  var quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i;
3974
4035
  var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i;
3975
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;
@@ -3994,8 +4055,31 @@ function isEmail(str, options) {
3994
4055
  var user = parts.join('@');
3995
4056
 
3996
4057
  var lower_domain = domain.toLowerCase();
3997
- if (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com') {
3998
- user = user.replace(/\./g, '').toLowerCase();
4058
+
4059
+ if (options.domain_specific_validation && (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com')) {
4060
+ /*
4061
+ Previously we removed dots for gmail addresses before validating.
4062
+ This was removed because it allows `multiple..dots@gmail.com`
4063
+ to be reported as valid, but it is not.
4064
+ Gmail only normalizes single dots, removing them from here is pointless,
4065
+ should be done in normalizeEmail
4066
+ */
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
+ }
3999
4083
  }
4000
4084
 
4001
4085
  if (!(0, _isByteLength2.default)(user, { max: 64 }) || !(0, _isByteLength2.default)(domain, { max: 254 })) {
@@ -4003,7 +4087,21 @@ function isEmail(str, options) {
4003
4087
  }
4004
4088
 
4005
4089
  if (!(0, _isFQDN2.default)(domain, { require_tld: options.require_tld })) {
4006
- 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
+ }
4007
4105
  }
4008
4106
 
4009
4107
  if (user[0] === '"') {
@@ -4014,8 +4112,8 @@ function isEmail(str, options) {
4014
4112
  var pattern = options.allow_utf8_local_part ? emailUserUtf8Part : emailUserPart;
4015
4113
 
4016
4114
  var user_parts = user.split('.');
4017
- for (var i = 0; i < user_parts.length; i++) {
4018
- if (!pattern.test(user_parts[i])) {
4115
+ for (var _i = 0; _i < user_parts.length; _i++) {
4116
+ if (!pattern.test(user_parts[_i])) {
4019
4117
  return false;
4020
4118
  }
4021
4119
  }
@@ -4023,7 +4121,7 @@ function isEmail(str, options) {
4023
4121
  return true;
4024
4122
  }
4025
4123
  module.exports = exports['default'];
4026
- },{"./isByteLength":17,"./isFQDN":25,"./util/assertString":71,"./util/merge":72}],24:[function(require,module,exports){
4124
+ },{"./isByteLength":17,"./isFQDN":25,"./isIP":32,"./util/assertString":74,"./util/merge":76}],24:[function(require,module,exports){
4027
4125
  'use strict';
4028
4126
 
4029
4127
  Object.defineProperty(exports, "__esModule", {
@@ -4042,7 +4140,7 @@ function isEmpty(str) {
4042
4140
  return str.length === 0;
4043
4141
  }
4044
4142
  module.exports = exports['default'];
4045
- },{"./util/assertString":71}],25:[function(require,module,exports){
4143
+ },{"./util/assertString":74}],25:[function(require,module,exports){
4046
4144
  'use strict';
4047
4145
 
4048
4146
  Object.defineProperty(exports, "__esModule", {
@@ -4075,6 +4173,11 @@ function isFQDN(str, options) {
4075
4173
  str = str.substring(0, str.length - 1);
4076
4174
  }
4077
4175
  var parts = str.split('.');
4176
+ for (var i = 0; i < parts.length; i++) {
4177
+ if (parts[i].length > 63) {
4178
+ return false;
4179
+ }
4180
+ }
4078
4181
  if (options.require_tld) {
4079
4182
  var tld = parts.pop();
4080
4183
  if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
@@ -4085,8 +4188,8 @@ function isFQDN(str, options) {
4085
4188
  return false;
4086
4189
  }
4087
4190
  }
4088
- for (var part, i = 0; i < parts.length; i++) {
4089
- part = parts[i];
4191
+ for (var part, _i = 0; _i < parts.length; _i++) {
4192
+ part = parts[_i];
4090
4193
  if (options.allow_underscores) {
4091
4194
  part = part.replace(/_/g, '');
4092
4195
  }
@@ -4104,7 +4207,7 @@ function isFQDN(str, options) {
4104
4207
  return true;
4105
4208
  }
4106
4209
  module.exports = exports['default'];
4107
- },{"./util/assertString":71,"./util/merge":72}],26:[function(require,module,exports){
4210
+ },{"./util/assertString":74,"./util/merge":76}],26:[function(require,module,exports){
4108
4211
  'use strict';
4109
4212
 
4110
4213
  Object.defineProperty(exports, "__esModule", {
@@ -4127,10 +4230,11 @@ function isFloat(str, options) {
4127
4230
  if (str === '' || str === '.' || str === '-' || str === '+') {
4128
4231
  return false;
4129
4232
  }
4130
- return float.test(str) && (!options.hasOwnProperty('min') || str >= options.min) && (!options.hasOwnProperty('max') || str <= options.max) && (!options.hasOwnProperty('lt') || str < options.lt) && (!options.hasOwnProperty('gt') || str > options.gt);
4233
+ var value = parseFloat(str.replace(',', '.'));
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);
4131
4235
  }
4132
4236
  module.exports = exports['default'];
4133
- },{"./alpha":5,"./util/assertString":71}],27:[function(require,module,exports){
4237
+ },{"./alpha":5,"./util/assertString":74}],27:[function(require,module,exports){
4134
4238
  'use strict';
4135
4239
 
4136
4240
  Object.defineProperty(exports, "__esModule", {
@@ -4151,7 +4255,7 @@ function isFullWidth(str) {
4151
4255
  (0, _assertString2.default)(str);
4152
4256
  return fullWidth.test(str);
4153
4257
  }
4154
- },{"./util/assertString":71}],28:[function(require,module,exports){
4258
+ },{"./util/assertString":74}],28:[function(require,module,exports){
4155
4259
  'use strict';
4156
4260
 
4157
4261
  Object.defineProperty(exports, "__esModule", {
@@ -4172,7 +4276,7 @@ function isHalfWidth(str) {
4172
4276
  (0, _assertString2.default)(str);
4173
4277
  return halfWidth.test(str);
4174
4278
  }
4175
- },{"./util/assertString":71}],29:[function(require,module,exports){
4279
+ },{"./util/assertString":74}],29:[function(require,module,exports){
4176
4280
  'use strict';
4177
4281
 
4178
4282
  Object.defineProperty(exports, "__esModule", {
@@ -4208,7 +4312,7 @@ function isHash(str, algorithm) {
4208
4312
  return hash.test(str);
4209
4313
  }
4210
4314
  module.exports = exports['default'];
4211
- },{"./util/assertString":71}],30:[function(require,module,exports){
4315
+ },{"./util/assertString":74}],30:[function(require,module,exports){
4212
4316
  'use strict';
4213
4317
 
4214
4318
  Object.defineProperty(exports, "__esModule", {
@@ -4229,7 +4333,7 @@ function isHexColor(str) {
4229
4333
  return hexcolor.test(str);
4230
4334
  }
4231
4335
  module.exports = exports['default'];
4232
- },{"./util/assertString":71}],31:[function(require,module,exports){
4336
+ },{"./util/assertString":74}],31:[function(require,module,exports){
4233
4337
  'use strict';
4234
4338
 
4235
4339
  Object.defineProperty(exports, "__esModule", {
@@ -4250,7 +4354,7 @@ function isHexadecimal(str) {
4250
4354
  return hexadecimal.test(str);
4251
4355
  }
4252
4356
  module.exports = exports['default'];
4253
- },{"./util/assertString":71}],32:[function(require,module,exports){
4357
+ },{"./util/assertString":74}],32:[function(require,module,exports){
4254
4358
  'use strict';
4255
4359
 
4256
4360
  Object.defineProperty(exports, "__esModule", {
@@ -4332,7 +4436,48 @@ function isIP(str) {
4332
4436
  return false;
4333
4437
  }
4334
4438
  module.exports = exports['default'];
4335
- },{"./util/assertString":71}],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){
4336
4481
  'use strict';
4337
4482
 
4338
4483
  Object.defineProperty(exports, "__esModule", {
@@ -4390,7 +4535,7 @@ function isISBN(str) {
4390
4535
  return false;
4391
4536
  }
4392
4537
  module.exports = exports['default'];
4393
- },{"./util/assertString":71}],34:[function(require,module,exports){
4538
+ },{"./util/assertString":74}],35:[function(require,module,exports){
4394
4539
  'use strict';
4395
4540
 
4396
4541
  Object.defineProperty(exports, "__esModule", {
@@ -4439,7 +4584,7 @@ function isISIN(str) {
4439
4584
  return parseInt(str.substr(str.length - 1), 10) === (10000 - sum) % 10;
4440
4585
  }
4441
4586
  module.exports = exports['default'];
4442
- },{"./util/assertString":71}],35:[function(require,module,exports){
4587
+ },{"./util/assertString":74}],36:[function(require,module,exports){
4443
4588
  'use strict';
4444
4589
 
4445
4590
  Object.defineProperty(exports, "__esModule", {
@@ -4451,6 +4596,10 @@ var _assertString = require('./util/assertString');
4451
4596
 
4452
4597
  var _assertString2 = _interopRequireDefault(_assertString);
4453
4598
 
4599
+ var _includes = require('./util/includes');
4600
+
4601
+ var _includes2 = _interopRequireDefault(_includes);
4602
+
4454
4603
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4455
4604
 
4456
4605
  // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
@@ -4458,10 +4607,36 @@ var validISO31661Alpha2CountriesCodes = ['AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM
4458
4607
 
4459
4608
  function isISO31661Alpha2(str) {
4460
4609
  (0, _assertString2.default)(str);
4461
- return validISO31661Alpha2CountriesCodes.includes(str.toUpperCase());
4610
+ return (0, _includes2.default)(validISO31661Alpha2CountriesCodes, str.toUpperCase());
4611
+ }
4612
+ module.exports = exports['default'];
4613
+ },{"./util/assertString":74,"./util/includes":75}],37:[function(require,module,exports){
4614
+ 'use strict';
4615
+
4616
+ Object.defineProperty(exports, "__esModule", {
4617
+ value: true
4618
+ });
4619
+ exports.default = isISO31661Alpha3;
4620
+
4621
+ var _assertString = require('./util/assertString');
4622
+
4623
+ var _assertString2 = _interopRequireDefault(_assertString);
4624
+
4625
+ var _includes = require('./util/includes');
4626
+
4627
+ var _includes2 = _interopRequireDefault(_includes);
4628
+
4629
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4630
+
4631
+ // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
4632
+ var validISO31661Alpha3CountriesCodes = ['AFG', 'ALA', 'ALB', 'DZA', 'ASM', 'AND', 'AGO', 'AIA', 'ATA', 'ATG', 'ARG', 'ARM', 'ABW', 'AUS', 'AUT', 'AZE', 'BHS', 'BHR', 'BGD', 'BRB', 'BLR', 'BEL', 'BLZ', 'BEN', 'BMU', 'BTN', 'BOL', 'BES', 'BIH', 'BWA', 'BVT', 'BRA', 'IOT', 'BRN', 'BGR', 'BFA', 'BDI', 'KHM', 'CMR', 'CAN', 'CPV', 'CYM', 'CAF', 'TCD', 'CHL', 'CHN', 'CXR', 'CCK', 'COL', 'COM', 'COG', 'COD', 'COK', 'CRI', 'CIV', 'HRV', 'CUB', 'CUW', 'CYP', 'CZE', 'DNK', 'DJI', 'DMA', 'DOM', 'ECU', 'EGY', 'SLV', 'GNQ', 'ERI', 'EST', 'ETH', 'FLK', 'FRO', 'FJI', 'FIN', 'FRA', 'GUF', 'PYF', 'ATF', 'GAB', 'GMB', 'GEO', 'DEU', 'GHA', 'GIB', 'GRC', 'GRL', 'GRD', 'GLP', 'GUM', 'GTM', 'GGY', 'GIN', 'GNB', 'GUY', 'HTI', 'HMD', 'VAT', 'HND', 'HKG', 'HUN', 'ISL', 'IND', 'IDN', 'IRN', 'IRQ', 'IRL', 'IMN', 'ISR', 'ITA', 'JAM', 'JPN', 'JEY', 'JOR', 'KAZ', 'KEN', 'KIR', 'PRK', 'KOR', 'KWT', 'KGZ', 'LAO', 'LVA', 'LBN', 'LSO', 'LBR', 'LBY', 'LIE', 'LTU', 'LUX', 'MAC', 'MKD', 'MDG', 'MWI', 'MYS', 'MDV', 'MLI', 'MLT', 'MHL', 'MTQ', 'MRT', 'MUS', 'MYT', 'MEX', 'FSM', 'MDA', 'MCO', 'MNG', 'MNE', 'MSR', 'MAR', 'MOZ', 'MMR', 'NAM', 'NRU', 'NPL', 'NLD', 'NCL', 'NZL', 'NIC', 'NER', 'NGA', 'NIU', 'NFK', 'MNP', 'NOR', 'OMN', 'PAK', 'PLW', 'PSE', 'PAN', 'PNG', 'PRY', 'PER', 'PHL', 'PCN', 'POL', 'PRT', 'PRI', 'QAT', 'REU', 'ROU', 'RUS', 'RWA', 'BLM', 'SHN', 'KNA', 'LCA', 'MAF', 'SPM', 'VCT', 'WSM', 'SMR', 'STP', 'SAU', 'SEN', 'SRB', 'SYC', 'SLE', 'SGP', 'SXM', 'SVK', 'SVN', 'SLB', 'SOM', 'ZAF', 'SGS', 'SSD', 'ESP', 'LKA', 'SDN', 'SUR', 'SJM', 'SWZ', 'SWE', 'CHE', 'SYR', 'TWN', 'TJK', 'TZA', 'THA', 'TLS', 'TGO', 'TKL', 'TON', 'TTO', 'TUN', 'TUR', 'TKM', 'TCA', 'TUV', 'UGA', 'UKR', 'ARE', 'GBR', 'USA', 'UMI', 'URY', 'UZB', 'VUT', 'VEN', 'VNM', 'VGB', 'VIR', 'WLF', 'ESH', 'YEM', 'ZMB', 'ZWE'];
4633
+
4634
+ function isISO31661Alpha3(str) {
4635
+ (0, _assertString2.default)(str);
4636
+ return (0, _includes2.default)(validISO31661Alpha3CountriesCodes, str.toUpperCase());
4462
4637
  }
4463
4638
  module.exports = exports['default'];
4464
- },{"./util/assertString":71}],36:[function(require,module,exports){
4639
+ },{"./util/assertString":74,"./util/includes":75}],38:[function(require,module,exports){
4465
4640
  'use strict';
4466
4641
 
4467
4642
  Object.defineProperty(exports, "__esModule", {
@@ -4485,7 +4660,7 @@ function isISO8601(str) {
4485
4660
  return iso8601.test(str);
4486
4661
  }
4487
4662
  module.exports = exports['default'];
4488
- },{"./util/assertString":71}],37:[function(require,module,exports){
4663
+ },{"./util/assertString":74}],39:[function(require,module,exports){
4489
4664
  'use strict';
4490
4665
 
4491
4666
  Object.defineProperty(exports, "__esModule", {
@@ -4507,7 +4682,7 @@ function isISRC(str) {
4507
4682
  return isrc.test(str);
4508
4683
  }
4509
4684
  module.exports = exports['default'];
4510
- },{"./util/assertString":71}],38:[function(require,module,exports){
4685
+ },{"./util/assertString":74}],40:[function(require,module,exports){
4511
4686
  'use strict';
4512
4687
 
4513
4688
  Object.defineProperty(exports, "__esModule", {
@@ -4533,40 +4708,16 @@ function isISSN(str) {
4533
4708
  if (!testIssn.test(str)) {
4534
4709
  return false;
4535
4710
  }
4536
- var issnDigits = str.replace('-', '');
4537
- var position = 8;
4711
+ var digits = str.replace('-', '').toUpperCase();
4538
4712
  var checksum = 0;
4539
- var _iteratorNormalCompletion = true;
4540
- var _didIteratorError = false;
4541
- var _iteratorError = undefined;
4542
-
4543
- try {
4544
- for (var _iterator = issnDigits[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
4545
- var digit = _step.value;
4546
-
4547
- var digitValue = digit.toUpperCase() === 'X' ? 10 : +digit;
4548
- checksum += digitValue * position;
4549
- --position;
4550
- }
4551
- } catch (err) {
4552
- _didIteratorError = true;
4553
- _iteratorError = err;
4554
- } finally {
4555
- try {
4556
- if (!_iteratorNormalCompletion && _iterator.return) {
4557
- _iterator.return();
4558
- }
4559
- } finally {
4560
- if (_didIteratorError) {
4561
- throw _iteratorError;
4562
- }
4563
- }
4713
+ for (var i = 0; i < digits.length; i++) {
4714
+ var digit = digits[i];
4715
+ checksum += (digit === 'X' ? 10 : +digit) * (8 - i);
4564
4716
  }
4565
-
4566
4717
  return checksum % 11 === 0;
4567
4718
  }
4568
4719
  module.exports = exports['default'];
4569
- },{"./util/assertString":71}],39:[function(require,module,exports){
4720
+ },{"./util/assertString":74}],41:[function(require,module,exports){
4570
4721
  'use strict';
4571
4722
 
4572
4723
  Object.defineProperty(exports, "__esModule", {
@@ -4606,7 +4757,7 @@ function isIn(str, options) {
4606
4757
  return false;
4607
4758
  }
4608
4759
  module.exports = exports['default'];
4609
- },{"./util/assertString":71,"./util/toString":73}],40:[function(require,module,exports){
4760
+ },{"./util/assertString":74,"./util/toString":77}],42:[function(require,module,exports){
4610
4761
  'use strict';
4611
4762
 
4612
4763
  Object.defineProperty(exports, "__esModule", {
@@ -4640,7 +4791,7 @@ function isInt(str, options) {
4640
4791
  return regex.test(str) && minCheckPassed && maxCheckPassed && ltCheckPassed && gtCheckPassed;
4641
4792
  }
4642
4793
  module.exports = exports['default'];
4643
- },{"./util/assertString":71}],41:[function(require,module,exports){
4794
+ },{"./util/assertString":74}],43:[function(require,module,exports){
4644
4795
  'use strict';
4645
4796
 
4646
4797
  Object.defineProperty(exports, "__esModule", {
@@ -4666,7 +4817,7 @@ function isJSON(str) {
4666
4817
  return false;
4667
4818
  }
4668
4819
  module.exports = exports['default'];
4669
- },{"./util/assertString":71}],42:[function(require,module,exports){
4820
+ },{"./util/assertString":74}],44:[function(require,module,exports){
4670
4821
  'use strict';
4671
4822
 
4672
4823
  Object.defineProperty(exports, "__esModule", {
@@ -4690,7 +4841,7 @@ var lat = /^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/;
4690
4841
  var long = /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/;
4691
4842
 
4692
4843
  module.exports = exports['default'];
4693
- },{"./util/assertString":71}],43:[function(require,module,exports){
4844
+ },{"./util/assertString":74}],45:[function(require,module,exports){
4694
4845
  'use strict';
4695
4846
 
4696
4847
  Object.defineProperty(exports, "__esModule", {
@@ -4725,7 +4876,7 @@ function isLength(str, options) {
4725
4876
  return len >= min && (typeof max === 'undefined' || len <= max);
4726
4877
  }
4727
4878
  module.exports = exports['default'];
4728
- },{"./util/assertString":71}],44:[function(require,module,exports){
4879
+ },{"./util/assertString":74}],46:[function(require,module,exports){
4729
4880
  'use strict';
4730
4881
 
4731
4882
  Object.defineProperty(exports, "__esModule", {
@@ -4744,7 +4895,7 @@ function isLowercase(str) {
4744
4895
  return str === str.toLowerCase();
4745
4896
  }
4746
4897
  module.exports = exports['default'];
4747
- },{"./util/assertString":71}],45:[function(require,module,exports){
4898
+ },{"./util/assertString":74}],47:[function(require,module,exports){
4748
4899
  'use strict';
4749
4900
 
4750
4901
  Object.defineProperty(exports, "__esModule", {
@@ -4759,13 +4910,17 @@ var _assertString2 = _interopRequireDefault(_assertString);
4759
4910
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4760
4911
 
4761
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}$/;
4762
4914
 
4763
- function isMACAddress(str) {
4915
+ function isMACAddress(str, options) {
4764
4916
  (0, _assertString2.default)(str);
4917
+ if (options && options.no_colons) {
4918
+ return macAddressNoColons.test(str);
4919
+ }
4765
4920
  return macAddress.test(str);
4766
4921
  }
4767
4922
  module.exports = exports['default'];
4768
- },{"./util/assertString":71}],46:[function(require,module,exports){
4923
+ },{"./util/assertString":74}],48:[function(require,module,exports){
4769
4924
  'use strict';
4770
4925
 
4771
4926
  Object.defineProperty(exports, "__esModule", {
@@ -4786,7 +4941,7 @@ function isMD5(str) {
4786
4941
  return md5.test(str);
4787
4942
  }
4788
4943
  module.exports = exports['default'];
4789
- },{"./util/assertString":71}],47:[function(require,module,exports){
4944
+ },{"./util/assertString":74}],49:[function(require,module,exports){
4790
4945
  'use strict';
4791
4946
 
4792
4947
  Object.defineProperty(exports, "__esModule", {
@@ -4839,7 +4994,7 @@ function isMimeType(str) {
4839
4994
  return mimeTypeSimple.test(str) || mimeTypeText.test(str) || mimeTypeMultipart.test(str);
4840
4995
  }
4841
4996
  module.exports = exports['default'];
4842
- },{"./util/assertString":71}],48:[function(require,module,exports){
4997
+ },{"./util/assertString":74}],50:[function(require,module,exports){
4843
4998
  'use strict';
4844
4999
 
4845
5000
  Object.defineProperty(exports, "__esModule", {
@@ -4858,14 +5013,18 @@ var phones = {
4858
5013
  'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/,
4859
5014
  'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/,
4860
5015
  'ar-EG': /^((\+?20)|0)?1[012]\d{8}$/,
5016
+ 'ar-IQ': /^(\+?964|0)?7[0-9]\d{8}$/,
4861
5017
  'ar-JO': /^(\+?962|0)?7[789]\d{7}$/,
5018
+ 'ar-KW': /^(\+?965)[569]\d{7}$/,
4862
5019
  'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/,
4863
5020
  'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/,
5021
+ 'ar-TN': /^(\+?216)?[2459]\d{7}$/,
4864
5022
  'be-BY': /^(\+?375)?(24|25|29|33|44)\d{7}$/,
4865
5023
  'bg-BG': /^(\+?359|0)?8[789]\d{7}$/,
5024
+ 'bn-BD': /\+?(88)?0?1[156789][0-9]{8}\b/,
4866
5025
  'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
4867
5026
  'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,
4868
- '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})?$/,
4869
5028
  'el-GR': /^(\+?30|0)?(69\d{8})$/,
4870
5029
  'en-AU': /^(\+?61|0)4\d{8}$/,
4871
5030
  'en-GB': /^(\+?44|0)7\d{9}$/,
@@ -4873,13 +5032,13 @@ var phones = {
4873
5032
  'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
4874
5033
  'en-KE': /^(\+?254|0)?[7]\d{8}$/,
4875
5034
  'en-NG': /^(\+?234|0)?[789]\d{9}$/,
4876
- 'en-NZ': /^(\+?64|0)2\d{7,9}$/,
5035
+ 'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
4877
5036
  'en-PK': /^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/,
4878
5037
  'en-RW': /^(\+?250|0)?[7]\d{8}$/,
4879
5038
  'en-SG': /^(\+65)?[89]\d{7}$/,
4880
5039
  'en-TZ': /^(\+?255|0)?[67]\d{8}$/,
4881
5040
  'en-UG': /^(\+?256|0)?[7]\d{8}$/,
4882
- '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})$/,
4883
5042
  'en-ZA': /^(\+?27|0)\d{9}$/,
4884
5043
  'en-ZM': /^(\+?26)?09[567]\d{7}$/,
4885
5044
  'es-ES': /^(\+?34)?(6\d{1}|7[1234])\d{7}$/,
@@ -4888,9 +5047,9 @@ var phones = {
4888
5047
  'fi-FI': /^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/,
4889
5048
  'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
4890
5049
  'fr-FR': /^(\+?33|0)[67]\d{8}$/,
4891
- 'he-IL': /^(\+972|0)([23489]|5[0248]|77)[1-9]\d{6}/,
5050
+ 'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}/,
4892
5051
  'hu-HU': /^(\+?36)(20|30|70)\d{7}$/,
4893
- 'id-ID': /^(\+?62|0[1-9])[\s|\d]+$/,
5052
+ 'id-ID': /^(\+?62|0)(0?8?\d\d\s?\d?)([\s?|\d]{7,12})$/,
4894
5053
  'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/,
4895
5054
  'ja-JP': /^(\+?81|0)[789]0[ \-]?[1-9]\d{2}[ \-]?\d{5}$/,
4896
5055
  'kk-KZ': /^(\+?7|8)?7\d{9}$/,
@@ -4908,11 +5067,12 @@ var phones = {
4908
5067
  'ru-RU': /^(\+?7|8)?9\d{9}$/,
4909
5068
  'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
4910
5069
  'sr-RS': /^(\+3816|06)[- \d]{5,9}$/,
5070
+ 'sv-SE': /^(\+?46|0)[\s\-]?7[\s\-]?[02369]([\s\-]?\d){7}$/,
4911
5071
  'th-TH': /^(\+66|66|0)\d{9}$/,
4912
5072
  'tr-TR': /^(\+?90|0)?5\d{9}$/,
4913
5073
  'uk-UA': /^(\+?38|8)?0\d{9}$/,
4914
5074
  'vi-VN': /^(\+?84|0)?((1(2([0-9])|6([2-9])|88|99))|(9((?!5)[0-9])))([0-9]{7})$/,
4915
- '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}$/,
4916
5076
  'zh-TW': /^(\+?886\-?|0)?9\d{8}$/
4917
5077
  };
4918
5078
  /* eslint-enable max-len */
@@ -4927,9 +5087,20 @@ function isMobilePhone(str, locale, options) {
4927
5087
  if (options && options.strictMode && !str.startsWith('+')) {
4928
5088
  return false;
4929
5089
  }
4930
- 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) {
4931
5101
  return phones[locale].test(str);
4932
- } else if (locale === 'any') {
5102
+ // alias falsey locale as 'any'
5103
+ } else if (!locale || locale === 'any') {
4933
5104
  for (var key in phones) {
4934
5105
  if (phones.hasOwnProperty(key)) {
4935
5106
  var phone = phones[key];
@@ -4943,7 +5114,7 @@ function isMobilePhone(str, locale, options) {
4943
5114
  throw new Error('Invalid locale \'' + locale + '\'');
4944
5115
  }
4945
5116
  module.exports = exports['default'];
4946
- },{"./util/assertString":71}],49:[function(require,module,exports){
5117
+ },{"./util/assertString":74}],51:[function(require,module,exports){
4947
5118
  'use strict';
4948
5119
 
4949
5120
  Object.defineProperty(exports, "__esModule", {
@@ -4966,7 +5137,7 @@ function isMongoId(str) {
4966
5137
  return (0, _isHexadecimal2.default)(str) && str.length === 24;
4967
5138
  }
4968
5139
  module.exports = exports['default'];
4969
- },{"./isHexadecimal":31,"./util/assertString":71}],50:[function(require,module,exports){
5140
+ },{"./isHexadecimal":31,"./util/assertString":74}],52:[function(require,module,exports){
4970
5141
  'use strict';
4971
5142
 
4972
5143
  Object.defineProperty(exports, "__esModule", {
@@ -4989,7 +5160,7 @@ function isMultibyte(str) {
4989
5160
  return multibyte.test(str);
4990
5161
  }
4991
5162
  module.exports = exports['default'];
4992
- },{"./util/assertString":71}],51:[function(require,module,exports){
5163
+ },{"./util/assertString":74}],53:[function(require,module,exports){
4993
5164
  'use strict';
4994
5165
 
4995
5166
  Object.defineProperty(exports, "__esModule", {
@@ -5003,14 +5174,18 @@ var _assertString2 = _interopRequireDefault(_assertString);
5003
5174
 
5004
5175
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5005
5176
 
5006
- var numeric = /^[-+]?[0-9]+$/;
5177
+ var numeric = /^[+-]?([0-9]*[.])?[0-9]+$/;
5178
+ var numericNoSymbols = /^[0-9]+$/;
5007
5179
 
5008
- function isNumeric(str) {
5180
+ function isNumeric(str, options) {
5009
5181
  (0, _assertString2.default)(str);
5182
+ if (options && options.no_symbols) {
5183
+ return numericNoSymbols.test(str);
5184
+ }
5010
5185
  return numeric.test(str);
5011
5186
  }
5012
5187
  module.exports = exports['default'];
5013
- },{"./util/assertString":71}],52:[function(require,module,exports){
5188
+ },{"./util/assertString":74}],54:[function(require,module,exports){
5014
5189
  'use strict';
5015
5190
 
5016
5191
  Object.defineProperty(exports, "__esModule", {
@@ -5028,7 +5203,7 @@ function isPort(str) {
5028
5203
  return (0, _isInt2.default)(str, { min: 0, max: 65535 });
5029
5204
  }
5030
5205
  module.exports = exports['default'];
5031
- },{"./isInt":40}],53:[function(require,module,exports){
5206
+ },{"./isInt":42}],55:[function(require,module,exports){
5032
5207
  'use strict';
5033
5208
 
5034
5209
  Object.defineProperty(exports, "__esModule", {
@@ -5067,6 +5242,7 @@ var fiveDigit = /^\d{5}$/;
5067
5242
  var sixDigit = /^\d{6}$/;
5068
5243
 
5069
5244
  var patterns = {
5245
+ AD: /^AD\d{3}$/,
5070
5246
  AT: fourDigit,
5071
5247
  AU: fourDigit,
5072
5248
  BE: fourDigit,
@@ -5077,11 +5253,14 @@ var patterns = {
5077
5253
  DE: fiveDigit,
5078
5254
  DK: fourDigit,
5079
5255
  DZ: fiveDigit,
5256
+ EE: fiveDigit,
5080
5257
  ES: fiveDigit,
5081
5258
  FI: fiveDigit,
5082
5259
  FR: /^\d{2}\s?\d{3}$/,
5083
5260
  GB: /^(gir\s?0aa|[a-z]{1,2}\d[\da-z]?\s?(\d[a-z]{2})?)$/i,
5084
5261
  GR: /^\d{3}\s?\d{2}$/,
5262
+ HR: /^([1-5]\d{4}$)/,
5263
+ HU: fourDigit,
5085
5264
  IL: fiveDigit,
5086
5265
  IN: sixDigit,
5087
5266
  IS: threeDigit,
@@ -5089,6 +5268,9 @@ var patterns = {
5089
5268
  JP: /^\d{3}\-\d{4}$/,
5090
5269
  KE: fiveDigit,
5091
5270
  LI: /^(948[5-9]|949[0-7])$/,
5271
+ LT: /^LT\-\d{5}$/,
5272
+ LU: fourDigit,
5273
+ LV: /^LV\-\d{4}$/,
5092
5274
  MX: fiveDigit,
5093
5275
  NL: /^\d{4}\s?[a-z]{2}$/i,
5094
5276
  NO: fourDigit,
@@ -5098,6 +5280,9 @@ var patterns = {
5098
5280
  RU: sixDigit,
5099
5281
  SA: fiveDigit,
5100
5282
  SE: /^\d{3}\s?\d{2}$/,
5283
+ SI: fourDigit,
5284
+ SK: /^\d{3}\s?\d{2}$/,
5285
+ TN: fourDigit,
5101
5286
  TW: /^\d{3}(\d{2})?$/,
5102
5287
  US: /^\d{5}(-\d{4})?$/,
5103
5288
  ZA: fourDigit,
@@ -5105,7 +5290,47 @@ var patterns = {
5105
5290
  };
5106
5291
 
5107
5292
  var locales = exports.locales = Object.keys(patterns);
5108
- },{"./util/assertString":71}],54:[function(require,module,exports){
5293
+ },{"./util/assertString":74}],56:[function(require,module,exports){
5294
+ 'use strict';
5295
+
5296
+ Object.defineProperty(exports, "__esModule", {
5297
+ value: true
5298
+ });
5299
+ exports.default = isRFC3339;
5300
+
5301
+ var _assertString = require('./util/assertString');
5302
+
5303
+ var _assertString2 = _interopRequireDefault(_assertString);
5304
+
5305
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5306
+
5307
+ /* Based on https://tools.ietf.org/html/rfc3339#section-5.6 */
5308
+
5309
+ var dateFullYear = /[0-9]{4}/;
5310
+ var dateMonth = /(0[1-9]|1[0-2])/;
5311
+ var dateMDay = /([12]\d|0[1-9]|3[01])/;
5312
+
5313
+ var timeHour = /([01][0-9]|2[0-3])/;
5314
+ var timeMinute = /[0-5][0-9]/;
5315
+ var timeSecond = /([0-5][0-9]|60)/;
5316
+
5317
+ var timeSecFrac = /(\.[0-9]+)?/;
5318
+ var timeNumOffset = new RegExp('[-+]' + timeHour.source + ':' + timeMinute.source);
5319
+ var timeOffset = new RegExp('([zZ]|' + timeNumOffset.source + ')');
5320
+
5321
+ var partialTime = new RegExp(timeHour.source + ':' + timeMinute.source + ':' + timeSecond.source + timeSecFrac.source);
5322
+
5323
+ var fullDate = new RegExp(dateFullYear.source + '-' + dateMonth.source + '-' + dateMDay.source);
5324
+ var fullTime = new RegExp('' + partialTime.source + timeOffset.source);
5325
+
5326
+ var rfc3339 = new RegExp(fullDate.source + '[ tT]' + fullTime.source);
5327
+
5328
+ function isRFC3339(str) {
5329
+ (0, _assertString2.default)(str);
5330
+ return rfc3339.test(str);
5331
+ }
5332
+ module.exports = exports['default'];
5333
+ },{"./util/assertString":74}],57:[function(require,module,exports){
5109
5334
  'use strict';
5110
5335
 
5111
5336
  Object.defineProperty(exports, "__esModule", {
@@ -5126,7 +5351,7 @@ function isSurrogatePair(str) {
5126
5351
  return surrogatePair.test(str);
5127
5352
  }
5128
5353
  module.exports = exports['default'];
5129
- },{"./util/assertString":71}],55:[function(require,module,exports){
5354
+ },{"./util/assertString":74}],58:[function(require,module,exports){
5130
5355
  'use strict';
5131
5356
 
5132
5357
  Object.defineProperty(exports, "__esModule", {
@@ -5211,7 +5436,10 @@ function isURL(url, options) {
5211
5436
  }
5212
5437
  } else if (options.require_protocol) {
5213
5438
  return false;
5214
- } 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
+ }
5215
5443
  split[0] = url.substr(2);
5216
5444
  }
5217
5445
  url = split.join('://');
@@ -5274,7 +5502,7 @@ function isURL(url, options) {
5274
5502
  return true;
5275
5503
  }
5276
5504
  module.exports = exports['default'];
5277
- },{"./isFQDN":25,"./isIP":32,"./util/assertString":71,"./util/merge":72}],56:[function(require,module,exports){
5505
+ },{"./isFQDN":25,"./isIP":32,"./util/assertString":74,"./util/merge":76}],59:[function(require,module,exports){
5278
5506
  'use strict';
5279
5507
 
5280
5508
  Object.defineProperty(exports, "__esModule", {
@@ -5303,7 +5531,7 @@ function isUUID(str) {
5303
5531
  return pattern && pattern.test(str);
5304
5532
  }
5305
5533
  module.exports = exports['default'];
5306
- },{"./util/assertString":71}],57:[function(require,module,exports){
5534
+ },{"./util/assertString":74}],60:[function(require,module,exports){
5307
5535
  'use strict';
5308
5536
 
5309
5537
  Object.defineProperty(exports, "__esModule", {
@@ -5322,7 +5550,7 @@ function isUppercase(str) {
5322
5550
  return str === str.toUpperCase();
5323
5551
  }
5324
5552
  module.exports = exports['default'];
5325
- },{"./util/assertString":71}],58:[function(require,module,exports){
5553
+ },{"./util/assertString":74}],61:[function(require,module,exports){
5326
5554
  'use strict';
5327
5555
 
5328
5556
  Object.defineProperty(exports, "__esModule", {
@@ -5345,7 +5573,7 @@ function isVariableWidth(str) {
5345
5573
  return _isFullWidth.fullWidth.test(str) && _isHalfWidth.halfWidth.test(str);
5346
5574
  }
5347
5575
  module.exports = exports['default'];
5348
- },{"./isFullWidth":27,"./isHalfWidth":28,"./util/assertString":71}],59:[function(require,module,exports){
5576
+ },{"./isFullWidth":27,"./isHalfWidth":28,"./util/assertString":74}],62:[function(require,module,exports){
5349
5577
  'use strict';
5350
5578
 
5351
5579
  Object.defineProperty(exports, "__esModule", {
@@ -5369,7 +5597,7 @@ function isWhitelisted(str, chars) {
5369
5597
  return true;
5370
5598
  }
5371
5599
  module.exports = exports['default'];
5372
- },{"./util/assertString":71}],60:[function(require,module,exports){
5600
+ },{"./util/assertString":74}],63:[function(require,module,exports){
5373
5601
  'use strict';
5374
5602
 
5375
5603
  Object.defineProperty(exports, "__esModule", {
@@ -5389,7 +5617,7 @@ function ltrim(str, chars) {
5389
5617
  return str.replace(pattern, '');
5390
5618
  }
5391
5619
  module.exports = exports['default'];
5392
- },{"./util/assertString":71}],61:[function(require,module,exports){
5620
+ },{"./util/assertString":74}],64:[function(require,module,exports){
5393
5621
  'use strict';
5394
5622
 
5395
5623
  Object.defineProperty(exports, "__esModule", {
@@ -5411,7 +5639,7 @@ function matches(str, pattern, modifiers) {
5411
5639
  return pattern.test(str);
5412
5640
  }
5413
5641
  module.exports = exports['default'];
5414
- },{"./util/assertString":71}],62:[function(require,module,exports){
5642
+ },{"./util/assertString":74}],65:[function(require,module,exports){
5415
5643
  'use strict';
5416
5644
 
5417
5645
  Object.defineProperty(exports, "__esModule", {
@@ -5454,6 +5682,10 @@ var default_normalize_email_options = {
5454
5682
  // Removes the subaddress (e.g. "-foo") from the email address
5455
5683
  yahoo_remove_subaddress: true,
5456
5684
 
5685
+ // The following conversions are specific to Yandex
5686
+ // Lowercases the local part of the Yandex address (known to be case-insensitive)
5687
+ yandex_lowercase: true,
5688
+
5457
5689
  // The following conversions are specific to iCloud
5458
5690
  // Lowercases the local part of the iCloud address (known to be case-insensitive)
5459
5691
  icloud_lowercase: true,
@@ -5474,6 +5706,17 @@ var outlookdotcom_domains = ['hotmail.at', 'hotmail.be', 'hotmail.ca', 'hotmail.
5474
5706
  // This list is likely incomplete
5475
5707
  var yahoo_domains = ['rocketmail.com', 'yahoo.ca', 'yahoo.co.uk', 'yahoo.com', 'yahoo.de', 'yahoo.fr', 'yahoo.in', 'yahoo.it', 'ymail.com'];
5476
5708
 
5709
+ // List of domains used by yandex.ru
5710
+ var yandex_domains = ['yandex.ru', 'yandex.ua', 'yandex.kz', 'yandex.com', 'yandex.by', 'ya.ru'];
5711
+
5712
+ // replace single dots, but not multiple consecutive dots
5713
+ function dotsReplacer(match) {
5714
+ if (match.length > 1) {
5715
+ return match;
5716
+ }
5717
+ return '';
5718
+ }
5719
+
5477
5720
  function normalizeEmail(email, options) {
5478
5721
  options = (0, _merge2.default)(options, default_normalize_email_options);
5479
5722
 
@@ -5491,7 +5734,8 @@ function normalizeEmail(email, options) {
5491
5734
  parts[0] = parts[0].split('+')[0];
5492
5735
  }
5493
5736
  if (options.gmail_remove_dots) {
5494
- parts[0] = parts[0].replace(/\./g, '');
5737
+ // this does not replace consecutive dots like example..email@gmail.com
5738
+ parts[0] = parts[0].replace(/\.+/g, dotsReplacer);
5495
5739
  }
5496
5740
  if (!parts[0].length) {
5497
5741
  return false;
@@ -5500,7 +5744,7 @@ function normalizeEmail(email, options) {
5500
5744
  parts[0] = parts[0].toLowerCase();
5501
5745
  }
5502
5746
  parts[1] = options.gmail_convert_googlemaildotcom ? 'gmail.com' : parts[1];
5503
- } else if (~icloud_domains.indexOf(parts[1])) {
5747
+ } else if (icloud_domains.indexOf(parts[1]) >= 0) {
5504
5748
  // Address is iCloud
5505
5749
  if (options.icloud_remove_subaddress) {
5506
5750
  parts[0] = parts[0].split('+')[0];
@@ -5511,7 +5755,7 @@ function normalizeEmail(email, options) {
5511
5755
  if (options.all_lowercase || options.icloud_lowercase) {
5512
5756
  parts[0] = parts[0].toLowerCase();
5513
5757
  }
5514
- } else if (~outlookdotcom_domains.indexOf(parts[1])) {
5758
+ } else if (outlookdotcom_domains.indexOf(parts[1]) >= 0) {
5515
5759
  // Address is Outlook.com
5516
5760
  if (options.outlookdotcom_remove_subaddress) {
5517
5761
  parts[0] = parts[0].split('+')[0];
@@ -5522,7 +5766,7 @@ function normalizeEmail(email, options) {
5522
5766
  if (options.all_lowercase || options.outlookdotcom_lowercase) {
5523
5767
  parts[0] = parts[0].toLowerCase();
5524
5768
  }
5525
- } else if (~yahoo_domains.indexOf(parts[1])) {
5769
+ } else if (yahoo_domains.indexOf(parts[1]) >= 0) {
5526
5770
  // Address is Yahoo
5527
5771
  if (options.yahoo_remove_subaddress) {
5528
5772
  var components = parts[0].split('-');
@@ -5534,6 +5778,11 @@ function normalizeEmail(email, options) {
5534
5778
  if (options.all_lowercase || options.yahoo_lowercase) {
5535
5779
  parts[0] = parts[0].toLowerCase();
5536
5780
  }
5781
+ } else if (yandex_domains.indexOf(parts[1]) >= 0) {
5782
+ if (options.all_lowercase || options.yandex_lowercase) {
5783
+ parts[0] = parts[0].toLowerCase();
5784
+ }
5785
+ parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preffered
5537
5786
  } else if (options.all_lowercase) {
5538
5787
  // Any other address
5539
5788
  parts[0] = parts[0].toLowerCase();
@@ -5541,7 +5790,7 @@ function normalizeEmail(email, options) {
5541
5790
  return parts.join('@');
5542
5791
  }
5543
5792
  module.exports = exports['default'];
5544
- },{"./util/merge":72}],63:[function(require,module,exports){
5793
+ },{"./util/merge":76}],66:[function(require,module,exports){
5545
5794
  'use strict';
5546
5795
 
5547
5796
  Object.defineProperty(exports, "__esModule", {
@@ -5560,14 +5809,12 @@ function rtrim(str, chars) {
5560
5809
  var pattern = chars ? new RegExp('[' + chars + ']') : /\s/;
5561
5810
 
5562
5811
  var idx = str.length - 1;
5563
- while (idx >= 0 && pattern.test(str[idx])) {
5564
- idx--;
5565
- }
5812
+ for (; idx >= 0 && pattern.test(str[idx]); idx--) {}
5566
5813
 
5567
5814
  return idx < str.length ? str.substr(0, idx + 1) : str;
5568
5815
  }
5569
5816
  module.exports = exports['default'];
5570
- },{"./util/assertString":71}],64:[function(require,module,exports){
5817
+ },{"./util/assertString":74}],67:[function(require,module,exports){
5571
5818
  'use strict';
5572
5819
 
5573
5820
  Object.defineProperty(exports, "__esModule", {
@@ -5591,7 +5838,7 @@ function stripLow(str, keep_new_lines) {
5591
5838
  return (0, _blacklist2.default)(str, chars);
5592
5839
  }
5593
5840
  module.exports = exports['default'];
5594
- },{"./blacklist":6,"./util/assertString":71}],65:[function(require,module,exports){
5841
+ },{"./blacklist":6,"./util/assertString":74}],68:[function(require,module,exports){
5595
5842
  'use strict';
5596
5843
 
5597
5844
  Object.defineProperty(exports, "__esModule", {
@@ -5613,7 +5860,7 @@ function toBoolean(str, strict) {
5613
5860
  return str !== '0' && str !== 'false' && str !== '';
5614
5861
  }
5615
5862
  module.exports = exports['default'];
5616
- },{"./util/assertString":71}],66:[function(require,module,exports){
5863
+ },{"./util/assertString":74}],69:[function(require,module,exports){
5617
5864
  'use strict';
5618
5865
 
5619
5866
  Object.defineProperty(exports, "__esModule", {
@@ -5633,7 +5880,7 @@ function toDate(date) {
5633
5880
  return !isNaN(date) ? new Date(date) : null;
5634
5881
  }
5635
5882
  module.exports = exports['default'];
5636
- },{"./util/assertString":71}],67:[function(require,module,exports){
5883
+ },{"./util/assertString":74}],70:[function(require,module,exports){
5637
5884
  'use strict';
5638
5885
 
5639
5886
  Object.defineProperty(exports, "__esModule", {
@@ -5652,7 +5899,7 @@ function toFloat(str) {
5652
5899
  return parseFloat(str);
5653
5900
  }
5654
5901
  module.exports = exports['default'];
5655
- },{"./util/assertString":71}],68:[function(require,module,exports){
5902
+ },{"./util/assertString":74}],71:[function(require,module,exports){
5656
5903
  'use strict';
5657
5904
 
5658
5905
  Object.defineProperty(exports, "__esModule", {
@@ -5671,7 +5918,7 @@ function toInt(str, radix) {
5671
5918
  return parseInt(str, radix || 10);
5672
5919
  }
5673
5920
  module.exports = exports['default'];
5674
- },{"./util/assertString":71}],69:[function(require,module,exports){
5921
+ },{"./util/assertString":74}],72:[function(require,module,exports){
5675
5922
  'use strict';
5676
5923
 
5677
5924
  Object.defineProperty(exports, "__esModule", {
@@ -5693,7 +5940,7 @@ function trim(str, chars) {
5693
5940
  return (0, _rtrim2.default)((0, _ltrim2.default)(str, chars), chars);
5694
5941
  }
5695
5942
  module.exports = exports['default'];
5696
- },{"./ltrim":60,"./rtrim":63}],70:[function(require,module,exports){
5943
+ },{"./ltrim":63,"./rtrim":66}],73:[function(require,module,exports){
5697
5944
  'use strict';
5698
5945
 
5699
5946
  Object.defineProperty(exports, "__esModule", {
@@ -5712,7 +5959,7 @@ function unescape(str) {
5712
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, '`');
5713
5960
  }
5714
5961
  module.exports = exports['default'];
5715
- },{"./util/assertString":71}],71:[function(require,module,exports){
5962
+ },{"./util/assertString":74}],74:[function(require,module,exports){
5716
5963
  'use strict';
5717
5964
 
5718
5965
  Object.defineProperty(exports, "__esModule", {
@@ -5727,7 +5974,21 @@ function assertString(input) {
5727
5974
  }
5728
5975
  }
5729
5976
  module.exports = exports['default'];
5730
- },{}],72:[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){
5731
5992
  'use strict';
5732
5993
 
5733
5994
  Object.defineProperty(exports, "__esModule", {
@@ -5746,7 +6007,7 @@ function merge() {
5746
6007
  return obj;
5747
6008
  }
5748
6009
  module.exports = exports['default'];
5749
- },{}],73:[function(require,module,exports){
6010
+ },{}],77:[function(require,module,exports){
5750
6011
  'use strict';
5751
6012
 
5752
6013
  Object.defineProperty(exports, "__esModule", {
@@ -5769,7 +6030,7 @@ function toString(input) {
5769
6030
  return String(input);
5770
6031
  }
5771
6032
  module.exports = exports['default'];
5772
- },{}],74:[function(require,module,exports){
6033
+ },{}],78:[function(require,module,exports){
5773
6034
  'use strict';
5774
6035
 
5775
6036
  Object.defineProperty(exports, "__esModule", {
@@ -5788,7 +6049,7 @@ function whitelist(str, chars) {
5788
6049
  return str.replace(new RegExp('[^' + chars + ']+', 'g'), '');
5789
6050
  }
5790
6051
  module.exports = exports['default'];
5791
- },{"./util/assertString":71}],75:[function(require,module,exports){
6052
+ },{"./util/assertString":74}],79:[function(require,module,exports){
5792
6053
  "use strict";
5793
6054
 
5794
6055
  module.exports = {
@@ -5796,6 +6057,7 @@ module.exports = {
5796
6057
  INVALID_TYPE: "Expected type {0} but found type {1}",
5797
6058
  INVALID_FORMAT: "Object didn't pass validation for format {0}: {1}",
5798
6059
  ENUM_MISMATCH: "No enum match for: {0}",
6060
+ ENUM_CASE_MISMATCH: "Enum does not match case for: {0}",
5799
6061
  ANY_OF_MISSING: "Data does not match any schemas from 'anyOf'",
5800
6062
  ONE_OF_MISSING: "Data does not match any schemas from 'oneOf'",
5801
6063
  ONE_OF_MULTIPLE: "Data is valid against more than one schema from 'oneOf'",
@@ -5849,7 +6111,7 @@ module.exports = {
5849
6111
 
5850
6112
  };
5851
6113
 
5852
- },{}],76:[function(require,module,exports){
6114
+ },{}],80:[function(require,module,exports){
5853
6115
  /*jshint maxlen: false*/
5854
6116
 
5855
6117
  var validator = require("validator");
@@ -5980,12 +6242,12 @@ var FormatValidators = {
5980
6242
 
5981
6243
  module.exports = FormatValidators;
5982
6244
 
5983
- },{"validator":4}],77:[function(require,module,exports){
6245
+ },{"validator":4}],81:[function(require,module,exports){
5984
6246
  "use strict";
5985
6247
 
5986
- var FormatValidators = require("./FormatValidators"),
5987
- Report = require("./Report"),
5988
- Utils = require("./Utils");
6248
+ var FormatValidators = require("./FormatValidators"),
6249
+ Report = require("./Report"),
6250
+ Utils = require("./Utils");
5989
6251
 
5990
6252
  var JsonValidators = {
5991
6253
  multipleOf: function (report, schema, json) {
@@ -5994,7 +6256,7 @@ var JsonValidators = {
5994
6256
  return;
5995
6257
  }
5996
6258
  if (Utils.whatIs(json / schema.multipleOf) !== "integer") {
5997
- report.addError("MULTIPLE_OF", [json, schema.multipleOf], null, schema.description);
6259
+ report.addError("MULTIPLE_OF", [json, schema.multipleOf], null, schema);
5998
6260
  }
5999
6261
  },
6000
6262
  maximum: function (report, schema, json) {
@@ -6004,11 +6266,11 @@ var JsonValidators = {
6004
6266
  }
6005
6267
  if (schema.exclusiveMaximum !== true) {
6006
6268
  if (json > schema.maximum) {
6007
- report.addError("MAXIMUM", [json, schema.maximum], null, schema.description);
6269
+ report.addError("MAXIMUM", [json, schema.maximum], null, schema);
6008
6270
  }
6009
6271
  } else {
6010
6272
  if (json >= schema.maximum) {
6011
- report.addError("MAXIMUM_EXCLUSIVE", [json, schema.maximum], null, schema.description);
6273
+ report.addError("MAXIMUM_EXCLUSIVE", [json, schema.maximum], null, schema);
6012
6274
  }
6013
6275
  }
6014
6276
  },
@@ -6022,11 +6284,11 @@ var JsonValidators = {
6022
6284
  }
6023
6285
  if (schema.exclusiveMinimum !== true) {
6024
6286
  if (json < schema.minimum) {
6025
- report.addError("MINIMUM", [json, schema.minimum], null, schema.description);
6287
+ report.addError("MINIMUM", [json, schema.minimum], null, schema);
6026
6288
  }
6027
6289
  } else {
6028
6290
  if (json <= schema.minimum) {
6029
- report.addError("MINIMUM_EXCLUSIVE", [json, schema.minimum], null, schema.description);
6291
+ report.addError("MINIMUM_EXCLUSIVE", [json, schema.minimum], null, schema);
6030
6292
  }
6031
6293
  }
6032
6294
  },
@@ -6039,7 +6301,7 @@ var JsonValidators = {
6039
6301
  return;
6040
6302
  }
6041
6303
  if (Utils.ucs2decode(json).length > schema.maxLength) {
6042
- report.addError("MAX_LENGTH", [json.length, schema.maxLength], null, schema.description);
6304
+ report.addError("MAX_LENGTH", [json.length, schema.maxLength], null, schema);
6043
6305
  }
6044
6306
  },
6045
6307
  minLength: function (report, schema, json) {
@@ -6048,7 +6310,7 @@ var JsonValidators = {
6048
6310
  return;
6049
6311
  }
6050
6312
  if (Utils.ucs2decode(json).length < schema.minLength) {
6051
- report.addError("MIN_LENGTH", [json.length, schema.minLength], null, schema.description);
6313
+ report.addError("MIN_LENGTH", [json.length, schema.minLength], null, schema);
6052
6314
  }
6053
6315
  },
6054
6316
  pattern: function (report, schema, json) {
@@ -6057,7 +6319,7 @@ var JsonValidators = {
6057
6319
  return;
6058
6320
  }
6059
6321
  if (RegExp(schema.pattern).test(json) === false) {
6060
- report.addError("PATTERN", [schema.pattern, json], null, schema.description);
6322
+ report.addError("PATTERN", [schema.pattern, json], null, schema);
6061
6323
  }
6062
6324
  },
6063
6325
  additionalItems: function (report, schema, json) {
@@ -6069,7 +6331,7 @@ var JsonValidators = {
6069
6331
  // the json is valid if its size is less than, or equal to, the size of "items".
6070
6332
  if (schema.additionalItems === false && Array.isArray(schema.items)) {
6071
6333
  if (json.length > schema.items.length) {
6072
- report.addError("ARRAY_ADDITIONAL_ITEMS", null, null, schema.description);
6334
+ report.addError("ARRAY_ADDITIONAL_ITEMS", null, null, schema);
6073
6335
  }
6074
6336
  }
6075
6337
  },
@@ -6082,7 +6344,7 @@ var JsonValidators = {
6082
6344
  return;
6083
6345
  }
6084
6346
  if (json.length > schema.maxItems) {
6085
- report.addError("ARRAY_LENGTH_LONG", [json.length, schema.maxItems], null, schema.description);
6347
+ report.addError("ARRAY_LENGTH_LONG", [json.length, schema.maxItems], null, schema);
6086
6348
  }
6087
6349
  },
6088
6350
  minItems: function (report, schema, json) {
@@ -6091,7 +6353,7 @@ var JsonValidators = {
6091
6353
  return;
6092
6354
  }
6093
6355
  if (json.length < schema.minItems) {
6094
- report.addError("ARRAY_LENGTH_SHORT", [json.length, schema.minItems], null, schema.description);
6356
+ report.addError("ARRAY_LENGTH_SHORT", [json.length, schema.minItems], null, schema);
6095
6357
  }
6096
6358
  },
6097
6359
  uniqueItems: function (report, schema, json) {
@@ -6102,7 +6364,7 @@ var JsonValidators = {
6102
6364
  if (schema.uniqueItems === true) {
6103
6365
  var matches = [];
6104
6366
  if (Utils.isUniqueArray(json, matches) === false) {
6105
- report.addError("ARRAY_UNIQUE", matches, null, schema.description);
6367
+ report.addError("ARRAY_UNIQUE", matches, null, schema);
6106
6368
  }
6107
6369
  }
6108
6370
  },
@@ -6113,7 +6375,7 @@ var JsonValidators = {
6113
6375
  }
6114
6376
  var keysCount = Object.keys(json).length;
6115
6377
  if (keysCount > schema.maxProperties) {
6116
- report.addError("OBJECT_PROPERTIES_MAXIMUM", [keysCount, schema.maxProperties], null, schema.description);
6378
+ report.addError("OBJECT_PROPERTIES_MAXIMUM", [keysCount, schema.maxProperties], null, schema);
6117
6379
  }
6118
6380
  },
6119
6381
  minProperties: function (report, schema, json) {
@@ -6123,7 +6385,7 @@ var JsonValidators = {
6123
6385
  }
6124
6386
  var keysCount = Object.keys(json).length;
6125
6387
  if (keysCount < schema.minProperties) {
6126
- report.addError("OBJECT_PROPERTIES_MINIMUM", [keysCount, schema.minProperties], null, schema.description);
6388
+ report.addError("OBJECT_PROPERTIES_MINIMUM", [keysCount, schema.minProperties], null, schema);
6127
6389
  }
6128
6390
  },
6129
6391
  required: function (report, schema, json) {
@@ -6135,7 +6397,7 @@ var JsonValidators = {
6135
6397
  while (idx--) {
6136
6398
  var requiredPropertyName = schema.required[idx];
6137
6399
  if (json[requiredPropertyName] === undefined) {
6138
- report.addError("OBJECT_MISSING_REQUIRED_PROPERTY", [requiredPropertyName], null, schema.description);
6400
+ report.addError("OBJECT_MISSING_REQUIRED_PROPERTY", [requiredPropertyName], null, schema);
6139
6401
  }
6140
6402
  }
6141
6403
  },
@@ -6191,7 +6453,7 @@ var JsonValidators = {
6191
6453
  }
6192
6454
  }
6193
6455
  if (s.length > 0) {
6194
- report.addError("OBJECT_ADDITIONAL_PROPERTIES", [s], null, schema.description);
6456
+ report.addError("OBJECT_ADDITIONAL_PROPERTIES", [s], null, schema);
6195
6457
  }
6196
6458
  }
6197
6459
  }
@@ -6219,7 +6481,7 @@ var JsonValidators = {
6219
6481
  while (idx2--) {
6220
6482
  var requiredPropertyName = dependencyDefinition[idx2];
6221
6483
  if (json[requiredPropertyName] === undefined) {
6222
- report.addError("OBJECT_DEPENDENCY_KEY", [requiredPropertyName, dependencyName], null, schema.description);
6484
+ report.addError("OBJECT_DEPENDENCY_KEY", [requiredPropertyName, dependencyName], null, schema);
6223
6485
  }
6224
6486
  }
6225
6487
  }
@@ -6229,23 +6491,35 @@ var JsonValidators = {
6229
6491
  enum: function (report, schema, json) {
6230
6492
  // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.1.2
6231
6493
  var match = false,
6494
+ caseInsensitiveMatch = false,
6232
6495
  idx = schema.enum.length;
6233
6496
  while (idx--) {
6234
6497
  if (Utils.areEqual(json, schema.enum[idx])) {
6235
6498
  match = true;
6236
6499
  break;
6500
+ } else if (Utils.areEqual(json, schema.enum[idx]), { caseInsensitiveComparison: true }) {
6501
+ caseInsensitiveMatch = true;
6237
6502
  }
6238
6503
  }
6504
+
6239
6505
  if (match === false) {
6240
- report.addError("ENUM_MISMATCH", [json], null, schema.description);
6506
+ var error = caseInsensitiveMatch && this.options.enumCaseInsensitiveComparison ? "ENUM_CASE_MISMATCH" : "ENUM_MISMATCH";
6507
+ report.addError(error, [json], null, schema);
6241
6508
  }
6242
6509
  },
6243
- /*
6244
6510
  type: function (report, schema, json) {
6245
6511
  // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.2.2
6246
- // type is handled before this is called so ignore
6512
+ var jsonType = Utils.whatIs(json);
6513
+ if (typeof schema.type === "string") {
6514
+ if (jsonType !== schema.type && (jsonType !== "integer" || schema.type !== "number")) {
6515
+ report.addError("INVALID_TYPE", [schema.type, jsonType], null, schema);
6516
+ }
6517
+ } else {
6518
+ if (schema.type.indexOf(jsonType) === -1 && (jsonType !== "integer" || schema.type.indexOf("number") === -1)) {
6519
+ report.addError("INVALID_TYPE", [schema.type, jsonType], null, schema);
6520
+ }
6521
+ }
6247
6522
  },
6248
- */
6249
6523
  allOf: function (report, schema, json) {
6250
6524
  // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.3.2
6251
6525
  var idx = schema.allOf.length;
@@ -6269,7 +6543,7 @@ var JsonValidators = {
6269
6543
  }
6270
6544
 
6271
6545
  if (passed === false) {
6272
- report.addError("ANY_OF_MISSING", undefined, subReports, schema.description);
6546
+ report.addError("ANY_OF_MISSING", undefined, subReports, schema);
6273
6547
  }
6274
6548
  },
6275
6549
  oneOf: function (report, schema, json) {
@@ -6287,16 +6561,16 @@ var JsonValidators = {
6287
6561
  }
6288
6562
 
6289
6563
  if (passes === 0) {
6290
- report.addError("ONE_OF_MISSING", undefined, subReports, schema.description);
6564
+ report.addError("ONE_OF_MISSING", undefined, subReports, schema);
6291
6565
  } else if (passes > 1) {
6292
- report.addError("ONE_OF_MULTIPLE", null, null, schema.description);
6566
+ report.addError("ONE_OF_MULTIPLE", null, null, schema);
6293
6567
  }
6294
6568
  },
6295
6569
  not: function (report, schema, json) {
6296
6570
  // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.6.2
6297
6571
  var subReport = new Report(report);
6298
6572
  if (exports.validate.call(this, subReport, schema.not, json) === true) {
6299
- report.addError("NOT_PASSED", null, null, schema.description);
6573
+ report.addError("NOT_PASSED", null, null, schema);
6300
6574
  }
6301
6575
  },
6302
6576
  definitions: function () { /*report, schema, json*/
@@ -6311,17 +6585,17 @@ var JsonValidators = {
6311
6585
  // async
6312
6586
  report.addAsyncTask(formatValidatorFn, [json], function (result) {
6313
6587
  if (result !== true) {
6314
- report.addError("INVALID_FORMAT", [schema.format, json], null, schema.description);
6588
+ report.addError("INVALID_FORMAT", [schema.format, json], null, schema);
6315
6589
  }
6316
6590
  });
6317
6591
  } else {
6318
6592
  // sync
6319
6593
  if (formatValidatorFn.call(this, json) !== true) {
6320
- report.addError("INVALID_FORMAT", [schema.format, json], null, schema.description);
6594
+ report.addError("INVALID_FORMAT", [schema.format, json], null, schema);
6321
6595
  }
6322
6596
  }
6323
6597
  } else if (this.options.ignoreUnknownFormats !== true) {
6324
- report.addError("UNKNOWN_FORMAT", [schema.format], null, schema.description);
6598
+ report.addError("UNKNOWN_FORMAT", [schema.format], null, schema);
6325
6599
  }
6326
6600
  }
6327
6601
  };
@@ -6433,7 +6707,7 @@ exports.validate = function (report, schema, json) {
6433
6707
  // check if schema is an object
6434
6708
  var to = Utils.whatIs(schema);
6435
6709
  if (to !== "object") {
6436
- report.addError("SCHEMA_NOT_AN_OBJECT", [to], null, schema.description);
6710
+ report.addError("SCHEMA_NOT_AN_OBJECT", [to], null, schema);
6437
6711
  return false;
6438
6712
  }
6439
6713
 
@@ -6456,7 +6730,7 @@ exports.validate = function (report, schema, json) {
6456
6730
  var maxRefs = 99;
6457
6731
  while (schema.$ref && maxRefs > 0) {
6458
6732
  if (!schema.__$refResolved) {
6459
- report.addError("REF_UNRESOLVED", [schema.$ref], null, schema.description);
6733
+ report.addError("REF_UNRESOLVED", [schema.$ref], null, schema);
6460
6734
  break;
6461
6735
  } else if (schema.__$refResolved === schema) {
6462
6736
  break;
@@ -6472,23 +6746,12 @@ exports.validate = function (report, schema, json) {
6472
6746
  }
6473
6747
 
6474
6748
  // type checking first
6475
- // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.2.2
6476
6749
  var jsonType = Utils.whatIs(json);
6477
6750
  if (schema.type) {
6478
- if (typeof schema.type === "string") {
6479
- if (jsonType !== schema.type && (jsonType !== "integer" || schema.type !== "number")) {
6480
- report.addError("INVALID_TYPE", [schema.type, jsonType], null, schema.description);
6481
- if (this.options.breakOnFirstError) {
6482
- return false;
6483
- }
6484
- }
6485
- } else {
6486
- if (schema.type.indexOf(jsonType) === -1 && (jsonType !== "integer" || schema.type.indexOf("number") === -1)) {
6487
- report.addError("INVALID_TYPE", [schema.type, jsonType], null, schema.description);
6488
- if (this.options.breakOnFirstError) {
6489
- return false;
6490
- }
6491
- }
6751
+ keys.splice(keys.indexOf("type"), 1);
6752
+ JsonValidators.type.call(this, report, schema, json);
6753
+ if (report.errors.length && this.options.breakOnFirstError) {
6754
+ return false;
6492
6755
  }
6493
6756
  }
6494
6757
 
@@ -6523,7 +6786,7 @@ exports.validate = function (report, schema, json) {
6523
6786
 
6524
6787
  };
6525
6788
 
6526
- },{"./FormatValidators":76,"./Report":79,"./Utils":83}],78:[function(require,module,exports){
6789
+ },{"./FormatValidators":80,"./Report":83,"./Utils":87}],82:[function(require,module,exports){
6527
6790
  // Number.isFinite polyfill
6528
6791
  // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite
6529
6792
  if (typeof Number.isFinite !== "function") {
@@ -6541,7 +6804,7 @@ if (typeof Number.isFinite !== "function") {
6541
6804
  };
6542
6805
  }
6543
6806
 
6544
- },{}],79:[function(require,module,exports){
6807
+ },{}],83:[function(require,module,exports){
6545
6808
  (function (process){
6546
6809
  "use strict";
6547
6810
 
@@ -6587,7 +6850,7 @@ Report.prototype.processAsyncTasks = function (timeout, callback) {
6587
6850
  function finish() {
6588
6851
  process.nextTick(function () {
6589
6852
  var valid = self.errors.length === 0,
6590
- err = valid ? undefined : self.errors;
6853
+ err = valid ? undefined : self.errors;
6591
6854
  callback(err, valid);
6592
6855
  });
6593
6856
  }
@@ -6690,13 +6953,13 @@ Report.prototype.hasError = function (errorCode, params) {
6690
6953
  return false;
6691
6954
  };
6692
6955
 
6693
- Report.prototype.addError = function (errorCode, params, subReports, schemaDescription) {
6956
+ Report.prototype.addError = function (errorCode, params, subReports, schema) {
6694
6957
  if (!errorCode) { throw new Error("No errorCode passed into addError()"); }
6695
6958
 
6696
- this.addCustomError(errorCode, Errors[errorCode], params, subReports, schemaDescription);
6959
+ this.addCustomError(errorCode, Errors[errorCode], params, subReports, schema);
6697
6960
  };
6698
6961
 
6699
- Report.prototype.addCustomError = function (errorCode, errorMessage, params, subReports, schemaDescription) {
6962
+ Report.prototype.addCustomError = function (errorCode, errorMessage, params, subReports, schema) {
6700
6963
  if (this.errors.length >= this.reportOptions.maxErrors) {
6701
6964
  return;
6702
6965
  }
@@ -6720,8 +6983,15 @@ Report.prototype.addCustomError = function (errorCode, errorMessage, params, sub
6720
6983
  schemaId: this.getSchemaId()
6721
6984
  };
6722
6985
 
6723
- if (schemaDescription) {
6724
- 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
+ }
6725
6995
  }
6726
6996
 
6727
6997
  if (subReports != null) {
@@ -6748,7 +7018,7 @@ Report.prototype.addCustomError = function (errorCode, errorMessage, params, sub
6748
7018
  module.exports = Report;
6749
7019
 
6750
7020
  }).call(this,require('_process'))
6751
- },{"./Errors":75,"./Utils":83,"_process":3,"lodash.get":1}],80:[function(require,module,exports){
7021
+ },{"./Errors":79,"./Utils":87,"_process":3,"lodash.get":1}],84:[function(require,module,exports){
6752
7022
  "use strict";
6753
7023
 
6754
7024
  var isequal = require("lodash.isequal");
@@ -6912,7 +7182,7 @@ exports.getSchemaByUri = function (report, uri, root) {
6912
7182
 
6913
7183
  exports.getRemotePath = getRemotePath;
6914
7184
 
6915
- },{"./Report":79,"./SchemaCompilation":81,"./SchemaValidation":82,"./Utils":83,"lodash.isequal":2}],81:[function(require,module,exports){
7185
+ },{"./Report":83,"./SchemaCompilation":85,"./SchemaValidation":86,"./Utils":87,"lodash.isequal":2}],85:[function(require,module,exports){
6916
7186
  "use strict";
6917
7187
 
6918
7188
  var Report = require("./Report");
@@ -7213,7 +7483,7 @@ exports.compileSchema = function (report, schema) {
7213
7483
 
7214
7484
  };
7215
7485
 
7216
- },{"./Report":79,"./SchemaCache":80,"./Utils":83}],82:[function(require,module,exports){
7486
+ },{"./Report":83,"./SchemaCache":84,"./Utils":87}],86:[function(require,module,exports){
7217
7487
  "use strict";
7218
7488
 
7219
7489
  var FormatValidators = require("./FormatValidators"),
@@ -7822,7 +8092,7 @@ exports.validateSchema = function (report, schema) {
7822
8092
  return isValid;
7823
8093
  };
7824
8094
 
7825
- },{"./FormatValidators":76,"./JsonValidation":77,"./Report":79,"./Utils":83}],83:[function(require,module,exports){
8095
+ },{"./FormatValidators":80,"./JsonValidation":81,"./Report":83,"./Utils":87}],87:[function(require,module,exports){
7826
8096
  "use strict";
7827
8097
 
7828
8098
  exports.isAbsoluteUri = function (uri) {
@@ -7866,7 +8136,11 @@ exports.whatIs = function (what) {
7866
8136
 
7867
8137
  };
7868
8138
 
7869
- exports.areEqual = function areEqual(json1, json2) {
8139
+ exports.areEqual = function areEqual(json1, json2, options) {
8140
+
8141
+ options = options || {};
8142
+ var caseInsensitiveComparison = options.caseInsensitiveComparison || false;
8143
+
7870
8144
  // http://json-schema.org/latest/json-schema-core.html#rfc.section.3.6
7871
8145
 
7872
8146
  // Two JSON values are said to be equal if and only if:
@@ -7877,6 +8151,12 @@ exports.areEqual = function areEqual(json1, json2) {
7877
8151
  if (json1 === json2) {
7878
8152
  return true;
7879
8153
  }
8154
+ if (
8155
+ caseInsensitiveComparison === true &&
8156
+ typeof json1 === "string" && typeof json2 === "string" &&
8157
+ json1.toUpperCase() === json2.toUpperCase()) {
8158
+ return true;
8159
+ }
7880
8160
 
7881
8161
  var i, len;
7882
8162
 
@@ -7889,7 +8169,7 @@ exports.areEqual = function areEqual(json1, json2) {
7889
8169
  // items at the same index are equal according to this definition; or
7890
8170
  len = json1.length;
7891
8171
  for (i = 0; i < len; i++) {
7892
- if (!areEqual(json1[i], json2[i])) {
8172
+ if (!areEqual(json1[i], json2[i], { caseInsensitiveComparison: caseInsensitiveComparison })) {
7893
8173
  return false;
7894
8174
  }
7895
8175
  }
@@ -7901,13 +8181,13 @@ exports.areEqual = function areEqual(json1, json2) {
7901
8181
  // have the same set of property names; and
7902
8182
  var keys1 = Object.keys(json1);
7903
8183
  var keys2 = Object.keys(json2);
7904
- if (!areEqual(keys1, keys2)) {
8184
+ if (!areEqual(keys1, keys2, { caseInsensitiveComparison: caseInsensitiveComparison })) {
7905
8185
  return false;
7906
8186
  }
7907
8187
  // values for a same property name are equal according to this definition.
7908
8188
  len = keys1.length;
7909
8189
  for (i = 0; i < len; i++) {
7910
- if (!areEqual(json1[keys1[i]], json2[keys1[i]])) {
8190
+ if (!areEqual(json1[keys1[i]], json2[keys1[i]], { caseInsensitiveComparison: caseInsensitiveComparison })) {
7911
8191
  return false;
7912
8192
  }
7913
8193
  }
@@ -8041,7 +8321,7 @@ exports.ucs2decode = function (string) {
8041
8321
  };
8042
8322
  /*jshint +W016*/
8043
8323
 
8044
- },{}],84:[function(require,module,exports){
8324
+ },{}],88:[function(require,module,exports){
8045
8325
  (function (process){
8046
8326
  "use strict";
8047
8327
 
@@ -8067,6 +8347,8 @@ var defaultOptions = {
8067
8347
  forceAdditional: false,
8068
8348
  // assume additionalProperties and additionalItems are defined as "false" where appropriate
8069
8349
  assumeAdditional: false,
8350
+ // do case insensitive comparison for enums
8351
+ enumCaseInsensitiveComparison: false,
8070
8352
  // force items to be defined on "array" types
8071
8353
  forceItems: false,
8072
8354
  // force minItems to be defined on "array" types
@@ -8157,6 +8439,7 @@ function normalizeOptions(options) {
8157
8439
  function ZSchema(options) {
8158
8440
  this.cache = {};
8159
8441
  this.referenceCache = [];
8442
+ this.validateOptions = {};
8160
8443
 
8161
8444
  this.options = normalizeOptions(options);
8162
8445
 
@@ -8203,6 +8486,8 @@ ZSchema.prototype.validate = function (json, schema, options, callback) {
8203
8486
  }
8204
8487
  if (!options) { options = {}; }
8205
8488
 
8489
+ this.validateOptions = options;
8490
+
8206
8491
  var whatIs = Utils.whatIs(schema);
8207
8492
  if (whatIs !== "string" && whatIs !== "object") {
8208
8493
  var e = new Error("Invalid .validate call - schema must be an string or object but " + whatIs + " was passed!");
@@ -8412,7 +8697,7 @@ ZSchema.getDefaultOptions = function () {
8412
8697
  module.exports = ZSchema;
8413
8698
 
8414
8699
  }).call(this,require('_process'))
8415
- },{"./FormatValidators":76,"./JsonValidation":77,"./Polyfills":78,"./Report":79,"./SchemaCache":80,"./SchemaCompilation":81,"./SchemaValidation":82,"./Utils":83,"./schemas/hyper-schema.json":85,"./schemas/schema.json":86,"_process":3,"lodash.get":1}],85:[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){
8416
8701
  module.exports={
8417
8702
  "$schema": "http://json-schema.org/draft-04/hyper-schema#",
8418
8703
  "id": "http://json-schema.org/draft-04/hyper-schema#",
@@ -8572,7 +8857,7 @@ module.exports={
8572
8857
  }
8573
8858
 
8574
8859
 
8575
- },{}],86:[function(require,module,exports){
8860
+ },{}],90:[function(require,module,exports){
8576
8861
  module.exports={
8577
8862
  "id": "http://json-schema.org/draft-04/schema#",
8578
8863
  "$schema": "http://json-schema.org/draft-04/schema#",
@@ -8725,5 +9010,5 @@ module.exports={
8725
9010
  "default": {}
8726
9011
  }
8727
9012
 
8728
- },{}]},{},[75,76,77,78,79,80,81,82,83,84])(84)
8729
- });
9013
+ },{}]},{},[79,80,81,82,83,84,85,86,87,88])(88)
9014
+ });