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

Commit 527d1f4

Browse files
committed
release v2.0.0-alpha.8
1 parent e84a252 commit 527d1f4

7 files changed

+106
-41
lines changed

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
<a name="2.0.0-alpha.8"></a>
2+
# [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)
3+
4+
5+
### Bug Fixes
6+
7+
* **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)
8+
9+
### Features
10+
11+
* **lazy:** support lazy initialization ([f5c24c9](https://github.com/vuejs/vue-validator/commit/f5c24c9)), closes [#25](https://github.com/vuejs/vue-validator/issues/25)
12+
* **validation:** support kebab-case ([b26a108](https://github.com/vuejs/vue-validator/commit/b26a108)), closes [#102](https://github.com/vuejs/vue-validator/issues/102)
13+
14+
15+
116
<a name="2.0.0-alpha.7"></a>
217
# [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)
318

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ You don't need to do this when using the standalone build because it installs it
4848
## CDN
4949
jsdelivr
5050
```html
51-
<script src="https://cdn.jsdelivr.net/vue.validator/2.0.0-alpha.6/vue-validator.min.js"></script>
51+
<script src="https://cdn.jsdelivr.net/vue.validator/2.0.0-alpha.8/vue-validator.min.js"></script>
5252
```
5353

5454

dist/vue-validator.common.js

+43-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-validator v2.0.0-alpha.7
2+
* vue-validator v2.0.0-alpha.8
33
* (c) 2015 kazuya kawaguchi
44
* Released under the MIT License.
55
*/
@@ -276,7 +276,9 @@ function Asset (Vue) {
276276
Vue.config._assetTypes.push('validator');
277277

278278
// set global validators asset
279-
Vue.options.validators = validators;
279+
var assets = Object.create(null);
280+
Vue.util.extend(assets, validators);
281+
Vue.options.validators = assets;
280282

281283
// set option merge strategy
282284
var strats = Vue.config.optionMergeStrategies;
@@ -327,7 +329,9 @@ var Validation = (function () {
327329
function Validation(dir) {
328330
babelHelpers.classCallCheck(this, Validation);
329331

330-
this.model = dir.arg;
332+
var camelize = exports$1.Vue.util.camelize;
333+
334+
this.model = camelize(dir.arg);
331335
this.el = dir.el;
332336
this.dir = dir;
333337
this.init = dir.el.value;
@@ -339,23 +343,17 @@ var Validation = (function () {
339343

340344
babelHelpers.createClass(Validation, [{
341345
key: 'setValidation',
342-
value: function setValidation(name, arg, msg, fn) {
343-
var resolveAsset = exports$1.Vue.util.resolveAsset;
344-
346+
value: function setValidation(name, arg, msg) {
345347
var validator = this.validators[name];
346348
if (!validator) {
347349
validator = this.validators[name] = {};
348-
validator.fn = resolveAsset(this.dir.vm.$options, 'validators', name);
350+
validator.name = name;
349351
}
350352

351353
validator.arg = arg;
352354
if (msg) {
353355
validator.msg = msg;
354356
}
355-
356-
if (fn) {
357-
validator.fn = fn;
358-
}
359357
}
360358
}, {
361359
key: 'listener',
@@ -387,7 +385,8 @@ var Validation = (function () {
387385
var valid = true;
388386

389387
each(this.validators, function (descriptor, name) {
390-
var res = descriptor.fn.call(_this.dir.vm, _this.el.value, descriptor.arg);
388+
var validator = _this._resolveValidator(name);
389+
var res = validator.call(_this.dir.vm, _this.el.value, descriptor.arg);
391390
if (!res) {
392391
valid = false;
393392
var msg = descriptor.msg;
@@ -416,6 +415,12 @@ var Validation = (function () {
416415

417416
return ret;
418417
}
418+
}, {
419+
key: '_resolveValidator',
420+
value: function _resolveValidator(name) {
421+
var resolveAsset = exports$1.Vue.util.resolveAsset;
422+
return resolveAsset(this.dir.vm.$options, 'validators', name);
423+
}
419424
}]);
420425
return Validation;
421426
})();
@@ -579,6 +584,17 @@ var Validator$1 = (function () {
579584
_this3._defineProperties(validations, group);
580585
}, this);
581586
}
587+
}, {
588+
key: 'waitFor',
589+
value: function waitFor(cb) {
590+
var vm = this._dir.vm;
591+
var method = '$activateValidator';
592+
593+
this._dir.vm[method] = function () {
594+
cb();
595+
vm[method] = null;
596+
};
597+
}
582598
}, {
583599
key: '_defineProperties',
584600
value: function _defineProperties(validations, target) {
@@ -690,11 +706,14 @@ function Validator (Vue) {
690706
var _ = Vue.util;
691707
var FragmentFactory = Vue.FragmentFactory;
692708
var vIf = Vue.directive('if');
709+
var _bind = Vue.util.bind;
693710

694711
Vue.elementDirective('validator', {
695-
params: ['name', 'groups'],
712+
params: ['name', 'groups', 'lazy'],
696713

697714
bind: function bind() {
715+
var _this = this;
716+
698717
if (!this.params.name) {
699718
// TODO: should be implemented validator:bind name params nothing error'
700719
warn('TODO: should be implemented validator:bind name params nothing error');
@@ -721,13 +740,19 @@ function Validator (Vue) {
721740
validator.enableReactive();
722741
validator.setupScope();
723742

743+
validator.waitFor(_bind(function () {
744+
_this.render(validator, validatorName);
745+
validator.validate();
746+
}, this));
747+
748+
if (!this.params.lazy) {
749+
this.vm.$activateValidator();
750+
}
751+
},
752+
render: function render(validator, validatorName) {
724753
this.anchor = _.createAnchor('vue-validator');
725754
_.replace(this.el, this.anchor);
726755
this.insert(validatorName);
727-
728-
this.vm.$on('hook:compiled', function () {
729-
validator.validate();
730-
});
731756
},
732757
insert: function insert(name) {
733758
_.extend(this.vm.$options, { _validator: name });
@@ -770,7 +795,7 @@ function plugin(Vue) {
770795
Validate(Vue);
771796
}
772797

773-
plugin.version = '2.0.0-alpha.7';
798+
plugin.version = '2.0.0-alpha.8';
774799

775800
if (typeof window !== 'undefined' && window.Vue) {
776801
window.Vue.use(plugin);

dist/vue-validator.js

+43-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-validator v2.0.0-alpha.7
2+
* vue-validator v2.0.0-alpha.8
33
* (c) 2015 kazuya kawaguchi
44
* Released under the MIT License.
55
*/
@@ -280,7 +280,9 @@
280280
Vue.config._assetTypes.push('validator');
281281

282282
// set global validators asset
283-
Vue.options.validators = validators;
283+
var assets = Object.create(null);
284+
Vue.util.extend(assets, validators);
285+
Vue.options.validators = assets;
284286

285287
// set option merge strategy
286288
var strats = Vue.config.optionMergeStrategies;
@@ -331,7 +333,9 @@
331333
function Validation(dir) {
332334
babelHelpers.classCallCheck(this, Validation);
333335

334-
this.model = dir.arg;
336+
var camelize = exports$1.Vue.util.camelize;
337+
338+
this.model = camelize(dir.arg);
335339
this.el = dir.el;
336340
this.dir = dir;
337341
this.init = dir.el.value;
@@ -343,23 +347,17 @@
343347

344348
babelHelpers.createClass(Validation, [{
345349
key: 'setValidation',
346-
value: function setValidation(name, arg, msg, fn) {
347-
var resolveAsset = exports$1.Vue.util.resolveAsset;
348-
350+
value: function setValidation(name, arg, msg) {
349351
var validator = this.validators[name];
350352
if (!validator) {
351353
validator = this.validators[name] = {};
352-
validator.fn = resolveAsset(this.dir.vm.$options, 'validators', name);
354+
validator.name = name;
353355
}
354356

355357
validator.arg = arg;
356358
if (msg) {
357359
validator.msg = msg;
358360
}
359-
360-
if (fn) {
361-
validator.fn = fn;
362-
}
363361
}
364362
}, {
365363
key: 'listener',
@@ -391,7 +389,8 @@
391389
var valid = true;
392390

393391
each(this.validators, function (descriptor, name) {
394-
var res = descriptor.fn.call(_this.dir.vm, _this.el.value, descriptor.arg);
392+
var validator = _this._resolveValidator(name);
393+
var res = validator.call(_this.dir.vm, _this.el.value, descriptor.arg);
395394
if (!res) {
396395
valid = false;
397396
var msg = descriptor.msg;
@@ -420,6 +419,12 @@
420419

421420
return ret;
422421
}
422+
}, {
423+
key: '_resolveValidator',
424+
value: function _resolveValidator(name) {
425+
var resolveAsset = exports$1.Vue.util.resolveAsset;
426+
return resolveAsset(this.dir.vm.$options, 'validators', name);
427+
}
423428
}]);
424429
return Validation;
425430
})();
@@ -583,6 +588,17 @@
583588
_this3._defineProperties(validations, group);
584589
}, this);
585590
}
591+
}, {
592+
key: 'waitFor',
593+
value: function waitFor(cb) {
594+
var vm = this._dir.vm;
595+
var method = '$activateValidator';
596+
597+
this._dir.vm[method] = function () {
598+
cb();
599+
vm[method] = null;
600+
};
601+
}
586602
}, {
587603
key: '_defineProperties',
588604
value: function _defineProperties(validations, target) {
@@ -694,11 +710,14 @@
694710
var _ = Vue.util;
695711
var FragmentFactory = Vue.FragmentFactory;
696712
var vIf = Vue.directive('if');
713+
var _bind = Vue.util.bind;
697714

698715
Vue.elementDirective('validator', {
699-
params: ['name', 'groups'],
716+
params: ['name', 'groups', 'lazy'],
700717

701718
bind: function bind() {
719+
var _this = this;
720+
702721
if (!this.params.name) {
703722
// TODO: should be implemented validator:bind name params nothing error'
704723
warn('TODO: should be implemented validator:bind name params nothing error');
@@ -725,13 +744,19 @@
725744
validator.enableReactive();
726745
validator.setupScope();
727746

747+
validator.waitFor(_bind(function () {
748+
_this.render(validator, validatorName);
749+
validator.validate();
750+
}, this));
751+
752+
if (!this.params.lazy) {
753+
this.vm.$activateValidator();
754+
}
755+
},
756+
render: function render(validator, validatorName) {
728757
this.anchor = _.createAnchor('vue-validator');
729758
_.replace(this.el, this.anchor);
730759
this.insert(validatorName);
731-
732-
this.vm.$on('hook:compiled', function () {
733-
validator.validate();
734-
});
735760
},
736761
insert: function insert(name) {
737762
_.extend(this.vm.$options, { _validator: name });
@@ -774,7 +799,7 @@
774799
Validate(Vue);
775800
}
776801

777-
plugin.version = '2.0.0-alpha.7';
802+
plugin.version = '2.0.0-alpha.8';
778803

779804
if (typeof window !== 'undefined' && window.Vue) {
780805
window.Vue.use(plugin);

dist/vue-validator.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-validator",
33
"description": "Validator component for Vue.js",
4-
"version": "2.0.0-alpha.7",
4+
"version": "2.0.0-alpha.8",
55
"author": {
66
"name": "kazuya kawaguchi",
77
"email": "[email protected]"

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function plugin (Vue, options = {}) {
2626
Validate(Vue)
2727
}
2828

29-
plugin.version = '2.0.0-alpha.7'
29+
plugin.version = '2.0.0-alpha.8'
3030

3131
export default plugin
3232

0 commit comments

Comments
 (0)