Skip to content
This repository has been archived by the owner on Dec 25, 2017. It is now read-only.

Commit

Permalink
chore(dist): updaet distribution files
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Dec 10, 2015
1 parent 9cb9328 commit aef7f75
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 78 deletions.
65 changes: 28 additions & 37 deletions dist/vue-validator.common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* vue-validator v2.0.0-alpha.6
* vue-validator v2.0.0-alpha.7
* (c) 2015 kazuya kawaguchi
* Released under the MIT License.
*/
Expand Down Expand Up @@ -334,40 +334,27 @@ var Validation = (function () {
this.touched = false;
this.dirty = false;
this.modified = false;
this.validates = this._buildValidates(dir);
this.validators = Object.create(null);
}

babelHelpers.createClass(Validation, [{
key: '_buildValidates',
value: function _buildValidates(dir) {
var arg = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];

key: 'setValidation',
value: function setValidation(name, arg, msg, fn) {
var resolveAsset = exports$1.Vue.util.resolveAsset;
var camelize = exports$1.Vue.util.camelize;

var ret = Object.create(null);
var validates = dir.modifiers;
var validator = this.validators[name];
if (!validator) {
validator = this.validators[name] = {};
validator.fn = resolveAsset(this.dir.vm.$options, 'validators', name);
}

for (var validate in validates) {
var fn = resolveAsset(dir.vm.$options, 'validators', camelize(validate));
if (fn) {
ret[validate] = { arg: arg, fn: fn };
}
validator.arg = arg;
if (msg) {
validator.msg = msg;
}

return ret;
}
}, {
key: 'updateValidate',
value: function updateValidate(name, arg, msg, fn) {
if (this.validates[name]) {
this.validates[name].arg = arg;
if (msg) {
this.validates[name].msg = msg;
}
if (fn) {
this.validates[name].fn = fn;
}
if (fn) {
validator.fn = fn;
}
}
}, {
Expand Down Expand Up @@ -399,8 +386,8 @@ var Validation = (function () {
var messages = Object.create(null);
var valid = true;

each(this.validates, function (descriptor, name) {
var res = descriptor.fn(_this.el.value, descriptor.arg);
each(this.validators, function (descriptor, name) {
var res = descriptor.fn.call(_this.dir.vm, _this.el.value, descriptor.arg);
if (!res) {
valid = false;
var msg = descriptor.msg;
Expand Down Expand Up @@ -467,26 +454,30 @@ function Validate (Vue) {

if (_.isPlainObject(value)) {
this.handleObject(value);
} else {
this.handleSingle(value);
} else if (Array.isArray(value)) {
this.handleArray(value);
}

this.validator.validate(this.validation);
},
handleSingle: function handleSingle(value) {
var validateKey = Object.keys(this.validation.validates)[0];
this.validation.updateValidate(validateKey, value);
handleArray: function handleArray(value) {
var _this = this;

each(value, function (val) {
_this.validation.setValidation(val);
}, this);
},
handleObject: function handleObject(value) {
var _this = this;
var _this2 = this;

each(value, function (val, key) {
if (_.isPlainObject(val)) {
if ('rule' in val) {
_this.validation.updateValidate(key, val.rule, 'message' in val ? val.message : null);
var msg = 'message' in val ? val.message : null;
_this2.validation.setValidation(key, val.rule, msg);
}
} else {
_this.validation.updateValidate(key, val);
_this2.validation.setValidation(key, val);
}
}, this);
},
Expand Down
65 changes: 28 additions & 37 deletions dist/vue-validator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* vue-validator v2.0.0-alpha.6
* vue-validator v2.0.0-alpha.7
* (c) 2015 kazuya kawaguchi
* Released under the MIT License.
*/
Expand Down Expand Up @@ -338,40 +338,27 @@
this.touched = false;
this.dirty = false;
this.modified = false;
this.validates = this._buildValidates(dir);
this.validators = Object.create(null);
}

babelHelpers.createClass(Validation, [{
key: '_buildValidates',
value: function _buildValidates(dir) {
var arg = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];

key: 'setValidation',
value: function setValidation(name, arg, msg, fn) {
var resolveAsset = exports$1.Vue.util.resolveAsset;
var camelize = exports$1.Vue.util.camelize;

var ret = Object.create(null);
var validates = dir.modifiers;
var validator = this.validators[name];
if (!validator) {
validator = this.validators[name] = {};
validator.fn = resolveAsset(this.dir.vm.$options, 'validators', name);
}

for (var validate in validates) {
var fn = resolveAsset(dir.vm.$options, 'validators', camelize(validate));
if (fn) {
ret[validate] = { arg: arg, fn: fn };
}
validator.arg = arg;
if (msg) {
validator.msg = msg;
}

return ret;
}
}, {
key: 'updateValidate',
value: function updateValidate(name, arg, msg, fn) {
if (this.validates[name]) {
this.validates[name].arg = arg;
if (msg) {
this.validates[name].msg = msg;
}
if (fn) {
this.validates[name].fn = fn;
}
if (fn) {
validator.fn = fn;
}
}
}, {
Expand Down Expand Up @@ -403,8 +390,8 @@
var messages = Object.create(null);
var valid = true;

each(this.validates, function (descriptor, name) {
var res = descriptor.fn(_this.el.value, descriptor.arg);
each(this.validators, function (descriptor, name) {
var res = descriptor.fn.call(_this.dir.vm, _this.el.value, descriptor.arg);
if (!res) {
valid = false;
var msg = descriptor.msg;
Expand Down Expand Up @@ -471,26 +458,30 @@

if (_.isPlainObject(value)) {
this.handleObject(value);
} else {
this.handleSingle(value);
} else if (Array.isArray(value)) {
this.handleArray(value);
}

this.validator.validate(this.validation);
},
handleSingle: function handleSingle(value) {
var validateKey = Object.keys(this.validation.validates)[0];
this.validation.updateValidate(validateKey, value);
handleArray: function handleArray(value) {
var _this = this;

each(value, function (val) {
_this.validation.setValidation(val);
}, this);
},
handleObject: function handleObject(value) {
var _this = this;
var _this2 = this;

each(value, function (val, key) {
if (_.isPlainObject(val)) {
if ('rule' in val) {
_this.validation.updateValidate(key, val.rule, 'message' in val ? val.message : null);
var msg = 'message' in val ? val.message : null;
_this2.validation.setValidation(key, val.rule, msg);
}
} else {
_this.validation.updateValidate(key, val);
_this2.validation.setValidation(key, val);
}
}, this);
},
Expand Down
Loading

0 comments on commit aef7f75

Please sign in to comment.