| 12 |
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.VeeValidate=t()}(this,function(){"use strict";function e(e){return e&&e.__esModule?e.default:e}function t(e,t){return t={exports:{}},e(t,t.exports),t.exports}function i(e,t,i){t&&(t.dirty?(ee(e,i.touched),te(e,i.untouched)):(ee(e,i.untouched),te(e,i.touched)),t.valid||t.passed?(ee(e,i.valid),te(e,i.invalid)):(ee(e,i.invalid),te(e,i.valid)))}function r(e,t){ee(e,t.dirty),te(e,t.pristine)}function n(e,t){ee(e,t.pristine),te(e,t.dirty)}var o=function(e){return/^[a-zA-Z]*$/.test(e)},a=function(e){return/^[a-zA-Z0-9_-]*$/.test(e)},s=function(e){return/^[a-zA-Z0-9]*$/.test(e)},u=function(e){return/^[a-zA-Z\s]*$/.test(e)},l=function(e,t){var i=t[0],r=t[1];return Number(i)<=e&&Number(r)>=e},c=function(e,t,i){var r=t[0],n=r?document.querySelector("input[name='"+r+"']"):document.querySelector("input[name='"+i+"_confirmation']");return!(!n||String(e)!==n.value)},f=t(function(e,t){function i(e){if("string"!=typeof e)throw new TypeError("This library (validator.js) validates strings only")}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i,e.exports=t.default}),d=t(function(e,t){function i(e){return e&&e.__esModule?e:{default:e}}function r(e){(0,o.default)(e);var t=e.replace(/[^0-9]+/g,"");if(!a.test(t))return!1;for(var i=0,r=void 0,n=void 0,s=void 0,u=t.length-1;u>=0;u--)r=t.substring(u,u+1),n=parseInt(r,10),s?(n*=2,i+=n>=10?n%10+1:n):i+=n,s=!s;return!(i%10!==0||!t)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var n=f,o=i(n),a=/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})|62[0-9]{14}$/;e.exports=t.default}),h=e(d),p=function(e){return h(String(e))},v=function(e,t){var i=Array.isArray(t)?t[0]||"*":"*";if(Array.isArray(e))return!1;if(null===e||void 0===e||""===e)return!0;if(0===Number(i))return/^-?\d*$/.test(e);var r="*"===i?"+":"{1,"+i+"}",n=new RegExp("^-?\\d*(\\.\\d"+r+")?$");if(!n.test(e))return!1;var o=parseFloat(e);return o===o},m=function(e,t){var i=t[0],r=String(e);return/^[0-9]*$/.test(r)&&r.length===Number(i)},_=function(e,t,i){var r=window.URL||window.webkitURL;return new Promise(function(n){var o=new Image;o.onerror=function(){return n({valid:!1})},o.onload=function(){return n({valid:o.width===Number(t)&&o.height===Number(i)})},o.src=r.createObjectURL(e)})},g=function(e,t){for(var i=t[0],r=t[1],n=[],o=0;o<e.length;o++){if(!/\.(jpg|svg|jpeg|png|bmp|gif)$/i.test(e[o].name))return!1;n.push(e[o])}return Promise.all(n.map(function(e){return _(e,i,r)}))},y=t(function(e,t){function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1];for(var i in t)"undefined"==typeof e[i]&&(e[i]=t[i]);return e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i,e.exports=t.default}),b=t(function(e,t){function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t){(0,a.default)(e);var i=void 0,r=void 0;"object"===("undefined"==typeof t?"undefined":n(t))?(i=t.min||0,r=t.max):(i=arguments[1],r=arguments[2]);var o=encodeURI(e).split(/%..|./).length-1;return o>=i&&("undefined"==typeof r||o<=r)}Object.defineProperty(t,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.default=r;var o=f,a=i(o);e.exports=t.default}),x=t(function(e,t){function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t){(0,o.default)(e),t=(0,s.default)(t,u),t.allow_trailing_dot&&"."===e[e.length-1]&&(e=e.substring(0,e.length-1));var i=e.split(".");if(t.require_tld){var r=i.pop();if(!i.length||!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(r))return!1}for(var n,a=0;a<i.length;a++){if(n=i[a],t.allow_underscores&&(n=n.replace(/_/g,"")),!/^[a-z\u00a1-\uffff0-9-]+$/i.test(n))return!1;if(/[\uff01-\uff5e]/.test(n))return!1;if("-"===n[0]||"-"===n[n.length-1])return!1}return!0}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var n=f,o=i(n),a=y,s=i(a),u={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1};e.exports=t.default}),F=t(function(e,t){function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if((0,o.default)(e),t=(0,s.default)(t,h),t.allow_display_name){var i=e.match(p);i&&(e=i[1])}var r=e.split("@"),n=r.pop(),a=r.join("@"),u=n.toLowerCase();if("gmail.com"!==u&&"googlemail.com"!==u||(a=a.replace(/\./g,"").toLowerCase()),!(0,l.default)(a,{max:64})||!(0,l.default)(n,{max:256}))return!1;if(!(0,d.default)(n,{require_tld:t.require_tld}))return!1;if('"'===a[0])return a=a.slice(1,a.length-1),t.allow_utf8_local_part?g.test(a):m.test(a);for(var c=t.allow_utf8_local_part?_:v,f=a.split("."),y=0;y<f.length;y++)if(!c.test(f[y]))return!1;return!0}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var n=f,o=i(n),a=y,s=i(a),u=b,l=i(u),c=x,d=i(c),h={allow_display_name:!1,allow_utf8_local_part:!0,require_tld:!0},p=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i,v=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,m=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,_=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,g=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i;e.exports=t.default}),$=e(F),w=function(e){return $(String(e))},A=function(e,t){var i=new RegExp(".("+t.join("|")+")$","i");return e.every(function(e){return i.test(e.name)})},E=function(e){return e.every(function(e){return/\.(jpg|svg|jpeg|png|bmp|gif)$/i.test(e.name)})},j=function(e,t){return!!t.filter(function(t){return t==e}).length},L=t(function(e,t){function i(e){return e&&e.__esModule?e:{default:e}}function r(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if((0,o.default)(e),t=String(t),!t)return r(e,4)||r(e,6);if("4"===t){if(!a.test(e))return!1;var i=e.split(".").sort(function(e,t){return e-t});return i[3]<=255}if("6"===t){var n=e.split(":"),u=!1,l=r(n[n.length-1],4),c=l?7:8;if(n.length>c)return!1;if("::"===e)return!0;"::"===e.substr(0,2)?(n.shift(),n.shift(),u=!0):"::"===e.substr(e.length-2)&&(n.pop(),n.pop(),u=!0);for(var f=0;f<n.length;++f)if(""===n[f]&&f>0&&f<n.length-1){if(u)return!1;u=!0}else if(l&&f===n.length-1);else if(!s.test(n[f]))return!1;return u?n.length>=1:n.length===c}return!1}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var n=f,o=i(n),a=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,s=/^[0-9A-F]{1,4}$/i;e.exports=t.default}),O=e(L),N=function(e,t){void 0===t&&(t=[4]);var i=t[0];return O(e,i)},S=function(e,t){var i=t[0];return void 0===e||null===e?i>=0:String(e).length<=i},T=function(e,t){var i=t[0];return!Array.isArray(e)&&null!==e&&void 0!==e&&""!==e&&Number(e)<=i},k=function(e,t){var i=new RegExp(t.join("|").replace("*",".+")+"$","i");return e.every(function(e){return i.test(e.type)})},M=function(e,t){var i=t[0];return void 0!==e&&null!==e&&String(e).length>=i},D=function(e,t){var i=t[0];return!Array.isArray(e)&&null!==e&&void 0!==e&&""!==e&&Number(e)>=i},q=function(e,t){return!t.filter(function(t){return t==e}).length},B=function(e){return/^[0-9]+$/.test(String(e))},R=function(e,t){var i=t[0],r=t.slice(1);return i instanceof RegExp?i.test(e):new RegExp(i,r).test(String(e))},V=function(e){return Array.isArray(e)?!!e.length:void 0!==e&&null!==e&&!!String(e).trim().length},z=function(e,t){var i=t[0];if(isNaN(i))return!1;for(var r=1024*Number(i),n=0;n<e.length;n++)if(e[n].size>r)return!1;return!0},P=t(function(e,t){function i(e){return e&&e.__esModule?e:{default:e}}function r(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function n(e,t){for(var i=0;i<t.length;i++){var n=t[i];if(e===n||r(n)&&n.test(e))return!0}return!1}function o(e,t){if((0,s.default)(e),!e||e.length>=2083||/\s/.test(e))return!1;if(0===e.indexOf("mailto:"))return!1;t=(0,p.default)(t,v);var i=void 0,r=void 0,o=void 0,a=void 0,u=void 0,c=void 0,f=void 0,h=void 0;if(f=e.split("#"),e=f.shift(),f=e.split("?"),e=f.shift(),f=e.split("://"),f.length>1){if(i=f.shift(),t.require_valid_protocol&&t.protocols.indexOf(i)===-1)return!1}else{if(t.require_protocol)return!1;t.allow_protocol_relative_urls&&"//"===e.substr(0,2)&&(f[0]=e.substr(2))}if(e=f.join("://"),f=e.split("/"),e=f.shift(),""===e&&!t.require_host)return!0;if(f=e.split("@"),f.length>1&&(r=f.shift(),r.indexOf(":")>=0&&r.split(":").length>2))return!1;a=f.join("@"),c=h=null;var _=a.match(m);return _?(o="",h=_[1],c=_[2]||null):(f=a.split(":"),o=f.shift(),f.length&&(c=f.join(":"))),!(null!==c&&(u=parseInt(c,10),!/^[0-9]+$/.test(c)||u<=0||u>65535))&&(!!((0,d.default)(o)||(0,l.default)(o,t)||h&&(0,d.default)(h,6)||"localhost"===o)&&(o=o||h,!(t.host_whitelist&&!n(o,t.host_whitelist))&&(!t.host_blacklist||!n(o,t.host_blacklist))))}Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var a=f,s=i(a),u=x,l=i(u),c=L,d=i(c),h=y,p=i(h),v={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_host:!0,require_valid_protocol:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1},m=/^\[([^\]]+)\](?::([0-9]+))?$/;e.exports=t.default}),C=e(P),U=function(e,t){void 0===t&&(t=[!0]);var i=t[0];return C(e,{require_protocol:!!i})},I={alpha_dash:a,alpha_num:s,alpha_spaces:u,alpha:o,between:l,confirmed:c,credit_card:p,decimal:v,digits:m,dimensions:g,email:w,ext:A,image:E,in:j,ip:N,max:S,max_value:T,mimes:k,min:M,min_value:D,not_in:q,numeric:B,regex:R,required:V,size:z,url:U},G=function(){this.errors=[]};G.prototype.add=function(e,t,i,r){void 0===r&&(r="__global__"),this.errors.push({field:e,msg:t,rule:i,scope:r})},G.prototype.all=function(e){return e?this.errors.filter(function(t){return t.scope===e}).map(function(e){return e.msg}):this.errors.map(function(e){return e.msg})},G.prototype.any=function(e){return e?!!this.errors.filter(function(t){return t.scope===e}).length:!!this.errors.length},G.prototype.clear=function(e){e||(e="__global__"),this.errors=this.errors.filter(function(t){return t.scope!==e})},G.prototype.collect=function(e,t,i){if(void 0===i&&(i=!0),!e){var r={};return this.errors.forEach(function(e){r[e.field]||(r[e.field]=[]),r[e.field].push(i?e.msg:e)}),r}return t?this.errors.filter(function(i){return i.field===e&&i.scope===t}).map(function(e){return i?e.msg:e}):this.errors.filter(function(t){return t.field===e&&"__global__"===t.scope}).map(function(e){return i?e.msg:e})},G.prototype.count=function(){return this.errors.length},G.prototype.first=function(e,t){var i=this;void 0===t&&(t="__global__");var r=this._selector(e),n=this._scope(e);if(n){var o=this.first(n.name,n.scope);if(o)return o}if(r)return this.firstByRule(r.name,r.rule,t);for(var a=0;a<this.errors.length;a++)if(i.errors[a].field===e&&i.errors[a].scope===t)return i.errors[a].msg;return null},G.prototype.firstRule=function(e,t){var i=this.collect(e,t,!1);return i.length&&i[0].rule||null},G.prototype.has=function(e,t){return void 0===t&&(t="__global__"),!!this.first(e,t)},G.prototype.firstByRule=function(e,t,i){var r=this.collect(e,i,!1).filter(function(e){return e.rule===t})[0];return r&&r.msg||null},G.prototype.remove=function(e,t){return t?void(this.errors=this.errors.filter(function(i){return i.field!==e||i.scope!==t})):void(this.errors=this.errors.filter(function(t){return t.field!==e&&"__global__"===t.scope}))},G.prototype._selector=function(e){if(e.indexOf(":")>-1){var t=e.split(":"),i=t[0],r=t[1];return{name:i,rule:r}}return null},G.prototype._scope=function(e){if(e.indexOf(".")>-1){var t=e.split("."),i=t[0],r=t[1];return{name:r,scope:i}}return null};var J=function(){function e(e){this.msg="[vee-validate]: "+e}return e.prototype.toString=function(){return this.msg},e}(),Y=function(e,t){return e.getAttribute("data-vv-"+t)},Z=function(e){var t=Y(e,"scope");return!t&&e.form&&(t=Y(e.form,"scope")),t},W=function(e,t,i){void 0===t&&(t=0);var r;return 0==t?e:function(){for(var n=[],o=arguments.length;o--;)n[o]=arguments[o];var a=function(){r=null,i||e.apply(void 0,n)},s=i&&!r;clearTimeout(r),r=setTimeout(a,t),s&&e(n)}},K=function(e){console&&console.warn("[vee-validate]: "+e)},H=function(e){return null!==e&&e&&"object"==typeof e&&!Array.isArray(e)},Q=function(e){return"function"==typeof e},X=function(e,t){return e.classList?e.classList.contains(t):!!e.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))},ee=function(e,t){return e.classList?void e.classList.add(t):void(X(e,t)||(e.className+=" "+t))},te=function(e,t){if(e.classList)return void e.classList.remove(t);if(X(e,t)){var i=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className=e.className.replace(i," ")}},ie=function(e){if(Array.from)return Array.from(e);for(var t=[],i=e.length,r=0;r<i;r++)t.push(e[r]);return t},re=function(e){for(var t=[],i=arguments.length-1;i-- >0;)t[i]=arguments[i+1];if(Object.assign)return Object.assign.apply(Object,[e].concat(t));if(null==e)throw new TypeError("Cannot convert undefined or null to object");var r=Object(e);return t.forEach(function(e){null!=e&&Object.keys(e).forEach(function(t){r[t]=e[t]})}),r},ne=function(e,t){if(e.find)return e.find(t);var i;return e.some(function(e){return!!t(e)&&(i=e,!0)}),i},oe=function(e,t,i){return e?"string"==typeof t?t:~["string","object"].indexOf(typeof t.rules)?t.rules:t:Y(i,"rules")},ae=function(e){void 0===e&&(e={}),this.dictionary={},this.merge(e)};ae.prototype.hasLocale=function(e){return!!this.dictionary[e]},ae.prototype.getMessage=function(e,t,i){return this.hasMessage(e,t)?this.dictionary[e].messages[t]:i||this._getDefaultMessage(e)},ae.prototype._getDefaultMessage=function(e){return this.hasMessage(e,"_default")?this.dictionary[e].messages._default:this.dictionary.en.messages._default},ae.prototype.getAttribute=function(e,t,i){return void 0===i&&(i=""),this.hasAttribute(e,t)?this.dictionary[e].attributes[t]:i},ae.prototype.hasMessage=function(e,t){return!!(this.hasLocale(e)&&this.dictionary[e].messages&&this.dictionary[e].messages[t])},ae.prototype.hasAttribute=function(e,t){return!!(this.hasLocale(e)&&this.dictionary[e].attributes&&this.dictionary[e].attributes[t])},ae.prototype.merge=function(e){this._merge(this.dictionary,e)},ae.prototype.setMessage=function(e,t,i){this.hasLocale(e)||(this.dictionary[e]={messages:{},attributes:{}}),this.dictionary[e].messages[t]=i},ae.prototype.setAttribute=function(e,t,i){this.hasLocale(e)||(this.dictionary[e]={messages:{},attributes:{}}),this.dictionary[e].attributes[t]=i},ae.prototype._merge=function(e,t){var i=this;return H(e)&&H(t)?(Object.keys(t).forEach(function(r){if(H(t[r])){if(!e[r]){re(e,(n={},n[r]={},n));var n}return void i._merge(e[r],t[r])}re(e,(o={},o[r]=t[r],o));var o}),e):e};var se={_default:function(e){return"The "+e+" value is not valid."},alpha_dash:function(e){return"The "+e+" field may contain alpha-numeric characters as well as dashes and underscores."},alpha_num:function(e){return"The "+e+" field may only contain alpha-numeric characters."},alpha_spaces:function(e){return"The "+e+" field may only contain alphabetic characters as well as spaces."},alpha:function(e){return"The "+e+" field may only contain alphabetic characters."},between:function(e,t){var i=t[0],r=t[1];return"The "+e+" field must be between "+i+" and "+r+"."},confirmed:function(e){return"The "+e+" confirmation does not match."},credit_card:function(e){return"The "+e+" field is invalid."},decimal:function(e,t){void 0===t&&(t=["*"]);var i=t[0];return"The "+e+" field must be numeric and may contain "+("*"===i?"":i)+" decimal points."},digits:function(e,t){var i=t[0];return"The "+e+" field must be numeric and exactly contain "+i+" digits."},dimensions:function(e,t){var i=t[0],r=t[1];return"The "+e+" field must be "+i+" pixels by "+r+" pixels."},email:function(e){return"The "+e+" field must be a valid email."},ext:function(e){return"The "+e+" field must be a valid file."},image:function(e){return"The "+e+" field must be an image."},in:function(e){return"The "+e+" field must be a valid value."},ip:function(e){return"The "+e+" field must be a valid ip address."},max:function(e,t){var i=t[0];return"The "+e+" field may not be greater than "+i+" characters."},max_value:function(e,t){var i=t[0];return"The "+e+" field must be "+i+" or less."},mimes:function(e){return"The "+e+" field must have a valid file type."},min:function(e,t){var i=t[0];return"The "+e+" field must be at least "+i+" characters."},min_value:function(e,t){var i=t[0];return"The "+e+" field must be "+i+" or more."},not_in:function(e){return"The "+e+" field must be a valid value."},numeric:function(e){return"The "+e+" field may only contain numeric characters."},regex:function(e){return"The "+e+" field format is invalid."},required:function(e){return"The "+e+" field is required."},size:function(e,t){var i=t[0];return"The "+e+" field must be less than "+i+" KB."},url:function(e){return"The "+e+" field is not a valid URL."}},ue=function(e){return function(t,i){var r=i[0],n=i[1],o=e(t,n,!0),a=document.querySelector("input[name='"+r+"']");if(!o.isValid()||!a)return!1;var s=e(a.value,n,!0);return!!s.isValid()&&o.isAfter(s)}},le=function(e){return function(t,i){var r=i[0],n=i[1],o=e(t,n,!0),a=document.querySelector("input[name='"+r+"']");if(!o.isValid()||!a)return!1;var s=e(a.value,n,!0);return!!s.isValid()&&o.isBefore(s)}},ce=function(e){return function(t,i){var r=i[0];return e(t,r,!0).isValid()}},fe=function(e){return function(t,i){var r=i[0],n=i[1],o=i[2],a=e(r,o,!0),s=e(n,o,!0),u=e(t,o,!0);return!!(a.isValid()&&s.isValid()&&u.isValid())&&u.isBetween(a,s)}},de={after:function(e,t){var i=t[0];return"The "+e+" must be after "+i+"."},before:function(e,t){var i=t[0];return"The "+e+" must be before "+i+"."},date_between:function(e,t){var i=t[0],r=t[1];return"The "+e+" must be between "+i+" and "+r+"."},date_format:function(e,t){var i=t[0];return"The "+e+" must be in the format "+i+"."}},he={make:function(e){return{date_format:ce(e),after:ue(e),before:le(e),date_between:fe(e)}},messages:de,installed:!1},pe=function(){this.fields={}};pe.prototype._add=function(e){this.fields[e]={},this._setFlags(e,{dirty:!1,valid:!1},!0)},pe.prototype._addIfNotExists=function(e){this.fields[e]||this._add(e)},pe.prototype._remove=function(e){delete this.fields[e]},pe.prototype.reset=function(e){var t=this;return e?void this._setFlags(e,{dirty:!1,valid:!1},!0):void Object.keys(this.fields).forEach(function(e){t._setFlags(e,{dirty:!1,valid:!1},!0)})},pe.prototype._setFlags=function(e,t,i){var r=this;return void 0===i&&(i=!1),Object.keys(t).every(function(n){return r._setFlag(e,n,t[n],i)})},pe.prototype._setFlag=function(e,t,i,r){void 0===r&&(r=!1);var n="set"+t.charAt(0).toUpperCase()+t.slice(1);return"function"==typeof this[n]&&(this[n](e,i,r),!0)},pe.prototype.setDirty=function(e,t,i){void 0===i&&(i=!1),this.fields[e].dirty=t,this.fields[e].clean=i||!t,this.fields[e].passed=this.fields[e].valid&&t,this.fields[e].failed=!this.fields[e].valid&&t},pe.prototype.setValid=function(e,t){this.fields[e].valid=t,this.fields[e].passed=this.fields[e].dirty&&t,this.fields[e].failed=this.fields[e].dirty&&!t},pe.prototype._getFieldFlag=function(e,t){return!!this.fields[e]&&this.fields[e][t]},pe.prototype.dirty=function(e){var t=this;return e?this._getFieldFlag(e,"dirty"):Object.keys(this.fields).some(function(e){return t.fields[e].dirty})},pe.prototype.valid=function(e){var t=this;return e?this._getFieldFlag(e,"valid"):Object.keys(this.fields).every(function(e){return t.fields[e].valid})},pe.prototype.passed=function(e){var t=this;return e?this._getFieldFlag(e,"passed"):Object.keys(this.fields).every(function(e){return t.fields[e].passed})},pe.prototype.failed=function(e){var t=this;return e?this._getFieldFlag(e,"failed"):Object.keys(this.fields).some(function(e){return t.fields[e].failed})},pe.prototype.clean=function(e){return e?this._getFieldFlag(e,"clean"):!this.dirty()};var ve="en",me=!0,_e=new ae({en:{messages:se,attributes:{}}}),ge=function(e,t){void 0===t&&(t={init:!0}),this.strictMode=me,this.$scopes={__global__:{}},this.fieldBag=new pe,this._createFields(e),this.errorBag=new G,this.$deferred=[],this.$ready=!1,"function"==typeof moment&&this.installDateTimeValidators(moment),t.init&&this.init()},ye={dictionary:{}};ye.dictionary.get=function(){return _e},ge._merge=function(e,t){return Q(t)?void(I[e]=t):(I[e]=t.validate,t.getMessage&&Q(t.getMessage)&&_e.setMessage("en",e,t.getMessage),void(t.messages&&_e.merge(Object.keys(t.messages).reduce(function(i,r){var n=i;n[r]={messages:(o={},o[e]=t.messages[r],o)};var o;return n},{}))))},ge._guardExtend=function(e,t){if(I[e])throw new J("Extension Error: There is an existing validator with the same name '"+e+"'.");if(!Q(t)){if(!Q(t.validate))throw new J("Extension Error: The validator '"+e+"' must be a function or have a 'validate' method.");if(!Q(t.getMessage)&&!H(t.messages))throw new J("Extension Error: The validator '"+e+"' must have a 'getMessage' method or have a 'messages' object.")}},ge.create=function(e,t,i){return new ge(e,t,i)},ge.extend=function(e,t){ge._guardExtend(e,t),ge._merge(e,t)},ge.installDateTimeValidators=function(e){if("function"!=typeof e)return K("To use the date-time validators you must provide moment reference."),!1;if(he.installed)return!0;var t=he.make(e);return Object.keys(t).forEach(function(e){ge.extend(e,t[e])}),ge.updateDictionary({en:{messages:he.messages}}),he.installed=!0,!0},ge.remove=function(e){delete I[e]},ge.setLocale=function(e){void 0===e&&(e="en"),_e.hasLocale(e)||K("You are setting the validator locale to a locale that is not defined in the dicitionary. English messages may still be generated."),ve=e},ge.setStrictMode=function(e){void 0===e&&(e=!0),me=e},ge.updateDictionary=function(e){_e.merge(e)},ge.addLocale=function(e){if(!e.name)return void K("Your locale must have a name property");this.updateDictionary((t={},t[e.name]=e,t));var t},ge.prototype.addLocale=function(e){ge.addLocale(e)},ge.prototype._resolveScope=function(e){if("string"==typeof e)return e;if(Q(e)){var t=e();return"string"==typeof t?t:"__global__"}return"__global__"},ge.prototype._resolveValuesFromGetters=function(e){var t=this;if(void 0===e&&(e="__global__"),!this.$scopes[e])return{};var i={};return Object.keys(this.$scopes[e]).forEach(function(r){var n=t.$scopes[e][r],o=n.getter,a=n.context,s=t._resolveScope(n.scope);o&&a&&("__global__"===e||s===e)&&(i[r]={value:o(a()),scope:s})}),i},ge.prototype._createFields=function(e){var t=this;e&&Object.keys(e).forEach(function(i){t._createField(i,e[i])})},ge.prototype._createField=function(e,t,i){void 0===i&&(i="__global__"),i=this._resolveScope(i),this.$scopes[i]||(this.$scopes[i]={}),this.$scopes[i][e]||(this.$scopes[i][e]={});var r=this.$scopes[i][e];this.fieldBag._addIfNotExists(e),r.validations=this._normalizeRules(e,t,i),r.required=this._isRequired(r)},ge.prototype._normalizeRules=function(e,t,i){return t?"string"==typeof t?this._normalizeString(t):H(t)?this._normalizeObject(t):(K("Your checks for '"+i+"."+e+"' must be either a string or an object."),{}):{}},ge.prototype._isRequired=function(e){return e.validations&&e.validations.required},ge.prototype._normalizeObject=function(e){var t=this,i={};return Object.keys(e).forEach(function(r){var n=[];n=e[r]===!0?[]:Array.isArray(e[r])?e[r]:[e[r]],e[r]===!1?delete i[r]:i[r]=n,he.installed&&t._isADateRule(r)&&i[r].push(t._getDateFormat(i))}),i},ge.prototype._getDateFormat=function(e){return e.date_format&&Array.isArray(e.date_format)?e.date_format[0]:null},ge.prototype._isADateRule=function(e){return!!~["after","before","date_between"].indexOf(e)},ge.prototype._normalizeString=function(e){var t=this,i={};return e.split("|").forEach(function(e){var r=t._parseRule(e);r.name&&("required"===r.name&&(i.required=!0),i[r.name]=r.params,he.installed&&t._isADateRule(r.name)&&i[r.name].push(t._getDateFormat(i)))}),i},ge.prototype._parseRule=function(e){var t=[],i=e.split(":")[0];return~e.indexOf(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:i,params:t}},ge.prototype._formatErrorMessage=function(e,t,i,r){void 0===i&&(i={}),void 0===r&&(r="__global__");var n=this._getFieldDisplayName(e,r),o=this._getLocalizedParams(t,r);return this.dictionary.hasLocale(ve)?this.dictionary.getMessage(ve,t.name)(n,o,i):this.dictionary.getMessage("en",t.name)(n,o,i)},ge.prototype._getLocalizedParams=function(e,t){if(void 0===t&&(t="__global__"),~["after","before","confirmed"].indexOf(e.name)&&e.params&&e.params[0]){var i=this.$scopes[t][e.params[0]];return i&&i.name?[i.name]:[this.dictionary.getAttribute(ve,e.params[0],e.params[0])]}return e.params},ge.prototype._getFieldDisplayName=function(e,t){return void 0===t&&(t="__global__"),this.$scopes[t][e].name||this.dictionary.getAttribute(ve,e,e)},ge.prototype._test=function(e,t,i,r){var n=this;void 0===r&&(r="__global__");var o=I[i.name];if(!o||"function"!=typeof o)throw new J("No such validator '"+i.name+"' exists.");var a=o(t,i.params,e);return Q(a.then)?a.then(function(t){var o=!0,a={};return Array.isArray(t)?o=t.every(function(e){return e.valid}):(o=t.valid,a=t.data),o||n.errorBag.add(e,n._formatErrorMessage(e,i,a,r),i.name,r),o}):(H(a)||(a={valid:a,data:{}}),a.valid||this.errorBag.add(e,this._formatErrorMessage(e,i,a.data,r),i.name,r),a.valid)},ge.prototype.attach=function e(t,i,r){var n=this;void 0===r&&(r={});var e=function(){r.scope=n._resolveScope(r.scope),n.updateField(t,i,r);var e=n.$scopes[r.scope][t];e.scope=r.scope,e.name=r.prettyName,e.getter=r.getter,e.context=r.context,e.listeners=r.listeners||{detach:function(){}},e.el=e.listeners.el,n._setAriaRequiredAttribute(e),n._setAriaValidAttribute(e,!0)},o=Q(r.scope)?r.scope():r.scope;return o||this.$ready?void e():void this.$deferred.push(e)},ge.prototype.init=function(){return this.$ready=!0,this.$deferred.forEach(function(e){e()}),this.$deferred=[],this},ge.prototype.append=function(e,t,i){void 0===i&&(i={}),i.scope=this._resolveScope(i.scope),this.$scopes[i.scope]&&this.$scopes[i.scope][e]||this.attach(e,t,i);var r=this.$scopes[i.scope][e],n=this._normalizeRules(e,t,i.scope);Object.keys(n).forEach(function(e){r.validations[e]=n[e]})},ge.prototype.updateField=function(e,t,i){void 0===i&&(i={});var r=this.$scopes[i.scope]&&this.$scopes[i.scope][e]||null,n=r?JSON.stringify(r.validations):"";this._createField(e,t,i.scope),r=this.$scopes[i.scope]&&this.$scopes[i.scope][e]||null;var o=r?JSON.stringify(r.validations):"";o!==n&&this.errorBag.remove(e,i.scope)},ge.prototype.detach=function(e,t){void 0===t&&(t="__global__"),this.$scopes[t]&&this.$scopes[t][e]&&(this.$scopes[t][e].listeners.detach(),this.errorBag.remove(e,t),this.fieldBag._remove(e),delete this.$scopes[t][e])},ge.prototype.extend=function(e,t){ge.extend(e,t)},ge.prototype.getErrors=function(){return this.errorBag},ge.prototype.getLocale=function(){return ve},ge.prototype.installDateTimeValidators=function(e){ge.installDateTimeValidators(e)},ge.prototype.remove=function(e){ge.remove(e)},ge.prototype.setLocale=function(e){this.dictionary.hasLocale(e)||K("You are setting the validator locale to a locale that is not defined in the dicitionary. English messages may still be generated."),ve=e},ge.prototype.setStrictMode=function(e){void 0===e&&(e=!0),this.strictMode=e},ge.prototype.updateDictionary=function(e){ge.updateDictionary(e)},ge.prototype.addScope=function(e){e&&!this.$scopes[e]&&(this.$scopes[e]={})},ge.prototype.validate=function(e,t,i){var r=this;if(void 0===i&&(i="__global__"),e&&e.indexOf(".")>-1&&!this.$scopes.__global__[e]){var n;n=e.split("."),i=n[0],e=n[1]}if(i||(i="__global__"),!this.$scopes[i]||!this.$scopes[i][e]){if(!this.strictMode)return Promise.resolve(!0);var o="__global__"===i?e:i+"."+e;return K('Validating a non-existant field: "'+o+'". Use "attach()" first.'),Promise.reject(!1)}var a=this.$scopes[i][e];if(this.errorBag.remove(e,i),!a.required&&~[null,void 0,""].indexOf(t))return this.fieldBag._setFlags(e,{valid:!0,dirty:!0}),Promise.resolve(!0);var s=[],u=Object.keys(a.validations).every(function(n){var o=r._test(e,t,{name:n,params:a.validations[n]},i);return Q(o.then)&&s.push(o),o});return s.length?Promise.all(s).then(function(t){var i=t.every(function(e){return e})&&u;return r.fieldBag._setFlags(e,{valid:i,dirty:!0}),r._setAriaValidAttribute(a,u),i}):(this.fieldBag._setFlags(e,{valid:u,dirty:!0}),this._setAriaValidAttribute(a,u),new Promise(function(e,t){return u?void e(u):void t(!1)}))},ge.prototype._setAriaValidAttribute=function(e,t){e.el&&e.el.setAttribute("aria-invalid",!t)},ge.prototype._setAriaRequiredAttribute=function(e){e.el&&e.el.setAttribute("aria-required",!!e.required)},ge.prototype.validateAll=function(e){var t,i=this;e&&"string"!=typeof e?(t={},Object.keys(e).forEach(function(i){t[i]={value:e[i]}})):(this.errorBag.clear(e),t=this._resolveValuesFromGetters(e));var r=Object.keys(t).map(function(e){return i.validate(e,t[e].value,t[e].scope)});return Promise.all(r).then(function(){return!0}).catch(function(){throw new J("Validation Failed")})},ge.prototype.validateScopes=function(){var e=this;return Promise.all(Object.keys(this.$scopes).map(function(t){return e.validateAll(t)}))},Object.defineProperties(ge.prototype,ye);var be=function(e,t){return{computed:(i={},i[t.errorBagName]={get:function(){return this.$validator.errorBag}},i[t.fieldsBagName]={get:function(){return this.$validator.fieldBag}},i),beforeCreate:function(){this.$validator=new ge(null,{init:!1}),e.util.defineReactive(this.$validator,"errorBag",this.$validator.errorBag),e.util.defineReactive(this.$validator,"fieldBag",this.$validator.fieldBag)},mounted:function(){this.$validator.init()}};var i},xe=function(e,t,i,r){this.unwatch=void 0,this.callbacks=[],this.el=e,this.scope=H(t.value)?t.value.scope:Z(e),this.binding=t,this.vm=i.context,this.component=i.child,this.options=r,this.fieldName=this._resolveFieldName(),this.model=this._resolveModel(i.data.directives)};xe.prototype._resolveModel=function(e){var t=/^[a-z_]+[0-9]*(\w*\.[a-z_]\w*)*$/i,i=ne(e,function(e){return"model"===e.name&&t.test(e.expression)});return i&&this._isExistingPath(i.expression)&&i.expression},xe.prototype._isExistingPath=function(e){var t=this.vm;return e.split(".").every(function(e){return!!Object.prototype.hasOwnProperty.call(t,e)&&(t=t[e],!0)})},xe.prototype._resolveFieldName=function(){return this.component?Y(this.el,"name")||this.component.name:Y(this.el,"name")||this.el.name},xe.prototype._hasFieldDependency=function(e){var t=this,i=!1;return!!e&&(H(e)?(Object.keys(e).forEach(function(t){if(/confirmed|after|before/.test(t))return i=e[t],!1}),i):(e.split("|").every(function(e){return/\b(confirmed|after|before):/.test(e)?(i=e.split(":")[1],!1):!/\b(confirmed)/.test(e)||(i=t.fieldName+"_confirmation",!1)}),i))},xe.prototype._inputListener=function(){this._validate(this.el.value)},xe.prototype._fileListener=function(){var e=this._validate(ie(this.el.files));!e&&this.binding.modifiers.reject&&(this.el.value="")},xe.prototype._radioListener=function(){var e=document.querySelector('input[name="'+this.el.name+'"]:checked');this._validate(e?e.value:null)},xe.prototype._checkboxListener=function(){var e=this,t=document.querySelectorAll('input[name="'+this.el.name+'"]:checked');return t&&t.length?void ie(t).forEach(function(t){e._validate(t.value)}):void this._validate(null)},xe.prototype._validate=function(e){return this.vm.$validator.validate(this.fieldName,e,this.scope||Z(this.el)).catch(function(e){return e})},xe.prototype._getScopedListener=function(e){var t=this;return function(i){(!i||i===t.scope||i instanceof window.Event)&&e()}},xe.prototype._attachValidatorEvent=function(){var e=this,t=this._getScopedListener(this._getSuitableListener().listener.bind(this)),i=this._hasFieldDependency(oe(this.binding.expression,this.binding.value,this.el));
- i&&this.vm.$nextTick(function(){var r=document.querySelector("input[name='"+i+"']");return r?(r.addEventListener("input",t),void e.callbacks.push({name:"input",listener:t,el:r})):void K("Cannot find target field, no additional listeners were attached.")})},xe.prototype._getSuitableListener=function(){var e;if("SELECT"===this.el.tagName)return{names:["change","blur"],listener:this._inputListener};switch(this.el.type){case"file":e={names:["change"],listener:this._fileListener};break;case"radio":e={names:["change"],listener:this._radioListener};break;case"checkbox":e={names:["change"],listener:this._checkboxListener};break;default:e={names:["input","blur"],listener:this._inputListener}}var t=Y(this.el,"validate-on");return t&&(e.names=t.split("|")),e},xe.prototype._attachComponentListeners=function(){var e=this;this.componentListener=W(function(t){e._validate(t)},Y(this.el,"delay")||this.options.delay),this.component.$on("input",this.componentListener)},xe.prototype._attachFieldListeners=function(){var e=this;if(this.component)return void this._attachComponentListeners();var t=this._getSuitableListener(),i=W(t.listener.bind(this),Y(this.el,"delay")||this.options.delay);return~["radio","checkbox"].indexOf(this.el.type)?void this.vm.$nextTick(function(){var r=document.querySelectorAll('input[name="'+e.el.name+'"]');ie(r).forEach(function(r){t.names.forEach(function(t){r.addEventListener(t,i),e.callbacks.push({name:t,listener:i,el:r})})})}):void t.names.forEach(function(t){e.el.addEventListener(t,i),e.callbacks.push({name:t,listener:i,el:e.el})})},xe.prototype._resolveValueGetter=function(){var e=this;if(this.component)return{context:function(){return e.component},getter:function(e){return e[Y(e.$el,"value-path")]||e.value}};switch(this.el.type){case"checkbox":return{context:function(){return document.querySelectorAll('input[name="'+e.el.name+'"]:checked')},getter:function(e){return e&&e.length?ie(e).map(function(e){return e.value}):null}};case"radio":return{context:function(){return document.querySelector('input[name="'+e.el.name+'"]:checked')},getter:function(e){return e&&e.value}};case"file":return{context:function(){return e.el},getter:function(e){return ie(e.files)}};default:return{context:function(){return e.el},getter:function(e){return e.value}}}},xe.prototype._getArg=function(){return this.binding.arg?this.binding.arg:this.model?this.model:H(this.binding.value)?this.binding.value.arg:null},xe.prototype._attachModelWatcher=function(e){var t=this,i=Y(this.el,"validate-on")||"input|blur",r=W(this._getSuitableListener().listener.bind(this),Y(this.el,"delay")||this.options.delay);i.split("|").forEach(function(i){if(~["input","change"].indexOf(i)){var n=W(function(e){t.vm.$validator.validate(t.fieldName,e,t.scope||Z(t.el)).catch(function(e){return e})},Y(t.el,"delay")||t.options.delay);return void(t.unwatch=t.vm.$watch(e,n,{deep:!0}))}t.el.addEventListener(i,r),t.callbacks.push({name:i,listener:r,el:t.el})})},xe.prototype.attach=function(){var e=this,t=this._resolveValueGetter(),i=t.context,r=t.getter;this.vm.$validator.attach(this.fieldName,oe(this.binding.expression,this.binding.value,this.el),{scope:function(){return e.scope||Z(e.el)},prettyName:Y(this.el,"as")||this.el.title,context:i,getter:r,listeners:this}),this._attachValidatorEvent();var n=this._getArg();return n?void this._attachModelWatcher(n):void this._attachFieldListeners()},xe.prototype.detach=function(){this.component&&this.component.$off("input",this.componentListener),this.unwatch&&this.unwatch(),this.callbacks.forEach(function(e){e.el.removeEventListener(e.name,e.listener)}),this.callbacks=[]};var Fe=[],$e=function(e){return{inserted:function(t,o,a){var s=new xe(t,o,a,e);s.attach(),Fe.push({vm:a.context,el:t,instance:s}),e.enableAutoClasses&&(n(t,e.classNames),t.onfocus=function(){r(t,e.classNames)},i(t,a.context.$validator.fieldBag.fields[s.fieldName],e.classNames))},update:function(t,r,n){var o=r.expression,a=r.value,s=(r.oldValue,n.context),u=ne(Fe,function(e){return e.vm===s&&e.el===t}),l=u.instance;if(e.enableAutoClasses&&i(t,s.$validator.fieldBag.fields[l.fieldName],e.classNames),o&&l.cachedExp!==JSON.stringify(a)){l.cachedExp=JSON.stringify(a);var c=H(a)?a.scope||Z(t):Z(t);s.$validator.updateField(l.fieldName,oe(o,a,t),{scope:c||"__global__"})}},unbind:function(e,t,i){var r=t.value,n=i.context,o=ne(Fe,function(t){return t.vm===n&&t.el===e});if("undefined"!=typeof o){var a=H(r)?r.scope:Z(e)||"__global__";n.$validator.detach(o.instance.fieldName,a),Fe.splice(Fe.indexOf(o),1)}}}},we={touched:"touched",untouched:"untouched",valid:"valid",invalid:"invalid",pristine:"pristine",dirty:"dirty"},Ae=function(e,t){void 0===t&&(t={});var i=t.locale;void 0===i&&(i="en");var r=t.delay;void 0===r&&(r=0);var n=t.errorBagName;void 0===n&&(n="errors");var o=t.dictionary;void 0===o&&(o=null);var a=t.strict;void 0===a&&(a=!0);var s=t.fieldsBagName;void 0===s&&(s="fields");var u=t.enableAutoClasses;void 0===u&&(u=!1);var l=t.classNames;void 0===l&&(l={}),o&&ge.updateDictionary(o),ge.setLocale(i),ge.setStrictMode(a);var c={locale:i,delay:r,dictionary:o,errorBagName:n,fieldsBagName:s,enableAutoClasses:u,classNames:re({},we,l)};e.mixin(be(e,c)),e.directive("validate",$e(c))},Ee={install:Ae,Validator:ge,ErrorBag:G,version:"2.0.0-beta.24"};return Ee});
|