vee-validate 2.2.5 → 2.2.9

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.
Files changed (58) hide show
  1. package/dist/locale/ar.js +1 -1
  2. package/dist/locale/az.js +1 -1
  3. package/dist/locale/bg.js +1 -1
  4. package/dist/locale/ca.js +1 -1
  5. package/dist/locale/cs.js +1 -1
  6. package/dist/locale/da.js +1 -1
  7. package/dist/locale/de.js +1 -1
  8. package/dist/locale/el.js +1 -1
  9. package/dist/locale/en.js +1 -1
  10. package/dist/locale/es.js +1 -1
  11. package/dist/locale/et.js +1 -1
  12. package/dist/locale/eu.js +1 -1
  13. package/dist/locale/fa.js +1 -1
  14. package/dist/locale/fi.js +1 -1
  15. package/dist/locale/fr.js +1 -1
  16. package/dist/locale/he.js +1 -1
  17. package/dist/locale/hi.js +1 -1
  18. package/dist/locale/hr.js +1 -1
  19. package/dist/locale/id.js +1 -1
  20. package/dist/locale/it.js +1 -1
  21. package/dist/locale/ja.js +1 -1
  22. package/dist/locale/ka.js +1 -1
  23. package/dist/locale/ko.js +1 -1
  24. package/dist/locale/lt.js +1 -1
  25. package/dist/locale/lv.js +1 -1
  26. package/dist/locale/mn.js +1 -1
  27. package/dist/locale/ms_MY.js +1 -1
  28. package/dist/locale/nb_NO.js +1 -1
  29. package/dist/locale/ne.js +1 -1
  30. package/dist/locale/nl.js +1 -1
  31. package/dist/locale/nn_NO.js +1 -1
  32. package/dist/locale/pl.js +1 -1
  33. package/dist/locale/pt_BR.js +1 -1
  34. package/dist/locale/pt_PT.js +1 -1
  35. package/dist/locale/ro.js +1 -1
  36. package/dist/locale/ru.js +1 -1
  37. package/dist/locale/sk.js +1 -1
  38. package/dist/locale/sl.js +1 -1
  39. package/dist/locale/sq.js +1 -1
  40. package/dist/locale/sr.js +1 -1
  41. package/dist/locale/sr_Latin.js +1 -1
  42. package/dist/locale/sv.js +1 -1
  43. package/dist/locale/th.js +1 -1
  44. package/dist/locale/tr.js +1 -1
  45. package/dist/locale/uk.js +1 -1
  46. package/dist/locale/vi.js +1 -1
  47. package/dist/locale/zh_CN.js +1 -1
  48. package/dist/locale/zh_TW.js +1 -1
  49. package/dist/rules.esm.js +4 -4
  50. package/dist/vee-validate.esm.js +246 -223
  51. package/dist/vee-validate.js +245 -222
  52. package/dist/vee-validate.min.js +1 -1
  53. package/dist/vee-validate.minimal.esm.js +243 -220
  54. package/dist/vee-validate.minimal.js +242 -219
  55. package/dist/vee-validate.minimal.min.js +1 -1
  56. package/package.json +27 -27
  57. package/types/vee-validate.d.ts +14 -3
  58. package/types/vue.d.ts +0 -12
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vee-validate v2.2.5
2
+ * vee-validate v2.2.9
3
3
  * (c) 2019 Abdelrahman Awad
4
4
  * @license MIT
5
5
  */
@@ -4727,7 +4727,7 @@
4727
4727
  };
4728
4728
 
4729
4729
  function unwrapExports (x) {
4730
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x.default : x;
4730
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
4731
4731
  }
4732
4732
 
4733
4733
  function createCommonjsModule(fn, module) {
@@ -5571,7 +5571,7 @@
5571
5571
  }
5572
5572
 
5573
5573
  var regexPart = decimals === '*' ? '+' : ("{1," + decimals + "}");
5574
- var regex = new RegExp(("^[-+]?\\d*(\\" + separator + "\\d" + regexPart + ")?$"));
5574
+ var regex = new RegExp(("^[-+]?\\d*(\\" + separator + "\\d" + regexPart + ")?([eE]{1}[-]?\\d+)?$"));
5575
5575
 
