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.
- package/dist/locale/ar.js +1 -1
- package/dist/locale/az.js +1 -1
- package/dist/locale/bg.js +1 -1
- package/dist/locale/ca.js +1 -1
- package/dist/locale/cs.js +1 -1
- package/dist/locale/da.js +1 -1
- package/dist/locale/de.js +1 -1
- package/dist/locale/el.js +1 -1
- package/dist/locale/en.js +1 -1
- package/dist/locale/es.js +1 -1
- package/dist/locale/et.js +1 -1
- package/dist/locale/eu.js +1 -1
- package/dist/locale/fa.js +1 -1
- package/dist/locale/fi.js +1 -1
- package/dist/locale/fr.js +1 -1
- package/dist/locale/he.js +1 -1
- package/dist/locale/hi.js +1 -1
- package/dist/locale/hr.js +1 -1
- package/dist/locale/id.js +1 -1
- package/dist/locale/it.js +1 -1
- package/dist/locale/ja.js +1 -1
- package/dist/locale/ka.js +1 -1
- package/dist/locale/ko.js +1 -1
- package/dist/locale/lt.js +1 -1
- package/dist/locale/lv.js +1 -1
- package/dist/locale/mn.js +1 -1
- package/dist/locale/ms_MY.js +1 -1
- package/dist/locale/nb_NO.js +1 -1
- package/dist/locale/ne.js +1 -1
- package/dist/locale/nl.js +1 -1
- package/dist/locale/nn_NO.js +1 -1
- package/dist/locale/pl.js +1 -1
- package/dist/locale/pt_BR.js +1 -1
- package/dist/locale/pt_PT.js +1 -1
- package/dist/locale/ro.js +1 -1
- package/dist/locale/ru.js +1 -1
- package/dist/locale/sk.js +1 -1
- package/dist/locale/sl.js +1 -1
- package/dist/locale/sq.js +1 -1
- package/dist/locale/sr.js +1 -1
- package/dist/locale/sr_Latin.js +1 -1
- package/dist/locale/sv.js +1 -1
- package/dist/locale/th.js +1 -1
- package/dist/locale/tr.js +1 -1
- package/dist/locale/uk.js +1 -1
- package/dist/locale/vi.js +1 -1
- package/dist/locale/zh_CN.js +1 -1
- package/dist/locale/zh_TW.js +1 -1
- package/dist/rules.esm.js +4 -4
- package/dist/vee-validate.esm.js +246 -223
- package/dist/vee-validate.js +245 -222
- package/dist/vee-validate.min.js +1 -1
- package/dist/vee-validate.minimal.esm.js +243 -220
- package/dist/vee-validate.minimal.js +242 -219
- package/dist/vee-validate.minimal.min.js +1 -1
- package/package.json +27 -27
- package/types/vee-validate.d.ts +14 -3
- package/types/vue.d.ts +0 -12
package/dist/rules.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v2.2.
|
|
2
|
+
* vee-validate v2.2.9
|
|
3
3
|
* (c) 2019 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -4721,7 +4721,7 @@ var confirmed = {
|
|
|
4721
4721
|
};
|
|
4722
4722
|
|
|
4723
4723
|
function unwrapExports (x) {
|
|
4724
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x
|
|
4724
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
4725
4725
|
}
|
|
4726
4726
|
|
|
4727
4727
|
function createCommonjsModule(fn, module) {
|
|
@@ -4985,7 +4985,7 @@ var validate$a = function (value, ref) {
|
|
|
4985
4985
|
}
|
|
4986
4986
|
|
|
4987
4987
|
var regexPart = decimals === '*' ? '+' : ("{1," + decimals + "}");
|
|
4988
|
-
var regex = new RegExp(("^[-+]?\\d*(\\" + separator + "\\d" + regexPart + ")?$"));
|
|
4988
|
+
var regex = new RegExp(("^[-+]?\\d*(\\" + separator + "\\d" + regexPart + ")?([eE]{1}[-]?\\d+)?$"));
|
|
4989
4989
|
|
|
4990
4990
|
if (! regex.test(value)) {
|
|
4991
4991
|
return false;
|
|
@@ -5944,4 +5944,4 @@ var url = {
|
|
|
5944
5944
|
|
|
5945
5945
|
/* eslint-disable camelcase */
|
|
5946
5946
|
|
|
5947
|
-
export { after, alpha_dash, alpha_num, alpha_spaces,
|
|
5947
|
+
export { after, alpha$1 as alpha, alpha_dash, alpha_num, alpha_spaces, before, between, confirmed, credit_card, date_between, date_format, decimal, digits, dimensions, email, excluded, ext, image, included, integer, ip, ip_or_fqdn, is, is_not, length, max, max_value, mimes, min, min_value, numeric, regex, required, required_if, size, url };
|
package/dist/vee-validate.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v2.2.
|
|
2
|
+
* vee-validate v2.2.9
|
|
3
3
|
* (c) 2019 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -1854,7 +1854,7 @@ prototypeAccessors$1.isRequired.get = function () {
|
|
|
1854
1854
|
};
|
|
1855
1855
|
|
|
1856
1856
|
prototypeAccessors$1.isDisabled.get = function () {
|
|
1857
|
-
return !!(this.
|
|
1857
|
+
return !!(this.el && this.el.disabled);
|
|
1858
1858
|
};
|
|
1859
1859
|
|
|
1860
1860
|
/**
|
|
@@ -2358,14 +2358,16 @@ Field.prototype.addValueListeners = function addValueListeners () {
|
|
|
2358
2358
|
var inputEvent = this._determineInputEvent();
|
|
2359
2359
|
var events = this._determineEventList(inputEvent);
|
|
2360
2360
|
|
|
2361
|
-
// if
|
|
2362
|
-
if (
|
|
2361
|
+
// if on input validation is requested.
|
|
2362
|
+
if (includes(events, inputEvent)) {
|
|
2363
2363
|
var ctx = null;
|
|
2364
|
-
var expression =
|
|
2364
|
+
var expression = null;
|
|
2365
|
+
var watchCtxVm = false;
|
|
2365
2366
|
// if its watchable from the context vm.
|
|
2366
|
-
if (this.model.expression) {
|
|
2367
|
+
if (this.model && this.model.expression) {
|
|
2367
2368
|
ctx = this.vm;
|
|
2368
2369
|
expression = this.model.expression;
|
|
2370
|
+
watchCtxVm = true;
|
|
2369
2371
|
}
|
|
2370
2372
|
|
|
2371
2373
|
// watch it from the custom component vm instead.
|
|
@@ -2386,8 +2388,10 @@ Field.prototype.addValueListeners = function addValueListeners () {
|
|
|
2386
2388
|
}
|
|
2387
2389
|
});
|
|
2388
2390
|
|
|
2389
|
-
// filter out input event
|
|
2390
|
-
|
|
2391
|
+
// filter out input event when we are watching from the context vm.
|
|
2392
|
+
if (watchCtxVm) {
|
|
2393
|
+
events = events.filter(function (e) { return e !== inputEvent; });
|
|
2394
|
+
}
|
|
2391
2395
|
}
|
|
2392
2396
|
}
|
|
2393
2397
|
|
|
@@ -3692,8 +3696,8 @@ Validator.prototype._shouldSkip = function _shouldSkip (field, value) {
|
|
|
3692
3696
|
return false;
|
|
3693
3697
|
}
|
|
3694
3698
|
|
|
3695
|
-
// disabled fields are skipped
|
|
3696
|
-
if (field.isDisabled) {
|
|
3699
|
+
// disabled fields are skipped if useConstraintAttrs is enabled in config
|
|
3700
|
+
if (field.isDisabled && getConfig().useConstraintAttrs) {
|
|
3697
3701
|
return true;
|
|
3698
3702
|
}
|
|
3699
3703
|
|
|
@@ -4084,6 +4088,10 @@ VeeValidate$1.prototype._initI18n = function _initI18n (config) {
|
|
|
4084
4088
|
var i18nRootKey = config.i18nRootKey;
|
|
4085
4089
|
var locale = config.locale;
|
|
4086
4090
|
var onLocaleChanged = function () {
|
|
4091
|
+
if (dictionary) {
|
|
4092
|
+
this$1.i18nDriver.merge(dictionary);
|
|
4093
|
+
}
|
|
4094
|
+
|
|
4087
4095
|
this$1._validator.errors.regenerate();
|
|
4088
4096
|
};
|
|
4089
4097
|
|
|
@@ -4184,7 +4192,7 @@ var messages = {
|
|
|
4184
4192
|
digits: function (field, ref) {
|
|
4185
4193
|
var length = ref[0];
|
|
4186
4194
|
|
|
4187
|
-
return ("The " + field + " field must be numeric and exactly
|
|
4195
|
+
return ("The " + field + " field must be numeric and contains exactly " + length + " digits.");
|
|
4188
4196
|
},
|
|
4189
4197
|
dimensions: function (field, ref) {
|
|
4190
4198
|
var width = ref[0];
|
|
@@ -8976,7 +8984,7 @@ var confirmed = {
|
|
|
8976
8984
|
};
|
|
8977
8985
|
|
|
8978
8986
|
function unwrapExports (x) {
|
|
8979
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x
|
|
8987
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
8980
8988
|
}
|
|
8981
8989
|
|
|
8982
8990
|
function createCommonjsModule(fn, module) {
|
|
@@ -9155,7 +9163,7 @@ var validate$a = function (value, ref) {
|
|
|
9155
9163
|
}
|
|
9156
9164
|
|
|
9157
9165
|
var regexPart = decimals === '*' ? '+' : ("{1," + decimals + "}");
|
|
9158
|
-
var regex = new RegExp(("^[-+]?\\d*(\\" + separator + "\\d" + regexPart + ")?$"));
|
|
9166
|
+
var regex = new RegExp(("^[-+]?\\d*(\\" + separator + "\\d" + regexPart + ")?([eE]{1}[-]?\\d+)?$"));
|
|
9159
9167
|
|
|
9160
9168
|
if (! regex.test(value)) {
|
|
9161
9169
|
return false;
|
|
@@ -10272,204 +10280,6 @@ var $validator = null;
|
|
|
10272
10280
|
|
|
10273
10281
|
var PROVIDER_COUNTER = 0;
|
|
10274
10282
|
|
|
10275
|
-
function createValidationCtx (ctx) {
|
|
10276
|
-
return {
|
|
10277
|
-
errors: ctx.messages,
|
|
10278
|
-
flags: ctx.flags,
|
|
10279
|
-
classes: ctx.classes,
|
|
10280
|
-
valid: ctx.isValid,
|
|
10281
|
-
failedRules: ctx.failedRules,
|
|
10282
|
-
reset: function () { return ctx.reset(); },
|
|
10283
|
-
validate: function () {
|
|
10284
|
-
var args = [], len = arguments.length;
|
|
10285
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
10286
|
-
|
|
10287
|
-
return ctx.validate.apply(ctx, args);
|
|
10288
|
-
},
|
|
10289
|
-
aria: {
|
|
10290
|
-
'aria-invalid': ctx.flags.invalid ? 'true' : 'false',
|
|
10291
|
-
'aria-required': ctx.isRequired ? 'true' : 'false'
|
|
10292
|
-
}
|
|
10293
|
-
};
|
|
10294
|
-
}
|
|
10295
|
-
|
|
10296
|
-
function normalizeValue$1 (value) {
|
|
10297
|
-
if (isEvent(value)) {
|
|
10298
|
-
return value.target.type === 'file' ? toArray(value.target.files) : value.target.value;
|
|
10299
|
-
}
|
|
10300
|
-
|
|
10301
|
-
return value;
|
|
10302
|
-
}
|
|
10303
|
-
|
|
10304
|
-
/**
|
|
10305
|
-
* Determines if a provider needs to run validation.
|
|
10306
|
-
*/
|
|
10307
|
-
function shouldValidate (ctx, model) {
|
|
10308
|
-
// when an immediate/initial validation is needed and wasn't done before.
|
|
10309
|
-
if (!ctx._ignoreImmediate && ctx.immediate) {
|
|
10310
|
-
return true;
|
|
10311
|
-
}
|
|
10312
|
-
|
|
10313
|
-
// when the value changes for whatever reason.
|
|
10314
|
-
if (ctx.value !== model.value) {
|
|
10315
|
-
return true;
|
|
10316
|
-
}
|
|
10317
|
-
|
|
10318
|
-
// when it needs validation due to props/cross-fields changes.
|
|
10319
|
-
if (ctx._needsValidation) {
|
|
10320
|
-
return true;
|
|
10321
|
-
}
|
|
10322
|
-
|
|
10323
|
-
// when the initial value is undefined and the field wasn't rendered yet.
|
|
10324
|
-
if (!ctx.initialized && model.value === undefined) {
|
|
10325
|
-
return true;
|
|
10326
|
-
}
|
|
10327
|
-
|
|
10328
|
-
return false;
|
|
10329
|
-
}
|
|
10330
|
-
|
|
10331
|
-
function computeModeSetting (ctx) {
|
|
10332
|
-
var compute = isCallable(ctx.mode) ? ctx.mode : modes[ctx.mode];
|
|
10333
|
-
|
|
10334
|
-
return compute({
|
|
10335
|
-
errors: ctx.messages,
|
|
10336
|
-
value: ctx.value,
|
|
10337
|
-
flags: ctx.flags
|
|
10338
|
-
});
|
|
10339
|
-
}
|
|
10340
|
-
|
|
10341
|
-
function onRenderUpdate (model) {
|
|
10342
|
-
if (!this.initialized) {
|
|
10343
|
-
this.initialValue = model.value;
|
|
10344
|
-
}
|
|
10345
|
-
|
|
10346
|
-
var validateNow = shouldValidate(this, model);
|
|
10347
|
-
this._needsValidation = false;
|
|
10348
|
-
this.value = model.value;
|
|
10349
|
-
this._ignoreImmediate = true;
|
|
10350
|
-
|
|
10351
|
-
if (!validateNow) {
|
|
10352
|
-
return;
|
|
10353
|
-
}
|
|
10354
|
-
|
|
10355
|
-
this.validateSilent().then(this.immediate || this.flags.validated ? this.applyResult : function (x) { return x; });
|
|
10356
|
-
}
|
|
10357
|
-
|
|
10358
|
-
// Creates the common handlers for a validatable context.
|
|
10359
|
-
function createCommonHandlers (ctx) {
|
|
10360
|
-
var onInput = function (e) {
|
|
10361
|
-
ctx.syncValue(e); // track and keep the value updated.
|
|
10362
|
-
ctx.setFlags({ dirty: true, pristine: false });
|
|
10363
|
-
};
|
|
10364
|
-
|
|
10365
|
-
// Blur event listener.
|
|
10366
|
-
var onBlur = function () {
|
|
10367
|
-
ctx.setFlags({ touched: true, untouched: false });
|
|
10368
|
-
};
|
|
10369
|
-
|
|
10370
|
-
var onValidate = ctx.$veeHandler;
|
|
10371
|
-
var mode = computeModeSetting(ctx);
|
|
10372
|
-
|
|
10373
|
-
// Handle debounce changes.
|
|
10374
|
-
if (!onValidate || ctx.$veeDebounce !== ctx.debounce) {
|
|
10375
|
-
onValidate = debounce(
|
|
10376
|
-
function () {
|
|
10377
|
-
ctx.$nextTick(function () {
|
|
10378
|
-
var pendingPromise = ctx.validateSilent();
|
|
10379
|
-
// avoids race conditions between successive validations.
|
|
10380
|
-
ctx._pendingValidation = pendingPromise;
|
|
10381
|
-
pendingPromise.then(function (result) {
|
|
10382
|
-
if (pendingPromise === ctx._pendingValidation) {
|
|
10383
|
-
ctx.applyResult(result);
|
|
10384
|
-
ctx._pendingValidation = null;
|
|
10385
|
-
}
|
|
10386
|
-
});
|
|
10387
|
-
});
|
|
10388
|
-
},
|
|
10389
|
-
mode.debounce || ctx.debounce
|
|
10390
|
-
);
|
|
10391
|
-
|
|
10392
|
-
// Cache the handler so we don't create it each time.
|
|
10393
|
-
ctx.$veeHandler = onValidate;
|
|
10394
|
-
// cache the debounce value so we detect if it was changed.
|
|
10395
|
-
ctx.$veeDebounce = ctx.debounce;
|
|
10396
|
-
}
|
|
10397
|
-
|
|
10398
|
-
return { onInput: onInput, onBlur: onBlur, onValidate: onValidate };
|
|
10399
|
-
}
|
|
10400
|
-
|
|
10401
|
-
// Adds all plugin listeners to the vnode.
|
|
10402
|
-
function addListeners (node) {
|
|
10403
|
-
var model = findModel(node);
|
|
10404
|
-
// cache the input eventName.
|
|
10405
|
-
this._inputEventName = this._inputEventName || getInputEventName(node, model);
|
|
10406
|
-
|
|
10407
|
-
onRenderUpdate.call(this, model);
|
|
10408
|
-
|
|
10409
|
-
var ref = createCommonHandlers(this);
|
|
10410
|
-
var onInput = ref.onInput;
|
|
10411
|
-
var onBlur = ref.onBlur;
|
|
10412
|
-
var onValidate = ref.onValidate;
|
|
10413
|
-
addVNodeListener(node, this._inputEventName, onInput);
|
|
10414
|
-
addVNodeListener(node, 'blur', onBlur);
|
|
10415
|
-
|
|
10416
|
-
// add the validation listeners.
|
|
10417
|
-
this.normalizedEvents.forEach(function (evt) {
|
|
10418
|
-
addVNodeListener(node, evt, onValidate);
|
|
10419
|
-
});
|
|
10420
|
-
|
|
10421
|
-
this.initialized = true;
|
|
10422
|
-
}
|
|
10423
|
-
|
|
10424
|
-
function createValuesLookup (ctx) {
|
|
10425
|
-
var providers = ctx.$_veeObserver.refs;
|
|
10426
|
-
|
|
10427
|
-
return ctx.fieldDeps.reduce(function (acc, depName) {
|
|
10428
|
-
if (!providers[depName]) {
|
|
10429
|
-
return acc;
|
|
10430
|
-
}
|
|
10431
|
-
|
|
10432
|
-
acc[depName] = providers[depName].value;
|
|
10433
|
-
|
|
10434
|
-
return acc;
|
|
10435
|
-
}, {});
|
|
10436
|
-
}
|
|
10437
|
-
|
|
10438
|
-
function updateRenderingContextRefs (ctx) {
|
|
10439
|
-
// IDs should not be nullable.
|
|
10440
|
-
if (isNullOrUndefined(ctx.id) && ctx.id === ctx.vid) {
|
|
10441
|
-
ctx.id = PROVIDER_COUNTER;
|
|
10442
|
-
PROVIDER_COUNTER++;
|
|
10443
|
-
}
|
|
10444
|
-
|
|
10445
|
-
var id = ctx.id;
|
|
10446
|
-
var vid = ctx.vid;
|
|
10447
|
-
// Nothing has changed.
|
|
10448
|
-
if (ctx.isDeactivated || (id === vid && ctx.$_veeObserver.refs[id])) {
|
|
10449
|
-
return;
|
|
10450
|
-
}
|
|
10451
|
-
|
|
10452
|
-
// vid was changed.
|
|
10453
|
-
if (id !== vid && ctx.$_veeObserver.refs[id] === ctx) {
|
|
10454
|
-
ctx.$_veeObserver.unsubscribe(ctx);
|
|
10455
|
-
}
|
|
10456
|
-
|
|
10457
|
-
ctx.$_veeObserver.subscribe(ctx);
|
|
10458
|
-
ctx.id = vid;
|
|
10459
|
-
}
|
|
10460
|
-
|
|
10461
|
-
function createObserver () {
|
|
10462
|
-
return {
|
|
10463
|
-
refs: {},
|
|
10464
|
-
subscribe: function subscribe (ctx) {
|
|
10465
|
-
this.refs[ctx.vid] = ctx;
|
|
10466
|
-
},
|
|
10467
|
-
unsubscribe: function unsubscribe (ctx) {
|
|
10468
|
-
delete this.refs[ctx.vid];
|
|
10469
|
-
}
|
|
10470
|
-
};
|
|
10471
|
-
}
|
|
10472
|
-
|
|
10473
10283
|
var ValidationProvider = {
|
|
10474
10284
|
$__veeInject: false,
|
|
10475
10285
|
inject: {
|
|
@@ -10574,19 +10384,10 @@ var ValidationProvider = {
|
|
|
10574
10384
|
var this$1 = this;
|
|
10575
10385
|
|
|
10576
10386
|
var rules = normalizeRules(this.rules);
|
|
10577
|
-
var providers = this.$_veeObserver.refs;
|
|
10578
10387
|
|
|
10579
10388
|
return Object.keys(rules).filter(RuleContainer.isTargetRule).map(function (rule) {
|
|
10580
10389
|
var depName = rules[rule][0];
|
|
10581
|
-
|
|
10582
|
-
if (!isCallable(this$1[watcherName]) && providers[depName]) {
|
|
10583
|
-
this$1[watcherName] = providers[depName].$watch('value', function () {
|
|
10584
|
-
if (this$1.flags.validated) {
|
|
10585
|
-
this$1._needsValidation = true;
|
|
10586
|
-
this$1.validate();
|
|
10587
|
-
}
|
|
10588
|
-
});
|
|
10589
|
-
}
|
|
10390
|
+
watchCrossFieldDep(this$1, depName);
|
|
10590
10391
|
|
|
10591
10392
|
return depName;
|
|
10592
10393
|
});
|
|
@@ -10745,6 +10546,228 @@ var ValidationProvider = {
|
|
|
10745
10546
|
}
|
|
10746
10547
|
};
|
|
10747
10548
|
|
|
10549
|
+
function createValidationCtx (ctx) {
|
|
10550
|
+
return {
|
|
10551
|
+
errors: ctx.messages,
|
|
10552
|
+
flags: ctx.flags,
|
|
10553
|
+
classes: ctx.classes,
|
|
10554
|
+
valid: ctx.isValid,
|
|
10555
|
+
failedRules: ctx.failedRules,
|
|
10556
|
+
reset: function () { return ctx.reset(); },
|
|
10557
|
+
validate: function () {
|
|
10558
|
+
var args = [], len = arguments.length;
|
|
10559
|
+
while ( len-- ) args[ len ] = arguments[ len ];
|
|
10560
|
+
|
|
10561
|
+
return ctx.validate.apply(ctx, args);
|
|
10562
|
+
},
|
|
10563
|
+
aria: {
|
|
10564
|
+
'aria-invalid': ctx.flags.invalid ? 'true' : 'false',
|
|
10565
|
+
'aria-required': ctx.isRequired ? 'true' : 'false'
|
|
10566
|
+
}
|
|
10567
|
+
};
|
|
10568
|
+
}
|
|
10569
|
+
|
|
10570
|
+
function normalizeValue$1 (value) {
|
|
10571
|
+
if (isEvent(value)) {
|
|
10572
|
+
return value.target.type === 'file' ? toArray(value.target.files) : value.target.value;
|
|
10573
|
+
}
|
|
10574
|
+
|
|
10575
|
+
return value;
|
|
10576
|
+
}
|
|
10577
|
+
|
|
10578
|
+
/**
|
|
10579
|
+
* Determines if a provider needs to run validation.
|
|
10580
|
+
*/
|
|
10581
|
+
function shouldValidate (ctx, model) {
|
|
10582
|
+
// when an immediate/initial validation is needed and wasn't done before.
|
|
10583
|
+
if (!ctx._ignoreImmediate && ctx.immediate) {
|
|
10584
|
+
return true;
|
|
10585
|
+
}
|
|
10586
|
+
|
|
10587
|
+
// when the value changes for whatever reason.
|
|
10588
|
+
if (ctx.value !== model.value) {
|
|
10589
|
+
return true;
|
|
10590
|
+
}
|
|
10591
|
+
|
|
10592
|
+
// when it needs validation due to props/cross-fields changes.
|
|
10593
|
+
if (ctx._needsValidation) {
|
|
10594
|
+
return true;
|
|
10595
|
+
}
|
|
10596
|
+
|
|
10597
|
+
// when the initial value is undefined and the field wasn't rendered yet.
|
|
10598
|
+
if (!ctx.initialized && model.value === undefined) {
|
|
10599
|
+
return true;
|
|
10600
|
+
}
|
|
10601
|
+
|
|
10602
|
+
return false;
|
|
10603
|
+
}
|
|
10604
|
+
|
|
10605
|
+
function computeModeSetting (ctx) {
|
|
10606
|
+
var compute = isCallable(ctx.mode) ? ctx.mode : modes[ctx.mode];
|
|
10607
|
+
|
|
10608
|
+
return compute({
|
|
10609
|
+
errors: ctx.messages,
|
|
10610
|
+
value: ctx.value,
|
|
10611
|
+
flags: ctx.flags
|
|
10612
|
+
});
|
|
10613
|
+
}
|
|
10614
|
+
|
|
10615
|
+
function onRenderUpdate (model) {
|
|
10616
|
+
if (!this.initialized) {
|
|
10617
|
+
this.initialValue = model.value;
|
|
10618
|
+
}
|
|
10619
|
+
|
|
10620
|
+
var validateNow = shouldValidate(this, model);
|
|
10621
|
+
this._needsValidation = false;
|
|
10622
|
+
this.value = model.value;
|
|
10623
|
+
this._ignoreImmediate = true;
|
|
10624
|
+
|
|
10625
|
+
if (!validateNow) {
|
|
10626
|
+
return;
|
|
10627
|
+
}
|
|
10628
|
+
|
|
10629
|
+
this.validateSilent().then(this.immediate || this.flags.validated ? this.applyResult : function (x) { return x; });
|
|
10630
|
+
}
|
|
10631
|
+
|
|
10632
|
+
// Creates the common handlers for a validatable context.
|
|
10633
|
+
function createCommonHandlers (ctx) {
|
|
10634
|
+
var onInput = function (e) {
|
|
10635
|
+
ctx.syncValue(e); // track and keep the value updated.
|
|
10636
|
+
ctx.setFlags({ dirty: true, pristine: false });
|
|
10637
|
+
};
|
|
10638
|
+
|
|
10639
|
+
// Blur event listener.
|
|
10640
|
+
var onBlur = function () {
|
|
10641
|
+
ctx.setFlags({ touched: true, untouched: false });
|
|
10642
|
+
};
|
|
10643
|
+
|
|
10644
|
+
var onValidate = ctx.$veeHandler;
|
|
10645
|
+
var mode = computeModeSetting(ctx);
|
|
10646
|
+
|
|
10647
|
+
// Handle debounce changes.
|
|
10648
|
+
if (!onValidate || ctx.$veeDebounce !== ctx.debounce) {
|
|
10649
|
+
onValidate = debounce(
|
|
10650
|
+
function () {
|
|
10651
|
+
ctx.$nextTick(function () {
|
|
10652
|
+
var pendingPromise = ctx.validateSilent();
|
|
10653
|
+
// avoids race conditions between successive validations.
|
|
10654
|
+
ctx._pendingValidation = pendingPromise;
|
|
10655
|
+
pendingPromise.then(function (result) {
|
|
10656
|
+
if (pendingPromise === ctx._pendingValidation) {
|
|
10657
|
+
ctx.applyResult(result);
|
|
10658
|
+
ctx._pendingValidation = null;
|
|
10659
|
+
}
|
|
10660
|
+
});
|
|
10661
|
+
});
|
|
10662
|
+
},
|
|
10663
|
+
mode.debounce || ctx.debounce
|
|
10664
|
+
);
|
|
10665
|
+
|
|
10666
|
+
// Cache the handler so we don't create it each time.
|
|
10667
|
+
ctx.$veeHandler = onValidate;
|
|
10668
|
+
// cache the debounce value so we detect if it was changed.
|
|
10669
|
+
ctx.$veeDebounce = ctx.debounce;
|
|
10670
|
+
}
|
|
10671
|
+
|
|
10672
|
+
return { onInput: onInput, onBlur: onBlur, onValidate: onValidate };
|
|
10673
|
+
}
|
|
10674
|
+
|
|
10675
|
+
// Adds all plugin listeners to the vnode.
|
|
10676
|
+
function addListeners (node) {
|
|
10677
|
+
var model = findModel(node);
|
|
10678
|
+
// cache the input eventName.
|
|
10679
|
+
this._inputEventName = this._inputEventName || getInputEventName(node, model);
|
|
10680
|
+
|
|
10681
|
+
onRenderUpdate.call(this, model);
|
|
10682
|
+
|
|
10683
|
+
var ref = createCommonHandlers(this);
|
|
10684
|
+
var onInput = ref.onInput;
|
|
10685
|
+
var onBlur = ref.onBlur;
|
|
10686
|
+
var onValidate = ref.onValidate;
|
|
10687
|
+
addVNodeListener(node, this._inputEventName, onInput);
|
|
10688
|
+
addVNodeListener(node, 'blur', onBlur);
|
|
10689
|
+
|
|
10690
|
+
// add the validation listeners.
|
|
10691
|
+
this.normalizedEvents.forEach(function (evt) {
|
|
10692
|
+
addVNodeListener(node, evt, onValidate);
|
|
10693
|
+
});
|
|
10694
|
+
|
|
10695
|
+
this.initialized = true;
|
|
10696
|
+
}
|
|
10697
|
+
|
|
10698
|
+
function createValuesLookup (ctx) {
|
|
10699
|
+
var providers = ctx.$_veeObserver.refs;
|
|
10700
|
+
|
|
10701
|
+
return ctx.fieldDeps.reduce(function (acc, depName) {
|
|
10702
|
+
if (!providers[depName]) {
|
|
10703
|
+
return acc;
|
|
10704
|
+
}
|
|
10705
|
+
|
|
10706
|
+
acc[depName] = providers[depName].value;
|
|
10707
|
+
|
|
10708
|
+
return acc;
|
|
10709
|
+
}, {});
|
|
10710
|
+
}
|
|
10711
|
+
|
|
10712
|
+
function updateRenderingContextRefs (ctx) {
|
|
10713
|
+
// IDs should not be nullable.
|
|
10714
|
+
if (isNullOrUndefined(ctx.id) && ctx.id === ctx.vid) {
|
|
10715
|
+
ctx.id = PROVIDER_COUNTER;
|
|
10716
|
+
PROVIDER_COUNTER++;
|
|
10717
|
+
}
|
|
10718
|
+
|
|
10719
|
+
var id = ctx.id;
|
|
10720
|
+
var vid = ctx.vid;
|
|
10721
|
+
// Nothing has changed.
|
|
10722
|
+
if (ctx.isDeactivated || (id === vid && ctx.$_veeObserver.refs[id])) {
|
|
10723
|
+
return;
|
|
10724
|
+
}
|
|
10725
|
+
|
|
10726
|
+
// vid was changed.
|
|
10727
|
+
if (id !== vid && ctx.$_veeObserver.refs[id] === ctx) {
|
|
10728
|
+
ctx.$_veeObserver.unsubscribe(ctx);
|
|
10729
|
+
}
|
|
10730
|
+
|
|
10731
|
+
ctx.$_veeObserver.subscribe(ctx);
|
|
10732
|
+
ctx.id = vid;
|
|
10733
|
+
}
|
|
10734
|
+
|
|
10735
|
+
function createObserver () {
|
|
10736
|
+
return {
|
|
10737
|
+
refs: {},
|
|
10738
|
+
subscribe: function subscribe (ctx) {
|
|
10739
|
+
this.refs[ctx.vid] = ctx;
|
|
10740
|
+
},
|
|
10741
|
+
unsubscribe: function unsubscribe (ctx) {
|
|
10742
|
+
delete this.refs[ctx.vid];
|
|
10743
|
+
}
|
|
10744
|
+
};
|
|
10745
|
+
}
|
|
10746
|
+
|
|
10747
|
+
function watchCrossFieldDep (ctx, depName, withHooks) {
|
|
10748
|
+
if ( withHooks === void 0 ) withHooks = true;
|
|
10749
|
+
|
|
10750
|
+
var providers = ctx.$_veeObserver.refs;
|
|
10751
|
+
if (!ctx._veeWatchers) {
|
|
10752
|
+
ctx._veeWatchers = {};
|
|
10753
|
+
}
|
|
10754
|
+
|
|
10755
|
+
if (!providers[depName] && withHooks) {
|
|
10756
|
+
return ctx.$once('hook:mounted', function () {
|
|
10757
|
+
watchCrossFieldDep(ctx, depName, false);
|
|
10758
|
+
});
|
|
10759
|
+
}
|
|
10760
|
+
|
|
10761
|
+
if (!isCallable(ctx._veeWatchers[depName]) && providers[depName]) {
|
|
10762
|
+
ctx._veeWatchers[depName] = providers[depName].$watch('value', function () {
|
|
10763
|
+
if (ctx.flags.validated) {
|
|
10764
|
+
ctx._needsValidation = true;
|
|
10765
|
+
ctx.validate();
|
|
10766
|
+
}
|
|
10767
|
+
});
|
|
10768
|
+
}
|
|
10769
|
+
}
|
|
10770
|
+
|
|
10748
10771
|
var flagMergingStrategy = {
|
|
10749
10772
|
pristine: 'every',
|
|
10750
10773
|
dirty: 'some',
|
|
@@ -10997,7 +11020,7 @@ function withValidation (component, ctxToProps) {
|
|
|
10997
11020
|
return hoc;
|
|
10998
11021
|
}
|
|
10999
11022
|
|
|
11000
|
-
var version = '2.2.
|
|
11023
|
+
var version = '2.2.9';
|
|
11001
11024
|
|
|
11002
11025
|
Object.keys(Rules).forEach(function (rule) {
|
|
11003
11026
|
Validator.extend(rule, Rules[rule].validate, assign({}, Rules[rule].options, { paramNames: Rules[rule].paramNames }));
|
|
@@ -11015,4 +11038,4 @@ VeeValidate$1.ValidationObserver = ValidationObserver;
|
|
|
11015
11038
|
VeeValidate$1.withValidation = withValidation;
|
|
11016
11039
|
|
|
11017
11040
|
export default VeeValidate$1;
|
|
11018
|
-
export {
|
|
11041
|
+
export { ErrorBag, Rules, ValidationObserver, ValidationProvider, Validator, directive, install, mapFields, mixin, version, withValidation };
|