diff --git a/dist/validators.min.js b/dist/validators.min.js index a07d0613..bcc2206f 100644 --- a/dist/validators.min.js +++ b/dist/validators.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.validators=t():e.validators=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var u=r[n]={exports:{},id:n,loaded:!1};return e[n].call(u.exports,u,u.exports,t),u.loaded=!0,u.exports}var r={};return t.m=e,t.c=r,t.p="/",t(0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.maxValue=t.minValue=t.and=t.or=t.url=t.sameAs=t.requiredUnless=t.requiredIf=t.required=t.minLength=t.maxLength=t.macAddress=t.ipAddress=t.email=t.between=t.numeric=t.alphaNum=t.alpha=void 0;var u=r(3),a=n(u),i=r(4),f=n(i),o=r(14),d=n(o),l=r(6),s=n(l),c=r(7),p=n(c),v=r(8),y=n(v),h=r(9),m=n(h),_=r(10),P=n(_),g=r(12),b=n(g),j=r(16),w=n(j),x=r(17),M=n(x),O=r(18),q=n(O),A=r(19),z=n(A),$=r(20),L=n($),V=r(15),N=n(V),S=r(5),D=n(S),Z=r(13),I=n(Z),U=r(11),k=n(U);t.alpha=a.default,t.alphaNum=f.default,t.numeric=d.default,t.between=s.default,t.email=p.default,t.ipAddress=y.default,t.macAddress=m.default,t.maxLength=P.default,t.minLength=b.default,t.required=w.default,t.requiredIf=M.default,t.requiredUnless=q.default,t.sameAs=z.default,t.url=L.default,t.or=N.default,t.and=D.default,t.minValue=I.default,t.maxValue=k.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.regex=t.ref=t.len=t.req=t.withParams=void 0;var u=r(22),a=n(u);t.withParams=a.default;var i=t.req=function(e){if(Array.isArray(e))return!!e.length;if(void 0===e||null===e||e===!1)return!1;if(e instanceof Date)return!isNaN(e.getTime());if("object"==typeof e){for(var t in e)return!0;return!1}return!!String(e).length};t.len=function(e){return Array.isArray(e)?e.length:"object"==typeof e?Object.keys(e).length:String(e).length},t.ref=function(e,t,r){return"function"==typeof e?e.call(t,r):r[e]},t.regex=function(e,t){return(0,a.default)({type:e},function(e){return!i(e)||t.test(e)})}},,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=(0,n.regex)("alpha",/^[a-zA-Z]*$/)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=(0,n.regex)("alphaNum",/^[a-zA-Z0-9]*$/)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(){for(var e=arguments.length,t=Array(e),r=0;r0&&t.reduce(function(t,r){return t&&r.apply(e,n)},!0)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(e,t){return(0,n.withParams)({type:"between",min:e,max:t},function(r){return!(0,n.req)(r)||(!/\s/.test(r)||r instanceof Date)&&+e<=+r&&+t>=+r})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1),u=/(^$|^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$)/;t.default=(0,n.regex)("email",u)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=(0,n.withParams)({type:"ipAddress"},function(e){if(!(0,n.req)(e))return!0;if("string"!=typeof e)return!1;var t=e.split(".");return 4===t.length&&t.every(u)});var u=function(e){if(e.length>3||0===e.length)return!1;if("0"===e[0]&&"0"!==e)return!1;if(!e.match(/^\d+$/))return!1;var t=0|+e;return t>=0&&t<=255}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:":";return(0,n.withParams)({type:"macAddress"},function(t){if(!(0,n.req)(t))return!0;if("string"!=typeof t)return!1;var r="string"==typeof e&&""!==e?t.split(e):12===t.length||16===t.length?t.match(/.{2}/g):null;return null!==r&&(6===r.length||8===r.length)&&r.every(u)})};var u=function(e){return e.toLowerCase().match(/^[0-9a-f]{2}$/)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(e){return(0,n.withParams)({type:"maxLength",max:e},function(t){return!(0,n.req)(t)||(0,n.len)(t)<=e})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(e){return(0,n.withParams)({type:"maxValue",max:e},function(t){return!(0,n.req)(t)||(!/\s/.test(t)||t instanceof Date)&&+t<=+e})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(e){return(0,n.withParams)({type:"minLength",min:e},function(t){return!(0,n.req)(t)||(0,n.len)(t)>=e})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(e){return(0,n.withParams)({type:"minValue",min:e},function(t){return!(0,n.req)(t)||(!/\s/.test(t)||t instanceof Date)&&+t>=+e})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=(0,n.regex)("numeric",/^[0-9]*$/)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(){for(var e=arguments.length,t=Array(e),r=0;r0&&t.reduce(function(t,r){return t||r.apply(e,n)},!1)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=(0,n.withParams)({type:"required"},n.req)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(e){return(0,n.withParams)({type:"requiredIf",prop:e},function(t,r){return!(0,n.ref)(e,this,r)||(0,n.req)(t)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(e){return(0,n.withParams)({type:"requiredUnless",prop:e},function(t,r){return!!(0,n.ref)(e,this,r)||(0,n.req)(t)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(e){return(0,n.withParams)({type:"sameAs",eq:e},function(t,r){return t===(0,n.ref)(e,this,r)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1),u=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:[\/?#]\S*)?$/;t.default=(0,n.regex)("url",u)},,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(23).withParams;t.default=n},function(e,t){(function(e){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r="undefined"!=typeof e?e:"undefined"!=typeof window?window:{},n=function(e,t){return"object"==typeof e&&void 0!==t?t:e(function(){})};t.withParams=r.vuelidate?r.vuelidate.withParams:n}).call(t,function(){return this}())}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.validators=t():e.validators=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var u=r[n]={exports:{},id:n,loaded:!1};return e[n].call(u.exports,u,u.exports,t),u.loaded=!0,u.exports}var r={};return t.m=e,t.c=r,t.p="/",t(0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.maxValue=t.minValue=t.and=t.or=t.url=t.sameAs=t.requiredUnless=t.requiredIf=t.required=t.minLength=t.maxLength=t.macAddress=t.ipAddress=t.email=t.between=t.numeric=t.alphaNum=t.alpha=void 0;var u=r(3),a=n(u),i=r(4),f=n(i),o=r(14),d=n(o),l=r(6),s=n(l),c=r(7),p=n(c),v=r(8),y=n(v),h=r(9),m=n(h),_=r(10),P=n(_),g=r(12),b=n(g),j=r(16),w=n(j),x=r(17),M=n(x),O=r(18),q=n(O),A=r(19),z=n(A),$=r(20),L=n($),V=r(15),N=n(V),S=r(5),D=n(S),Z=r(13),I=n(Z),U=r(11),k=n(U);t.alpha=a.default,t.alphaNum=f.default,t.numeric=d.default,t.between=s.default,t.email=p.default,t.ipAddress=y.default,t.macAddress=m.default,t.maxLength=P.default,t.minLength=b.default,t.required=w.default,t.requiredIf=M.default,t.requiredUnless=q.default,t.sameAs=z.default,t.url=L.default,t.or=N.default,t.and=D.default,t.minValue=I.default,t.maxValue=k.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.regex=t.ref=t.len=t.req=t.withParams=void 0;var u=r(22),a=n(u);t.withParams=a.default;var i=t.req=function(e){if(Array.isArray(e))return!!e.length;if(void 0===e||null===e||e===!1)return!1;if(e instanceof Date)return!isNaN(e.getTime());if("object"==typeof e){for(var t in e)return!0;return!1}return!!String(e).length};t.len=function(e){return Array.isArray(e)?e.length:"object"==typeof e?Object.keys(e).length:String(e).length},t.ref=function(e,t,r){return"function"==typeof e?e.call(t,r):r[e]},t.regex=function(e,t){return(0,a.default)({type:e},function(e){return!i(e)||t.test(e)})}},,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=(0,n.regex)("alpha",/^[a-zA-Z]*$/)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=(0,n.regex)("alphaNum",/^[a-zA-Z0-9]*$/)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(){for(var e=arguments.length,t=Array(e),r=0;r0&&t.reduce(function(t,r){return t&&r.apply(e,n)},!0)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(e,t){return(0,n.withParams)({type:"between",min:e,max:t},function(r){return!(0,n.req)(r)||(!/\s/.test(r)||r instanceof Date)&&+e<=+r&&+t>=+r})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1),u=/(^$|^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$)/;t.default=(0,n.regex)("email",u)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=(0,n.withParams)({type:"ipAddress"},function(e){if(!(0,n.req)(e))return!0;if("string"!=typeof e)return!1;var t=e.split(".");return 4===t.length&&t.every(u)});var u=function(e){if(e.length>3||0===e.length)return!1;if("0"===e[0]&&"0"!==e)return!1;if(!e.match(/^\d+$/))return!1;var t=0|+e;return t>=0&&t<=255}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:":";return(0,n.withParams)({type:"macAddress"},function(t){if(!(0,n.req)(t))return!0;if("string"!=typeof t)return!1;var r="string"==typeof e&&""!==e?t.split(e):12===t.length||16===t.length?t.match(/.{2}/g):null;return null!==r&&(6===r.length||8===r.length)&&r.every(u)})};var u=function(e){return e.toLowerCase().match(/^[0-9a-f]{2}$/)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(e){return(0,n.withParams)({type:"maxLength",max:e},function(t){return!(0,n.req)(t)||(0,n.len)(t)<=e})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(e){return(0,n.withParams)({type:"maxValue",max:e},function(t){return!(0,n.req)(t)||(!/\s/.test(t)||t instanceof Date)&&+t<=+e})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(e){return(0,n.withParams)({type:"minLength",min:e},function(t){return!(0,n.req)(t)||(0,n.len)(t)>=e})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(e){return(0,n.withParams)({type:"minValue",min:e},function(t){return!(0,n.req)(t)||(!/\s/.test(t)||t instanceof Date)&&+t>=+e})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=(0,n.regex)("numeric",/^[0-9]*$/)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(){for(var e=arguments.length,t=Array(e),r=0;r0&&t.reduce(function(t,r){return t||r.apply(e,n)},!1)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=(0,n.withParams)({type:"required"},n.req)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(e){return(0,n.withParams)({type:"requiredIf",prop:e},function(t,r){return!(0,n.ref)(e,this,r)||(0,n.req)(t)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(e){return(0,n.withParams)({type:"requiredUnless",prop:e},function(t,r){return!!(0,n.ref)(e,this,r)||(0,n.req)(t)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);t.default=function(e){return(0,n.withParams)({type:"sameAs",eq:e},function(t,r){return t===(0,n.ref)(e,this,r)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1),u=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:[\/?#]\S*)?$/i;t.default=(0,n.regex)("url",u)},,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(23).withParams;t.default=n},function(e,t){(function(e){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r="undefined"!=typeof e?e:"undefined"!=typeof window?window:{},n=function(e,t){return"object"==typeof e&&void 0!==t?t:e(function(){})};t.withParams=r.vuelidate?r.vuelidate.withParams:n}).call(t,function(){return this}())}])}); \ No newline at end of file diff --git a/dist/vuelidate.min.js b/dist/vuelidate.min.js index 2bf076d9..2a6879ac 100644 --- a/dist/vuelidate.min.js +++ b/dist/vuelidate.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.vuelidate=e():t.vuelidate=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="/",e(0)}({0:function(t,e,n){"use strict";function r(t){return"function"==typeof t}function o(t){return null!==t&&("object"==typeof t||r(t))}function i(t){return o(t)&&r(t.then)}function u(t,e){var n=new t({data:{p:!0,v:!1}});return e.then(function(t){n.p=!1,n.v=t},function(t){throw n.p=!1,n.v=!1,t}),n[p]=!0,n}function a(t){this.dirty=t;var e=this.proxy,n=t?"$touch":"$reset";this.nestedKeys.forEach(function(t){e[t][n]()})}function l(t){if(x)return x;for(var e=t.constructor;e.super;)e=e.super;return x=e,e}function s(t){t.mixin(k)}Object.defineProperty(e,"__esModule",{value:!0}),e.withParams=e.validationMixin=e.Vuelidate=void 0;var f=Object.assign||function(t){for(var e=1;e1?a:a.$sub[0]:null;return{output:o,params:l}}},computed:{run:function(){return this.runRule(this.lazyParentModel())},$params:function(){return this.run.params},proxy:function(){var t=this.run.output;return t[p]?!!t.v:!!t},$pending:function(){var t=this.run.output;return!!t[p]&&t.p}}}),r=e.extend({data:function(){return{dirty:!1,validations:null,lazyModel:null,model:null,prop:null,lazyParentModel:null,rootModel:null}},methods:f({},g,{refProxy:function(t){return this.getRef(t).proxy},getRef:function(t){return this.refs[t]},isNested:function(t){return"function"!=typeof this.validations[t]}}),computed:f({},m,{nestedKeys:function(){return this.keys.filter(this.isNested)},ruleKeys:function(){var t=this;return this.keys.filter(function(e){return!t.isNested(e)})},keys:function(){return Object.keys(this.validations).filter(function(t){return"$params"!==t})},proxy:function(){var t=this,e=v(this.keys,function(e){return{enumerable:!0,configurable:!1,get:function(){return t.refProxy(e)}}}),n=v(M,function(e){return{enumerable:!0,configurable:!1,get:function(){return t[e]}}}),r=v($,function(e){return{enumerable:!1,configurable:!1,get:function(){return t[e]}}});return Object.defineProperties({},f({},e,n,r))},children:function(){var t=this;return[].concat(this.nestedKeys.map(function(e){return s(t,e)}),this.ruleKeys.map(function(e){return P(t,e)})).filter(Boolean)}})}),a=r.extend({methods:{isNested:function(t){return"undefined"!=typeof this.validations[t]()},getRef:function(t){var e=this;return{get proxy(){return e.validations[t]()||!1}}}}}),l=r.extend({computed:{keys:function(){var t=this.getModel();return o(t)?Object.keys(t):[]},tracker:function(){var t=this,e=this.validations.$trackBy;return e?function(n){return""+y(t.rootModel,t.getModelKey(n),e)}:function(t){return""+t}},eagerParentModel:function(){var t=this.lazyParentModel();return function(){return t}},children:function(){var t=this,e=this.validations,n=this.getModel(),o=f({},e);delete o.$trackBy;var i={};return this.keys.map(function(e){var u=t.tracker(e);return i.hasOwnProperty(u)?null:(i[u]=!0,(0,c.h)(r,u,{validations:o,prop:e,lazyParentModel:t.eagerParentModel,model:n[e],rootModel:t.rootModel}))}).filter(Boolean)}},methods:{isNested:function(){return!0},getRef:function(t){return this.refs[this.tracker(t)]}}}),s=function(t,e){if("$each"===e)return(0,c.h)(l,e,{validations:t.validations[e],lazyParentModel:t.lazyParentModel,prop:e,lazyModel:t.getModel,rootModel:t.rootModel});var n=t.validations[e];if(Array.isArray(n)){var o=t.rootModel,i=v(n,function(t){return function(){return y(o,o.$v,t)}},function(t){return Array.isArray(t)?t.join("."):t});return(0,c.h)(a,e,{validations:i,lazyParentModel:h,prop:e,lazyModel:h,rootModel:o})}return(0,c.h)(r,e,{validations:n,lazyParentModel:t.getModel,prop:e,lazyModel:t.getModelKey,rootModel:t.rootModel})},P=function(t,e){return(0,c.h)(n,e,{rule:t.validations[e],lazyParentModel:t.lazyParentModel,lazyModel:t.getModel,rootModel:t.rootModel})};return b={VBase:e,Validation:r}},x=null,j=function(t,e){var n=l(t),r=P(n),o=r.Validation,i=r.VBase,u=new i({computed:{children:function(){var n="function"==typeof e?e.call(t):e;return[(0,c.h)(o,"$v",{validations:n,lazyParentModel:h,prop:"$v",model:t,rootModel:t})]}}});return u},k={data:function(){var t=this.$options.validations;return t&&(this._vuelidate=j(this,t)),{}},beforeCreate:function(){var t=this,e=this.$options,n=e.validations;n&&(e.computed||(e.computed={}),e.computed.$v=function(){return t._vuelidate.refs.$v.proxy})},beforeDestroy:function(){this._vuelidate&&(this._vuelidate.$destroy(),this._vuelidate=null)}};e.Vuelidate=s,e.validationMixin=k,e.withParams=d.withParams,e.default=s},2:function(t,e){"use strict";function n(){null!==f&&s.push(f),e.target=f={}}function r(){var t=f,n=e.target=f=s.pop()||null;return n&&(Array.isArray(n.$sub)||(n.$sub=[]),n.$sub.push(t)),t}function o(t){if("object"!=typeof t||Array.isArray(t))throw new Error("params must be an object");e.target=f=l({},f,t)}function i(t,e){return u(function(n){return function(){n(t);for(var r=arguments.length,o=Array(r),i=0;id?s(e,l,y):l>y&&f(t,u,d)}function s(t,e,n){for(;e<=n;++e)i(t[e])}function f(t,e,n){for(;e<=n;++e){var o=t[e];r(o)&&(o.vm.$destroy(),o.vm=null)}}function c(t,e){t!==e&&(e.vm=t.vm,u(e))}function d(t,e){r(t)&&r(e)?t!==e&&l(t,e):r(e)?s(e,0,e.length-1):r(t)&&f(t,0,t.length-1)}function h(t,e,n){return{tag:t,key:e,args:n}}Object.defineProperty(e,"__esModule",{value:!0}),e.patchChildren=d,e.h=h}})}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.vuelidate=e():t.vuelidate=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="/",e(0)}({0:function(t,e,n){"use strict";function r(t){return"function"==typeof t}function o(t){return null!==t&&("object"==typeof t||r(t))}function i(t){return o(t)&&r(t.then)}function u(t,e){var n=new t({data:{p:!0,v:!1}});return e.then(function(t){n.p=!1,n.v=t},function(t){throw n.p=!1,n.v=!1,t}),n[p]=!0,n}function a(t){this.dirty=t;var e=this.proxy,n=t?"$touch":"$reset";this.nestedKeys.forEach(function(t){e[t][n]()})}function l(t){if(x)return x;for(var e=t.constructor;e.super;)e=e.super;return x=e,e}function s(t){t.mixin(k)}Object.defineProperty(e,"__esModule",{value:!0}),e.withParams=e.validationMixin=e.Vuelidate=void 0;var f=Object.assign||function(t){for(var e=1;e1?a:a.$sub[0]:null;return{output:o,params:l}}},computed:{run:function(){return this.runRule(this.lazyParentModel())},$params:function(){return this.run.params},proxy:function(){var t=this.run.output;return t[p]?!!t.v:!!t},$pending:function(){var t=this.run.output;return!!t[p]&&t.p}}}),r=e.extend({data:function(){return{dirty:!1,validations:null,lazyModel:null,model:null,prop:null,lazyParentModel:null,rootModel:null}},methods:f({},g,{refProxy:function(t){return this.getRef(t).proxy},getRef:function(t){return this.refs[t]},isNested:function(t){return"function"!=typeof this.validations[t]}}),computed:f({},m,{nestedKeys:function(){return this.keys.filter(this.isNested)},ruleKeys:function(){var t=this;return this.keys.filter(function(e){return!t.isNested(e)})},keys:function(){return Object.keys(this.validations).filter(function(t){return"$params"!==t})},proxy:function(){var t=this,e=v(this.keys,function(e){return{enumerable:!0,configurable:!0,get:function(){return t.refProxy(e)}}}),n=v(M,function(e){return{enumerable:!0,configurable:!0,get:function(){return t[e]}}}),r=v($,function(e){return{enumerable:!1,configurable:!0,get:function(){return t[e]}}});return Object.defineProperties({},f({},e,n,r))},children:function(){var t=this;return[].concat(this.nestedKeys.map(function(e){return s(t,e)}),this.ruleKeys.map(function(e){return P(t,e)})).filter(Boolean)}})}),a=r.extend({methods:{isNested:function(t){return"undefined"!=typeof this.validations[t]()},getRef:function(t){var e=this;return{get proxy(){return e.validations[t]()||!1}}}}}),l=r.extend({computed:{keys:function(){var t=this.getModel();return o(t)?Object.keys(t):[]},tracker:function(){var t=this,e=this.validations.$trackBy;return e?function(n){return""+y(t.rootModel,t.getModelKey(n),e)}:function(t){return""+t}},eagerParentModel:function(){var t=this.lazyParentModel();return function(){return t}},children:function(){var t=this,e=this.validations,n=this.getModel(),o=f({},e);delete o.$trackBy;var i={};return this.keys.map(function(e){var u=t.tracker(e);return i.hasOwnProperty(u)?null:(i[u]=!0,(0,c.h)(r,u,{validations:o,prop:e,lazyParentModel:t.eagerParentModel,model:n[e],rootModel:t.rootModel}))}).filter(Boolean)}},methods:{isNested:function(){return!0},getRef:function(t){return this.refs[this.tracker(t)]}}}),s=function(t,e){if("$each"===e)return(0,c.h)(l,e,{validations:t.validations[e],lazyParentModel:t.lazyParentModel,prop:e,lazyModel:t.getModel,rootModel:t.rootModel});var n=t.validations[e];if(Array.isArray(n)){var o=t.rootModel,i=v(n,function(t){return function(){return y(o,o.$v,t)}},function(t){return Array.isArray(t)?t.join("."):t});return(0,c.h)(a,e,{validations:i,lazyParentModel:h,prop:e,lazyModel:h,rootModel:o})}return(0,c.h)(r,e,{validations:n,lazyParentModel:t.getModel,prop:e,lazyModel:t.getModelKey,rootModel:t.rootModel})},P=function(t,e){return(0,c.h)(n,e,{rule:t.validations[e],lazyParentModel:t.lazyParentModel,lazyModel:t.getModel,rootModel:t.rootModel})};return b={VBase:e,Validation:r}},x=null,j=function(t,e){var n=l(t),r=P(n),o=r.Validation,i=r.VBase,u=new i({computed:{children:function(){var n="function"==typeof e?e.call(t):e;return[(0,c.h)(o,"$v",{validations:n,lazyParentModel:h,prop:"$v",model:t,rootModel:t})]}}});return u},k={data:function(){var t=this.$options.validations;return t&&(this._vuelidate=j(this,t)),{}},beforeCreate:function(){var t=this.$options,e=t.validations;e&&(t.computed||(t.computed={}),t.computed.$v||(t.computed.$v=function(){return this._vuelidate?this._vuelidate.refs.$v.proxy:null}))},beforeDestroy:function(){this._vuelidate&&(this._vuelidate.$destroy(),this._vuelidate=null)}};e.Vuelidate=s,e.validationMixin=k,e.withParams=d.withParams,e.default=s},2:function(t,e){"use strict";function n(){null!==f&&s.push(f),e.target=f={}}function r(){var t=f,n=e.target=f=s.pop()||null;return n&&(Array.isArray(n.$sub)||(n.$sub=[]),n.$sub.push(t)),t}function o(t){if("object"!=typeof t||Array.isArray(t))throw new Error("params must be an object");e.target=f=l({},f,t)}function i(t,e){return u(function(n){return function(){n(t);for(var r=arguments.length,o=Array(r),i=0;id?s(e,l,y):l>y&&f(t,u,d)}function s(t,e,n){for(;e<=n;++e)i(t[e])}function f(t,e,n){for(;e<=n;++e){var o=t[e];r(o)&&(o.vm.$destroy(),o.vm=null)}}function c(t,e){t!==e&&(e.vm=t.vm,u(e))}function d(t,e){r(t)&&r(e)?t!==e&&l(t,e):r(e)?s(e,0,e.length-1):r(t)&&f(t,0,t.length-1)}function h(t,e,n){return{tag:t,key:e,args:n}}Object.defineProperty(e,"__esModule",{value:!0}),e.patchChildren=d,e.h=h}})}); \ No newline at end of file diff --git a/src/index.js b/src/index.js index e5507218..11c071ab 100644 --- a/src/index.js +++ b/src/index.js @@ -458,7 +458,10 @@ const validationMixin = { const vals = options.validations if (!vals) return if (!options.computed) options.computed = {} - options.computed.$v = () => this._vuelidate.refs.$v.proxy + if (options.computed.$v) return + options.computed.$v = function () { + return this._vuelidate ? this._vuelidate.refs.$v.proxy : null + } }, beforeDestroy () { if (this._vuelidate) {