5576
5576
  if (! regex.test(value)) {
5577
5577
  return false;
@@ -7755,7 +7755,7 @@
7755
7755
  };
7756
7756
 
7757
7757
  prototypeAccessors$1.isDisabled.get = function () {
7758
- return !!(this.componentInstance && this.componentInstance.disabled) || !!(this.el && this.el.disabled);
7758
+ return !!(this.el && this.el.disabled);
7759
7759
  };
7760
7760
 
7761
7761
  /**
@@ -8259,14 +8259,16 @@
8259
8259
  var inputEvent = this._determineInputEvent();
8260
8260
  var events = this._determineEventList(inputEvent);
8261
8261
 
8262
- // if there is a model and an on input validation is requested.
8263
- if (this.model && includes(events, inputEvent)) {
8262
+ // if on input validation is requested.
8263
+ if (includes(events, inputEvent)) {
8264
8264
  var ctx = null;
8265
- var expression = this.model.expression;
8265
+ var expression = null;
8266
+ var watchCtxVm = false;
8266
8267
  // if its watchable from the context vm.
8267
- if (this.model.expression) {
8268
+ if (this.model && this.model.expression) {
8268
8269
  ctx = this.vm;
8269
8270
  expression = this.model.expression;
8271
+ watchCtxVm = true;
8270
8272
  }
8271
8273
 
8272
8274
  // watch it from the custom component vm instead.
@@ -8287,8 +8289,10 @@
8287
8289
  }
8288
8290
  });
8289
8291
 
8290
- // filter out input event as it is already handled by the watcher API.
8291
- events = events.filter(function (e) { return e !== inputEvent; });
8292
+ // filter out input event when we are watching from the context vm.
8293
+ if (watchCtxVm) {
8294
+ events = events.filter(function (e) { return e !== inputEvent; });
8295
+ }
8292
8296
  }
8293
8297
  }
8294
8298
 
@@ -9593,8 +9597,8 @@
9593
9597
  return false;
9594
9598
  }
9595
9599
 
9596
- // disabled fields are skipped
9597
- if (field.isDisabled) {
9600
+ // disabled fields are skipped if useConstraintAttrs is enabled in config
9601
+ if (field.isDisabled && getConfig().useConstraintAttrs) {
9598
9602
  return true;
9599
9603
  }
9600
9604
 
@@ -9985,6 +9989,10 @@
9985
9989
  var i18nRootKey = config.i18nRootKey;
9986
9990
  var locale = config.locale;
9987
9991
  var onLocaleChanged = function () {
9992
+ if (dictionary) {
9993
+ this$1.i18nDriver.merge(dictionary);
9994
+ }
9995
+
9988
9996
  this$1._validator.errors.regenerate();
9989
9997
  };
9990
9998
 
@@ -10136,204 +10144,6 @@
10136
10144
 
10137
10145
  var PROVIDER_COUNTER = 0;
10138
10146
 
10139
- function createValidationCtx (ctx) {
10140
- return {
10141
- errors: ctx.messages,
10142
- flags: ctx.flags,
10143
- classes: ctx.classes,
10144
- valid: ctx.isValid,
10145
- failedRules: ctx.failedRules,
10146
- reset: function () { return ctx.reset(); },
10147
- validate: function () {
10148
- var args = [], len = arguments.length;
10149
- while ( len-- ) args[ len ] = arguments[ len ];
10150
-
10151
- return ctx.validate.apply(ctx, args);
10152
- },
10153
- aria: {
10154
- 'aria-invalid': ctx.flags.invalid ? 'true' : 'false',
10155
- 'aria-required': ctx.isRequired ? 'true' : 'false'
10156
- }
10157
- };
10158
- }
10159
-
10160
- function normalizeValue$1 (value) {
10161
- if (isEvent(value)) {
10162
- return value.target.type === 'file' ? toArray(value.target.files) : value.target.value;
10163
- }
10164
-
10165
- return value;
10166
- }
10167
-
10168
- /**
10169
- * Determines if a provider needs to run validation.
10170
- */
10171
- function shouldValidate (ctx, model) {
10172
- // when an immediate/initial validation is needed and wasn't done before.
10173
- if (!ctx._ignoreImmediate && ctx.immediate) {
10174
- return true;
10175
- }
10176
-
10177
- // when the value changes for whatever reason.
10178
- if (ctx.value !== model.value) {
10179
- return true;
10180
- }
10181
-
10182
- // when it needs validation due to props/cross-fields changes.
10183
- if (ctx._needsValidation) {
10184
- return true;
10185
- }
10186
-
10187
- // when the initial value is undefined and the field wasn't rendered yet.
10188
- if (!ctx.initialized && model.value === undefined) {
10189
- return true;
10190
- }
10191
-
10192
- return false;
10193
- }
10194
-
10195
- function computeModeSetting (ctx) {
10196
- var compute = isCallable(ctx.mode) ? ctx.mode : modes[ctx.mode];
10197
-
10198
- return compute({
10199
- errors: ctx.messages,
10200
- value: ctx.value,
10201
- flags: ctx.flags
10202
- });
10203
- }
10204
-
10205
- function onRenderUpdate (model) {
10206
- if (!this.initialized) {
10207
- this.initialValue = model.value;
10208
- }
10209
-
10210
- var validateNow = shouldValidate(this, model);
10211
- this._needsValidation = false;
10212
- this.value = model.value;
10213
- this._ignoreImmediate = true;
10214
-
10215
- if (!validateNow) {
10216
- return;
10217
- }
10218
-
10219
- this.validateSilent().then(this.immediate || this.flags.validated ? this.applyResult : function (x) { return x; });
10220
- }
10221
-
10222
- // Creates the common handlers for a validatable context.
10223
- function createCommonHandlers (ctx) {
10224
- var onInput = function (e) {
10225
- ctx.syncValue(e); // track and keep the value updated.
10226
- ctx.setFlags({ dirty: true, pristine: false });
10227
- };
10228
-
10229
- // Blur event listener.
10230
- var onBlur = function () {
10231
- ctx.setFlags({ touched: true, untouched: false });
10232
- };
10233
-
10234
- var onValidate = ctx.$veeHandler;
10235
- var mode = computeModeSetting(ctx);
10236
-
10237
- // Handle debounce changes.
10238
- if (!onValidate || ctx.$veeDebounce !== ctx.debounce) {
10239
- onValidate = debounce(
10240
- function () {
10241
- ctx.$nextTick(function () {
10242
- var pendingPromise = ctx.validateSilent();
10243
- // avoids race conditions between successive validations.
10244
- ctx._pendingValidation = pendingPromise;
10245
- pendingPromise.then(function (result) {
10246
- if (pendingPromise === ctx._pendingValidation) {
10247
- ctx.applyResult(result);
10248
- ctx._pendingValidation = null;
10249
- }
10250
- });
10251
- });
10252
- },
10253
- mode.debounce || ctx.debounce
10254
- );
10255
-
10256
- // Cache the handler so we don't create it each time.
10257
- ctx.$veeHandler = onValidate;
10258
- // cache the debounce value so we detect if it was changed.
10259
- ctx.$veeDebounce = ctx.debounce;
10260
- }
10261
-
10262
- return { onInput: onInput, onBlur: onBlur, onValidate: onValidate };
10263
- }
10264
-
10265
- // Adds all plugin listeners to the vnode.
10266
- function addListeners (node) {
10267
- var model = findModel(node);
10268
- // cache the input eventName.
10269
- this._inputEventName = this._inputEventName || getInputEventName(node, model);
10270
-
10271
- onRenderUpdate.call(this, model);
10272
-
10273
- var ref = createCommonHandlers(this);
10274
- var onInput = ref.onInput;
10275
- var onBlur = ref.onBlur;
10276
- var onValidate = ref.onValidate;
10277
- addVNodeListener(node, this._inputEventName, onInput);
10278
- addVNodeListener(node, 'blur', onBlur);
10279
-
10280
- // add the validation listeners.
10281
- this.normalizedEvents.forEach(function (evt) {
10282
- addVNodeListener(node, evt, onValidate);
10283
- });
10284
-
10285
- this.initialized = true;
10286
- }
10287
-
10288
- function createValuesLookup (ctx) {
10289
- var providers = ctx.$_veeObserver.refs;
10290
-
10291
- return ctx.fieldDeps.reduce(function (acc, depName) {
10292
- if (!providers[depName]) {
10293
- return acc;
10294
- }
10295
-
10296
- acc[depName] = providers[depName].value;
10297
-
10298
- return acc;
10299
- }, {});
10300
- }
10301
-
10302
- function updateRenderingContextRefs (ctx) {
10303
- // IDs should not be nullable.
10304
- if (isNullOrUndefined(ctx.id) && ctx.id === ctx.vid) {
10305
- ctx.id = PROVIDER_COUNTER;
10306
- PROVIDER_COUNTER++;
10307
- }
10308
-
10309
- var id = ctx.id;
10310
- var vid = ctx.vid;
10311
- // Nothing has changed.
10312
- if (ctx.isDeactivated || (id === vid && ctx.$_veeObserver.refs[id])) {
10313
- return;
10314
- }
10315
-
10316
- // vid was changed.
10317
- if (id !== vid && ctx.$_veeObserver.refs[id] === ctx) {
10318
- ctx.$_veeObserver.unsubscribe(ctx);
10319
- }
10320
-
10321
- ctx.$_veeObserver.subscribe(ctx);
10322
- ctx.id = vid;
10323
- }
10324
-
10325
- function createObserver () {
10326
- return {
10327
- refs: {},
10328
- subscribe: function subscribe (ctx) {
10329
- this.refs[ctx.vid] = ctx;
10330
- },
10331
- unsubscribe: function unsubscribe (ctx) {
10332
- delete this.refs[ctx.vid];
10333
- }
10334
- };
10335
- }
10336
-
10337
10147
  var ValidationProvider = {
10338
10148
  $__veeInject: false,
10339
10149
  inject: {
@@ -10438,19 +10248,10 @@
10438
10248
  var this$1 = this;
10439
10249
 
10440
10250
  var rules = normalizeRules(this.rules);
10441
- var providers = this.$_veeObserver.refs;
10442
10251
 
10443
10252
  return Object.keys(rules).filter(RuleContainer.isTargetRule).map(function (rule) {
10444
10253
  var depName = rules[rule][0];
10445
- var watcherName = "$__" + depName;
10446
- if (!isCallable(this$1[watcherName]) && providers[depName]) {
10447
- this$1[watcherName] = providers[depName].$watch('value', function () {
10448
- if (this$1.flags.validated) {
10449
- this$1._needsValidation = true;
10450
- this$1.validate();
10451
- }
10452
- });
10453
- }
10254
+ watchCrossFieldDep(this$1, depName);
10454
10255
 
10455
10256
  return depName;
10456
10257
  });
@@ -10609,6 +10410,228 @@
10609
10410
  }
10610
10411
  };
