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
  */
@@ -1839,7 +1839,7 @@
1839
1839
  };
1840
1840
 
1841
1841
  prototypeAccessors$1.isDisabled.get = function () {
1842
- return !!(this.componentInstance && this.componentInstance.disabled) || !!(this.el && this.el.disabled);
1842
+ return !!(this.el && this.el.disabled);
1843
1843
  };
1844
1844
 
1845
1845
  /**
@@ -2339,14 +2339,16 @@
2339
2339
  var inputEvent = this._determineInputEvent();
2340
2340
  var events = this._determineEventList(inputEvent);
2341
2341
 
2342
- // if there is a model and an on input validation is requested.
2343
- if (this.model && includes(events, inputEvent)) {
2342
+ // if on input validation is requested.
2343
+ if (includes(events, inputEvent)) {
2344
2344
  var ctx = null;
2345
- var expression = this.model.expression;
2345
+ var expression = null;
2346
+ var watchCtxVm = false;
2346
2347
  // if its watchable from the context vm.
2347
- if (this.model.expression) {
2348
+ if (this.model && this.model.expression) {
2348
2349
  ctx = this.vm;
2349
2350
  expression = this.model.expression;
2351
+ watchCtxVm = true;
2350
2352
  }
2351
2353
 
2352
2354
  // watch it from the custom component vm instead.
@@ -2367,8 +2369,10 @@
2367
2369
  }
2368
2370
  });
2369
2371
 
2370
- // filter out input event as it is already handled by the watcher API.
2371
- events = events.filter(function (e) { return e !== inputEvent; });
2372
+ // filter out input event when we are watching from the context vm.
2373
+ if (watchCtxVm) {
2374
+ events = events.filter(function (e) { return e !== inputEvent; });
2375
+ }
2372
2376
  }
2373
2377
  }
2374
2378
 
@@ -3658,8 +3662,8 @@
3658
3662
  return false;
3659
3663
  }
3660
3664
 
3661
- // disabled fields are skipped
3662
- if (field.isDisabled) {
3665
+ // disabled fields are skipped if useConstraintAttrs is enabled in config
3666
+ if (field.isDisabled && getConfig().useConstraintAttrs) {
3663
3667
  return true;
3664
3668
  }
3665
3669
 
@@ -4047,6 +4051,10 @@
4047
4051
  var i18nRootKey = config.i18nRootKey;
4048
4052
  var locale = config.locale;
4049
4053
  var onLocaleChanged = function () {
4054
+ if (dictionary) {
4055
+ this$1.i18nDriver.merge(dictionary);
4056
+ }
4057
+
4050
4058
  this$1._validator.errors.regenerate();
4051
4059
  };
4052
4060
 
@@ -4198,204 +4206,6 @@
4198
4206
 
4199
4207
  var PROVIDER_COUNTER = 0;
4200
4208
 
4201
- function createValidationCtx (ctx) {
4202
- return {
4203
- errors: ctx.messages,
4204
- flags: ctx.flags,
4205
- classes: ctx.classes,
4206
- valid: ctx.isValid,
4207
- failedRules: ctx.failedRules,
4208
- reset: function () { return ctx.reset(); },
4209
- validate: function () {
4210
- var args = [], len = arguments.length;
4211
- while ( len-- ) args[ len ] = arguments[ len ];
4212
-
4213
- return ctx.validate.apply(ctx, args);
4214
- },
4215
- aria: {
4216
- 'aria-invalid': ctx.flags.invalid ? 'true' : 'false',
4217
- 'aria-required': ctx.isRequired ? 'true' : 'false'
4218
- }
4219
- };
4220
- }
4221
-
4222
- function normalizeValue$1 (value) {
4223
- if (isEvent(value)) {
4224
- return value.target.type === 'file' ? toArray(value.target.files) : value.target.value;
4225
- }
4226
-
4227
- return value;
4228
- }
4229
-
4230
- /**
4231
- * Determines if a provider needs to run validation.
4232
- */
4233
- function shouldValidate (ctx, model) {
4234
- // when an immediate/initial validation is needed and wasn't done before.
4235
- if (!ctx._ignoreImmediate && ctx.immediate) {
4236
- return true;
4237
- }
4238
-
4239
- // when the value changes for whatever reason.
4240
- if (ctx.value !== model.value) {
4241
- return true;
4242
- }
4243
-
4244
- // when it needs validation due to props/cross-fields changes.
4245
- if (ctx._needsValidation) {
4246
- return true;
4247
- }
4248
-
4249
- // when the initial value is undefined and the field wasn't rendered yet.
4250
- if (!ctx.initialized && model.value === undefined) {
4251
- return true;
4252
- }
4253
-
4254
- return false;
4255
- }
4256
-
4257
- function computeModeSetting (ctx) {
4258
- var compute = isCallable(ctx.mode) ? ctx.mode : modes[ctx.mode];
4259
-
4260
- return compute({
4261
- errors: ctx.messages,
4262
- value: ctx.value,
4263
- flags: ctx.flags
4264
- });
4265
- }
4266
-
4267
- function onRenderUpdate (model) {
4268
- if (!this.initialized) {
4269
- this.initialValue = model.value;
4270
- }
4271
-
4272
- var validateNow = shouldValidate(this, model);
4273
- this._needsValidation = false;
4274
- this.value = model.value;
4275
- this._ignoreImmediate = true;
4276
-
4277
- if (!validateNow) {
4278
- return;
4279
- }
4280
-
4281
- this.validateSilent().then(this.immediate || this.flags.validated ? this.applyResult : function (x) { return x; });
4282
- }
4283
-
4284
- // Creates the common handlers for a validatable context.
4285
- function createCommonHandlers (ctx) {
4286
- var onInput = function (e) {
4287
- ctx.syncValue(e); // track and keep the value updated.
4288
- ctx.setFlags({ dirty: true, pristine: false });
4289
- };
4290
-
4291
- // Blur event listener.
4292
- var onBlur = function () {
4293
- ctx.setFlags({ touched: true, untouched: false });
4294
- };
4295
-
4296
- var onValidate = ctx.$veeHandler;
4297
- var mode = computeModeSetting(ctx);
4298
-
4299
- // Handle debounce changes.
4300
- if (!onValidate || ctx.$veeDebounce !== ctx.debounce) {
4301
- onValidate = debounce(
4302
- function () {
4303
- ctx.$nextTick(function () {
4304
- var pendingPromise = ctx.validateSilent();
4305
- // avoids race conditions between successive validations.
4306
- ctx._pendingValidation = pendingPromise;
4307
- pendingPromise.then(function (result) {
4308
- if (pendingPromise === ctx._pendingValidation) {
4309
- ctx.applyResult(result);
4310
- ctx._pendingValidation = null;
4311
- }
4312
- });
4313
- });
4314
- },
4315
- mode.debounce || ctx.debounce
4316
- );
4317
-
4318
- // Cache the handler so we don't create it each time.
4319
- ctx.$veeHandler = onValidate;
4320
- // cache the debounce value so we detect if it was changed.
4321
- ctx.$veeDebounce = ctx.debounce;
4322
- }
4323
-
4324
- return { onInput: onInput, onBlur: onBlur, onValidate: onValidate };
4325
- }
4326
-
4327
- // Adds all plugin listeners to the vnode.
4328
- function addListeners (node) {
4329
- var model = findModel(node);
4330
- // cache the input eventName.
4331
- this._inputEventName = this._inputEventName || getInputEventName(node, model);
4332
-
4333
- onRenderUpdate.call(this, model);
4334
-
4335
- var ref = createCommonHandlers(this);
4336
- var onInput = ref.onInput;
4337
- var onBlur = ref.onBlur;
4338
- var onValidate = ref.onValidate;
4339
- addVNodeListener(node, this._inputEventName, onInput);
4340
- addVNodeListener(node, 'blur', onBlur);
4341
-
4342
- // add the validation listeners.
4343
- this.normalizedEvents.forEach(function (evt) {
4344
- addVNodeListener(node, evt, onValidate);
4345
- });
4346
-
4347
- this.initialized = true;
4348
- }
4349
-
4350
- function createValuesLookup (ctx) {
4351
- var providers = ctx.$_veeObserver.refs;
4352
-
4353
- return ctx.fieldDeps.reduce(function (acc, depName) {
4354
- if (!providers[depName]) {
4355
- return acc;
4356
- }
4357
-
4358
- acc[depName] = providers[depName].value;
4359
-
4360
- return acc;
4361
- }, {});
4362
- }
4363
-
4364
- function updateRenderingContextRefs (ctx) {
4365
- // IDs should not be nullable.
4366
- if (isNullOrUndefined(ctx.id) && ctx.id === ctx.vid) {
4367
- ctx.id = PROVIDER_COUNTER;
4368
- PROVIDER_COUNTER++;
4369
- }
4370
-
4371
- var id = ctx.id;
4372
- var vid = ctx.vid;
4373
- // Nothing has changed.
4374
- if (ctx.isDeactivated || (id === vid && ctx.$_veeObserver.refs[id])) {
4375
- return;
4376
- }
4377
-
4378
- // vid was changed.
4379
- if (id !== vid && ctx.$_veeObserver.refs[id] === ctx) {
4380
- ctx.$_veeObserver.unsubscribe(ctx);
4381
- }
4382
-
4383
- ctx.$_veeObserver.subscribe(ctx);
4384
- ctx.id = vid;
4385
- }
4386
-
4387
- function createObserver () {
4388
- return {
4389
- refs: {},
4390
- subscribe: function subscribe (ctx) {
4391
- this.refs[ctx.vid] = ctx;
4392
- },
4393
- unsubscribe: function unsubscribe (ctx) {
4394
- delete this.refs[ctx.vid];
4395
- }
4396
- };
4397
- }
4398
-
4399
4209
  var ValidationProvider = {
4400
4210
  $__veeInject: false,
4401
4211
  inject: {
@@ -4496,19 +4306,10 @@
4496
4306
  var this$1 = this;
4497
4307
 
4498
4308
  var rules = normalizeRules(this.rules);
4499
- var providers = this.$_veeObserver.refs;
4500
4309
 
4501
4310
  return Object.keys(rules).filter(RuleContainer.isTargetRule).map(function (rule) {
4502
4311
  var depName = rules[rule][0];
4503
- var watcherName = "$__" + depName;
4504
- if (!isCallable(this$1[watcherName]) && providers[depName]) {
4505
- this$1[watcherName] = providers[depName].$watch('value', function () {
4506
- if (this$1.flags.validated) {
4507
- this$1._needsValidation = true;
4508
- this$1.validate();
4509
- }
4510
- });
4511
- }
4312
+ watchCrossFieldDep(this$1, depName);
4512
4313
 
4513
4314
  return depName;
4514
4315
  });
@@ -4664,6 +4465,228 @@
4664
4465
  }
4665
4466
  };
