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

Commit

Permalink
release v2.0.0-alpha.8
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Dec 13, 2015
1 parent e84a252 commit 527d1f4
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 41 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
<a name="2.0.0-alpha.8"></a>
# [2.0.0-alpha.8](https://github.com/vuejs/vue-validator/compare/v2.0.0-alpha.7...v2.0.0-alpha.8) (2015-12-13)


### Bug Fixes

* **asset:** fix cannot register validator issue ([dce7e96](https://github.com/vuejs/vue-validator/commit/dce7e96)), closes [#108](https://github.com/vuejs/vue-validator/issues/108)

### Features

* **lazy:** support lazy initialization ([f5c24c9](https://github.com/vuejs/vue-validator/commit/f5c24c9)), closes [#25](https://github.com/vuejs/vue-validator/issues/25)
* **validation:** support kebab-case ([b26a108](https://github.com/vuejs/vue-validator/commit/b26a108)), closes [#102](https://github.com/vuejs/vue-validator/issues/102)



<a name="2.0.0-alpha.7"></a>
# [2.0.0-alpha.7](https://github.com/vuejs/vue-validator/compare/v2.0.0-alpha.6...v2.0.0-alpha.7) (2015-12-10)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ You don't need to do this when using the standalone build because it installs it
## CDN
jsdelivr
```html
<script src="https://cdn.jsdelivr.net/vue.validator/2.0.0-alpha.6/vue-validator.min.js"></script>
<script src="https://cdn.jsdelivr.net/vue.validator/2.0.0-alpha.8/vue-validator.min.js"></script>
```


Expand Down
61 changes: 43 additions & 18 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.7
* vue-validator v2.0.0-alpha.8
* (c) 2015 kazuya kawaguchi
* Released under the MIT License.
*/
Expand Down Expand Up @@ -276,7 +276,9 @@ function Asset (Vue) {
Vue.config._assetTypes.push('validator');

// set global validators asset
Vue.options.validators = validators;
var assets = Object.create(null);
Vue.util.extend(assets, validators);
Vue.options.validators = assets;

// set option merge strategy
var strats = Vue.config.optionMergeStrategies;
Expand Down Expand Up @@ -327,7 +329,9 @@ var Validation = (function () {
function Validation(dir) {
babelHelpers.classCallCheck(this, Validation);

this.model = dir.arg;
var camelize = exports$1.Vue.util.camelize;

this.model = camelize(dir.arg);
this.el = dir.el;
this.dir = dir;
this.init = dir.el.value;
Expand All @@ -339,23 +343,17 @@ var Validation = (function () {

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

value: function setValidation(name, arg, msg) {
var validator = this.validators[name];
if (!validator) {
validator = this.validators[name] = {};
validator.fn = resolveAsset(this.dir.vm.$options, 'validators', name);
validator.name = name;
}

validator.arg = arg;
if (msg) {
validator.msg = msg;
}

if (fn) {
validator.fn = fn;
}
}
}, {
key: 'listener',
Expand Down Expand Up @@ -387,7 +385,8 @@ var Validation = (function () {
var valid = true;

each(this.validators, function (descriptor, name) {
var res = descriptor.fn.call(_this.dir.vm, _this.el.value, descriptor.arg);
var validator = _this._resolveValidator(name);
var res = validator.call(_this.dir.vm, _this.el.value, descriptor.arg);
if (!res) {
valid = false;
var msg = descriptor.msg;
Expand Down Expand Up @@ -416,6 +415,12 @@ var Validation = (function () {

return ret;
}
}, {
key: '_resolveValidator',
value: function _resolveValidator(name) {
var resolveAsset = exports$1.Vue.util.resolveAsset;
return resolveAsset(this.dir.vm.$options, 'validators', name);
}
}]);
return Validation;
})();
Expand Down Expand Up @@ -579,6 +584,17 @@ var Validator$1 = (function () {
_this3._defineProperties(validations, group);
}, this);
}
}, {
key: 'waitFor',
value: function waitFor(cb) {
var vm = this._dir.vm;
var method = '$activateValidator';

this._dir.vm[method] = function () {
cb();
vm[method] = null;
};
}
}, {
key: '_defineProperties',
value: function _defineProperties(validations, target) {
Expand Down Expand Up @@ -690,11 +706,14 @@ function Validator (Vue) {
var _ = Vue.util;
var FragmentFactory = Vue.FragmentFactory;
var vIf = Vue.directive('if');
var _bind = Vue.util.bind;

Vue.elementDirective('validator', {
params: ['name', 'groups'],
params: ['name', 'groups', 'lazy'],

bind: function bind() {
var _this = this;

if (!this.params.name) {
// TODO: should be implemented validator:bind name params nothing error'
warn('TODO: should be implemented validator:bind name params nothing error');
Expand All @@ -721,13 +740,19 @@ function Validator (Vue) {
validator.enableReactive();
validator.setupScope();

validator.waitFor(_bind(function () {
_this.render(validator, validatorName);
validator.validate();
}, this));

if (!this.params.lazy) {
this.vm.$activateValidator();
}
},
render: function render(validator, validatorName) {
this.anchor = _.createAnchor('vue-validator');
_.replace(this.el, this.anchor);
this.insert(validatorName);

this.vm.$on('hook:compiled', function () {
validator.validate();
});
},
insert: function insert(name) {
_.extend(this.vm.$options, { _validator: name });
Expand Down Expand Up @@ -770,7 +795,7 @@ function plugin(Vue) {
Validate(Vue);
}

plugin.version = '2.0.0-alpha.7';
plugin.version = '2.0.0-alpha.8';

if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(plugin);
Expand Down
61 changes: 43 additions & 18 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.7
* vue-validator v2.0.0-alpha.8
* (c) 2015 kazuya kawaguchi
* Released under the MIT License.
*/
Expand Down Expand Up @@ -280,7 +280,9 @@
Vue.config._assetTypes.push('validator');

// set global validators asset
Vue.options.validators = validators;
var assets = Object.create(null);
Vue.util.extend(assets, validators);
Vue.options.validators = assets;

// set option merge strategy
var strats = Vue.config.optionMergeStrategies;
Expand Down Expand Up @@ -331,7 +333,9 @@
function Validation(dir) {
babelHelpers.classCallCheck(this, Validation);

this.model = dir.arg;
var camelize = exports$1.Vue.util.camelize;

this.model = camelize(dir.arg);
this.el = dir.el;
this.dir = dir;
this.init = dir.el.value;
Expand All @@ -343,23 +347,17 @@

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

value: function setValidation(name, arg, msg) {
var validator = this.validators[name];
if (!validator) {
validator = this.validators[name] = {};
validator.fn = resolveAsset(this.dir.vm.$options, 'validators', name);
validator.name = name;
}

validator.arg = arg;
if (msg) {
validator.msg = msg;
}

if (fn) {
validator.fn = fn;
}
}
}, {
key: 'listener',
Expand Down Expand Up @@ -391,7 +389,8 @@
var valid = true;

each(this.validators, function (descriptor, name) {
var res = descriptor.fn.call(_this.dir.vm, _this.el.value, descriptor.arg);
var validator = _this._resolveValidator(name);
var res = validator.call(_this.dir.vm, _this.el.value, descriptor.arg);
if (!res) {
valid = false;
var msg = descriptor.msg;
Expand Down Expand Up @@ -420,6 +419,12 @@

return ret;
}
}, {
key: '_resolveValidator',
value: function _resolveValidator(name) {
var resolveAsset = exports$1.Vue.util.resolveAsset;
return resolveAsset(this.dir.vm.$options, 'validators', name);
}
}]);
return Validation;
})();
Expand Down Expand Up @@ -583,6 +588,17 @@
_this3._defineProperties(validations, group);
}, this);
}
}, {
key: 'waitFor',
value: function waitFor(cb) {
var vm = this._dir.vm;
var method = '$activateValidator';

this._dir.vm[method] = function () {
cb();
vm[method] = null;
};
}
}, {
key: '_defineProperties',
value: function _defineProperties(validations, target) {
Expand Down Expand Up @@ -694,11 +710,14 @@
var _ = Vue.util;
var FragmentFactory = Vue.FragmentFactory;
var vIf = Vue.directive('if');
var _bind = Vue.util.bind;

Vue.elementDirective('validator', {
params: ['name', 'groups'],
params: ['name', 'groups', 'lazy'],

bind: function bind() {
var _this = this;

if (!this.params.name) {
// TODO: should be implemented validator:bind name params nothing error'
warn('TODO: should be implemented validator:bind name params nothing error');
Expand All @@ -725,13 +744,19 @@
validator.enableReactive();
validator.setupScope();

validator.waitFor(_bind(function () {
_this.render(validator, validatorName);
validator.validate();
}, this));

if (!this.params.lazy) {
this.vm.$activateValidator();
}
},
render: function render(validator, validatorName) {
this.anchor = _.createAnchor('vue-validator');
_.replace(this.el, this.anchor);
this.insert(validatorName);

this.vm.$on('hook:compiled', function () {
validator.validate();
});
},
insert: function insert(name) {
_.extend(this.vm.$options, { _validator: name });
Expand Down Expand Up @@ -774,7 +799,7 @@
Validate(Vue);
}

plugin.version = '2.0.0-alpha.7';
plugin.version = '2.0.0-alpha.8';

if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(plugin);
Expand Down
4 changes: 2 additions & 2 deletions dist/vue-validator.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-validator",
"description": "Validator component for Vue.js",
"version": "2.0.0-alpha.7",
"version": "2.0.0-alpha.8",
"author": {
"name": "kazuya kawaguchi",
"email": "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function plugin (Vue, options = {}) {
Validate(Vue)
}

plugin.version = '2.0.0-alpha.7'
plugin.version = '2.0.0-alpha.8'

export default plugin

Expand Down

0 comments on commit 527d1f4

Please sign in to comment.