z-schema 3.19.0 → 3.22.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/>
@@ -3178,10 +3178,18 @@ var _isISO = require('./lib/isISO8601');
3178
3178
 
3179
3179
  var _isISO2 = _interopRequireDefault(_isISO);
3180
3180
 
3181
+ var _isRFC = require('./lib/isRFC3339');
3182
+
3183
+ var _isRFC2 = _interopRequireDefault(_isRFC);
3184
+
3181
3185
  var _isISO31661Alpha = require('./lib/isISO31661Alpha2');
3182
3186
 
3183
3187
  var _isISO31661Alpha2 = _interopRequireDefault(_isISO31661Alpha);
3184
3188
 
3189
+ var _isISO31661Alpha3 = require('./lib/isISO31661Alpha3');
3190
+
3191
+ var _isISO31661Alpha4 = _interopRequireDefault(_isISO31661Alpha3);
3192
+
3185
3193
  var _isBase = require('./lib/isBase64');
3186
3194
 
3187
3195
  var _isBase2 = _interopRequireDefault(_isBase);
@@ -3190,6 +3198,10 @@ var _isDataURI = require('./lib/isDataURI');
3190
3198
 
3191
3199
  var _isDataURI2 = _interopRequireDefault(_isDataURI);
3192
3200
 
3201
+ var _isMimeType = require('./lib/isMimeType');
3202
+
3203
+ var _isMimeType2 = _interopRequireDefault(_isMimeType);
3204
+
3193
3205
  var _isLatLong = require('./lib/isLatLong');
3194
3206
 
3195
3207
  var _isLatLong2 = _interopRequireDefault(_isLatLong);
@@ -3244,7 +3256,7 @@ var _toString2 = _interopRequireDefault(_toString);
3244
3256
 
3245
3257
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3246
3258
 
3247
- var version = '9.1.1';
3259
+ var version = '10.2.0';
3248
3260
 