4666
4467
 
4468
+ function createValidationCtx (ctx) {
4469
+ return {
4470
+ errors: ctx.messages,
4471
+ flags: ctx.flags,
4472
+ classes: ctx.classes,
4473
+ valid: ctx.isValid,
4474
+ failedRules: ctx.failedRules,
4475
+ reset: function () { return ctx.reset(); },
4476
+ validate: function () {
4477
+ var args = [], len = arguments.length;
4478
+ while ( len-- ) args[ len ] = arguments[ len ];
4479
+
4480
+ return ctx.validate.apply(ctx, args);
4481
+ },
4482
+ aria: {
4483
+ 'aria-invalid': ctx.flags.invalid ? 'true' : 'false',
4484
+ 'aria-required': ctx.isRequired ? 'true' : 'false'
4485
+ }
4486
+ };
4487
+ }
4488
+
4489
+ function normalizeValue$1 (value) {
4490
+ if (isEvent(value)) {
4491
+ return value.target.type === 'file' ? toArray(value.target.files) : value.target.value;
4492
+ }
4493
+
4494
+ return value;
4495
+ }
4496
+
4497
+ /**
4498
+ * Determines if a provider needs to run validation.
4499
+ */
4500
+ function shouldValidate (ctx, model) {
4501
+ // when an immediate/initial validation is needed and wasn't done before.
4502
+ if (!ctx._ignoreImmediate && ctx.immediate) {
4503
+ return true;
4504
+ }
4505
+
4506
+ // when the value changes for whatever reason.
4507
+ if (ctx.value !== model.value) {
4508
+ return true;
4509
+ }
4510
+
4511
+ // when it needs validation due to props/cross-fields changes.
4512
+ if (ctx._needsValidation) {
4513
+ return true;
4514
+ }
4515
+
4516
+ // when the initial value is undefined and the field wasn't rendered yet.
4517
+ if (!ctx.initialized && model.value === undefined) {
4518
+ return true;
4519
+ }
4520
+
4521
+ return false;
4522
+ }
4523
+
4524
+ function computeModeSetting (ctx) {
4525
+ var compute = isCallable(ctx.mode) ? ctx.mode : modes[ctx.mode];
4526
+
4527
+ return compute({
4528
+ errors: ctx.messages,
4529
+ value: ctx.value,
4530
+ flags: ctx.flags
4531
+ });
4532
+ }
4533
+
4534
+ function onRenderUpdate (model) {
4535
+ if (!this.initialized) {
4536
+ this.initialValue = model.value;
4537
+ }
4538
+
4539
+ var validateNow = shouldValidate(this, model);
4540
+ this._needsValidation = false;
4541
+ this.value = model.value;
4542
+ this._ignoreImmediate = true;
4543
+
4544
+ if (!validateNow) {
4545
+ return;
4546
+ }
4547
+
4548
+ this.validateSilent().then(this.immediate || this.flags.validated ? this.applyResult : function (x) { return x; });
4549
+ }
4550
+
4551
+ // Creates the common handlers for a validatable context.
4552
+ function createCommonHandlers (ctx) {
4553
+ var onInput = function (e) {
4554
+ ctx.syncValue(e); // track and keep the value updated.
4555
+ ctx.setFlags({ dirty: true, pristine: false });
4556
+ };
4557
+
4558
+ // Blur event listener.
4559
+ var onBlur = function () {
4560
+ ctx.setFlags({ touched: true, untouched: false });
4561
+ };
4562
+
4563
+ var onValidate = ctx.$veeHandler;
4564
+ var mode = computeModeSetting(ctx);
4565
+
4566
+ // Handle debounce changes.
4567
+ if (!onValidate || ctx.$veeDebounce !== ctx.debounce) {
4568
+ onValidate = debounce(
4569
+ function () {
4570
+ ctx.$nextTick(function () {
4571
+ var pendingPromise = ctx.validateSilent();
4572
+ // avoids race conditions between successive validations.
4573
+ ctx._pendingValidation = pendingPromise;
4574
+ pendingPromise.then(function (result) {
4575
+ if (pendingPromise === ctx._pendingValidation) {
4576
+ ctx.applyResult(result);
4577
+ ctx._pendingValidation = null;
4578
+ }
4579
+ });
4580
+ });
4581
+ },
4582
+ mode.debounce || ctx.debounce
4583
+ );
4584
+
4585
+ // Cache the handler so we don't create it each time.
4586
+ ctx.$veeHandler = onValidate;
4587
+ // cache the debounce value so we detect if it was changed.
4588
+ ctx.$veeDebounce = ctx.debounce;
4589
+ }
4590
+
4591
+ return { onInput: onInput, onBlur: onBlur, onValidate: onValidate };
4592
+ }
4593
+
4594
+ // Adds all plugin listeners to the vnode.
4595
+ function addListeners (node) {
4596
+ var model = findModel(node);
4597
+ // cache the input eventName.
4598
+ this._inputEventName = this._inputEventName || getInputEventName(node, model);
4599
+
4600
+ onRenderUpdate.call(this, model);
4601
+
4602
+ var ref = createCommonHandlers(this);
4603
+ var onInput = ref.onInput;
4604
+ var onBlur = ref.onBlur;
4605
+ var onValidate = ref.onValidate;
4606
+ addVNodeListener(node, this._inputEventName, onInput);
4607
+ addVNodeListener(node, 'blur', onBlur);
4608
+
4609
+ // add the validation listeners.
4610
+ this.normalizedEvents.forEach(function (evt) {
4611
+ addVNodeListener(node, evt, onValidate);
4612
+ });
4613
+
4614
+ this.initialized = true;
4615
+ }
4616
+
4617
+ function createValuesLookup (ctx) {
4618
+ var providers = ctx.$_veeObserver.refs;
4619
+
4620
+ return ctx.fieldDeps.reduce(function (acc, depName) {
4621
+ if (!providers[depName]) {
4622
+ return acc;
4623
+ }
4624
+
4625
+ acc[depName] = providers[depName].value;
4626
+
4627
+ return acc;
4628
+ }, {});
4629
+ }
4630
+
4631
+ function updateRenderingContextRefs (ctx) {
4632
+ // IDs should not be nullable.
4633
+ if (isNullOrUndefined(ctx.id) && ctx.id === ctx.vid) {
4634
+ ctx.id = PROVIDER_COUNTER;
4635
+ PROVIDER_COUNTER++;
4636
+ }
4637
+
4638
+ var id = ctx.id;
4639
+ var vid = ctx.vid;
4640
+ // Nothing has changed.
4641
+ if (ctx.isDeactivated || (id === vid && ctx.$_veeObserver.refs[id])) {
4642
+ return;
4643
+ }
4644
+
4645
+ // vid was changed.
4646
+ if (id !== vid && ctx.$_veeObserver.refs[id] === ctx) {
4647
+ ctx.$_veeObserver.unsubscribe(ctx);
4648
+ }
4649
+
4650
+ ctx.$_veeObserver.subscribe(ctx);
4651
+ ctx.id = vid;
4652
+ }
4653
+
4654
+ function createObserver () {
4655
+ return {
4656
+ refs: {},
4657
+ subscribe: function subscribe (ctx) {
4658
+ this.refs[ctx.vid] = ctx;
4659
+ },
4660
+ unsubscribe: function unsubscribe (ctx) {
4661
+ delete this.refs[ctx.vid];
4662
+ }
4663
+ };
4664
+ }
4665
+
4666
+ function watchCrossFieldDep (ctx, depName, withHooks) {
4667
+ if ( withHooks === void 0 ) withHooks = true;
4668
+
4669
+ var providers = ctx.$_veeObserver.refs;
4670
+ if (!ctx._veeWatchers) {
4671
+ ctx._veeWatchers = {};
4672
+ }
4673
+
4674
+ if (!providers[depName] && withHooks) {
4675
+ return ctx.$once('hook:mounted', function () {
4676
+ watchCrossFieldDep(ctx, depName, false);
4677
+ });
4678
+ }
4679
+
4680
+ if (!isCallable(ctx._veeWatchers[depName]) && providers[depName]) {
4681
+ ctx._veeWatchers[depName] = providers[depName].$watch('value', function () {
4682
+ if (ctx.flags.validated) {
4683
+ ctx._needsValidation = true;
4684
+ ctx.validate();
4685
+ }
4686
+ });
4687
+ }
4688
+ }
4689
+
4667
4690
  var flagMergingStrategy = {
4668
4691
  pristine: 'every',
4669
4692
  dirty: 'some',
@@ -4910,7 +4933,7 @@
4910
4933
  return hoc;
4911
4934
  }
4912
4935
 
4913
- VeeValidate.version = '2.2.5';
4936
+ VeeValidate.version = '2.2.9';
4914
4937
  VeeValidate.mapFields = mapFields;
4915
4938
  VeeValidate.ValidationProvider = ValidationProvider;
4916
4939
  VeeValidate.ValidationObserver = ValidationObserver;