Comparing version 0.1.5 to 0.2.0
{ | ||
"name": "vue-form", | ||
"version": "0.1.5", | ||
"version": "0.2.0", | ||
"description": "Form validation for Vue.js", | ||
@@ -16,2 +16,3 @@ "main": "vue-form.js", | ||
"karma-babel-preprocessor": "^5.2.2", | ||
"karma-firefox-launcher": "^0.1.7", | ||
"karma-jasmine": "^0.3.6", | ||
@@ -21,4 +22,4 @@ "karma-phantomjs-launcher": "^0.2.1", | ||
"uglify-js": "^2.5.0", | ||
"vue": "^1.0.0-rc.1" | ||
"vue": "^1.0.8" | ||
} | ||
} |
@@ -21,3 +21,3 @@ # vue-form | ||
Apply the `v-form-ctrl` directive to each of the form elements. `v-form-ctrl` will watch `v-model` and validate on change. Use static or binding attributes to specify validators (`required`, `maxlength`, `type="email"`, `type="url"`, etc) | ||
Apply the `v-form-ctrl` directive to each of the form inputs. `v-form-ctrl` will watch `v-model` and validate on change. Use static or binding attributes to specify validators (`required`, `maxlength`, `type="email"`, `type="url"`, etc) | ||
@@ -24,0 +24,0 @@ ```html |
@@ -277,2 +277,88 @@ describe('vue-form', function () { | ||
it('should work with v-for scope', function (done) { | ||
vm.$destroy(); | ||
var vmx = new Vue({ | ||
el: 'body', | ||
replace: false, | ||
template: ` | ||
<form v-form name="myform"> | ||
<label v-for="input in inputs"> | ||
<label> {{input.label}} <br> | ||
<input v-form-ctrl type="text" :name="input.name" v-model="input.model" :required="input.required" /> | ||
</label> | ||
</label> | ||
</form> | ||
`, | ||
data: { | ||
inputs: [{ | ||
label: 'Input A', | ||
name: 'a', | ||
model: '', | ||
required: true | ||
}, { | ||
label: 'Input B', | ||
name: 'b', | ||
model: '', | ||
required: false | ||
}, { | ||
label: 'Input C', | ||
name: 'c', | ||
model: 'abc', | ||
required: true | ||
}], | ||
myform: {} | ||
}, | ||
ready: function () { | ||
setTimeout(function () { | ||
expect(vmx.myform.a.$valid).toBe(false); | ||
expect(vmx.myform.b.$valid).toBe(true); | ||
expect(vmx.myform.c.$valid).toBe(true); | ||
done(); | ||
}, 100); | ||
} | ||
}); | ||
}); | ||
it('should work with v-bind object syntax', function (done) { | ||
vm.$destroy(); | ||
var vmx = new Vue({ | ||
el: 'body', | ||
replace: false, | ||
template: ` | ||
<form v-form name="myform"> | ||
<input v-model="model.a" v-form-ctrl v-bind="{'name': 'a', required: true}" /> | ||
<input v-model="model.b" v-form-ctrl v-bind="{'name': 'b', required: false}" /> | ||
</form> | ||
`, | ||
data: { | ||
model: { | ||
b: 'xxx' | ||
}, | ||
myform: {} | ||
}, | ||
ready: function () { | ||
this.$nextTick(function () { | ||
expect(vmx.myform.a.$valid).toBe(false); | ||
expect(vmx.myform.b.$valid).toBe(true); | ||
/*vmx.model.a = 'aaa'; | ||
vmx.model.b = 'aa'; | ||
this.$nextTick(function () { | ||
console.log(vmx.model); | ||
expect(vmx.myform.a.$valid).toBe(true); | ||
expect(vmx.myform.b.$valid).toBe(false); | ||
done(); | ||
});*/ | ||
done(); | ||
}); | ||
} | ||
}); | ||
}); | ||
}); |
@@ -77,6 +77,6 @@ ; (function () { | ||
min: function (value, min) { | ||
return value >= min; | ||
return value * 1 >= min * 1; | ||
}, | ||
max: function (value, max) { | ||
return max >= value; | ||
return max * 1 >= value * 1; | ||
} | ||
@@ -87,7 +87,7 @@ }; | ||
// if it is a binding, watch it and re-validate on change | ||
function checkAttribute($this, attribute) { | ||
function checkAttribute($this, scope, attribute, objectBinding) { | ||
var vueFormCtrl = $this._vueFormCtrl; | ||
var binding = Vue.util.getBindAttr($this.el, attribute); | ||
var binding = typeof objectBinding[attribute] !== 'undefined' ? objectBinding[attribute] + '' : Vue.util.getBindAttr($this.el, attribute); | ||
if (binding) { | ||
$this.vm.$watch(binding, function (value, oldValue) { | ||
scope.$watch(binding, function (value, oldValue) { | ||
vueFormCtrl[attribute] = value; | ||
@@ -97,2 +97,4 @@ if (attribute === 'type') { | ||
vueFormCtrl.validators[value] = validators[value]; | ||
} else if (attribute === 'custom-validator') { | ||
vueFormCtrl.validators[attribute] = scope.$eval(binding); | ||
} else { | ||
@@ -124,3 +126,3 @@ vueFormCtrl.validators[attribute] = validators[attribute]; | ||
} else if (attribute === 'custom-validator') { | ||
vueFormCtrl.validators[attribute] = $this.vm[staticAttr]; | ||
vueFormCtrl.validators[attribute] = scope[staticAttr]; | ||
} else { | ||
@@ -249,2 +251,3 @@ vueFormCtrl.validators[attribute] = validators[attribute]; | ||
var inputName = this.el.getAttribute('name'), | ||
boundInputName = this.el.getAttribute(':name') || this.el.getAttribute('v-bind:name'), | ||
vModel = this.el.getAttribute('v-model'), | ||
@@ -255,4 +258,29 @@ hook = this.el.getAttribute('hook'), | ||
self = this, | ||
vueForm; | ||
scope, objectBinding; | ||
if (this._scope) { | ||
// is inside loop | ||
scope = this._scope; | ||
} else { | ||
scope = this.vm; | ||
} | ||
if (boundInputName) { | ||
scope.$watch(boundInputName, function (value) { | ||
inputName = value; | ||
}, { | ||
immediate: true | ||
}); | ||
} | ||
el._vue_directives.forEach(function (directive) { | ||
// is object syntax | ||
if (directive.name === 'bind' && !directive.arg) { | ||
objectBinding = directive.vm.$eval(directive.expression); | ||
if (objectBinding.name) { | ||
inputName = objectBinding.name; | ||
} | ||
} | ||
}); | ||
if (!inputName) { | ||
@@ -279,2 +307,6 @@ console.warn('Name attribute must be populated'); | ||
if (!vueForm) { | ||
return; | ||
} | ||
if (typeof key === 'boolean') { | ||
@@ -293,7 +325,8 @@ // when key is boolean, we are setting | ||
Vue.util.addClass(el, invalidClass); | ||
} | ||
vueForm.checkValidity(); | ||
} | ||
vueForm.checkValidity(); | ||
return; | ||
} | ||
key = Vue.util.camelize(key); | ||
if (isValid) { | ||
@@ -305,3 +338,3 @@ vueForm.setData(inputName + '.$error.' + key, false); | ||
vueForm.setData(inputName + '.$error.' + key, true); | ||
vueForm.setData('$error.' + inputName, state); | ||
vueForm.setData('$error.' + inputName, state); | ||
Vue.util.addClass(el, invalidClass + '-' + key); | ||
@@ -328,2 +361,4 @@ } | ||
_this = this; | ||
//console.log('value', value) | ||
@@ -340,3 +375,3 @@ Object.keys(this.validators).forEach(function (validator) { | ||
return; | ||
} | ||
} | ||
@@ -373,6 +408,6 @@ // if not the required validator and value is | ||
attrs.forEach(function (attr) { | ||
checkAttribute(self, attr); | ||
}); | ||
checkAttribute(self, scope, attr, objectBinding || {}); | ||
}); | ||
// find parent form | ||
// find parent form | ||
var form; | ||
@@ -389,6 +424,6 @@ if (el.form) { | ||
// must be detached | ||
Vue.nextTick(function () { | ||
setTimeout(function () { | ||
form = el.form || closest(el, 'form[name]'); | ||
init(form._vueForm); | ||
}); | ||
}, 0); | ||
} | ||
@@ -413,3 +448,3 @@ } | ||
if (vModel) { | ||
self.vm.$watch(vModel, function (value, oldValue) { | ||
scope.$watch(vModel, function (value, oldValue) { | ||
if (!first) { | ||
@@ -432,2 +467,5 @@ vueFormCtrl.setDirty(); | ||
update: function (value, oldValue) { | ||
if (typeof value === 'undefined') { | ||
return; | ||
} | ||
if (this._notfirst) { | ||
@@ -434,0 +472,0 @@ this._vueFormCtrl.setDirty(); |
@@ -1,1 +0,1 @@ | ||
!function(){var vueForm={};vueForm.install=function(Vue){function closest(elem,selector){for(var matchesSelector=elem.matches||elem.webkitMatchesSelector||elem.mozMatchesSelector||elem.msMatchesSelector;elem;){if(matchesSelector.call(elem,selector))return elem;elem=elem.parentElement}return null}function removeClassWithPrefix(el,prefix){var classes=el.className.split(" ").filter(function(c){return 0!==c.lastIndexOf(prefix,0)});el.className=classes.join(" ").trim()}function checkAttribute($this,attribute){var vueFormCtrl=$this._vueFormCtrl,binding=Vue.util.getBindAttr($this.el,attribute);binding&&$this.vm.$watch(binding,function(value,oldValue){vueFormCtrl[attribute]=value,"type"===attribute?(delete vueFormCtrl.validators[oldValue],vueFormCtrl.validators[value]=validators[value]):(vueFormCtrl.validators[attribute]=validators[attribute],(value===!1||"undefined"==typeof value)&&(vueFormCtrl.validators[attribute]=!1)),$this._vueForm?vueFormCtrl.validate($this._value):Vue.nextTick(function(){Vue.nextTick(function(){vueFormCtrl.validate($this._value)})})},{immediate:!0});var staticAttr=$this.el.getAttribute(attribute);null!==staticAttr&&(vueFormCtrl[attribute]=staticAttr||!0,"type"===attribute?vueFormCtrl.validators[staticAttr]=validators[staticAttr]:"custom-validator"===attribute?vueFormCtrl.validators[attribute]=$this.vm[staticAttr]:vueFormCtrl.validators[attribute]=validators[attribute])}var emailRegExp=/^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i,urlRegExp=/^(http\:\/\/|https\:\/\/)(.{4,})$/,dirtyClass="vf-dirty",pristineClass="vf-pristine",validClass="vf-valid",invalidClass="vf-invalid",submittedClass="vf-submitted",attrs=["type","required","pattern","multiple","minlength","maxlength","min","max","custom-validator"],attrsWithValue=["minlength","maxlength","min","max","pattern"],validators={required:function(value){return Vue.util.isArray(value)?!!value.length:!!value},email:function(value,multiple){return emailRegExp.test(value)},number:function(value){return!isNaN(value)},url:function(value){return urlRegExp.test(value)},minlength:function(value,length){return value.length>=length},maxlength:function(value,length){return length>=value.length},pattern:function(value,pattern){var patternRegExp=new RegExp("^"+pattern+"$");return patternRegExp.test(value)},min:function(value,min){return value>=min},max:function(value,max){return max>=value}};Vue.directive("form",{id:"form",priority:10001,bind:function(){var el=this.el,formName=el.getAttribute("name"),hook=el.getAttribute("hook"),vm=this.vm,controls={};el.noValidate=!0;var state=this._state={$name:formName,$dirty:!1,$pristine:!0,$valid:!0,$invalid:!1,$submitted:!1,$error:{}};vm.$set(formName,state),Vue.util.addClass(el,pristineClass),Vue.util.addClass(el,validClass);var vueForm=this.el._vueForm={name:formName,state:state,addControl:function(ctrl){controls[ctrl.name]=ctrl},removeControl:function(ctrl){this.removeError(ctrl.name),delete controls[ctrl.name],this.checkValidity()},setData:function(key,data){vm.$set(formName+"."+key,data)},removeError:function(key){state.$error[key]=!1,delete state.$error[key]},checkValidity:function(){var isValid=!0;Object.keys(controls).forEach(function(ctrl){controls[ctrl].state.$invalid&&(isValid=!1)}),this.setValidity(isValid)},setValidity:function(isValid){state.$valid=isValid,state.$invalid=!isValid,isValid?(Vue.util.addClass(el,validClass),Vue.util.removeClass(el,invalidClass),removeClassWithPrefix(el,invalidClass+"-")):(Vue.util.removeClass(el,validClass),Vue.util.addClass(el,invalidClass))},setDirty:function(){state.$dirty=!0,state.$pristine=!1,Vue.util.addClass(el,dirtyClass),Vue.util.removeClass(el,pristineClass)},setPristine:function(){state.$dirty=!1,state.$pristine=!0,Object.keys(controls).forEach(function(ctrl){controls[ctrl].setPristine()}),vueForm.setSubmitted(!1),Vue.util.removeClass(el,dirtyClass),Vue.util.addClass(el,pristineClass)},setSubmitted:function(isSubmitted){state.$submitted=isSubmitted,isSubmitted?Vue.util.addClass(el,submittedClass):Vue.util.removeClass(el,submittedClass)}};hook&&vm[hook](vueForm),this._submitEvent=function(){vueForm.setSubmitted(!0)},Vue.util.on(el,"submit",this._submitEvent)},update:function(){},unbind:function(){Vue.util.off(this.el,"submit",this._submitEvent),delete this.el._vueForm}}),Vue.directive("formCtrl",{id:"formCtrl",priority:1e4,bind:function(){function init(vueForm){if(vueForm){self._vueForm=vueForm,vueForm.addControl(vueFormCtrl),vueForm.setData(inputName,state),Vue.util.addClass(el,pristineClass),Vue.util.addClass(el,validClass);var first=!0;vModel&&self.vm.$watch(vModel,function(value,oldValue){first||vueFormCtrl.setDirty(),first=!1,vueFormCtrl.validate(value),self._value=value},{immediate:!0})}}var inputName=this.el.getAttribute("name"),vModel=this.el.getAttribute("v-model"),hook=this.el.getAttribute("hook"),vm=this.vm,el=this.el,self=this;if(!inputName)return void console.warn("Name attribute must be populated");var state=self._state={$name:inputName,$dirty:!1,$pristine:!0,$valid:!0,$invalid:!1,$error:{}},vueFormCtrl=el._vueFormCtrl=self._vueFormCtrl={el:el,name:inputName,state:state,setVadility:function(key,isValid){var vueForm=self._vueForm;return"boolean"==typeof key?(state.$valid=isValid,state.$invalid=!isValid,isValid?(vueForm.removeError(inputName),Vue.util.addClass(el,validClass),Vue.util.removeClass(el,invalidClass)):(Vue.util.removeClass(el,validClass),Vue.util.addClass(el,invalidClass)),void vueForm.checkValidity()):void(isValid?(vueForm.setData(inputName+".$error."+key,!1),delete state.$error[key],removeClassWithPrefix(el,invalidClass+"-")):(vueForm.setData(inputName+".$error."+key,!0),vueForm.setData("$error."+inputName,state),Vue.util.addClass(el,invalidClass+"-"+key)))},setDirty:function(){state.$dirty=!0,state.$pristine=!1,self._vueForm.setDirty(),Vue.util.addClass(el,dirtyClass),Vue.util.removeClass(el,pristineClass)},setPristine:function(){state.$dirty=!1,state.$pristine=!0,Vue.util.removeClass(el,dirtyClass),Vue.util.addClass(el,pristineClass)},validators:{},error:{},validate:function(value){var isValid=!0,_this=this;return Object.keys(this.validators).forEach(function(validator){var args=[value];if(_this.validators[validator]===!1)return void _this.setVadility(validator,!0);if(_this.validators[validator]){if("required"!==validator&&!value&&"number"!=typeof value)return void _this.setVadility(validator,!0);"email"===validator?args.push(_this.multiple):-1!==attrsWithValue.indexOf(validator)&&args.push(_this[validator]),_this.validators[validator].apply(this,args)?_this.setVadility(validator,!0):(isValid=!1,_this.setVadility(validator,!1))}}),_this.setVadility(!0,isValid),isValid}};attrs.forEach(function(attr){checkAttribute(self,attr)});var form;el.form?init(el.form._vueForm):(form=closest(el,"form[name]"),form&&form._vueForm?init(form._vueForm):Vue.nextTick(function(){form=el.form||closest(el,"form[name]"),init(form._vueForm)})),hook&&vm[hook](vueFormCtrl)},update:function(value,oldValue){this._notfirst&&this._vueFormCtrl.setDirty(),this._notfirst=!0,this._vueFormCtrl.validate(value),this._value=value},unbind:function(){this._vueForm.removeControl(this._vueFormCtrl),delete this.el._vueFormCtrl}})},"object"==typeof exports?module.exports=vueForm:"function"==typeof define&&define.amd?define([],function(){return vueForm}):window.Vue&&(window.vueForm=vueForm,Vue.use(vueForm))}(); | ||
!function(){var vueForm={};vueForm.install=function(Vue){function closest(elem,selector){for(var matchesSelector=elem.matches||elem.webkitMatchesSelector||elem.mozMatchesSelector||elem.msMatchesSelector;elem;){if(matchesSelector.call(elem,selector))return elem;elem=elem.parentElement}return null}function removeClassWithPrefix(el,prefix){var classes=el.className.split(" ").filter(function(c){return 0!==c.lastIndexOf(prefix,0)});el.className=classes.join(" ").trim()}function checkAttribute($this,scope,attribute,objectBinding){var vueFormCtrl=$this._vueFormCtrl,binding="undefined"!=typeof objectBinding[attribute]?objectBinding[attribute]+"":Vue.util.getBindAttr($this.el,attribute);binding&&scope.$watch(binding,function(value,oldValue){vueFormCtrl[attribute]=value,"type"===attribute?(delete vueFormCtrl.validators[oldValue],vueFormCtrl.validators[value]=validators[value]):"custom-validator"===attribute?vueFormCtrl.validators[attribute]=scope.$eval(binding):(vueFormCtrl.validators[attribute]=validators[attribute],(value===!1||"undefined"==typeof value)&&(vueFormCtrl.validators[attribute]=!1)),$this._vueForm?vueFormCtrl.validate($this._value):Vue.nextTick(function(){Vue.nextTick(function(){vueFormCtrl.validate($this._value)})})},{immediate:!0});var staticAttr=$this.el.getAttribute(attribute);null!==staticAttr&&(vueFormCtrl[attribute]=staticAttr||!0,"type"===attribute?vueFormCtrl.validators[staticAttr]=validators[staticAttr]:"custom-validator"===attribute?vueFormCtrl.validators[attribute]=scope[staticAttr]:vueFormCtrl.validators[attribute]=validators[attribute])}var emailRegExp=/^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i,urlRegExp=/^(http\:\/\/|https\:\/\/)(.{4,})$/,dirtyClass="vf-dirty",pristineClass="vf-pristine",validClass="vf-valid",invalidClass="vf-invalid",submittedClass="vf-submitted",attrs=["type","required","pattern","multiple","minlength","maxlength","min","max","custom-validator"],attrsWithValue=["minlength","maxlength","min","max","pattern"],validators={required:function(value){return Vue.util.isArray(value)?!!value.length:!!value},email:function(value,multiple){return emailRegExp.test(value)},number:function(value){return!isNaN(value)},url:function(value){return urlRegExp.test(value)},minlength:function(value,length){return value.length>=length},maxlength:function(value,length){return length>=value.length},pattern:function(value,pattern){var patternRegExp=new RegExp("^"+pattern+"$");return patternRegExp.test(value)},min:function(value,min){return 1*value>=1*min},max:function(value,max){return 1*max>=1*value}};Vue.directive("form",{id:"form",priority:10001,bind:function(){var el=this.el,formName=el.getAttribute("name"),hook=el.getAttribute("hook"),vm=this.vm,controls={};el.noValidate=!0;var state=this._state={$name:formName,$dirty:!1,$pristine:!0,$valid:!0,$invalid:!1,$submitted:!1,$error:{}};vm.$set(formName,state),Vue.util.addClass(el,pristineClass),Vue.util.addClass(el,validClass);var vueForm=this.el._vueForm={name:formName,state:state,addControl:function(ctrl){controls[ctrl.name]=ctrl},removeControl:function(ctrl){this.removeError(ctrl.name),delete controls[ctrl.name],this.checkValidity()},setData:function(key,data){vm.$set(formName+"."+key,data)},removeError:function(key){state.$error[key]=!1,delete state.$error[key]},checkValidity:function(){var isValid=!0;Object.keys(controls).forEach(function(ctrl){controls[ctrl].state.$invalid&&(isValid=!1)}),this.setValidity(isValid)},setValidity:function(isValid){state.$valid=isValid,state.$invalid=!isValid,isValid?(Vue.util.addClass(el,validClass),Vue.util.removeClass(el,invalidClass),removeClassWithPrefix(el,invalidClass+"-")):(Vue.util.removeClass(el,validClass),Vue.util.addClass(el,invalidClass))},setDirty:function(){state.$dirty=!0,state.$pristine=!1,Vue.util.addClass(el,dirtyClass),Vue.util.removeClass(el,pristineClass)},setPristine:function(){state.$dirty=!1,state.$pristine=!0,Object.keys(controls).forEach(function(ctrl){controls[ctrl].setPristine()}),vueForm.setSubmitted(!1),Vue.util.removeClass(el,dirtyClass),Vue.util.addClass(el,pristineClass)},setSubmitted:function(isSubmitted){state.$submitted=isSubmitted,isSubmitted?Vue.util.addClass(el,submittedClass):Vue.util.removeClass(el,submittedClass)}};hook&&vm[hook](vueForm),this._submitEvent=function(){vueForm.setSubmitted(!0)},Vue.util.on(el,"submit",this._submitEvent)},update:function(){},unbind:function(){Vue.util.off(this.el,"submit",this._submitEvent),delete this.el._vueForm}}),Vue.directive("formCtrl",{id:"formCtrl",priority:1e4,bind:function(){function init(vueForm){if(vueForm){self._vueForm=vueForm,vueForm.addControl(vueFormCtrl),vueForm.setData(inputName,state),Vue.util.addClass(el,pristineClass),Vue.util.addClass(el,validClass);var first=!0;vModel&&scope.$watch(vModel,function(value,oldValue){first||vueFormCtrl.setDirty(),first=!1,vueFormCtrl.validate(value),self._value=value},{immediate:!0})}}var scope,objectBinding,inputName=this.el.getAttribute("name"),boundInputName=this.el.getAttribute(":name")||this.el.getAttribute("v-bind:name"),vModel=this.el.getAttribute("v-model"),hook=this.el.getAttribute("hook"),vm=this.vm,el=this.el,self=this;if(scope=this._scope?this._scope:this.vm,boundInputName&&scope.$watch(boundInputName,function(value){inputName=value},{immediate:!0}),el._vue_directives.forEach(function(directive){"bind"!==directive.name||directive.arg||(objectBinding=directive.vm.$eval(directive.expression),objectBinding.name&&(inputName=objectBinding.name))}),!inputName)return void console.warn("Name attribute must be populated");var state=self._state={$name:inputName,$dirty:!1,$pristine:!0,$valid:!0,$invalid:!1,$error:{}},vueFormCtrl=el._vueFormCtrl=self._vueFormCtrl={el:el,name:inputName,state:state,setVadility:function(key,isValid){var vueForm=self._vueForm;if(vueForm){if("boolean"==typeof key)return state.$valid=isValid,state.$invalid=!isValid,isValid?(vueForm.removeError(inputName),Vue.util.addClass(el,validClass),Vue.util.removeClass(el,invalidClass)):(Vue.util.removeClass(el,validClass),Vue.util.addClass(el,invalidClass)),void vueForm.checkValidity();key=Vue.util.camelize(key),isValid?(vueForm.setData(inputName+".$error."+key,!1),delete state.$error[key],removeClassWithPrefix(el,invalidClass+"-")):(vueForm.setData(inputName+".$error."+key,!0),vueForm.setData("$error."+inputName,state),Vue.util.addClass(el,invalidClass+"-"+key))}},setDirty:function(){state.$dirty=!0,state.$pristine=!1,self._vueForm.setDirty(),Vue.util.addClass(el,dirtyClass),Vue.util.removeClass(el,pristineClass)},setPristine:function(){state.$dirty=!1,state.$pristine=!0,Vue.util.removeClass(el,dirtyClass),Vue.util.addClass(el,pristineClass)},validators:{},error:{},validate:function(value){var isValid=!0,_this=this;return Object.keys(this.validators).forEach(function(validator){var args=[value];if(_this.validators[validator]===!1)return void _this.setVadility(validator,!0);if(_this.validators[validator]){if("required"!==validator&&!value&&"number"!=typeof value)return void _this.setVadility(validator,!0);"email"===validator?args.push(_this.multiple):-1!==attrsWithValue.indexOf(validator)&&args.push(_this[validator]),_this.validators[validator].apply(this,args)?_this.setVadility(validator,!0):(isValid=!1,_this.setVadility(validator,!1))}}),_this.setVadility(!0,isValid),isValid}};attrs.forEach(function(attr){checkAttribute(self,scope,attr,objectBinding||{})});var form;el.form?init(el.form._vueForm):(form=closest(el,"form[name]"),form&&form._vueForm?init(form._vueForm):setTimeout(function(){form=el.form||closest(el,"form[name]"),init(form._vueForm)},0)),hook&&vm[hook](vueFormCtrl)},update:function(value,oldValue){"undefined"!=typeof value&&(this._notfirst&&this._vueFormCtrl.setDirty(),this._notfirst=!0,this._vueFormCtrl.validate(value),this._value=value)},unbind:function(){this._vueForm.removeControl(this._vueFormCtrl),delete this.el._vueFormCtrl}})},"object"==typeof exports?module.exports=vueForm:"function"==typeof define&&define.amd?define([],function(){return vueForm}):window.Vue&&(window.vueForm=vueForm,Vue.use(vueForm))}(); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61145
14
858
9