10611
10412
 
10413
+ function createValidationCtx (ctx) {
10414
+ return {
10415
+ errors: ctx.messages,
10416
+ flags: ctx.flags,
10417
+ classes: ctx.classes,
10418
+ valid: ctx.isValid,
10419
+ failedRules: ctx.failedRules,
10420
+ reset: function () { return ctx.reset(); },
10421
+ validate: function () {
10422
+ var args = [], len = arguments.length;
10423
+ while ( len-- ) args[ len ] = arguments[ len ];
10424
+
10425
+ return ctx.validate.apply(ctx, args);
10426
+ },
10427
+ aria: {
10428
+ 'aria-invalid': ctx.flags.invalid ? 'true' : 'false',
10429
+ 'aria-required': ctx.isRequired ? 'true' : 'false'
10430
+ }
10431
+ };
10432
+ }
10433
+
10434
+ function normalizeValue$1 (value) {
10435
+ if (isEvent(value)) {
10436
+ return value.target.type === 'file' ? toArray(value.target.files) : value.target.value;
10437
+ }
10438
+
10439
+ return value;
10440
+ }
10441
+
10442
+ /**
10443
+ * Determines if a provider needs to run validation.
10444
+ */
10445
+ function shouldValidate (ctx, model) {
10446
+ // when an immediate/initial validation is needed and wasn't done before.
10447
+ if (!ctx._ignoreImmediate && ctx.immediate) {
10448
+ return true;
10449
+ }
10450
+
10451
+ // when the value changes for whatever reason.
10452
+ if (ctx.value !== model.value) {
10453
+ return true;
10454
+ }
10455
+
10456
+ // when it needs validation due to props/cross-fields changes.
10457
+ if (ctx._needsValidation) {
10458
+ return true;
10459
+ }
10460
+
10461
+ // when the initial value is undefined and the field wasn't rendered yet.
10462
+ if (!ctx.initialized && model.value === undefined) {
10463
+ return true;
10464
+ }
10465
+
10466
+ return false;
10467
+ }
10468
+
10469
+ function computeModeSetting (ctx) {
10470
+ var compute = isCallable(ctx.mode) ? ctx.mode : modes[ctx.mode];
10471
+
10472
+ return compute({
10473
+ errors: ctx.messages,
10474
+ value: ctx.value,
10475
+ flags: ctx.flags
10476
+ });
10477
+ }
10478
+
10479
+ function onRenderUpdate (model) {
10480
+ if (!this.initialized) {
10481
+ this.initialValue = model.value;
10482
+ }
10483
+
10484
+ var validateNow = shouldValidate(this, model);
10485
+ this._needsValidation = false;
10486
+ this.value = model.value;
10487
+ this._ignoreImmediate = true;
10488
+
10489
+ if (!validateNow) {
10490
+ return;
10491
+ }
10492
+
10493
+ this.validateSilent().then(this.immediate || this.flags.validated ? this.applyResult : function (x) { return x; });
10494
+ }
10495
+
10496
+ // Creates the common handlers for a validatable context.
10497
+ function createCommonHandlers (ctx) {
10498
+ var onInput = function (e) {
10499
+ ctx.syncValue(e); // track and keep the value updated.
10500
+ ctx.setFlags({ dirty: true, pristine: false });
10501
+ };
10502
+
10503
+ // Blur event listener.
10504
+ var onBlur = function () {
10505
+ ctx.setFlags({ touched: true, untouched: false });
10506
+ };
10507
+
10508
+ var onValidate = ctx.$veeHandler;
10509
+ var mode = computeModeSetting(ctx);
10510
+
10511
+ // Handle debounce changes.
10512
+ if (!onValidate || ctx.$veeDebounce !== ctx.debounce) {
10513
+ onValidate = debounce(
10514
+ function () {
10515
+ ctx.$nextTick(function () {
10516
+ var pendingPromise = ctx.validateSilent();
10517
+ // avoids race conditions between successive validations.
10518
+ ctx._pendingValidation = pendingPromise;
10519
+ pendingPromise.then(function (result) {
10520
+ if (pendingPromise === ctx._pendingValidation) {
10521
+ ctx.applyResult(result);
10522
+ ctx._pendingValidation = null;
10523
+ }
10524
+ });
10525
+ });
10526
+ },
10527
+ mode.debounce || ctx.debounce
10528
+ );
10529
+
10530
+ // Cache the handler so we don't create it each time.
10531
+ ctx.$veeHandler = onValidate;
10532
+ // cache the debounce value so we detect if it was changed.
10533
+ ctx.$veeDebounce = ctx.debounce;
10534
+ }
10535
+
10536
+ return { onInput: onInput, onBlur: onBlur, onValidate: onValidate };
10537
+ }
10538
+
10539
+ // Adds all plugin listeners to the vnode.
10540
+ function addListeners (node) {
10541
+ var model = findModel(node);
10542
+ // cache the input eventName.
10543
+ this._inputEventName = this._inputEventName || getInputEventName(node, model);
10544
+
10545
+ onRenderUpdate.call(this, model);
10546
+
10547
+ var ref = createCommonHandlers(this);
10548
+ var onInput = ref.onInput;
10549
+ var onBlur = ref.onBlur;
10550
+ var onValidate = ref.onValidate;
10551
+ addVNodeListener(node, this._inputEventName, onInput);
10552
+ addVNodeListener(node, 'blur', onBlur);
10553
+
10554
+ // add the validation listeners.
10555
+ this.normalizedEvents.forEach(function (evt) {
10556
+ addVNodeListener(node, evt, onValidate);
10557
+ });
10558
+
10559
+ this.initialized = true;
10560
+ }
10561
+
10562
+ function createValuesLookup (ctx) {
10563
+ var providers = ctx.$_veeObserver.refs;
10564
+
10565
+ return ctx.fieldDeps.reduce(function (acc, depName) {
10566
+ if (!providers[depName]) {
10567
+ return acc;
10568
+ }
10569
+
10570
+ acc[depName] = providers[depName].value;
10571
+
10572
+ return acc;
10573
+ }, {});
10574
+ }
10575
+
10576
+ function updateRenderingContextRefs (ctx) {
10577
+ // IDs should not be nullable.
10578
+ if (isNullOrUndefined(ctx.id) && ctx.id === ctx.vid) {
10579
+ ctx.id = PROVIDER_COUNTER;
10580
+ PROVIDER_COUNTER++;
10581
+ }
10582
+
10583
+ var id = ctx.id;
10584
+ var vid = ctx.vid;
10585
+ // Nothing has changed.
10586
+ if (ctx.isDeactivated || (id === vid && ctx.$_veeObserver.refs[id])) {
10587
+ return;
10588
+ }
10589
+
10590
+ // vid was changed.
10591
+ if (id !== vid && ctx.$_veeObserver.refs[id] === ctx) {
10592
+ ctx.$_veeObserver.unsubscribe(ctx);
10593
+ }
10594
+
10595
+ ctx.$_veeObserver.subscribe(ctx);
10596
+ ctx.id = vid;
10597
+ }
10598
+
10599
+ function createObserver () {
10600
+ return {
10601
+ refs: {},
10602
+ subscribe: function subscribe (ctx) {
10603
+ this.refs[ctx.vid] = ctx;
10604
+ },
10605
+ unsubscribe: function unsubscribe (ctx) {
10606
+ delete this.refs[ctx.vid];
10607
+ }
10608
+ };
10609
+ }
10610
+
10611
+ function watchCrossFieldDep (ctx, depName, withHooks) {
10612
+ if ( withHooks === void 0 ) withHooks = true;
10613
+
10614
+ var providers = ctx.$_veeObserver.refs;
10615
+ if (!ctx._veeWatchers) {
10616
+ ctx._veeWatchers = {};
10617
+ }
10618
+
10619
+ if (!providers[depName] && withHooks) {
10620
+ return ctx.$once('hook:mounted', function () {
10621
+ watchCrossFieldDep(ctx, depName, false);
10622
+ });
10623
+ }
10624
+
10625
+ if (!isCallable(ctx._veeWatchers[depName]) && providers[depName]) {
10626
+ ctx._veeWatchers[depName] = providers[depName].$watch('value', function () {
10627
+ if (ctx.flags.validated) {
10628
+ ctx._needsValidation = true;
10629
+ ctx.validate();
10630
+ }
10631
+ });
10632
+ }
10633
+ }
10634
+
10612
10635
  var flagMergingStrategy = {
10613
10636
  pristine: 'every',
10614
10637
  dirty: 'some',
@@ -10929,7 +10952,7 @@
10929
10952
  digits: function (field, ref) {
10930
10953
  var length = ref[0];
10931
10954
 
10932
- return ("The " + field + " field must be numeric and exactly contain " + length + " digits.");
10955
+ return ("The " + field + " field must be numeric and contains exactly " + length + " digits.");
10933
10956
  },
10934
10957
  dimensions: function (field, ref) {
10935
10958
  var width = ref[0];
@@ -11014,7 +11037,7 @@
11014
11037
  en: locale$1
11015
11038
  });
11016
11039
 
11017
- VeeValidate$1.version = '2.2.5';
11040
+ VeeValidate$1.version = '2.2.9';
11018
11041
  VeeValidate$1.Rules = Rules;
11019
11042
  VeeValidate$1.mapFields = mapFields;
11020
11043
  VeeValidate$1.ValidationProvider = ValidationProvider;