3249
3261
  var validator = {
3250
3262
  version: version,
@@ -3297,11 +3309,15 @@ var validator = {
3297
3309
  isISSN: _isISSN2.default,
3298
3310
  isMobilePhone: _isMobilePhone2.default,
3299
3311
  isPostalCode: _isPostalCode2.default,
3312
+ isPostalCodeLocales: _isPostalCode.locales,
3300
3313
  isCurrency: _isCurrency2.default,
3301
3314
  isISO8601: _isISO2.default,
3315
+ isRFC3339: _isRFC2.default,
3302
3316
  isISO31661Alpha2: _isISO31661Alpha2.default,
3317
+ isISO31661Alpha3: _isISO31661Alpha4.default,
3303
3318
  isBase64: _isBase2.default,
3304
3319
  isDataURI: _isDataURI2.default,
3320
+ isMimeType: _isMimeType2.default,
3305
3321
  isLatLong: _isLatLong2.default,
3306
3322
  ltrim: _ltrim2.default,
3307
3323
  rtrim: _rtrim2.default,
@@ -3318,7 +3334,7 @@ var validator = {
3318
3334
 
3319
3335
  exports.default = validator;
3320
3336
  module.exports = exports['default'];
3321
- },{"./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/isMobilePhone":47,"./lib/isMongoId":48,"./lib/isMultibyte":49,"./lib/isNumeric":50,"./lib/isPort":51,"./lib/isPostalCode":52,"./lib/isSurrogatePair":53,"./lib/isURL":54,"./lib/isUUID":55,"./lib/isUppercase":56,"./lib/isVariableWidth":57,"./lib/isWhitelisted":58,"./lib/ltrim":59,"./lib/matches":60,"./lib/normalizeEmail":61,"./lib/rtrim":62,"./lib/stripLow":63,"./lib/toBoolean":64,"./lib/toDate":65,"./lib/toFloat":66,"./lib/toInt":67,"./lib/trim":68,"./lib/unescape":69,"./lib/util/toString":72,"./lib/whitelist":73}],5:[function(require,module,exports){
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){
3322
3338
  'use strict';
3323
3339
 
3324
3340
  Object.defineProperty(exports, "__esModule", {
@@ -3326,9 +3342,11 @@ Object.defineProperty(exports, "__esModule", {
3326
3342
  });
3327
3343
  var alpha = exports.alpha = {
3328
3344
  'en-US': /^[A-Z]+$/i,
3345
+ 'bg-BG': /^[А-Я]+$/i,
3329
3346
  'cs-CZ': /^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,
3330
3347
  'da-DK': /^[A-ZÆØÅ]+$/i,
3331
3348
  'de-DE': /^[A-ZÄÖÜß]+$/i,
3349
+ 'el-GR': /^[Α-ω]+$/i,
3332
3350
  'es-ES': /^[A-ZÁÉÍÑÓÚÜ]+$/i,
3333
3351
  'fr-FR': /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
3334
3352
  'it-IT': /^[A-ZÀÉÈÌÎÓÒÙ]+$/i,
@@ -3339,6 +3357,7 @@ var alpha = exports.alpha = {
3339
3357
  'pl-PL': /^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,
3340
3358
  'pt-PT': /^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,
3341
3359
  'ru-RU': /^[А-ЯЁ]+$/i,
3360
+ 'sk-SK': /^[A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,
3342
3361
  'sr-RS@latin': /^[A-ZČĆŽŠĐ]+$/i,
3343
3362
  'sr-RS': /^[А-ЯЂЈЉЊЋЏ]+$/i,
3344
3363
  'sv-SE': /^[A-ZÅÄÖ]+$/i,
@@ -3349,9 +3368,11 @@ var alpha = exports.alpha = {
3349
3368
 
3350
3369
  var alphanumeric = exports.alphanumeric = {
3351
3370
  'en-US': /^[0-9A-Z]+$/i,
3371
+ 'bg-BG': /^[0-9А-Я]+$/i,
3352
3372
  'cs-CZ': /^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,
3353
3373
  'da-DK': /^[0-9A-ZÆØÅ]+$/i,
3354
3374
  'de-DE': /^[0-9A-ZÄÖÜß]+$/i,
3375
+ 'el-GR': /^[0-9Α-ω]+$/i,
3355
3376
  'es-ES': /^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,
3356
3377
  'fr-FR': /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
3357
3378
  'it-IT': /^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i,
@@ -3362,6 +3383,7 @@ var alphanumeric = exports.alphanumeric = {
3362
3383
  'pl-PL': /^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i,
3363
3384
  'pt-PT': /^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,
3364
3385
  'ru-RU': /^[0-9А-ЯЁ]+$/i,
3386
+ 'sk-SK': /^[0-9A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,
3365
3387
  'sr-RS@latin': /^[0-9A-ZČĆŽŠĐ]+$/i,
3366
3388
  'sr-RS': /^[0-9А-ЯЂЈЉЊЋЏ]+$/i,
3367
3389
  'sv-SE': /^[0-9A-ZÅÄÖ]+$/i,
@@ -3396,7 +3418,7 @@ for (var _locale, _i = 0; _i < arabicLocales.length; _i++) {
3396
3418
 
3397
3419
  // Source: https://en.wikipedia.org/wiki/Decimal_mark
3398
3420
  var dotDecimal = exports.dotDecimal = [];
3399
- var commaDecimal = exports.commaDecimal = ['cs-CZ', 'da-DK', 'de-DE', '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'];
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'];
3400
3422
 
3401
3423
  for (var _i2 = 0; _i2 < dotDecimal.length; _i2++) {
3402
3424
  decimal[dotDecimal[_i2]] = decimal['en-US'];
@@ -3428,7 +3450,7 @@ function blacklist(str, chars) {
3428
3450
  return str.replace(new RegExp('[' + chars + ']+', 'g'), '');
3429
3451
  }
3430
3452
  module.exports = exports['default'];
3431
- },{"./util/assertString":70}],7:[function(require,module,exports){
3453
+ },{"./util/assertString":73}],7:[function(require,module,exports){
3432
3454
  'use strict';
3433
3455
 
3434
3456
  Object.defineProperty(exports, "__esModule", {
@@ -3451,7 +3473,7 @@ function contains(str, elem) {
3451
3473
  return str.indexOf((0, _toString2.default)(elem)) >= 0;
3452
3474
  }
3453
3475
  module.exports = exports['default'];
3454
- },{"./util/assertString":70,"./util/toString":72}],8:[function(require,module,exports){
3476
+ },{"./util/assertString":73,"./util/toString":75}],8:[function(require,module,exports){
3455
3477
  'use strict';
3456
3478
 
3457
3479
  Object.defineProperty(exports, "__esModule", {
@@ -3470,7 +3492,7 @@ function equals(str, comparison) {
3470
3492
  return str === comparison;
3471
3493
  }
3472
3494
  module.exports = exports['default'];
3473
- },{"./util/assertString":70}],9:[function(require,module,exports){
3495
+ },{"./util/assertString":73}],9:[function(require,module,exports){
3474
3496
  'use strict';
3475
3497
 
3476
3498
  Object.defineProperty(exports, "__esModule", {
@@ -3489,7 +3511,7 @@ function escape(str) {
3489
3511
  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;');
3490
3512
  }
3491
3513
  module.exports = exports['default'];
3492
- },{"./util/assertString":70}],10:[function(require,module,exports){
3514
+ },{"./util/assertString":73}],10:[function(require,module,exports){
3493
3515
  'use strict';
3494
3516
 
3495
3517
  Object.defineProperty(exports, "__esModule", {
@@ -3516,7 +3538,7 @@ function isAfter(str) {
3516
3538
  return !!(original && comparison && original > comparison);
3517
3539
  }
3518
3540
  module.exports = exports['default'];
3519
- },{"./toDate":65,"./util/assertString":70}],11:[function(require,module,exports){
3541
+ },{"./toDate":68,"./util/assertString":73}],11:[function(require,module,exports){
3520
3542
  'use strict';
3521
3543
 
3522
3544
  Object.defineProperty(exports, "__esModule", {
@@ -3542,7 +3564,7 @@ function isAlpha(str) {
3542
3564
  throw new Error('Invalid locale \'' + locale + '\'');
3543
3565
  }
3544
3566
  module.exports = exports['default'];
3545
- },{"./alpha":5,"./util/assertString":70}],12:[function(require,module,exports){
3567
+ },{"./alpha":5,"./util/assertString":73}],12:[function(require,module,exports){
3546
3568
  'use strict';
3547
3569
 
3548
3570
  Object.defineProperty(exports, "__esModule", {
@@ -3568,7 +3590,7 @@ function isAlphanumeric(str) {
3568
3590
  throw new Error('Invalid locale \'' + locale + '\'');
3569
3591
  }
3570
3592
  module.exports = exports['default'];
3571
- },{"./alpha":5,"./util/assertString":70}],13:[function(require,module,exports){
3593
+ },{"./alpha":5,"./util/assertString":73}],13:[function(require,module,exports){
3572
3594
  'use strict';
3573
3595
 
3574
3596
  Object.defineProperty(exports, "__esModule", {
@@ -3591,7 +3613,7 @@ function isAscii(str) {
3591
3613
  return ascii.test(str);
3592
3614
  }
3593
3615
  module.exports = exports['default'];
3594
- },{"./util/assertString":70}],14:[function(require,module,exports){
3616
+ },{"./util/assertString":73}],14:[function(require,module,exports){
3595
3617
  'use strict';
3596
3618
 
3597
3619
  Object.defineProperty(exports, "__esModule", {
@@ -3617,7 +3639,7 @@ function isBase64(str) {
3617
3639
  return firstPaddingChar === -1 || firstPaddingChar === len - 1 || firstPaddingChar === len - 2 && str[len - 1] === '=';
3618
3640
  }
3619
3641
  module.exports = exports['default'];
3620
- },{"./util/assertString":70}],15:[function(require,module,exports){
3642
+ },{"./util/assertString":73}],15:[function(require,module,exports){
3621
3643
  'use strict';
3622
3644
 
3623
3645
  Object.defineProperty(exports, "__esModule", {
@@ -3644,7 +3666,7 @@ function isBefore(str) {
3644
3666
  return !!(original && comparison && original < comparison);
3645
3667
  }
3646
3668
  module.exports = exports['default'];
3647
- },{"./toDate":65,"./util/assertString":70}],16:[function(require,module,exports){
3669
+ },{"./toDate":68,"./util/assertString":73}],16:[function(require,module,exports){
3648
3670
  'use strict';
3649
3671
 
3650
3672
  Object.defineProperty(exports, "__esModule", {
@@ -3663,7 +3685,7 @@ function isBoolean(str) {
3663
3685
  return ['true', 'false', '1', '0'].indexOf(str) >= 0;
3664
3686
  }
3665
3687
  module.exports = exports['default'];
3666
- },{"./util/assertString":70}],17:[function(require,module,exports){
3688
+ },{"./util/assertString":73}],17:[function(require,module,exports){
3667
3689
  'use strict';
3668
3690
 
3669
3691
  Object.defineProperty(exports, "__esModule", {
@@ -3697,7 +3719,7 @@ function isByteLength(str, options) {
3697
3719
  return len >= min && (typeof max === 'undefined' || len <= max);
3698
3720
  }
3699
3721
  module.exports = exports['default'];
3700
- },{"./util/assertString":70}],18:[function(require,module,exports){
3722
+ },{"./util/assertString":73}],18:[function(require,module,exports){
3701
3723
  'use strict';
3702
3724
 
3703
3725
  Object.defineProperty(exports, "__esModule", {
@@ -3712,7 +3734,7 @@ var _assertString2 = _interopRequireDefault(_assertString);
3712
3734
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3713
3735
 
3714
3736
  /* eslint-disable max-len */
3715
- 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})$/;
3737
+ 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})$/;
3716
3738
  /* eslint-enable max-len */
3717
3739
 
3718
3740
  function isCreditCard(str) {
@@ -3743,7 +3765,7 @@ function isCreditCard(str) {
3743
3765
  return !!(sum % 10 === 0 ? sanitized : false);
3744
3766
  }
3745
3767
  module.exports = exports['default'];
3746
- },{"./util/assertString":70}],19:[function(require,module,exports){
3768
+ },{"./util/assertString":73}],19:[function(require,module,exports){
3747
3769
  'use strict';
3748
3770
 
3749
3771
  Object.defineProperty(exports, "__esModule", {
@@ -3836,7 +3858,7 @@ function isCurrency(str, options) {
3836
3858
  return currencyRegex(options).test(str);
3837
3859
  }
3838
3860
  module.exports = exports['default'];
3839
- },{"./util/assertString":70,"./util/merge":71}],20:[function(require,module,exports){
3861
+ },{"./util/assertString":73,"./util/merge":74}],20:[function(require,module,exports){
3840
3862
  'use strict';
3841
3863
 
3842
3864
  Object.defineProperty(exports, "__esModule", {
@@ -3850,14 +3872,43 @@ var _assertString2 = _interopRequireDefault(_assertString);
3850
3872
 
3851
3873
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3852
3874
 
3853
- 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
3875
+ var validMediaType = /^[a-z]+\/[a-z0-9\-\+]+$/i;
3876
+
3877
+ var validAttribute = /^[a-z\-]+=[a-z0-9\-]+$/i;
3878
+
3879
+ var validData = /^[a-z0-9!\$&'\(\)\*\+,;=\-\._~:@\/\?%\s]*$/i;
3854
3880
 
3855
3881
  function isDataURI(str) {
3856
3882
  (0, _assertString2.default)(str);
3857
- return dataURI.test(str);
3883
+ var data = str.split(',');
3884
+ if (data.length < 2) {
3885
+ return false;
3886
+ }
3887
+ var attributes = data.shift().trim().split(';');
3888
+ var schemeAndMediaType = attributes.shift();
3889
+ if (schemeAndMediaType.substr(0, 5) !== 'data:') {
3890
+ return false;
3891
+ }
3892
+ var mediaType = schemeAndMediaType.substr(5);
3893
+ if (mediaType !== '' && !validMediaType.test(mediaType)) {
3894
+ return false;
3895
+ }
3896
+ for (var i = 0; i < attributes.length; i++) {
3897
+ if (i === attributes.length - 1 && attributes[i].toLowerCase() === 'base64') {
3898
+ // ok
3899
+ } else if (!validAttribute.test(attributes[i])) {
3900
+ return false;
3901
+ }
3902
+ }
3903
+ for (var _i = 0; _i < data.length; _i++) {
3904
+ if (!validData.test(data[_i])) {
3905
+ return false;
3906
+ }
3907
+ }
3908
+ return true;
3858
3909
  }
3859
3910
  module.exports = exports['default'];
3860
- },{"./util/assertString":70}],21:[function(require,module,exports){
3911
+ },{"./util/assertString":73}],21:[function(require,module,exports){
3861
3912
  'use strict';
3862
3913
 
3863
3914
  Object.defineProperty(exports, "__esModule", {
@@ -3899,7 +3950,7 @@ function isDecimal(str, options) {
3899
3950
  throw new Error('Invalid locale \'' + options.locale + '\'');
3900
3951
  }
3901
3952
  module.exports = exports['default'];
3902
- },{"./alpha":5,"./util/assertString":70,"./util/merge":71}],22:[function(require,module,exports){
3953
+ },{"./alpha":5,"./util/assertString":73,"./util/merge":74}],22:[function(require,module,exports){
3903
3954
  'use strict';
3904
3955
 
3905
3956
  Object.defineProperty(exports, "__esModule", {
@@ -3922,7 +3973,7 @@ function isDivisibleBy(str, num) {
3922
3973
  return (0, _toFloat2.default)(str) % parseInt(num, 10) === 0;
3923
3974
  }
3924
3975
  module.exports = exports['default'];
3925
- },{"./toFloat":66,"./util/assertString":70}],23:[function(require,module,exports){
3976
+ },{"./toFloat":69,"./util/assertString":73}],23:[function(require,module,exports){
3926
3977
  'use strict';
3927
3978
 
3928
3979
  Object.defineProperty(exports, "__esModule", {
@@ -3983,8 +4034,16 @@ function isEmail(str, options) {
3983
4034
  var user = parts.join('@');
3984
4035
 
3985
4036
  var lower_domain = domain.toLowerCase();
4037
+
3986
4038
  if (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com') {
3987
- user = user.replace(/\./g, '').toLowerCase();
4039
+ /*
4040
+ Previously we removed dots for gmail addresses before validating.
4041
+ This was removed because it allows `multiple..dots@gmail.com`
4042
+ to be reported as valid, but it is not.
4043
+ Gmail only normalizes single dots, removing them from here is pointless,
4044
+ should be done in normalizeEmail
4045
+ */
4046
+ user = user.toLowerCase();
3988
4047
  }
3989
4048
 
3990
4049
  if (!(0, _isByteLength2.default)(user, { max: 64 }) || !(0, _isByteLength2.default)(domain, { max: 254 })) {
@@ -4012,7 +4071,7 @@ function isEmail(str, options) {
4012
4071
  return true;
4013
4072
  }
4014
4073
  module.exports = exports['default'];
4015
- },{"./isByteLength":17,"./isFQDN":25,"./util/assertString":70,"./util/merge":71}],24:[function(require,module,exports){
4074
+ },{"./isByteLength":17,"./isFQDN":25,"./util/assertString":73,"./util/merge":74}],24:[function(require,module,exports){
4016
4075
  'use strict';
4017
4076
 
4018
4077
  Object.defineProperty(exports, "__esModule", {
@@ -4031,13 +4090,13 @@ function isEmpty(str) {
4031
4090
  return str.length === 0;
4032
4091
  }
4033
4092
  module.exports = exports['default'];
4034
- },{"./util/assertString":70}],25:[function(require,module,exports){
4093
+ },{"./util/assertString":73}],25:[function(require,module,exports){
4035
4094
  'use strict';
4036
4095
 
4037
4096
  Object.defineProperty(exports, "__esModule", {
4038
4097
  value: true
4039
4098
  });
4040
- exports.default = isFDQN;
4099
+ exports.default = isFQDN;
4041
4100
 
4042
4101
  var _assertString = require('./util/assertString');
4043
4102
 
@@ -4055,7 +4114,7 @@ var default_fqdn_options = {
4055
4114
  allow_trailing_dot: false
4056
4115
  };
4057
4116
 
4058
- function isFDQN(str, options) {
4117
+ function isFQDN(str, options) {
4059
4118
  (0, _assertString2.default)(str);
4060
4119
  options = (0, _merge2.default)(options, default_fqdn_options);
4061
4120
 
@@ -4064,6 +4123,11 @@ function isFDQN(str, options) {
4064
4123
  str = str.substring(0, str.length - 1);
4065
4124
  }
4066
4125
  var parts = str.split('.');
4126
+ for (var i = 0; i < parts.length; i++) {
4127
+ if (parts[i].length > 63) {
4128
+ return false;
4129
+ }
4130
+ }
4067
4131
  if (options.require_tld) {
4068
4132
  var tld = parts.pop();
4069
4133
  if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
@@ -4074,8 +4138,8 @@ function isFDQN(str, options) {
4074
4138
  return false;
4075
4139
  }
4076
4140
  }
4077
- for (var part, i = 0; i < parts.length; i++) {
4078
- part = parts[i];
4141
+ for (var part, _i = 0; _i < parts.length; _i++) {
4142
+ part = parts[_i];
4079
4143
  if (options.allow_underscores) {
4080
4144
  part = part.replace(/_/g, '');
4081
4145
  }
@@ -4093,7 +4157,7 @@ function isFDQN(str, options) {
4093
4157
  return true;
4094
4158
  }
4095
4159
  module.exports = exports['default'];
4096
- },{"./util/assertString":70,"./util/merge":71}],26:[function(require,module,exports){
4160
+ },{"./util/assertString":73,"./util/merge":74}],26:[function(require,module,exports){
4097
4161
  'use strict';
4098
4162
 
4099
4163
  Object.defineProperty(exports, "__esModule", {
@@ -4113,13 +4177,14 @@ function isFloat(str, options) {
4113
4177
  (0, _assertString2.default)(str);
4114
4178
  options = options || {};
4115
4179
  var float = new RegExp('^(?:[-+])?(?:[0-9]+)?(?:\\' + (options.locale ? _alpha.decimal[options.locale] : '.') + '[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$');
4116
- if (str === '' || str === '.') {
4180
+ if (str === '' || str === '.' || str === '-' || str === '+') {
4117
4181
  return false;
4118
4182
  }
4119
- 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);
4183
+ var value = parseFloat(str.replace(',', '.'));
4184
+ 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);
4120
4185
  }
4121
4186
  module.exports = exports['default'];
4122
- },{"./alpha":5,"./util/assertString":70}],27:[function(require,module,exports){
4187
+ },{"./alpha":5,"./util/assertString":73}],27:[function(require,module,exports){
4123
4188
  'use strict';
4124
4189
 
4125
4190
  Object.defineProperty(exports, "__esModule", {
@@ -4140,7 +4205,7 @@ function isFullWidth(str) {
4140
4205
  (0, _assertString2.default)(str);
4141
4206
  return fullWidth.test(str);
4142
4207
  }
4143
- },{"./util/assertString":70}],28:[function(require,module,exports){
4208
+ },{"./util/assertString":73}],28:[function(require,module,exports){
4144
4209
  'use strict';
4145
4210
 
4146
4211
  Object.defineProperty(exports, "__esModule", {
@@ -4161,7 +4226,7 @@ function isHalfWidth(str) {
4161
4226
  (0, _assertString2.default)(str);
4162
4227
  return halfWidth.test(str);
4163
4228
  }
4164
- },{"./util/assertString":70}],29:[function(require,module,exports){
4229
+ },{"./util/assertString":73}],29:[function(require,module,exports){
4165
4230
  'use strict';
4166
4231
 
4167
4232
  Object.defineProperty(exports, "__esModule", {
@@ -4197,7 +4262,7 @@ function isHash(str, algorithm) {
4197
4262
  return hash.test(str);
4198
4263
  }
4199
4264
  module.exports = exports['default'];
4200
- },{"./util/assertString":70}],30:[function(require,module,exports){
4265
+ },{"./util/assertString":73}],30:[function(require,module,exports){
4201
4266
  'use strict';
4202
4267
 
4203
4268
  Object.defineProperty(exports, "__esModule", {
@@ -4218,7 +4283,7 @@ function isHexColor(str) {
4218
4283
  return hexcolor.test(str);
4219
4284
  }
4220
4285
  module.exports = exports['default'];
4221
- },{"./util/assertString":70}],31:[function(require,module,exports){
4286
+ },{"./util/assertString":73}],31:[function(require,module,exports){
4222
4287
  'use strict';
4223
4288
 
4224
4289
  Object.defineProperty(exports, "__esModule", {
@@ -4239,7 +4304,7 @@ function isHexadecimal(str) {
4239
4304
  return hexadecimal.test(str);
4240
4305
  }
4241
4306
  module.exports = exports['default'];
4242
- },{"./util/assertString":70}],32:[function(require,module,exports){
4307
+ },{"./util/assertString":73}],32:[function(require,module,exports){
4243
4308
  'use strict';
4244
4309
 
4245
4310
  Object.defineProperty(exports, "__esModule", {
@@ -4321,7 +4386,7 @@ function isIP(str) {
4321
4386
  return false;
4322
4387
  }
4323
4388
  module.exports = exports['default'];
4324
- },{"./util/assertString":70}],33:[function(require,module,exports){
4389
+ },{"./util/assertString":73}],33:[function(require,module,exports){
4325
4390
  'use strict';
4326
4391
 
4327
4392
  Object.defineProperty(exports, "__esModule", {
@@ -4379,7 +4444,7 @@ function isISBN(str) {
4379
4444
  return false;
4380
4445
  }
4381
4446
  module.exports = exports['default'];
4382
- },{"./util/assertString":70}],34:[function(require,module,exports){
4447
+ },{"./util/assertString":73}],34:[function(require,module,exports){
4383
4448
  'use strict';
4384
4449
 
4385
4450
  Object.defineProperty(exports, "__esModule", {
@@ -4428,7 +4493,7 @@ function isISIN(str) {
4428
4493
  return parseInt(str.substr(str.length - 1), 10) === (10000 - sum) % 10;
4429
4494
  }
4430
4495
  module.exports = exports['default'];
4431
- },{"./util/assertString":70}],35:[function(require,module,exports){
4496
+ },{"./util/assertString":73}],35:[function(require,module,exports){
4432
4497
  'use strict';
4433
4498
 
4434
4499
  Object.defineProperty(exports, "__esModule", {
@@ -4450,7 +4515,29 @@ function isISO31661Alpha2(str) {
4450
4515
  return validISO31661Alpha2CountriesCodes.includes(str.toUpperCase());
4451
4516
  }
4452
4517
  module.exports = exports['default'];
4453
- },{"./util/assertString":70}],36:[function(require,module,exports){
4518
+ },{"./util/assertString":73}],36:[function(require,module,exports){
4519
+ 'use strict';
4520
+
4521
+ Object.defineProperty(exports, "__esModule", {
4522
+ value: true
4523
+ });
4524
+ exports.default = isISO31661Alpha3;
4525
+
4526
+ var _assertString = require('./util/assertString');
4527
+
4528
+ var _assertString2 = _interopRequireDefault(_assertString);
4529
+
4530
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4531
+
4532
+ // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
4533
+ 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'];
4534
+
4535
+ function isISO31661Alpha3(str) {
4536
+ (0, _assertString2.default)(str);
4537
+ return validISO31661Alpha3CountriesCodes.includes(str.toUpperCase());
4538
+ }
4539
+ module.exports = exports['default'];
4540
+ },{"./util/assertString":73}],37:[function(require,module,exports){
4454
4541
  'use strict';
4455
4542
 
4456
4543
  Object.defineProperty(exports, "__esModule", {
@@ -4474,7 +4561,7 @@ function isISO8601(str) {
4474
4561
  return iso8601.test(str);
4475
4562
  }
4476
4563
  module.exports = exports['default'];
4477
- },{"./util/assertString":70}],37:[function(require,module,exports){
4564
+ },{"./util/assertString":73}],38:[function(require,module,exports){
4478
4565
  'use strict';
4479
4566
 
4480
4567
  Object.defineProperty(exports, "__esModule", {
@@ -4496,7 +4583,7 @@ function isISRC(str) {
4496
4583
  return isrc.test(str);
4497
4584
  }
4498
4585
  module.exports = exports['default'];
4499
- },{"./util/assertString":70}],38:[function(require,module,exports){
4586
+ },{"./util/assertString":73}],39:[function(require,module,exports){
4500
4587
  'use strict';
4501
4588
 
4502
4589
  Object.defineProperty(exports, "__esModule", {
@@ -4555,7 +4642,7 @@ function isISSN(str) {
4555
4642
  return checksum % 11 === 0;
4556
4643
  }
4557
4644
  module.exports = exports['default'];
4558
- },{"./util/assertString":70}],39:[function(require,module,exports){
4645
+ },{"./util/assertString":73}],40:[function(require,module,exports){
4559
4646
  'use strict';
4560
4647
 
4561
4648
  Object.defineProperty(exports, "__esModule", {
@@ -4595,7 +4682,7 @@ function isIn(str, options) {
4595
4682
  return false;
4596
4683
  }
4597
4684
  module.exports = exports['default'];
4598
- },{"./util/assertString":70,"./util/toString":72}],40:[function(require,module,exports){
4685
+ },{"./util/assertString":73,"./util/toString":75}],41:[function(require,module,exports){
4599
4686
  'use strict';
4600
4687
 
4601
4688
  Object.defineProperty(exports, "__esModule", {
@@ -4629,7 +4716,7 @@ function isInt(str, options) {
4629
4716
  return regex.test(str) && minCheckPassed && maxCheckPassed && ltCheckPassed && gtCheckPassed;
4630
4717
  }
4631
4718
  module.exports = exports['default'];
4632
- },{"./util/assertString":70}],41:[function(require,module,exports){
4719
+ },{"./util/assertString":73}],42:[function(require,module,exports){
4633
4720
  'use strict';
4634
4721
 
4635
4722
  Object.defineProperty(exports, "__esModule", {
@@ -4655,7 +4742,7 @@ function isJSON(str) {
4655
4742
  return false;
4656
4743
  }
4657
4744
  module.exports = exports['default'];
4658
- },{"./util/assertString":70}],42:[function(require,module,exports){
4745
+ },{"./util/assertString":73}],43:[function(require,module,exports){
4659
4746
  'use strict';
4660
4747
 
4661
4748
  Object.defineProperty(exports, "__esModule", {
@@ -4679,7 +4766,7 @@ var lat = /^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/;
4679
4766
  var long = /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/;
4680
4767
 
4681
4768
  module.exports = exports['default'];
4682
- },{"./util/assertString":70}],43:[function(require,module,exports){
4769
+ },{"./util/assertString":73}],44:[function(require,module,exports){
4683
4770
  'use strict';
4684
4771
 
4685
4772
  Object.defineProperty(exports, "__esModule", {
@@ -4714,7 +4801,7 @@ function isLength(str, options) {
4714
4801
  return len >= min && (typeof max === 'undefined' || len <= max);
4715
4802
  }
4716
4803
  module.exports = exports['default'];
4717
- },{"./util/assertString":70}],44:[function(require,module,exports){
4804
+ },{"./util/assertString":73}],45:[function(require,module,exports){
4718
4805
  'use strict';
4719
4806
 
4720
4807
  Object.defineProperty(exports, "__esModule", {
@@ -4733,7 +4820,7 @@ function isLowercase(str) {
4733
4820
  return str === str.toLowerCase();
4734
4821
  }
4735
4822
  module.exports = exports['default'];
4736
- },{"./util/assertString":70}],45:[function(require,module,exports){
4823
+ },{"./util/assertString":73}],46:[function(require,module,exports){
4737
4824
  'use strict';
4738
4825
 
4739
4826
  Object.defineProperty(exports, "__esModule", {
@@ -4754,7 +4841,7 @@ function isMACAddress(str) {
4754
4841
  return macAddress.test(str);
4755
4842
  }
4756
4843
  module.exports = exports['default'];
4757
- },{"./util/assertString":70}],46:[function(require,module,exports){
4844
+ },{"./util/assertString":73}],47:[function(require,module,exports){
4758
4845
  'use strict';
4759
4846
 
4760
4847
  Object.defineProperty(exports, "__esModule", {
@@ -4775,7 +4862,60 @@ function isMD5(str) {
4775
4862
  return md5.test(str);
4776
4863
  }
4777
4864
  module.exports = exports['default'];
4778
- },{"./util/assertString":70}],47:[function(require,module,exports){
4865
+ },{"./util/assertString":73}],48:[function(require,module,exports){
4866
+ 'use strict';
4867
+
4868
+ Object.defineProperty(exports, "__esModule", {
4869
+ value: true
4870
+ });
4871
+ exports.default = isMimeType;
4872
+
4873
+ var _assertString = require('./util/assertString');
4874
+
4875
+ var _assertString2 = _interopRequireDefault(_assertString);
4876
+
4877
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4878
+
4879
+ /*
4880
+ Checks if the provided string matches to a correct Media type format (MIME type)
4881
+
4882
+ This function only checks is the string format follows the
4883
+ etablished rules by the according RFC specifications.
4884
+ This function supports 'charset' in textual media types
4885
+ (https://tools.ietf.org/html/rfc6657).
4886
+
4887
+ This function does not check against all the media types listed
4888
+ by the IANA (https://www.iana.org/assignments/media-types/media-types.xhtml)
4889
+ because of lightness purposes : it would require to include
4890
+ all these MIME types in this librairy, which would weigh it
4891
+ significantly. This kind of effort maybe is not worth for the use that
4892
+ this function has in this entire librairy.
4893
+
4894
+ More informations in the RFC specifications :
4895
+ - https://tools.ietf.org/html/rfc2045
4896
+ - https://tools.ietf.org/html/rfc2046
4897
+ - https://tools.ietf.org/html/rfc7231#section-3.1.1.1
4898
+ - https://tools.ietf.org/html/rfc7231#section-3.1.1.5
4899
+ */
4900
+
4901
+ // Match simple MIME types
4902
+ // NB :
4903
+ // Subtype length must not exceed 100 characters.
4904
+ // This rule does not comply to the RFC specs (what is the max length ?).
4905
+ var mimeTypeSimple = /^(application|audio|font|image|message|model|multipart|text|video)\/[a-zA-Z0-9\.\-\+]{1,100}$/i; // eslint-disable-line max-len
4906
+
4907
+ // Handle "charset" in "text/*"
4908
+ var mimeTypeText = /^text\/[a-zA-Z0-9\.\-\+]{1,100};\s?charset=("[a-zA-Z0-9\.\-\+\s]{0,70}"|[a-zA-Z0-9\.\-\+]{0,70})(\s?\([a-zA-Z0-9\.\-\+\s]{1,20}\))?$/i; // eslint-disable-line max-len
4909
+
4910
+ // Handle "boundary" in "multipart/*"
4911
+ var mimeTypeMultipart = /^multipart\/[a-zA-Z0-9\.\-\+]{1,100}(;\s?(boundary|charset)=("[a-zA-Z0-9\.\-\+\s]{0,70}"|[a-zA-Z0-9\.\-\+]{0,70})(\s?\([a-zA-Z0-9\.\-\+\s]{1,20}\))?){0,2}$/i; // eslint-disable-line max-len
4912
+
4913
+ function isMimeType(str) {
4914
+ (0, _assertString2.default)(str);
4915
+ return mimeTypeSimple.test(str) || mimeTypeText.test(str) || mimeTypeMultipart.test(str);
4916
+ }
4917
+ module.exports = exports['default'];
4918
+ },{"./util/assertString":73}],49:[function(require,module,exports){
4779
4919
  'use strict';
4780
4920
 
4781
4921
  Object.defineProperty(exports, "__esModule", {
@@ -4797,19 +4937,22 @@ var phones = {
4797
4937
  'ar-JO': /^(\+?962|0)?7[789]\d{7}$/,
4798
4938
  'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/,
4799
4939
  'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/,
4940
+ 'be-BY': /^(\+?375)?(24|25|29|33|44)\d{7}$/,
4941
+ 'bg-BG': /^(\+?359|0)?8[789]\d{7}$/,
4800
4942
  'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
4801
4943
  'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,
4802
4944
  'de-DE': /^(\+?49[ \.\-])?([\(]{1}[0-9]{1,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/,
4803
- 'el-GR': /^(\+?30)?(69\d{8})$/,
4945
+ 'el-GR': /^(\+?30|0)?(69\d{8})$/,
4804
4946
  'en-AU': /^(\+?61|0)4\d{8}$/,
4805
4947
  'en-GB': /^(\+?44|0)7\d{9}$/,
4806
4948
  'en-HK': /^(\+?852\-?)?[456789]\d{3}\-?\d{4}$/,
4807
- 'en-IN': /^(\+?91|0)?[789]\d{9}$/,
4949
+ 'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
4808
4950
  'en-KE': /^(\+?254|0)?[7]\d{8}$/,
4809
4951
  'en-NG': /^(\+?234|0)?[789]\d{9}$/,
4810
4952
  'en-NZ': /^(\+?64|0)2\d{7,9}$/,
4811
4953
  'en-PK': /^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/,
4812
4954
  'en-RW': /^(\+?250|0)?[7]\d{8}$/,
4955
+ 'en-SG': /^(\+65)?[89]\d{7}$/,
4813
4956
  'en-TZ': /^(\+?255|0)?[67]\d{8}$/,
4814
4957
  'en-UG': /^(\+?256|0)?[7]\d{8}$/,
4815
4958
  'en-US': /^(\+?1)?[2-9]\d{2}[2-9](?!11)\d{6}$/,
@@ -4821,11 +4964,12 @@ var phones = {
4821
4964
  'fi-FI': /^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/,
4822
4965
  'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
4823
4966
  'fr-FR': /^(\+?33|0)[67]\d{8}$/,
4824
- 'he-IL': /^(\+972|0)([23489]|5[0248]|77)[1-9]\d{6}/,
4967
+ 'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}/,
4825
4968
  'hu-HU': /^(\+?36)(20|30|70)\d{7}$/,
4826
4969
  'id-ID': /^(\+?62|0[1-9])[\s|\d]+$/,
4827
4970
  'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/,
4828
4971
  'ja-JP': /^(\+?81|0)[789]0[ \-]?[1-9]\d{2}[ \-]?\d{5}$/,
4972
+ 'kk-KZ': /^(\+?7|8)?7\d{9}$/,
4829
4973
  'kl-GL': /^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
4830
4974
  'ko-KR': /^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,
4831
4975
  'lt-LT': /^(\+370|8)\d{8}$/,
@@ -4840,10 +4984,11 @@ var phones = {
4840
4984
  'ru-RU': /^(\+?7|8)?9\d{9}$/,
4841
4985
  'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
4842
4986
  'sr-RS': /^(\+3816|06)[- \d]{5,9}$/,
4987
+ 'th-TH': /^(\+66|66|0)\d{9}$/,
4843
4988
  'tr-TR': /^(\+?90|0)?5\d{9}$/,
4844
4989
  'uk-UA': /^(\+?38|8)?0\d{9}$/,
4845
4990
  'vi-VN': /^(\+?84|0)?((1(2([0-9])|6([2-9])|88|99))|(9((?!5)[0-9])))([0-9]{7})$/,
4846
- 'zh-CN': /^(\+?0?86\-?)?1[345789]\d{9}$/,
4991
+ 'zh-CN': /^(\+?0?86\-?)?1[3456789]\d{9}$/,
4847
4992
  'zh-TW': /^(\+?886\-?|0)?9\d{8}$/
4848
4993
  };
4849
4994
  /* eslint-enable max-len */
@@ -4853,8 +4998,11 @@ phones['en-CA'] = phones['en-US'];
4853
4998
  phones['fr-BE'] = phones['nl-BE'];
4854
4999
  phones['zh-HK'] = phones['en-HK'];
4855
5000
 
4856
- function isMobilePhone(str, locale) {
5001
+ function isMobilePhone(str, locale, options) {
4857
5002
  (0, _assertString2.default)(str);
5003
+ if (options && options.strictMode && !str.startsWith('+')) {
5004
+ return false;
5005
+ }
4858
5006
  if (locale in phones) {
4859
5007
  return phones[locale].test(str);
4860
5008
  } else if (locale === 'any') {
@@ -4871,7 +5019,7 @@ function isMobilePhone(str, locale) {
4871
5019
  throw new Error('Invalid locale \'' + locale + '\'');
4872
5020
  }
4873
5021
  module.exports = exports['default'];
4874
- },{"./util/assertString":70}],48:[function(require,module,exports){
5022
+ },{"./util/assertString":73}],50:[function(require,module,exports){
4875
5023
  'use strict';
4876
5024
 
4877
5025
  Object.defineProperty(exports, "__esModule", {
@@ -4894,7 +5042,7 @@ function isMongoId(str) {
4894
5042
  return (0, _isHexadecimal2.default)(str) && str.length === 24;
4895
5043
  }
4896
5044
  module.exports = exports['default'];
4897
- },{"./isHexadecimal":31,"./util/assertString":70}],49:[function(require,module,exports){
5045
+ },{"./isHexadecimal":31,"./util/assertString":73}],51:[function(require,module,exports){
4898
5046
  'use strict';
4899
5047
 
4900
5048
  Object.defineProperty(exports, "__esModule", {
@@ -4917,7 +5065,7 @@ function isMultibyte(str) {
4917
5065
  return multibyte.test(str);
4918
5066
  }
4919
5067
  module.exports = exports['default'];
4920
- },{"./util/assertString":70}],50:[function(require,module,exports){
5068
+ },{"./util/assertString":73}],52:[function(require,module,exports){
4921
5069
  'use strict';
4922
5070
 
4923
5071
  Object.defineProperty(exports, "__esModule", {
@@ -4931,14 +5079,14 @@ var _assertString2 = _interopRequireDefault(_assertString);
4931
5079
 
4932
5080
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4933
5081
 
4934
- var numeric = /^[-+]?[0-9]+$/;
5082
+ var numeric = /^[+-]?([0-9]*[.])?[0-9]+$/;
4935
5083
 
4936
5084
  function isNumeric(str) {
4937
5085
  (0, _assertString2.default)(str);
4938
5086
  return numeric.test(str);
4939
5087
  }
4940
5088
  module.exports = exports['default'];
4941
- },{"./util/assertString":70}],51:[function(require,module,exports){
5089
+ },{"./util/assertString":73}],53:[function(require,module,exports){
4942
5090
  'use strict';
4943
5091
 
4944
5092
  Object.defineProperty(exports, "__esModule", {
@@ -4956,7 +5104,7 @@ function isPort(str) {
4956
5104
  return (0, _isInt2.default)(str, { min: 0, max: 65535 });
4957
5105
  }
4958
5106
  module.exports = exports['default'];
4959
- },{"./isInt":40}],52:[function(require,module,exports){
5107
+ },{"./isInt":41}],54:[function(require,module,exports){
4960
5108
  'use strict';
4961
5109
 
4962
5110
  Object.defineProperty(exports, "__esModule", {
@@ -4998,6 +5146,7 @@ var patterns = {
4998
5146
  AT: fourDigit,
4999
5147
  AU: fourDigit,
5000
5148
  BE: fourDigit,
5149
+ BG: fourDigit,
5001
5150
  CA: /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,
5002
5151
  CH: fourDigit,
5003
5152
  CZ: /^\d{3}\s?\d{2}$/,
@@ -5020,11 +5169,12 @@ var patterns = {
5020
5169
  NL: /^\d{4}\s?[a-z]{2}$/i,
5021
5170
  NO: fourDigit,
5022
5171
  PL: /^\d{2}\-\d{3}$/,
5023
- PT: /^\d{4}(\-\d{3})?$/,
5172
+ PT: /^\d{4}\-\d{3}?$/,
5024
5173
  RO: sixDigit,
5025
5174
  RU: sixDigit,
5026
5175
  SA: fiveDigit,
5027
5176
  SE: /^\d{3}\s?\d{2}$/,
5177
+ SK: /^\d{3}\s?\d{2}$/,
5028
5178
  TW: /^\d{3}(\d{2})?$/,
5029
5179
  US: /^\d{5}(-\d{4})?$/,
5030
5180
  ZA: fourDigit,
@@ -5032,7 +5182,47 @@ var patterns = {
5032
5182
  };
5033
5183
 
5034
5184
  var locales = exports.locales = Object.keys(patterns);
5035
- },{"./util/assertString":70}],53:[function(require,module,exports){
5185
+ },{"./util/assertString":73}],55:[function(require,module,exports){
5186
+ 'use strict';
5187
+
5188
+ Object.defineProperty(exports, "__esModule", {
5189
+ value: true
5190
+ });
5191
+ exports.default = isRFC3339;
5192
+
5193
+ var _assertString = require('./util/assertString');
5194
+
5195
+ var _assertString2 = _interopRequireDefault(_assertString);
5196
+
5197
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5198
+
5199
+ /* Based on https://tools.ietf.org/html/rfc3339#section-5.6 */
5200
+
5201
+ var dateFullYear = /[0-9]{4}/;
5202
+ var dateMonth = /(0[1-9]|1[0-2])/;
5203
+ var dateMDay = /([12]\d|0[1-9]|3[01])/;
5204
+
5205
+ var timeHour = /([01][0-9]|2[0-3])/;
5206
+ var timeMinute = /[0-5][0-9]/;
5207
+ var timeSecond = /([0-5][0-9]|60)/;
5208
+
5209
+ var timeSecFrac = /(\.[0-9]+)?/;
5210
+ var timeNumOffset = new RegExp('[-+]' + timeHour.source + ':' + timeMinute.source);
5211
+ var timeOffset = new RegExp('([zZ]|' + timeNumOffset.source + ')');
5212
+
5213
+ var partialTime = new RegExp(timeHour.source + ':' + timeMinute.source + ':' + timeSecond.source + timeSecFrac.source);
5214
+
5215
+ var fullDate = new RegExp(dateFullYear.source + '-' + dateMonth.source + '-' + dateMDay.source);
5216
+ var fullTime = new RegExp('' + partialTime.source + timeOffset.source);
5217
+
5218
+ var rfc3339 = new RegExp(fullDate.source + '[ tT]' + fullTime.source);
5219
+
5220
+ function isRFC3339(str) {
5221
+ (0, _assertString2.default)(str);
5222
+ return rfc3339.test(str);
5223
+ }
5224
+ module.exports = exports['default'];
5225
+ },{"./util/assertString":73}],56:[function(require,module,exports){
5036
5226
  'use strict';
5037
5227
 
5038
5228
  Object.defineProperty(exports, "__esModule", {
@@ -5053,7 +5243,7 @@ function isSurrogatePair(str) {
5053
5243
  return surrogatePair.test(str);
5054
5244
  }
5055
5245
  module.exports = exports['default'];
5056
- },{"./util/assertString":70}],54:[function(require,module,exports){
5246
+ },{"./util/assertString":73}],57:[function(require,module,exports){
5057
5247
  'use strict';
5058
5248
 
5059
5249
  Object.defineProperty(exports, "__esModule", {
@@ -5201,7 +5391,7 @@ function isURL(url, options) {
5201
5391
  return true;
5202
5392
  }
5203
5393
  module.exports = exports['default'];
5204
- },{"./isFQDN":25,"./isIP":32,"./util/assertString":70,"./util/merge":71}],55:[function(require,module,exports){
5394
+ },{"./isFQDN":25,"./isIP":32,"./util/assertString":73,"./util/merge":74}],58:[function(require,module,exports){
5205
5395
  'use strict';
5206
5396
 
5207
5397
  Object.defineProperty(exports, "__esModule", {
@@ -5230,7 +5420,7 @@ function isUUID(str) {
5230
5420
  return pattern && pattern.test(str);
5231
5421
  }
5232
5422
  module.exports = exports['default'];
5233
- },{"./util/assertString":70}],56:[function(require,module,exports){
5423
+ },{"./util/assertString":73}],59:[function(require,module,exports){
5234
5424
  'use strict';
5235
5425
 
5236
5426
  Object.defineProperty(exports, "__esModule", {
@@ -5249,7 +5439,7 @@ function isUppercase(str) {
5249
5439
  return str === str.toUpperCase();
5250
5440
  }
5251
5441
  module.exports = exports['default'];
5252
- },{"./util/assertString":70}],57:[function(require,module,exports){
5442
+ },{"./util/assertString":73}],60:[function(require,module,exports){
5253
5443
  'use strict';
5254
5444
 
5255
5445
  Object.defineProperty(exports, "__esModule", {
@@ -5272,7 +5462,7 @@ function isVariableWidth(str) {
5272
5462
  return _isFullWidth.fullWidth.test(str) && _isHalfWidth.halfWidth.test(str);
5273
5463
  }
5274
5464
  module.exports = exports['default'];
5275
- },{"./isFullWidth":27,"./isHalfWidth":28,"./util/assertString":70}],58:[function(require,module,exports){
5465
+ },{"./isFullWidth":27,"./isHalfWidth":28,"./util/assertString":73}],61:[function(require,module,exports){
5276
5466
  'use strict';
5277
5467
 
5278
5468
  Object.defineProperty(exports, "__esModule", {
@@ -5296,7 +5486,7 @@ function isWhitelisted(str, chars) {
5296
5486
  return true;
5297
5487
  }
5298
5488
  module.exports = exports['default'];
5299
- },{"./util/assertString":70}],59:[function(require,module,exports){
5489
+ },{"./util/assertString":73}],62:[function(require,module,exports){
5300
5490
  'use strict';
5301
5491
 
5302
5492
  Object.defineProperty(exports, "__esModule", {
@@ -5316,7 +5506,7 @@ function ltrim(str, chars) {
5316
5506
  return str.replace(pattern, '');
5317
5507
  }
5318
5508
  module.exports = exports['default'];
5319
- },{"./util/assertString":70}],60:[function(require,module,exports){
5509
+ },{"./util/assertString":73}],63:[function(require,module,exports){
5320
5510
  'use strict';
5321
5511
 
5322
5512
  Object.defineProperty(exports, "__esModule", {
@@ -5338,7 +5528,7 @@ function matches(str, pattern, modifiers) {
5338
5528
  return pattern.test(str);
5339
5529
  }
5340
5530
  module.exports = exports['default'];
5341
- },{"./util/assertString":70}],61:[function(require,module,exports){
5531
+ },{"./util/assertString":73}],64:[function(require,module,exports){
5342
5532
  'use strict';
5343
5533
 
5344
5534
  Object.defineProperty(exports, "__esModule", {
@@ -5381,6 +5571,10 @@ var default_normalize_email_options = {
5381
5571
  // Removes the subaddress (e.g. "-foo") from the email address
5382
5572
  yahoo_remove_subaddress: true,
5383
5573
 
5574
+ // The following conversions are specific to Yandex
5575
+ // Lowercases the local part of the Yandex address (known to be case-insensitive)
5576
+ yandex_lowercase: true,
5577
+
5384
5578
  // The following conversions are specific to iCloud
5385
5579
  // Lowercases the local part of the iCloud address (known to be case-insensitive)
5386
5580
  icloud_lowercase: true,
@@ -5401,6 +5595,17 @@ var outlookdotcom_domains = ['hotmail.at', 'hotmail.be', 'hotmail.ca', 'hotmail.
5401
5595
  // This list is likely incomplete
5402
5596
  var yahoo_domains = ['rocketmail.com', 'yahoo.ca', 'yahoo.co.uk', 'yahoo.com', 'yahoo.de', 'yahoo.fr', 'yahoo.in', 'yahoo.it', 'ymail.com'];
5403
5597
 
5598
+ // List of domains used by yandex.ru
5599
+ var yandex_domains = ['yandex.ru', 'yandex.ua', 'yandex.kz', 'yandex.com', 'yandex.by', 'ya.ru'];
5600
+
5601
+ // replace single dots, but not multiple consecutive dots
5602
+ function dotsReplacer(match) {
5603
+ if (match.length > 1) {
5604
+ return match;
5605
+ }
5606
+ return '';
5607
+ }
5608
+
5404
5609
  function normalizeEmail(email, options) {
5405
5610
  options = (0, _merge2.default)(options, default_normalize_email_options);
5406
5611
 
@@ -5418,7 +5623,8 @@ function normalizeEmail(email, options) {
5418
5623
  parts[0] = parts[0].split('+')[0];
5419
5624
  }
5420
5625
  if (options.gmail_remove_dots) {
5421
- parts[0] = parts[0].replace(/\./g, '');
5626
+ // this does not replace consecutive dots like example..email@gmail.com
5627
+ parts[0] = parts[0].replace(/\.+/g, dotsReplacer);
5422
5628
  }
5423
5629
  if (!parts[0].length) {
5424
5630
  return false;
@@ -5461,6 +5667,11 @@ function normalizeEmail(email, options) {
5461
5667
  if (options.all_lowercase || options.yahoo_lowercase) {
5462
5668
  parts[0] = parts[0].toLowerCase();
5463
5669
  }
5670
+ } else if (~yandex_domains.indexOf(parts[1])) {
5671
+ if (options.all_lowercase || options.yandex_lowercase) {
5672
+ parts[0] = parts[0].toLowerCase();
5673
+ }
5674
+ parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preffered
5464
5675
  } else if (options.all_lowercase) {
5465
5676
  // Any other address
5466
5677
  parts[0] = parts[0].toLowerCase();
@@ -5468,7 +5679,7 @@ function normalizeEmail(email, options) {
5468
5679
  return parts.join('@');
5469
5680
  }
5470
5681
  module.exports = exports['default'];
5471
- },{"./util/merge":71}],62:[function(require,module,exports){
5682
+ },{"./util/merge":74}],65:[function(require,module,exports){
5472
5683
  'use strict';
5473
5684
 
5474
5685
  Object.defineProperty(exports, "__esModule", {
@@ -5494,7 +5705,7 @@ function rtrim(str, chars) {
5494
5705
  return idx < str.length ? str.substr(0, idx + 1) : str;
5495
5706
  }
5496
5707
  module.exports = exports['default'];
5497
- },{"./util/assertString":70}],63:[function(require,module,exports){
5708
+ },{"./util/assertString":73}],66:[function(require,module,exports){
5498
5709
  'use strict';
5499
5710
 
5500
5711
  Object.defineProperty(exports, "__esModule", {
@@ -5518,7 +5729,7 @@ function stripLow(str, keep_new_lines) {
5518
5729
  return (0, _blacklist2.default)(str, chars);
5519
5730
  }
5520
5731
  module.exports = exports['default'];
5521
- },{"./blacklist":6,"./util/assertString":70}],64:[function(require,module,exports){
5732
+ },{"./blacklist":6,"./util/assertString":73}],67:[function(require,module,exports){
5522
5733
  'use strict';
5523
5734
 
5524
5735
  Object.defineProperty(exports, "__esModule", {
@@ -5540,7 +5751,7 @@ function toBoolean(str, strict) {
5540
5751
  return str !== '0' && str !== 'false' && str !== '';
5541
5752
  }
5542
5753
  module.exports = exports['default'];
5543
- },{"./util/assertString":70}],65:[function(require,module,exports){
5754
+ },{"./util/assertString":73}],68:[function(require,module,exports){
5544
5755
  'use strict';
5545
5756
 
5546
5757
  Object.defineProperty(exports, "__esModule", {
@@ -5560,7 +5771,7 @@ function toDate(date) {
5560
5771
  return !isNaN(date) ? new Date(date) : null;
5561
5772
  }
5562
5773
  module.exports = exports['default'];
5563
- },{"./util/assertString":70}],66:[function(require,module,exports){
5774
+ },{"./util/assertString":73}],69:[function(require,module,exports){
5564
5775
  'use strict';
5565
5776
 
5566
5777
  Object.defineProperty(exports, "__esModule", {
@@ -5579,7 +5790,7 @@ function toFloat(str) {
5579
5790
  return parseFloat(str);
5580
5791
  }
5581
5792
  module.exports = exports['default'];
5582
- },{"./util/assertString":70}],67:[function(require,module,exports){
5793
+ },{"./util/assertString":73}],70:[function(require,module,exports){
5583
5794
  'use strict';
5584
5795
 
5585
5796
  Object.defineProperty(exports, "__esModule", {
@@ -5598,7 +5809,7 @@ function toInt(str, radix) {
5598
5809
  return parseInt(str, radix || 10);
5599
5810
  }
5600
5811
  module.exports = exports['default'];
5601
- },{"./util/assertString":70}],68:[function(require,module,exports){
5812
+ },{"./util/assertString":73}],71:[function(require,module,exports){
5602
5813
  'use strict';
5603
5814
 
5604
5815
  Object.defineProperty(exports, "__esModule", {
@@ -5620,7 +5831,7 @@ function trim(str, chars) {
5620
5831
  return (0, _rtrim2.default)((0, _ltrim2.default)(str, chars), chars);
5621
5832
  }
5622
5833
  module.exports = exports['default'];
5623
- },{"./ltrim":59,"./rtrim":62}],69:[function(require,module,exports){
5834
+ },{"./ltrim":62,"./rtrim":65}],72:[function(require,module,exports){
5624
5835
  'use strict';
5625
5836
 
5626
5837
  Object.defineProperty(exports, "__esModule", {
@@ -5639,7 +5850,7 @@ function unescape(str) {
5639
5850
  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, '`');
5640
5851
  }
5641
5852
  module.exports = exports['default'];
5642
- },{"./util/assertString":70}],70:[function(require,module,exports){
5853
+ },{"./util/assertString":73}],73:[function(require,module,exports){
5643
5854
  'use strict';
5644
5855
 
5645
5856
  Object.defineProperty(exports, "__esModule", {
@@ -5654,7 +5865,7 @@ function assertString(input) {
5654
5865
  }
5655
5866
  }
5656
5867
  module.exports = exports['default'];
5657
- },{}],71:[function(require,module,exports){
5868
+ },{}],74:[function(require,module,exports){
5658
5869
  'use strict';
5659
5870
 
5660
5871
  Object.defineProperty(exports, "__esModule", {
@@ -5673,7 +5884,7 @@ function merge() {
5673
5884
  return obj;
5674
5885
  }
5675
5886
  module.exports = exports['default'];
5676
- },{}],72:[function(require,module,exports){
5887
+ },{}],75:[function(require,module,exports){
5677
5888
  'use strict';
5678
5889
 
5679
5890
  Object.defineProperty(exports, "__esModule", {
@@ -5696,7 +5907,7 @@ function toString(input) {
5696
5907
  return String(input);
5697
5908
  }
5698
5909
  module.exports = exports['default'];
5699
- },{}],73:[function(require,module,exports){
5910
+ },{}],76:[function(require,module,exports){
5700
5911
  'use strict';
5701
5912
 
5702
5913
  Object.defineProperty(exports, "__esModule", {
@@ -5715,7 +5926,7 @@ function whitelist(str, chars) {
5715
5926
  return str.replace(new RegExp('[^' + chars + ']+', 'g'), '');
5716
5927
  }
5717
5928
  module.exports = exports['default'];
5718
- },{"./util/assertString":70}],74:[function(require,module,exports){
5929
+ },{"./util/assertString":73}],77:[function(require,module,exports){
5719
5930
  "use strict";
5720
5931
 
5721
5932
  module.exports = {
@@ -5723,6 +5934,7 @@ module.exports = {
5723
5934
  INVALID_TYPE: "Expected type {0} but found type {1}",
5724
5935
  INVALID_FORMAT: "Object didn't pass validation for format {0}: {1}",
5725
5936
  ENUM_MISMATCH: "No enum match for: {0}",
5937
+ ENUM_CASE_MISMATCH: "Enum does not match case for: {0}",
5726
5938
  ANY_OF_MISSING: "Data does not match any schemas from 'anyOf'",
5727
5939
  ONE_OF_MISSING: "Data does not match any schemas from 'oneOf'",
5728
5940
  ONE_OF_MULTIPLE: "Data is valid against more than one schema from 'oneOf'",
@@ -5776,7 +5988,7 @@ module.exports = {
5776
5988
 
5777
5989
  };
5778
5990
 
5779
- },{}],75:[function(require,module,exports){
5991
+ },{}],78:[function(require,module,exports){
5780
5992
  /*jshint maxlen: false*/
5781
5993
 
5782
5994
  var validator = require("validator");
@@ -5907,7 +6119,7 @@ var FormatValidators = {
5907
6119
 
5908
6120
  module.exports = FormatValidators;
5909
6121
 
5910
- },{"validator":4}],76:[function(require,module,exports){
6122
+ },{"validator":4}],79:[function(require,module,exports){
5911
6123
  "use strict";
5912
6124
 
5913
6125
  var FormatValidators = require("./FormatValidators"),
@@ -6156,23 +6368,35 @@ var JsonValidators = {
6156
6368
  enum: function (report, schema, json) {
6157
6369
  // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.1.2
6158
6370
  var match = false,
6371
+ caseInsensitiveMatch = false,
6159
6372
  idx = schema.enum.length;
6160
6373
  while (idx--) {
6161
6374
  if (Utils.areEqual(json, schema.enum[idx])) {
6162
6375
  match = true;
6163
6376
  break;
6377
+ } else if (Utils.areEqual(json, schema.enum[idx]), { caseInsensitiveComparison: true }) {
6378
+ caseInsensitiveMatch = true;
6164
6379
  }
6165
6380
  }
6381
+
6166
6382
  if (match === false) {
6167
- report.addError("ENUM_MISMATCH", [json], null, schema.description);
6383
+ var error = caseInsensitiveMatch && this.options.enumCaseInsensitiveComparison ? "ENUM_CASE_MISMATCH" : "ENUM_MISMATCH";
6384
+ report.addError(error, [json], null, schema.description);
6168
6385
  }
6169
6386
  },
6170
- /*
6171
6387
  type: function (report, schema, json) {
6172
6388
  // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.2.2
6173
- // type is handled before this is called so ignore
6389
+ var jsonType = Utils.whatIs(json);
6390
+ if (typeof schema.type === "string") {
6391
+ if (jsonType !== schema.type && (jsonType !== "integer" || schema.type !== "number")) {
6392
+ report.addError("INVALID_TYPE", [schema.type, jsonType], null, schema.description);
6393
+ }
6394
+ } else {
6395
+ if (schema.type.indexOf(jsonType) === -1 && (jsonType !== "integer" || schema.type.indexOf("number") === -1)) {
6396
+ report.addError("INVALID_TYPE", [schema.type, jsonType], null, schema.description);
6397
+ }
6398
+ }
6174
6399
  },
6175
- */
6176
6400
  allOf: function (report, schema, json) {
6177
6401
  // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.3.2
6178
6402
  var idx = schema.allOf.length;
@@ -6399,23 +6623,12 @@ exports.validate = function (report, schema, json) {
6399
6623
  }
6400
6624
 
6401
6625
  // type checking first
6402
- // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.2.2
6403
6626
  var jsonType = Utils.whatIs(json);
6404
6627
  if (schema.type) {
6405
- if (typeof schema.type === "string") {
6406
- if (jsonType !== schema.type && (jsonType !== "integer" || schema.type !== "number")) {
6407
- report.addError("INVALID_TYPE", [schema.type, jsonType], null, schema.description);
6408
- if (this.options.breakOnFirstError) {
6409
- return false;
6410
- }
6411
- }
6412
- } else {
6413
- if (schema.type.indexOf(jsonType) === -1 && (jsonType !== "integer" || schema.type.indexOf("number") === -1)) {
6414
- report.addError("INVALID_TYPE", [schema.type, jsonType], null, schema.description);
6415
- if (this.options.breakOnFirstError) {
6416
- return false;
6417
- }
6418
- }
6628
+ keys.splice(keys.indexOf("type"), 1);
6629
+ JsonValidators.type.call(this, report, schema, json);
6630
+ if (report.errors.length && this.options.breakOnFirstError) {
6631
+ return false;
6419
6632
  }
6420
6633
  }
6421
6634
 
@@ -6450,7 +6663,7 @@ exports.validate = function (report, schema, json) {
6450
6663
 
6451
6664
  };
6452
6665
 
6453
- },{"./FormatValidators":75,"./Report":78,"./Utils":82}],77:[function(require,module,exports){
6666
+ },{"./FormatValidators":78,"./Report":81,"./Utils":85}],80:[function(require,module,exports){
6454
6667
  // Number.isFinite polyfill
6455
6668
  // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite
6456
6669
  if (typeof Number.isFinite !== "function") {
@@ -6468,7 +6681,7 @@ if (typeof Number.isFinite !== "function") {
6468
6681
  };
6469
6682
  }
6470
6683
 
6471
- },{}],78:[function(require,module,exports){
6684
+ },{}],81:[function(require,module,exports){
6472
6685
  (function (process){
6473
6686
  "use strict";
6474
6687
 
@@ -6529,7 +6742,8 @@ Report.prototype.processAsyncTasks = function (timeout, callback) {
6529
6742
  };
6530
6743
  }
6531
6744
 
6532
- if (tasksCount === 0 || this.errors.length > 0) {
6745
+ // finish if tasks are completed or there are any errors and breaking on first error was requested
6746
+ if (tasksCount === 0 || (this.errors.length > 0 && this.options.breakOnFirstError)) {
6533
6747
  finish();
6534
6748
  return;
6535
6749
  }
@@ -6674,7 +6888,7 @@ Report.prototype.addCustomError = function (errorCode, errorMessage, params, sub
6674
6888
  module.exports = Report;
6675
6889
 
6676
6890
  }).call(this,require('_process'))
6677
- },{"./Errors":74,"./Utils":82,"_process":3,"lodash.get":1}],79:[function(require,module,exports){
6891
+ },{"./Errors":77,"./Utils":85,"_process":3,"lodash.get":1}],82:[function(require,module,exports){
6678
6892
  "use strict";
6679
6893
 
6680
6894
  var isequal = require("lodash.isequal");
@@ -6838,7 +7052,7 @@ exports.getSchemaByUri = function (report, uri, root) {
6838
7052
 
6839
7053
  exports.getRemotePath = getRemotePath;
6840
7054
 
6841
- },{"./Report":78,"./SchemaCompilation":80,"./SchemaValidation":81,"./Utils":82,"lodash.isequal":2}],80:[function(require,module,exports){
7055
+ },{"./Report":81,"./SchemaCompilation":83,"./SchemaValidation":84,"./Utils":85,"lodash.isequal":2}],83:[function(require,module,exports){
6842
7056
  "use strict";
6843
7057
 
6844
7058
  var Report = require("./Report");
@@ -7139,7 +7353,7 @@ exports.compileSchema = function (report, schema) {
7139
7353
 
7140
7354
  };
7141
7355
 
7142
- },{"./Report":78,"./SchemaCache":79,"./Utils":82}],81:[function(require,module,exports){
7356
+ },{"./Report":81,"./SchemaCache":82,"./Utils":85}],84:[function(require,module,exports){
7143
7357
  "use strict";
7144
7358
 
7145
7359
  var FormatValidators = require("./FormatValidators"),
@@ -7748,7 +7962,7 @@ exports.validateSchema = function (report, schema) {
7748
7962
  return isValid;
7749
7963
  };
7750
7964
 
7751
- },{"./FormatValidators":75,"./JsonValidation":76,"./Report":78,"./Utils":82}],82:[function(require,module,exports){
7965
+ },{"./FormatValidators":78,"./JsonValidation":79,"./Report":81,"./Utils":85}],85:[function(require,module,exports){
7752
7966
  "use strict";
7753
7967
 
7754
7968
  exports.isAbsoluteUri = function (uri) {
@@ -7792,7 +8006,11 @@ exports.whatIs = function (what) {
7792
8006
 
7793
8007
  };
7794
8008
 
7795
- exports.areEqual = function areEqual(json1, json2) {
8009
+ exports.areEqual = function areEqual(json1, json2, options) {
8010
+
8011
+ options = options || {};
8012
+ var caseInsensitiveComparison = options.caseInsensitiveComparison || false;
8013
+
7796
8014
  // http://json-schema.org/latest/json-schema-core.html#rfc.section.3.6
7797
8015
 
7798
8016
  // Two JSON values are said to be equal if and only if:
@@ -7803,6 +8021,12 @@ exports.areEqual = function areEqual(json1, json2) {
7803
8021
  if (json1 === json2) {
7804
8022
  return true;
7805
8023
  }
8024
+ if (
8025
+ caseInsensitiveComparison === true &&
8026
+ typeof json1 === "string" && typeof json2 === "string" &&
8027
+ json1.toUpperCase() === json2.toUpperCase()) {
8028
+ return true;
8029
+ }
7806
8030
 
7807
8031
  var i, len;
7808
8032
 
@@ -7815,7 +8039,7 @@ exports.areEqual = function areEqual(json1, json2) {
7815
8039
  // items at the same index are equal according to this definition; or
7816
8040
  len = json1.length;
7817
8041
  for (i = 0; i < len; i++) {
7818
- if (!areEqual(json1[i], json2[i])) {
8042
+ if (!areEqual(json1[i], json2[i], { caseInsensitiveComparison: caseInsensitiveComparison })) {
7819
8043
  return false;
7820
8044
  }
7821
8045
  }
@@ -7827,13 +8051,13 @@ exports.areEqual = function areEqual(json1, json2) {
7827
8051
  // have the same set of property names; and
7828
8052
  var keys1 = Object.keys(json1);
7829
8053
  var keys2 = Object.keys(json2);
7830
- if (!areEqual(keys1, keys2)) {
8054
+ if (!areEqual(keys1, keys2, { caseInsensitiveComparison: caseInsensitiveComparison })) {
7831
8055
  return false;
7832
8056
  }
7833
8057
  // values for a same property name are equal according to this definition.
7834
8058
  len = keys1.length;
7835
8059
  for (i = 0; i < len; i++) {
7836
- if (!areEqual(json1[keys1[i]], json2[keys1[i]])) {
8060
+ if (!areEqual(json1[keys1[i]], json2[keys1[i]], { caseInsensitiveComparison: caseInsensitiveComparison })) {
7837
8061
  return false;
7838
8062
  }
7839
8063
  }
@@ -7967,7 +8191,7 @@ exports.ucs2decode = function (string) {
7967
8191
  };
7968
8192
  /*jshint +W016*/
7969
8193
 
7970
- },{}],83:[function(require,module,exports){
8194
+ },{}],86:[function(require,module,exports){
7971
8195
  (function (process){
7972
8196
  "use strict";
7973
8197
 
@@ -7993,6 +8217,8 @@ var defaultOptions = {
7993
8217
  forceAdditional: false,
7994
8218
  // assume additionalProperties and additionalItems are defined as "false" where appropriate
7995
8219
  assumeAdditional: false,
8220
+ // do case insensitive comparison for enums
8221
+ enumCaseInsensitiveComparison: false,
7996
8222
  // force items to be defined on "array" types
7997
8223
  forceItems: false,
7998
8224
  // force minItems to be defined on "array" types
@@ -8083,6 +8309,7 @@ function normalizeOptions(options) {
8083
8309
  function ZSchema(options) {
8084
8310
  this.cache = {};
8085
8311
  this.referenceCache = [];
8312
+ this.validateOptions = {};
8086
8313
 
8087
8314
  this.options = normalizeOptions(options);
8088
8315
 
@@ -8129,6 +8356,8 @@ ZSchema.prototype.validate = function (json, schema, options, callback) {
8129
8356
  }
8130
8357
  if (!options) { options = {}; }
8131
8358
 
8359
+ this.validateOptions = options;
8360
+
8132
8361
  var whatIs = Utils.whatIs(schema);
8133
8362
  if (whatIs !== "string" && whatIs !== "object") {
8134
8363
  var e = new Error("Invalid .validate call - schema must be an string or object but " + whatIs + " was passed!");
@@ -8338,7 +8567,7 @@ ZSchema.getDefaultOptions = function () {
8338
8567
  module.exports = ZSchema;
8339
8568
 
8340
8569
  }).call(this,require('_process'))
8341
- },{"./FormatValidators":75,"./JsonValidation":76,"./Polyfills":77,"./Report":78,"./SchemaCache":79,"./SchemaCompilation":80,"./SchemaValidation":81,"./Utils":82,"./schemas/hyper-schema.json":84,"./schemas/schema.json":85,"_process":3,"lodash.get":1}],84:[function(require,module,exports){
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){
8342
8571
  module.exports={
8343
8572
  "$schema": "http://json-schema.org/draft-04/hyper-schema#",
8344
8573
  "id": "http://json-schema.org/draft-04/hyper-schema#",
@@ -8498,7 +8727,7 @@ module.exports={
8498
8727
  }
8499
8728
 
8500
8729
 
8501
- },{}],85:[function(require,module,exports){
8730
+ },{}],88:[function(require,module,exports){
8502
8731
  module.exports={
8503
8732
  "id": "http://json-schema.org/draft-04/schema#",
8504
8733
  "$schema": "http://json-schema.org/draft-04/schema#",
@@ -8651,5 +8880,5 @@ module.exports={
8651
8880
  "default": {}
8652
8881
  }
8653
8882
 
8654
- },{}]},{},[74,75,76,77,78,79,80,81,82,83])(83)
8655
- });
8883
+ },{}]},{},[77,78,79,80,81,82,83,84,85,86])(86)
8884
+ });