Skip to content

Commit

Permalink
add additional listeners for after and before rules
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Aug 27, 2016
1 parent a23336e commit 1ae3b89
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
31 changes: 20 additions & 11 deletions dist/vee-validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,17 @@ var Validator = function () {

var DEFAULT_EVENT_NAME = 'veeValidate';

var hasFieldDependency = function hasFieldDependency(rules) {
var results = rules.split('|').filter(function (r) {
return !!r.match(/confirmed|after|before/);
});
if (!results.length) {
return false;
}

return results[0].split(':')[1];
};

/* harmony default export */ exports["a"] = function (options) {
return {
onInput: function onInput() {
Expand Down Expand Up @@ -930,16 +941,11 @@ var DEFAULT_EVENT_NAME = 'veeValidate';
this.el.addEventListener(this.handles, this.handler);

this.attachValidatorEvent();
if (this.el.dataset.rules && ~this.el.dataset.rules.indexOf('confirmed')) {
(function () {
var fieldName = _this2.el.dataset.rules.split('|').filter(function (r) {
return !!~r.indexOf('confirmed');
})[0].split(':')[1];

_this2.vm.$once('validatorReady', function () {
document.querySelector('input[name=\'' + fieldName + '\']').addEventListener('input', _this2.handler);
});
})();
var fieldName = hasFieldDependency(this.el.dataset.rules);
if (this.el.dataset.rules && fieldName) {
this.vm.$once('validatorReady', function () {
document.querySelector('input[name=\'' + fieldName + '\']').addEventListener('input', _this2.handler);
});
}
},
update: function update(value) {
Expand Down Expand Up @@ -1834,19 +1840,22 @@ var install = function install(Vue) {
locale: 'en',
delay: 0,
errorBagName: 'errors',
messages: null
messages: null,
strict: true
} : arguments[1];

var locale = _ref.locale;
var delay = _ref.delay;
var errorBagName = _ref.errorBagName;
var messages = _ref.messages;
var strict = _ref.strict;

if (messages) {
__WEBPACK_IMPORTED_MODULE_0__validator__["a" /* default */].updateDictionary(messages);
}

__WEBPACK_IMPORTED_MODULE_0__validator__["a" /* default */].setDefaultLocale(locale);
__WEBPACK_IMPORTED_MODULE_0__validator__["a" /* default */].setStrictMode(strict);

var options = {
locale: locale,
Expand Down
Loading

0 comments on commit 1ae3b89

Please sign in to comment.