Comparing version 0.2.2 to 0.2.4
@@ -1,1 +0,1 @@ | ||
"use strict";const r=r=>null!==r&&r&&"object"==typeof r&&!Array.isArray(r),t=(t,e)=>(...i)=>{const s=e(...i),n=i.splice(0,i.length-1);return(...e)=>{const i=s(...e);if(i){const e={[t]:n};return Array.isArray(i)||r(i)?i:{code:i,rule:e}}return""}},e=r=>{if(!r)return!1;const{tag:t}=r.componentOptions;return/^(keep-alive|transition|transition-group)$/.test(t)};var i={isPrimitiveValue:r=>"string"==typeof r||(!("number"!=typeof r||!isFinite(r))||"boolean"==typeof r),looksLikeNumber:r=>!isNaN(+r),isObject:r=>Object(r)===r&&Object.getPrototypeOf(r)===Object.prototype,isEmptyObject(r){for(const t in r)if(r.hasOwnProperty(t))return!1;return!0},escapeRegExp:r=>r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),isNoValue:r=>null==r||""===r};const s={};let n=0;class o{constructor(r,t){this.isPrepared=!1,this.livrRules=r,this.validators={},this.validatorBuilders={},this.errors=null,this.isAutoTrim=null!=t?t:n,this.registerRules(s)}static getDefaultRules(){return s}static registerAliasedDefaultRule(r){if(!r.name)throw"Alias name required";s[r.name]=this._buildAliasedRule(r.rules,r.error)}static registerDefaultRules(r){for(const t in r)s[t]=r[t]}static defaultAutoTrim(r){n=!!r}static _buildAliasedRule(r,t){if(!r)throw"Alias rules required";const e={value:r};return r=>{const i=new o(e).registerRules(r).prepare();return(r,e,s)=>{const n=i.validate({value:r});return n?void s.push(n.value):t||i.getErrors().value}}}prepare(){const r=this.livrRules;for(const t in r){let e=r[t];Array.isArray(e)||(e=[e]);const i=[];for(const r of e){const t=this._parseRule(r);i.push(this._buildValidator(t.name,t.args))}this.validators[t]=i}return this.isPrepared=!0,this}validate(r){if(this.isPrepared||this.prepare(),!i.isObject(r))return void(this.errors="FORMAT_ERROR");this.isAutoTrim&&(r=this._autoTrim(r));const t={},e={};for(const i in this.validators){const s=this.validators[i];if(!s||!s.length)continue;const n=r[i];for(const o of s){const s=[],u=o(e.hasOwnProperty(i)?e[i]:n,r,s);if(u){t[i]=u;break}s.length?e[i]=s[0]:r.hasOwnProperty(i)&&!e.hasOwnProperty(i)&&(e[i]=n)}}return i.isEmptyObject(t)?(this.errors=null,e):(this.errors=t,!1)}getErrors(){return this.errors}registerRules(r){for(const t in r)this.validatorBuilders[t]=r[t];return this}registerAliasedRule(r){if(!r.name)throw"Alias name required";return this.validatorBuilders[r.name]=this.constructor._buildAliasedRule(r.rules,r.error),this}getRules(){return this.validatorBuilders}_parseRule(r){let t,e;return i.isObject(r)?(t=Object.keys(r)[0],e=r[t],Array.isArray(e)||(e=[e])):(t=r,e=[]),{name:t,args:e}}_buildValidator(r,t){if(!this.validatorBuilders[r])throw"Rule ["+r+"] not registered";const e=[];return e.push.apply(e,t),e.push(this.getRules()),this.validatorBuilders[r].apply(null,e)}_autoTrim(r){const t=typeof r;if("object"!==t&&r)return r.replace?r.replace(/^\s*/,"").replace(/\s*$/,""):r;if("object"==t&&Array.isArray(r)){const t=[];for(const e of r)t.push(this._autoTrim(e));return t}if("object"==t&&i.isObject(r)){const t={};for(const e in r)r.hasOwnProperty(e)&&(t[e]=this._autoTrim(r[e]));return t}return r}}var u=o;const a={required:function(){return r=>{if(i.isNoValue(r))return"REQUIRED"}},not_empty:function(){return r=>{if(null!=r&&""===r)return"CANNOT_BE_EMPTY"}},not_empty_list:function(){return r=>void 0===r||""===r?"CANNOT_BE_EMPTY":Array.isArray(r)?r.length<1?"CANNOT_BE_EMPTY":void 0:"FORMAT_ERROR"},any_object:function(){return r=>{if(!i.isNoValue(r))return i.isObject(r)?void 0:"FORMAT_ERROR"}},string:function(){return(r,t,e)=>{if(!i.isNoValue(r))return i.isPrimitiveValue(r)?void e.push(r+""):"FORMAT_ERROR"}},eq:function(r){return(t,e,s)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if(t+""!=r+"")return"NOT_ALLOWED_VALUE";s.push(r)}}},one_of:function(r){return Array.isArray(r)||(r=Array.prototype.slice.call(arguments)).pop(),(t,e,s)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";for(const e of r)if(t+""==e+"")return void s.push(e);return"NOT_ALLOWED_VALUE"}}},max_length:function(r){return(t,e,s)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if((t+="").length>r)return"TOO_LONG";s.push(t)}}},min_length:function(r){return(t,e,s)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if((t+="").length<r)return"TOO_SHORT";s.push(t)}}},length_equal:function(r){return(t,e,s)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?(t+="").length<r?"TOO_SHORT":t.length>r?"TOO_LONG":void s.push(t):"FORMAT_ERROR"}},length_between:function(r,t){return(e,s,n)=>{if(!i.isNoValue(e))return i.isPrimitiveValue(e)?(e+="").length<r?"TOO_SHORT":e.length>t?"TOO_LONG":void n.push(e):"FORMAT_ERROR"}},like:function(r,t){const e=3===arguments.length&&t.match("i"),s=new RegExp(r,e?"i":"");return(r,t,e)=>{if(!i.isNoValue(r)){if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";if(!(r+="").match(s))return"WRONG_FORMAT";e.push(r)}}},integer:function(){return(r,t,e)=>{if(!i.isNoValue(r))return i.isPrimitiveValue(r)?i.looksLikeNumber(r)&&Number.isInteger(+r)?void e.push(+r):"NOT_INTEGER":"FORMAT_ERROR"}},positive_integer:function(){return(r,t,e)=>{if(!i.isNoValue(r))return i.isPrimitiveValue(r)?i.looksLikeNumber(r)?!Number.isInteger(+r)||+r<1?"NOT_POSITIVE_INTEGER":void e.push(+r):"NOT_POSITIVE_INTEGER":"FORMAT_ERROR"}},decimal:function(){return(r,t,e)=>{if(!i.isNoValue(r)){if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";if(!i.looksLikeNumber(r))return"NOT_DECIMAL";if(!/^(?:\-?(?:(?:[0-9]+\.[0-9]+)|(?:[0-9]+)))$/.test(r+=""))return"NOT_DECIMAL";e.push(+r)}}},positive_decimal:function(){return(r,t,e)=>{if(!i.isNoValue(r)){if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";if(!i.looksLikeNumber(r))return"NOT_POSITIVE_DECIMAL";if(!/^(?:(?:[0-9]*\.[0-9]+)|(?:[1-9][0-9]*))$/.test(r+=""))return"NOT_POSITIVE_DECIMAL";e.push(+r)}}},max_number:function(r){return(t,e,s)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?i.looksLikeNumber(t)?+t>+r?"TOO_HIGH":void s.push(+t):"NOT_NUMBER":"FORMAT_ERROR"}},min_number:function(r){return(t,e,s)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?i.looksLikeNumber(t)?+t<+r?"TOO_LOW":void s.push(+t):"NOT_NUMBER":"FORMAT_ERROR"}},number_between:function(r,t){return(e,s,n)=>{if(!i.isNoValue(e))return i.isPrimitiveValue(e)?i.looksLikeNumber(e)?+e<+r?"TOO_LOW":+e>+t?"TOO_HIGH":void n.push(+e):"NOT_NUMBER":"FORMAT_ERROR"}},email:function(){var r=/^(([^<>()\[\]\\.,;:\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,}))$/;return t=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?(t+="",r.test(t)?/\@.*\@/.test(t)||/\@.*_/.test(t)?"WRONG_EMAIL":void 0:"WRONG_EMAIL"):"FORMAT_ERROR"}},equal_to_field:function(r){return(t,e)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?t!=e[r]?"FIELDS_NOT_EQUAL":void 0:"FORMAT_ERROR"}},url:function(){const r=new RegExp("^(?:(?:http|https)://)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[0-1]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-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,})))\\.?|localhost)(?::\\d{2,5})?(?:[/?#]\\S*)?$","i");return t=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if(!(t.length<2083&&r.test(t)))return"WRONG_URL"}}},iso_date:function(){return r=>{if(i.isNoValue(r))return;if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";const t=r.match(/^(\d{4})-([0-1][0-9])-([0-3][0-9])$/);if(t){const e=Date.parse(r);if(!e&&0!==e)return"WRONG_DATE";const i=new Date(e);if(i.setTime(i.getTime()+60*i.getTimezoneOffset()*1e3),i.getFullYear()==t[1]&&i.getMonth()+1==+t[2]&&i.getDate()==+t[3])return}return"WRONG_DATE"}},nested_object:function(r,t){const e=new u(r).registerRules(t).prepare();return(r,t,s)=>{if(i.isNoValue(r))return;if(!i.isObject(r))return"FORMAT_ERROR";const n=e.validate(r);return n?void s.push(n):e.getErrors()}},variable_object:function(r,t,e){const s={};for(const r in t){const i=new u(t[r]).registerRules(e).prepare();s[r]=i}return(t,e,n)=>{if(i.isNoValue(t))return;if(!i.isObject(t)||!t[r]||!s[t[r]])return"FORMAT_ERROR";const o=s[t[r]],u=o.validate(t);return u?void n.push(u):o.getErrors()}},list_of:function(r,t){Array.isArray(r)||(t=(r=Array.prototype.slice.call(arguments)).pop());const e={field:r},s=new u(e).registerRules(t).prepare();return(r,t,e)=>{if(i.isNoValue(r))return;if(!Array.isArray(r))return"FORMAT_ERROR";const n=[],o=[];let u=!1;for(const t of r){const r=s.validate({field:t});r?(n.push(r.field),o.push(null)):(u=!0,o.push(s.getErrors().field),n.push(null))}return u?o:void e.push(n)}},list_of_objects:function(r,t){const e=new u(r).registerRules(t).prepare();return(r,t,s)=>{if(i.isNoValue(r))return;if(!Array.isArray(r))return"FORMAT_ERROR";const n=[],o=[];let u=!1;for(const t of r){const r=e.validate(t);r?(n.push(r),o.push(null)):(u=!0,o.push(e.getErrors()),n.push(null))}return u?o:void s.push(n)}},or:function(){const r=Array.prototype.slice.call(arguments),t=r.pop(),e=r.map(r=>new u({field:r}).registerRules(t).prepare());return(r,t,i)=>{let s;for(const t of e){const e=t.validate({field:r});if(e)return void i.push(e.field);s=t.getErrors().field}return s}},list_of_different_objects:function(r,t,e){const s={};for(const r in t){const i=new u(t[r]).registerRules(e).prepare();s[r]=i}return(t,e,n)=>{if(i.isNoValue(t))return;if(!Array.isArray(t))return"FORMAT_ERROR";const o=[],u=[];let a=!1;for(const e of t){if("object"!=typeof e||!e[r]||!s[e[r]]){u.push("FORMAT_ERROR");continue}const t=s[e[r]],i=t.validate(e);i?(o.push(i),u.push(null)):(a=!0,u.push(t.getErrors()),o.push(null))}return a?u:void n.push(o)}},default:r=>(t,e,s)=>{i.isNoValue(t)&&s.push(r)},trim:function(){return(r,t,e)=>{i.isNoValue(r)||"object"==typeof r||(r+="",e.push(r.replace(/^\s*/,"").replace(/\s*$/,"")))}},to_lc:function(){return(r,t,e)=>{i.isNoValue(r)||"object"==typeof r||(r+="",e.push(r.toLowerCase()))}},to_uc:function(){return(r,t,e)=>{i.isNoValue(r)||"object"==typeof r||(r+="",e.push(r.toUpperCase()))}},remove:function(r){r=i.escapeRegExp(r);const t=new RegExp("["+r+"]","g");return(r,e,s)=>{i.isNoValue(r)||"object"==typeof r||(r+="",s.push(r.replace(t,"")))}},leave_only:function(r){r=i.escapeRegExp(r);const t=new RegExp("[^"+r+"]","g");return(r,e,s)=>{i.isNoValue(r)||"object"==typeof r||(r+="",s.push(r.replace(t,"")))}}};u.registerDefaultRules(a);var l={Validator:u,rules:a,util:i},c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},f="object"==typeof c&&c&&c.Object===Object&&c,h="object"==typeof self&&self&&self.Object===Object&&self,p=f||h||Function("return this")(),d=p.Symbol,v=Object.prototype,_=v.hasOwnProperty,R=v.toString,O=d?d.toStringTag:void 0;var g=function(r){var t=_.call(r,O),e=r[O];try{r[O]=void 0;var i=!0}catch(r){}var s=R.call(r);return i&&(t?r[O]=e:delete r[O]),s},y=Object.prototype.toString;var E=function(r){return y.call(r)},m=d?d.toStringTag:void 0;var b=function(r){return null==r?void 0===r?"[object Undefined]":"[object Null]":m&&m in Object(r)?g(r):E(r)};var A=function(r){var t=typeof r;return null!=r&&("object"==t||"function"==t)};var T,N=function(r){if(!A(r))return!1;var t=b(r);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},j=p["__core-js_shared__"],V=(T=/[^.]+$/.exec(j&&j.keys&&j.keys.IE_PROTO||""))?"Symbol(src)_1."+T:"";var $=function(r){return!!V&&V in r},w=Function.prototype.toString;var P=function(r){if(null!=r){try{return w.call(r)}catch(r){}try{return r+""}catch(r){}}return""},M=/^\[object .+?Constructor\]$/,F=Function.prototype,L=Object.prototype,I=F.toString,x=L.hasOwnProperty,D=RegExp("^"+I.call(x).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var k=function(r){return!(!A(r)||$(r))&&(N(r)?D:M).test(P(r))};var z=function(r,t){return null==r?void 0:r[t]};var S=function(r,t){var e=z(r,t);return k(e)?e:void 0},B=function(){try{var r=S(Object,"defineProperty");return r({},"",{}),r}catch(r){}}();var G=function(r,t,e){"__proto__"==t&&B?B(r,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):r[t]=e};var C=function(r,t){return r===t||r!=r&&t!=t},H=Object.prototype.hasOwnProperty;var U=function(r,t,e){var i=r[t];H.call(r,t)&&C(i,e)&&(void 0!==e||t in r)||G(r,t,e)},W=Array.isArray;var q=function(r){return null!=r&&"object"==typeof r};var Y=function(r){return"symbol"==typeof r||q(r)&&"[object Symbol]"==b(r)},Q=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Z=/^\w*$/;var J=function(r,t){if(W(r))return!1;var e=typeof r;return!("number"!=e&&"symbol"!=e&&"boolean"!=e&&null!=r&&!Y(r))||(Z.test(r)||!Q.test(r)||null!=t&&r in Object(t))},K=S(Object,"create");var X=function(){this.__data__=K?K(null):{},this.size=0};var rr=function(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t},tr=Object.prototype.hasOwnProperty;var er=function(r){var t=this.__data__;if(K){var e=t[r];return"__lodash_hash_undefined__"===e?void 0:e}return tr.call(t,r)?t[r]:void 0},ir=Object.prototype.hasOwnProperty;var sr=function(r){var t=this.__data__;return K?void 0!==t[r]:ir.call(t,r)};var nr=function(r,t){var e=this.__data__;return this.size+=this.has(r)?0:1,e[r]=K&&void 0===t?"__lodash_hash_undefined__":t,this};function or(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t<e;){var i=r[t];this.set(i[0],i[1])}}or.prototype.clear=X,or.prototype.delete=rr,or.prototype.get=er,or.prototype.has=sr,or.prototype.set=nr;var ur=or;var ar=function(){this.__data__=[],this.size=0};var lr=function(r,t){for(var e=r.length;e--;)if(C(r[e][0],t))return e;return-1},cr=Array.prototype.splice;var fr=function(r){var t=this.__data__,e=lr(t,r);return!(e<0)&&(e==t.length-1?t.pop():cr.call(t,e,1),--this.size,!0)};var hr=function(r){var t=this.__data__,e=lr(t,r);return e<0?void 0:t[e][1]};var pr=function(r){return lr(this.__data__,r)>-1};var dr=function(r,t){var e=this.__data__,i=lr(e,r);return i<0?(++this.size,e.push([r,t])):e[i][1]=t,this};function vr(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t<e;){var i=r[t];this.set(i[0],i[1])}}vr.prototype.clear=ar,vr.prototype.delete=fr,vr.prototype.get=hr,vr.prototype.has=pr,vr.prototype.set=dr;var _r=vr,Rr=S(p,"Map");var Or=function(){this.size=0,this.__data__={hash:new ur,map:new(Rr||_r),string:new ur}};var gr=function(r){var t=typeof r;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==r:null===r};var yr=function(r,t){var e=r.__data__;return gr(t)?e["string"==typeof t?"string":"hash"]:e.map};var Er=function(r){var t=yr(this,r).delete(r);return this.size-=t?1:0,t};var mr=function(r){return yr(this,r).get(r)};var br=function(r){return yr(this,r).has(r)};var Ar=function(r,t){var e=yr(this,r),i=e.size;return e.set(r,t),this.size+=e.size==i?0:1,this};function Tr(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t<e;){var i=r[t];this.set(i[0],i[1])}}Tr.prototype.clear=Or,Tr.prototype.delete=Er,Tr.prototype.get=mr,Tr.prototype.has=br,Tr.prototype.set=Ar;var Nr=Tr;function jr(r,t){if("function"!=typeof r||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var e=function(){var i=arguments,s=t?t.apply(this,i):i[0],n=e.cache;if(n.has(s))return n.get(s);var o=r.apply(this,i);return e.cache=n.set(s,o)||n,o};return e.cache=new(jr.Cache||Nr),e}jr.Cache=Nr;var Vr=jr;var $r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,wr=/\\(\\)?/g,Pr=function(r){var t=Vr(r,(function(r){return 500===e.size&&e.clear(),r})),e=t.cache;return t}((function(r){var t=[];return 46===r.charCodeAt(0)&&t.push(""),r.replace($r,(function(r,e,i,s){t.push(i?s.replace(wr,"$1"):e||r)})),t}));var Mr=function(r,t){for(var e=-1,i=null==r?0:r.length,s=Array(i);++e<i;)s[e]=t(r[e],e,r);return s},Fr=d?d.prototype:void 0,Lr=Fr?Fr.toString:void 0;var Ir=function r(t){if("string"==typeof t)return t;if(W(t))return Mr(t,r)+"";if(Y(t))return Lr?Lr.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e};var xr=function(r){return null==r?"":Ir(r)};var Dr=function(r,t){return W(r)?r:J(r,t)?[r]:Pr(xr(r))},kr=/^(?:0|[1-9]\d*)$/;var zr=function(r,t){var e=typeof r;return!!(t=null==t?9007199254740991:t)&&("number"==e||"symbol"!=e&&kr.test(r))&&r>-1&&r%1==0&&r<t};var Sr=function(r){if("string"==typeof r||Y(r))return r;var t=r+"";return"0"==t&&1/r==-1/0?"-0":t};var Br=function(r,t,e,i){if(!A(r))return r;for(var s=-1,n=(t=Dr(t,r)).length,o=n-1,u=r;null!=u&&++s<n;){var a=Sr(t[s]),l=e;if("__proto__"===a||"constructor"===a||"prototype"===a)return r;if(s!=o){var c=u[a];void 0===(l=i?i(c,a,u):void 0)&&(l=A(c)?c:zr(t[s+1])?[]:{})}U(u,a,l),u=u[a]}return r};var Gr=function(r,t,e){return null==r?r:Br(r,t,e)};var Cr=function(r,t){for(var e=0,i=(t=Dr(t,r)).length;null!=r&&e<i;)r=r[Sr(t[e++])];return e&&e==i?r:void 0};var Hr=function(r,t,e){var i=null==r?void 0:Cr(r,t);return void 0===i?e:i};const Ur=(r={},t,e,i)=>{const s=r[e];return s?s(t,i):""},Wr=(r,t,e=[])=>{const i=Array.isArray(r);return Object.entries(r).reduce((r,[s,n])=>{let o=[].concat(e);if(i||o.push(s),n&&n.code){const[[,r]]=Object.entries(n.rule);Object.assign(n,{msg:Ur(t,o.join("."),n.code,r)}),o=[]}else n&&Wr(n,t,o);return Object.assign(r,{[s]:n})},{})};class qr{constructor(r,t={}){this.errorHandlers=t.errorHandlers,this.extendedErrors=t.extendedErrors,this.msgPath=this.extendedErrors?"msg":"",this.allTouched=!1,r&&r instanceof qr?(this.items=r.items,this.touchedFields=r.touchedFields):(this.items={},this.touchedFields={})}setTouched(r){Gr(this.touchedFields,r,!0)}setAllTouched(r=!1){this.allTouched=r}setError(r,t){const e=this.extendedErrors?Wr(r,this.errorHandlers):r,i=t?this.items:{};if(this.items=Object.assign({},i,e),t){Hr(e,t,!1)||Gr(this.items,t,"")}}clearErrors(r=this.items){r&&Object.entries(r).forEach(([r,t])=>"object"==typeof t?this.clearErrors(t):this.clearError(r))}clearError(r){this.setError({},r)}getError(r,t=0){if(!this.hasError(r,t))return"";const e=this.getErrors(r);return this.getMessage(e[t])}getMessage(r){return this.msgPath&&r?r[this.msgPath]:r}getErrors(r){return[].concat(Hr(this.items,r,[]))}hasError(r,t=0){const e=this.allTouched||Hr(this.touchedFields,r,!1),i=this.getErrors(r);return e&&!(r=>null==r||""===r)(this.getMessage(i[t]))}}class Yr{constructor(r,e){this.extendedErrors=e.extendedErrors,this.aliasedRules=e.aliasedRules,this.aliasedRules.forEach(this.registerAliasedDefaultRule),l.Validator.registerDefaultRules(e.extraRules),this.errors=new qr(null,e),this.extendedErrors&&(()=>{const r=l.Validator.getDefaultRules(),e=Object.entries(r).reduce((r,[e,i])=>Object.assign(r,{[e]:t(e,i)}),{});l.Validator.registerDefaultRules(e)})(),this.fields={items:[]},this.$gzLivr=r||{_vm:{$emit:()=>{},$off:()=>{}}}}validate(r,t,e){const i=new l.Validator(r),s=i.validate(t),n=s||i.getErrors();return s?(this.errors.clearError(e),n):(this.errors.setError(Object.assign({},n),e),this.errors.setTouched(e),{errors:this.errors.items})}registerAliasedDefaultRule(r){l.Validator.registerAliasedDefaultRule(r)}validateAll(r,t){this.validator=new l.Validator(r);const e=this.validator.validate(t),i=e||this.validator.getErrors();return e?(this.errors.clearErrors(),i):(this.errors.setError(i),this.errors.setAllTouched(!0),{errors:this.errors.items})}clearErrors(){this.errors.clearErrors()}clearError(r){this.errors.clearError(r)}}let Qr=null;const Zr=()=>Qr;let Jr=Object.assign({},{errorBagName:"errors",fieldsBagName:"fields",inject:!0,extendedErrors:!1,extraRules:{},aliasedRules:[]});const Kr=()=>Jr,Xr=r=>{Jr=Object.assign({},Jr,r)};var rt={provide(){return this.$livr&&!e(this.$vnode)?{$livr:this.$livr}:{}},beforeCreate(){if(e(this.$vnode)||!1===this.$options.$__livrInject)return;this.$parent||Xr(this.$options.$_livr||{});const t=(r=>{const t=Hr(r,"$options.$_livr",{});return Object.assign({},Jr,t)})(this);(!this.$parent||this.$options.$_livr&&/new/.test(this.$options.$_livr.validator))&&(this.$livr=new Yr(Zr(),t));const i=(s=this.$options.inject,!(!r(s)||!s.$livr));var s;if(this.$livr||!t.inject||i||(this.$livr=new Yr(Zr(),t)),i||this.$livr){if(!i&&this.$livr){this.$options._base.util.defineReactive(this.$livr,"errors",this.$livr.errors)}this.$options.computed||(this.$options.computed={}),this.$options.computed[t.errorBagName||"errors"]=function(){return this.$livr.errors},this.$options.computed[t.fieldsBagName||"fields"]=function(){return this.$livr.fields.items.reduce((r,t)=>t.scope?(r["$"+t.scope]||(r["$"+t.scope]={}),r["$"+t.scope][t.name]=t.flags,r):(r[t.name]=t.flags,r),{})}}}};let tt,et;class it{constructor(r,t){var e;this.configure(r),et=this,t&&(tt=t),this.livrInstance=(e=new Yr(null,this.config),Qr=e,e),this.initVM(this.config)}static install(r,t={}){tt&&r===tt?"production"!==process.env.NODE_ENV&&console.warn("already installed, Vue.use(LivrPlugin) should only be called once."):(tt=r,et=new it(t),Yr.$livr=et,tt.mixin(rt))}initVM({errorBagName:r,fieldsBagName:t}){this._vm=new tt({data:()=>({[r]:this.livrInstance.errors,[t]:this.livrInstance.fields})})}configure(r){Xr(r)}get config(){return Kr()}static get config(){return Kr()}static get instance(){return et}}module.exports=it; | ||
"use strict";const r=r=>null!==r&&r&&"object"==typeof r&&!Array.isArray(r),t=(t,e)=>(...i)=>{const s=e(...i),n=i.splice(0,i.length-1);return(...e)=>{const i=s(...e);if(i){const e={[t]:n};return Array.isArray(i)||r(i)?i:{code:i,rule:e}}return""}},e=r=>{if(!r)return!1;const{tag:t}=r.componentOptions;return/^(keep-alive|transition|transition-group)$/.test(t)};var i={isPrimitiveValue:r=>"string"==typeof r||(!("number"!=typeof r||!isFinite(r))||"boolean"==typeof r),looksLikeNumber:r=>!isNaN(+r),isObject:r=>Object(r)===r&&Object.getPrototypeOf(r)===Object.prototype,isEmptyObject(r){for(const t in r)if(r.hasOwnProperty(t))return!1;return!0},escapeRegExp:r=>r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),isNoValue:r=>null==r||""===r};const s={};let n=0;class o{constructor(r,t){this.isPrepared=!1,this.livrRules=r,this.validators={},this.validatorBuilders={},this.errors=null,this.isAutoTrim=null!=t?t:n,this.registerRules(s)}static getDefaultRules(){return s}static registerAliasedDefaultRule(r){if(!r.name)throw"Alias name required";s[r.name]=this._buildAliasedRule(r.rules,r.error)}static registerDefaultRules(r){for(const t in r)s[t]=r[t]}static defaultAutoTrim(r){n=!!r}static _buildAliasedRule(r,t){if(!r)throw"Alias rules required";const e={value:r};return r=>{const i=new o(e).registerRules(r).prepare();return(r,e,s)=>{const n=i.validate({value:r});return n?void s.push(n.value):t||i.getErrors().value}}}prepare(){const r=this.livrRules;for(const t in r){let e=r[t];Array.isArray(e)||(e=[e]);const i=[];for(const r of e){const t=this._parseRule(r);i.push(this._buildValidator(t.name,t.args))}this.validators[t]=i}return this.isPrepared=!0,this}validate(r){if(this.isPrepared||this.prepare(),!i.isObject(r))return void(this.errors="FORMAT_ERROR");this.isAutoTrim&&(r=this._autoTrim(r));const t={},e={};for(const i in this.validators){const s=this.validators[i];if(!s||!s.length)continue;const n=r[i];for(const o of s){const s=[],u=o(e.hasOwnProperty(i)?e[i]:n,r,s);if(u){t[i]=u;break}s.length?e[i]=s[0]:r.hasOwnProperty(i)&&!e.hasOwnProperty(i)&&(e[i]=n)}}return i.isEmptyObject(t)?(this.errors=null,e):(this.errors=t,!1)}getErrors(){return this.errors}registerRules(r){for(const t in r)this.validatorBuilders[t]=r[t];return this}registerAliasedRule(r){if(!r.name)throw"Alias name required";return this.validatorBuilders[r.name]=this.constructor._buildAliasedRule(r.rules,r.error),this}getRules(){return this.validatorBuilders}_parseRule(r){let t,e;return i.isObject(r)?(t=Object.keys(r)[0],e=r[t],Array.isArray(e)||(e=[e])):(t=r,e=[]),{name:t,args:e}}_buildValidator(r,t){if(!this.validatorBuilders[r])throw"Rule ["+r+"] not registered";const e=[];return e.push.apply(e,t),e.push(this.getRules()),this.validatorBuilders[r].apply(null,e)}_autoTrim(r){const t=typeof r;if("object"!==t&&r)return r.replace?r.replace(/^\s*/,"").replace(/\s*$/,""):r;if("object"==t&&Array.isArray(r)){const t=[];for(const e of r)t.push(this._autoTrim(e));return t}if("object"==t&&i.isObject(r)){const t={};for(const e in r)r.hasOwnProperty(e)&&(t[e]=this._autoTrim(r[e]));return t}return r}}var u=o;const a={required:function(){return r=>{if(i.isNoValue(r))return"REQUIRED"}},not_empty:function(){return r=>{if(null!=r&&""===r)return"CANNOT_BE_EMPTY"}},not_empty_list:function(){return r=>void 0===r||""===r?"CANNOT_BE_EMPTY":Array.isArray(r)?r.length<1?"CANNOT_BE_EMPTY":void 0:"FORMAT_ERROR"},any_object:function(){return r=>{if(!i.isNoValue(r))return i.isObject(r)?void 0:"FORMAT_ERROR"}},string:function(){return(r,t,e)=>{if(!i.isNoValue(r))return i.isPrimitiveValue(r)?void e.push(r+""):"FORMAT_ERROR"}},eq:function(r){return(t,e,s)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if(t+""!=r+"")return"NOT_ALLOWED_VALUE";s.push(r)}}},one_of:function(r){return Array.isArray(r)||(r=Array.prototype.slice.call(arguments)).pop(),(t,e,s)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";for(const e of r)if(t+""==e+"")return void s.push(e);return"NOT_ALLOWED_VALUE"}}},max_length:function(r){return(t,e,s)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if((t+="").length>r)return"TOO_LONG";s.push(t)}}},min_length:function(r){return(t,e,s)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if((t+="").length<r)return"TOO_SHORT";s.push(t)}}},length_equal:function(r){return(t,e,s)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?(t+="").length<r?"TOO_SHORT":t.length>r?"TOO_LONG":void s.push(t):"FORMAT_ERROR"}},length_between:function(r,t){return(e,s,n)=>{if(!i.isNoValue(e))return i.isPrimitiveValue(e)?(e+="").length<r?"TOO_SHORT":e.length>t?"TOO_LONG":void n.push(e):"FORMAT_ERROR"}},like:function(r,t){const e=3===arguments.length&&t.match("i"),s=new RegExp(r,e?"i":"");return(r,t,e)=>{if(!i.isNoValue(r)){if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";if(!(r+="").match(s))return"WRONG_FORMAT";e.push(r)}}},integer:function(){return(r,t,e)=>{if(!i.isNoValue(r))return i.isPrimitiveValue(r)?i.looksLikeNumber(r)&&Number.isInteger(+r)?void e.push(+r):"NOT_INTEGER":"FORMAT_ERROR"}},positive_integer:function(){return(r,t,e)=>{if(!i.isNoValue(r))return i.isPrimitiveValue(r)?i.looksLikeNumber(r)?!Number.isInteger(+r)||+r<1?"NOT_POSITIVE_INTEGER":void e.push(+r):"NOT_POSITIVE_INTEGER":"FORMAT_ERROR"}},decimal:function(){return(r,t,e)=>{if(!i.isNoValue(r)){if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";if(!i.looksLikeNumber(r))return"NOT_DECIMAL";if(!/^(?:\-?(?:(?:[0-9]+\.[0-9]+)|(?:[0-9]+)))$/.test(r+=""))return"NOT_DECIMAL";e.push(+r)}}},positive_decimal:function(){return(r,t,e)=>{if(!i.isNoValue(r)){if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";if(!i.looksLikeNumber(r))return"NOT_POSITIVE_DECIMAL";if(!/^(?:(?:[0-9]*\.[0-9]+)|(?:[1-9][0-9]*))$/.test(r+=""))return"NOT_POSITIVE_DECIMAL";e.push(+r)}}},max_number:function(r){return(t,e,s)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?i.looksLikeNumber(t)?+t>+r?"TOO_HIGH":void s.push(+t):"NOT_NUMBER":"FORMAT_ERROR"}},min_number:function(r){return(t,e,s)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?i.looksLikeNumber(t)?+t<+r?"TOO_LOW":void s.push(+t):"NOT_NUMBER":"FORMAT_ERROR"}},number_between:function(r,t){return(e,s,n)=>{if(!i.isNoValue(e))return i.isPrimitiveValue(e)?i.looksLikeNumber(e)?+e<+r?"TOO_LOW":+e>+t?"TOO_HIGH":void n.push(+e):"NOT_NUMBER":"FORMAT_ERROR"}},email:function(){var r=/^(([^<>()\[\]\\.,;:\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,}))$/;return t=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?(t+="",r.test(t)?/\@.*\@/.test(t)||/\@.*_/.test(t)?"WRONG_EMAIL":void 0:"WRONG_EMAIL"):"FORMAT_ERROR"}},equal_to_field:function(r){return(t,e)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?t!=e[r]?"FIELDS_NOT_EQUAL":void 0:"FORMAT_ERROR"}},url:function(){const r=new RegExp("^(?:(?:http|https)://)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[0-1]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-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,})))\\.?|localhost)(?::\\d{2,5})?(?:[/?#]\\S*)?$","i");return t=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if(!(t.length<2083&&r.test(t)))return"WRONG_URL"}}},iso_date:function(){return r=>{if(i.isNoValue(r))return;if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";const t=r.match(/^(\d{4})-([0-1][0-9])-([0-3][0-9])$/);if(t){const e=Date.parse(r);if(!e&&0!==e)return"WRONG_DATE";const i=new Date(e);if(i.setTime(i.getTime()+60*i.getTimezoneOffset()*1e3),i.getFullYear()==t[1]&&i.getMonth()+1==+t[2]&&i.getDate()==+t[3])return}return"WRONG_DATE"}},nested_object:function(r,t){const e=new u(r).registerRules(t).prepare();return(r,t,s)=>{if(i.isNoValue(r))return;if(!i.isObject(r))return"FORMAT_ERROR";const n=e.validate(r);return n?void s.push(n):e.getErrors()}},variable_object:function(r,t,e){const s={};for(const r in t){const i=new u(t[r]).registerRules(e).prepare();s[r]=i}return(t,e,n)=>{if(i.isNoValue(t))return;if(!i.isObject(t)||!t[r]||!s[t[r]])return"FORMAT_ERROR";const o=s[t[r]],u=o.validate(t);return u?void n.push(u):o.getErrors()}},list_of:function(r,t){Array.isArray(r)||(t=(r=Array.prototype.slice.call(arguments)).pop());const e={field:r},s=new u(e).registerRules(t).prepare();return(r,t,e)=>{if(i.isNoValue(r))return;if(!Array.isArray(r))return"FORMAT_ERROR";const n=[],o=[];let u=!1;for(const t of r){const r=s.validate({field:t});r?(n.push(r.field),o.push(null)):(u=!0,o.push(s.getErrors().field),n.push(null))}return u?o:void e.push(n)}},list_of_objects:function(r,t){const e=new u(r).registerRules(t).prepare();return(r,t,s)=>{if(i.isNoValue(r))return;if(!Array.isArray(r))return"FORMAT_ERROR";const n=[],o=[];let u=!1;for(const t of r){const r=e.validate(t);r?(n.push(r),o.push(null)):(u=!0,o.push(e.getErrors()),n.push(null))}return u?o:void s.push(n)}},or:function(){const r=Array.prototype.slice.call(arguments),t=r.pop(),e=r.map(r=>new u({field:r}).registerRules(t).prepare());return(r,t,i)=>{let s;for(const t of e){const e=t.validate({field:r});if(e)return void i.push(e.field);s=t.getErrors().field}return s}},list_of_different_objects:function(r,t,e){const s={};for(const r in t){const i=new u(t[r]).registerRules(e).prepare();s[r]=i}return(t,e,n)=>{if(i.isNoValue(t))return;if(!Array.isArray(t))return"FORMAT_ERROR";const o=[],u=[];let a=!1;for(const e of t){if("object"!=typeof e||!e[r]||!s[e[r]]){u.push("FORMAT_ERROR");continue}const t=s[e[r]],i=t.validate(e);i?(o.push(i),u.push(null)):(a=!0,u.push(t.getErrors()),o.push(null))}return a?u:void n.push(o)}},default:r=>(t,e,s)=>{i.isNoValue(t)&&s.push(r)},trim:function(){return(r,t,e)=>{i.isNoValue(r)||"object"==typeof r||(r+="",e.push(r.replace(/^\s*/,"").replace(/\s*$/,"")))}},to_lc:function(){return(r,t,e)=>{i.isNoValue(r)||"object"==typeof r||(r+="",e.push(r.toLowerCase()))}},to_uc:function(){return(r,t,e)=>{i.isNoValue(r)||"object"==typeof r||(r+="",e.push(r.toUpperCase()))}},remove:function(r){r=i.escapeRegExp(r);const t=new RegExp("["+r+"]","g");return(r,e,s)=>{i.isNoValue(r)||"object"==typeof r||(r+="",s.push(r.replace(t,"")))}},leave_only:function(r){r=i.escapeRegExp(r);const t=new RegExp("[^"+r+"]","g");return(r,e,s)=>{i.isNoValue(r)||"object"==typeof r||(r+="",s.push(r.replace(t,"")))}}};u.registerDefaultRules(a);var l={Validator:u,rules:a,util:i},c="object"==typeof global&&global&&global.Object===Object&&global,f="object"==typeof self&&self&&self.Object===Object&&self,h=c||f||Function("return this")(),p=h.Symbol,d=Object.prototype,v=d.hasOwnProperty,_=d.toString,R=p?p.toStringTag:void 0;var O=function(r){var t=v.call(r,R),e=r[R];try{r[R]=void 0;var i=!0}catch(r){}var s=_.call(r);return i&&(t?r[R]=e:delete r[R]),s},g=Object.prototype.toString;var y=function(r){return g.call(r)},E=p?p.toStringTag:void 0;var m=function(r){return null==r?void 0===r?"[object Undefined]":"[object Null]":E&&E in Object(r)?O(r):y(r)};var b=function(r){var t=typeof r;return null!=r&&("object"==t||"function"==t)};var A,T=function(r){if(!b(r))return!1;var t=m(r);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},N=h["__core-js_shared__"],j=(A=/[^.]+$/.exec(N&&N.keys&&N.keys.IE_PROTO||""))?"Symbol(src)_1."+A:"";var V=function(r){return!!j&&j in r},$=Function.prototype.toString;var P=function(r){if(null!=r){try{return $.call(r)}catch(r){}try{return r+""}catch(r){}}return""},w=/^\[object .+?Constructor\]$/,M=Function.prototype,F=Object.prototype,L=M.toString,I=F.hasOwnProperty,x=RegExp("^"+L.call(I).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var D=function(r){return!(!b(r)||V(r))&&(T(r)?x:w).test(P(r))};var k=function(r,t){return null==r?void 0:r[t]};var z=function(r,t){var e=k(r,t);return D(e)?e:void 0},S=function(){try{var r=z(Object,"defineProperty");return r({},"",{}),r}catch(r){}}();var B=function(r,t,e){"__proto__"==t&&S?S(r,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):r[t]=e};var G=function(r,t){return r===t||r!=r&&t!=t},C=Object.prototype.hasOwnProperty;var H=function(r,t,e){var i=r[t];C.call(r,t)&&G(i,e)&&(void 0!==e||t in r)||B(r,t,e)},U=Array.isArray;var W=function(r){return null!=r&&"object"==typeof r};var q=function(r){return"symbol"==typeof r||W(r)&&"[object Symbol]"==m(r)},Y=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Q=/^\w*$/;var Z=function(r,t){if(U(r))return!1;var e=typeof r;return!("number"!=e&&"symbol"!=e&&"boolean"!=e&&null!=r&&!q(r))||(Q.test(r)||!Y.test(r)||null!=t&&r in Object(t))},J=z(Object,"create");var K=function(){this.__data__=J?J(null):{},this.size=0};var X=function(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t},rr=Object.prototype.hasOwnProperty;var tr=function(r){var t=this.__data__;if(J){var e=t[r];return"__lodash_hash_undefined__"===e?void 0:e}return rr.call(t,r)?t[r]:void 0},er=Object.prototype.hasOwnProperty;var ir=function(r){var t=this.__data__;return J?void 0!==t[r]:er.call(t,r)};var sr=function(r,t){var e=this.__data__;return this.size+=this.has(r)?0:1,e[r]=J&&void 0===t?"__lodash_hash_undefined__":t,this};function nr(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t<e;){var i=r[t];this.set(i[0],i[1])}}nr.prototype.clear=K,nr.prototype.delete=X,nr.prototype.get=tr,nr.prototype.has=ir,nr.prototype.set=sr;var or=nr;var ur=function(){this.__data__=[],this.size=0};var ar=function(r,t){for(var e=r.length;e--;)if(G(r[e][0],t))return e;return-1},lr=Array.prototype.splice;var cr=function(r){var t=this.__data__,e=ar(t,r);return!(e<0)&&(e==t.length-1?t.pop():lr.call(t,e,1),--this.size,!0)};var fr=function(r){var t=this.__data__,e=ar(t,r);return e<0?void 0:t[e][1]};var hr=function(r){return ar(this.__data__,r)>-1};var pr=function(r,t){var e=this.__data__,i=ar(e,r);return i<0?(++this.size,e.push([r,t])):e[i][1]=t,this};function dr(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t<e;){var i=r[t];this.set(i[0],i[1])}}dr.prototype.clear=ur,dr.prototype.delete=cr,dr.prototype.get=fr,dr.prototype.has=hr,dr.prototype.set=pr;var vr=dr,_r=z(h,"Map");var Rr=function(){this.size=0,this.__data__={hash:new or,map:new(_r||vr),string:new or}};var Or=function(r){var t=typeof r;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==r:null===r};var gr=function(r,t){var e=r.__data__;return Or(t)?e["string"==typeof t?"string":"hash"]:e.map};var yr=function(r){var t=gr(this,r).delete(r);return this.size-=t?1:0,t};var Er=function(r){return gr(this,r).get(r)};var mr=function(r){return gr(this,r).has(r)};var br=function(r,t){var e=gr(this,r),i=e.size;return e.set(r,t),this.size+=e.size==i?0:1,this};function Ar(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t<e;){var i=r[t];this.set(i[0],i[1])}}Ar.prototype.clear=Rr,Ar.prototype.delete=yr,Ar.prototype.get=Er,Ar.prototype.has=mr,Ar.prototype.set=br;var Tr=Ar;function Nr(r,t){if("function"!=typeof r||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var e=function(){var i=arguments,s=t?t.apply(this,i):i[0],n=e.cache;if(n.has(s))return n.get(s);var o=r.apply(this,i);return e.cache=n.set(s,o)||n,o};return e.cache=new(Nr.Cache||Tr),e}Nr.Cache=Tr;var jr=Nr;var Vr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,$r=/\\(\\)?/g,Pr=function(r){var t=jr(r,(function(r){return 500===e.size&&e.clear(),r})),e=t.cache;return t}((function(r){var t=[];return 46===r.charCodeAt(0)&&t.push(""),r.replace(Vr,(function(r,e,i,s){t.push(i?s.replace($r,"$1"):e||r)})),t}));var wr=function(r,t){for(var e=-1,i=null==r?0:r.length,s=Array(i);++e<i;)s[e]=t(r[e],e,r);return s},Mr=p?p.prototype:void 0,Fr=Mr?Mr.toString:void 0;var Lr=function r(t){if("string"==typeof t)return t;if(U(t))return wr(t,r)+"";if(q(t))return Fr?Fr.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e};var Ir=function(r){return null==r?"":Lr(r)};var xr=function(r,t){return U(r)?r:Z(r,t)?[r]:Pr(Ir(r))},Dr=/^(?:0|[1-9]\d*)$/;var kr=function(r,t){var e=typeof r;return!!(t=null==t?9007199254740991:t)&&("number"==e||"symbol"!=e&&Dr.test(r))&&r>-1&&r%1==0&&r<t};var zr=function(r){if("string"==typeof r||q(r))return r;var t=r+"";return"0"==t&&1/r==-1/0?"-0":t};var Sr=function(r,t,e,i){if(!b(r))return r;for(var s=-1,n=(t=xr(t,r)).length,o=n-1,u=r;null!=u&&++s<n;){var a=zr(t[s]),l=e;if("__proto__"===a||"constructor"===a||"prototype"===a)return r;if(s!=o){var c=u[a];void 0===(l=i?i(c,a,u):void 0)&&(l=b(c)?c:kr(t[s+1])?[]:{})}H(u,a,l),u=u[a]}return r};var Br=function(r,t,e){return null==r?r:Sr(r,t,e)};var Gr=function(r,t){for(var e=0,i=(t=xr(t,r)).length;null!=r&&e<i;)r=r[zr(t[e++])];return e&&e==i?r:void 0};var Cr=function(r,t,e){var i=null==r?void 0:Gr(r,t);return void 0===i?e:i};const Hr=(r={},t,e,i)=>{const s=r[e];return s?s(t,i):""},Ur=(r,t,e=[])=>{const i=Array.isArray(r);return Object.entries(r).reduce((r,[s,n])=>{let o=[].concat(e);if(i||o.push(s),n&&n.code){const[[,r]]=Object.entries(n.rule);Object.assign(n,{msg:Hr(t,o.join("."),n.code,r)}),o=[]}else n&&Ur(n,t,o);return Object.assign(r,{[s]:n})},{})};class Wr{constructor(r,t={}){this.errorHandlers=t.errorHandlers,this.extendedErrors=t.extendedErrors,this.msgPath=this.extendedErrors?"msg":"",this.allTouched=!1,r&&r instanceof Wr?(this.items=r.items,this.touchedFields=r.touchedFields):(this.items={},this.touchedFields={})}setTouched(r){Br(this.touchedFields,r,!0)}setAllTouched(r=!1){this.allTouched=r}setError(r,t){const e=this.extendedErrors?Ur(r,this.errorHandlers):r,i=t?this.items:{};if(this.items=Object.assign({},i,e),t){Cr(e,t,!1)||Br(this.items,t,"")}}clearErrors(r=this.items){r&&Object.entries(r).forEach(([r,t])=>"object"==typeof t?this.clearErrors(t):this.clearError(r))}clearError(r){this.setError({},r)}getError(r,t=0){if(!this.hasError(r,t))return"";const e=this.getErrors(r);return this.getMessage(e[t])}getMessage(r){return this.msgPath&&r?r[this.msgPath]:r}getErrors(r){return[].concat(Cr(this.items,r,[]))}hasError(r,t=0){const e=this.allTouched||Cr(this.touchedFields,r,!1),i=this.getErrors(r);return e&&!(r=>null==r||""===r)(this.getMessage(i[t]))}}class qr{constructor(r,e){this.extendedErrors=e.extendedErrors,this.aliasedRules=e.aliasedRules,this.aliasedRules.forEach(this.registerAliasedDefaultRule),l.Validator.registerDefaultRules(e.extraRules),this.errors=new Wr(null,e),this.extendedErrors&&(()=>{const r=l.Validator.getDefaultRules(),e=Object.entries(r).reduce((r,[e,i])=>Object.assign(r,{[e]:t(e,i)}),{});l.Validator.registerDefaultRules(e)})(),this.fields={items:[]},this.$gzLivr=r||{_vm:{$emit:()=>{},$off:()=>{}}}}validate(r,t,e){const i=new l.Validator(r),s=i.validate(t),n=s||i.getErrors();return s?(this.errors.clearError(e),n):(this.errors.setError(Object.assign({},n),e),this.errors.setTouched(e),{errors:this.errors.items})}registerAliasedDefaultRule(r){l.Validator.registerAliasedDefaultRule(r)}validateAll(r,t){this.validator=new l.Validator(r);const e=this.validator.validate(t),i=e||this.validator.getErrors();return e?(this.errors.clearErrors(),i):(this.errors.setError(i),this.errors.setAllTouched(!0),{errors:this.errors.items})}clearErrors(){this.errors.clearErrors()}clearError(r){this.errors.clearError(r)}}let Yr=null;const Qr=()=>Yr;let Zr=Object.assign({},{errorBagName:"errors",fieldsBagName:"fields",inject:!0,extendedErrors:!1,extraRules:{},aliasedRules:[]});const Jr=()=>Zr,Kr=r=>{Zr=Object.assign({},Zr,r)};var Xr={provide(){return this.$livr&&!e(this.$vnode)?{$livr:this.$livr}:{}},beforeCreate(){if(e(this.$vnode)||!1===this.$options.$__livrInject)return;this.$parent||Kr(this.$options.$_livr||{});const t=(r=>{const t=Cr(r,"$options.$_livr",{});return Object.assign({},Zr,t)})(this);(!this.$parent||this.$options.$_livr&&/new/.test(this.$options.$_livr.validator))&&(this.$livr=new qr(Qr(),t));const i=(s=this.$options.inject,!(!r(s)||!s.$livr));var s;if(this.$livr||!t.inject||i||(this.$livr=new qr(Qr(),t)),i||this.$livr){if(!i&&this.$livr){this.$options._base.util.defineReactive(this.$livr,"errors",this.$livr.errors)}this.$options.computed||(this.$options.computed={}),this.$options.computed[t.errorBagName||"errors"]=function(){return this.$livr.errors},this.$options.computed[t.fieldsBagName||"fields"]=function(){return this.$livr.fields.items.reduce((r,t)=>t.scope?(r["$"+t.scope]||(r["$"+t.scope]={}),r["$"+t.scope][t.name]=t.flags,r):(r[t.name]=t.flags,r),{})}}}};let rt,tt;class et{constructor(r,t){var e;this.configure(r),tt=this,t&&(rt=t),this.livrInstance=(e=new qr(null,this.config),Yr=e,e),this.initVM(this.config)}initVM({errorBagName:r,fieldsBagName:t}){this._vm=new rt({data:()=>({[r]:this.livrInstance.errors,[t]:this.livrInstance.fields})})}configure(r){Kr(r)}get config(){return Jr()}static get config(){return Jr()}static get instance(){return tt}}var it={install:function(r,t={}){rt&&r===rt?"production"!==process.env.NODE_ENV&&console.warn("already installed, Vue.use(LivrPlugin) should only be called once."):(rt=r,tt=new et(t),qr.$livr=tt,rt.mixin(Xr))}};module.exports=it; |
@@ -1,1 +0,1 @@ | ||
const r=r=>null!==r&&r&&"object"==typeof r&&!Array.isArray(r),t=(t,e)=>(...i)=>{const n=e(...i),s=i.splice(0,i.length-1);return(...e)=>{const i=n(...e);if(i){const e={[t]:s};return Array.isArray(i)||r(i)?i:{code:i,rule:e}}return""}},e=r=>{if(!r)return!1;const{tag:t}=r.componentOptions;return/^(keep-alive|transition|transition-group)$/.test(t)};var i={isPrimitiveValue:r=>"string"==typeof r||(!("number"!=typeof r||!isFinite(r))||"boolean"==typeof r),looksLikeNumber:r=>!isNaN(+r),isObject:r=>Object(r)===r&&Object.getPrototypeOf(r)===Object.prototype,isEmptyObject(r){for(const t in r)if(r.hasOwnProperty(t))return!1;return!0},escapeRegExp:r=>r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),isNoValue:r=>null==r||""===r};const n={};let s=0;class o{constructor(r,t){this.isPrepared=!1,this.livrRules=r,this.validators={},this.validatorBuilders={},this.errors=null,this.isAutoTrim=null!=t?t:s,this.registerRules(n)}static getDefaultRules(){return n}static registerAliasedDefaultRule(r){if(!r.name)throw"Alias name required";n[r.name]=this._buildAliasedRule(r.rules,r.error)}static registerDefaultRules(r){for(const t in r)n[t]=r[t]}static defaultAutoTrim(r){s=!!r}static _buildAliasedRule(r,t){if(!r)throw"Alias rules required";const e={value:r};return r=>{const i=new o(e).registerRules(r).prepare();return(r,e,n)=>{const s=i.validate({value:r});return s?void n.push(s.value):t||i.getErrors().value}}}prepare(){const r=this.livrRules;for(const t in r){let e=r[t];Array.isArray(e)||(e=[e]);const i=[];for(const r of e){const t=this._parseRule(r);i.push(this._buildValidator(t.name,t.args))}this.validators[t]=i}return this.isPrepared=!0,this}validate(r){if(this.isPrepared||this.prepare(),!i.isObject(r))return void(this.errors="FORMAT_ERROR");this.isAutoTrim&&(r=this._autoTrim(r));const t={},e={};for(const i in this.validators){const n=this.validators[i];if(!n||!n.length)continue;const s=r[i];for(const o of n){const n=[],u=o(e.hasOwnProperty(i)?e[i]:s,r,n);if(u){t[i]=u;break}n.length?e[i]=n[0]:r.hasOwnProperty(i)&&!e.hasOwnProperty(i)&&(e[i]=s)}}return i.isEmptyObject(t)?(this.errors=null,e):(this.errors=t,!1)}getErrors(){return this.errors}registerRules(r){for(const t in r)this.validatorBuilders[t]=r[t];return this}registerAliasedRule(r){if(!r.name)throw"Alias name required";return this.validatorBuilders[r.name]=this.constructor._buildAliasedRule(r.rules,r.error),this}getRules(){return this.validatorBuilders}_parseRule(r){let t,e;return i.isObject(r)?(t=Object.keys(r)[0],e=r[t],Array.isArray(e)||(e=[e])):(t=r,e=[]),{name:t,args:e}}_buildValidator(r,t){if(!this.validatorBuilders[r])throw"Rule ["+r+"] not registered";const e=[];return e.push.apply(e,t),e.push(this.getRules()),this.validatorBuilders[r].apply(null,e)}_autoTrim(r){const t=typeof r;if("object"!==t&&r)return r.replace?r.replace(/^\s*/,"").replace(/\s*$/,""):r;if("object"==t&&Array.isArray(r)){const t=[];for(const e of r)t.push(this._autoTrim(e));return t}if("object"==t&&i.isObject(r)){const t={};for(const e in r)r.hasOwnProperty(e)&&(t[e]=this._autoTrim(r[e]));return t}return r}}var u=o;const a={required:function(){return r=>{if(i.isNoValue(r))return"REQUIRED"}},not_empty:function(){return r=>{if(null!=r&&""===r)return"CANNOT_BE_EMPTY"}},not_empty_list:function(){return r=>void 0===r||""===r?"CANNOT_BE_EMPTY":Array.isArray(r)?r.length<1?"CANNOT_BE_EMPTY":void 0:"FORMAT_ERROR"},any_object:function(){return r=>{if(!i.isNoValue(r))return i.isObject(r)?void 0:"FORMAT_ERROR"}},string:function(){return(r,t,e)=>{if(!i.isNoValue(r))return i.isPrimitiveValue(r)?void e.push(r+""):"FORMAT_ERROR"}},eq:function(r){return(t,e,n)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if(t+""!=r+"")return"NOT_ALLOWED_VALUE";n.push(r)}}},one_of:function(r){return Array.isArray(r)||(r=Array.prototype.slice.call(arguments)).pop(),(t,e,n)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";for(const e of r)if(t+""==e+"")return void n.push(e);return"NOT_ALLOWED_VALUE"}}},max_length:function(r){return(t,e,n)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if((t+="").length>r)return"TOO_LONG";n.push(t)}}},min_length:function(r){return(t,e,n)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if((t+="").length<r)return"TOO_SHORT";n.push(t)}}},length_equal:function(r){return(t,e,n)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?(t+="").length<r?"TOO_SHORT":t.length>r?"TOO_LONG":void n.push(t):"FORMAT_ERROR"}},length_between:function(r,t){return(e,n,s)=>{if(!i.isNoValue(e))return i.isPrimitiveValue(e)?(e+="").length<r?"TOO_SHORT":e.length>t?"TOO_LONG":void s.push(e):"FORMAT_ERROR"}},like:function(r,t){const e=3===arguments.length&&t.match("i"),n=new RegExp(r,e?"i":"");return(r,t,e)=>{if(!i.isNoValue(r)){if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";if(!(r+="").match(n))return"WRONG_FORMAT";e.push(r)}}},integer:function(){return(r,t,e)=>{if(!i.isNoValue(r))return i.isPrimitiveValue(r)?i.looksLikeNumber(r)&&Number.isInteger(+r)?void e.push(+r):"NOT_INTEGER":"FORMAT_ERROR"}},positive_integer:function(){return(r,t,e)=>{if(!i.isNoValue(r))return i.isPrimitiveValue(r)?i.looksLikeNumber(r)?!Number.isInteger(+r)||+r<1?"NOT_POSITIVE_INTEGER":void e.push(+r):"NOT_POSITIVE_INTEGER":"FORMAT_ERROR"}},decimal:function(){return(r,t,e)=>{if(!i.isNoValue(r)){if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";if(!i.looksLikeNumber(r))return"NOT_DECIMAL";if(!/^(?:\-?(?:(?:[0-9]+\.[0-9]+)|(?:[0-9]+)))$/.test(r+=""))return"NOT_DECIMAL";e.push(+r)}}},positive_decimal:function(){return(r,t,e)=>{if(!i.isNoValue(r)){if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";if(!i.looksLikeNumber(r))return"NOT_POSITIVE_DECIMAL";if(!/^(?:(?:[0-9]*\.[0-9]+)|(?:[1-9][0-9]*))$/.test(r+=""))return"NOT_POSITIVE_DECIMAL";e.push(+r)}}},max_number:function(r){return(t,e,n)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?i.looksLikeNumber(t)?+t>+r?"TOO_HIGH":void n.push(+t):"NOT_NUMBER":"FORMAT_ERROR"}},min_number:function(r){return(t,e,n)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?i.looksLikeNumber(t)?+t<+r?"TOO_LOW":void n.push(+t):"NOT_NUMBER":"FORMAT_ERROR"}},number_between:function(r,t){return(e,n,s)=>{if(!i.isNoValue(e))return i.isPrimitiveValue(e)?i.looksLikeNumber(e)?+e<+r?"TOO_LOW":+e>+t?"TOO_HIGH":void s.push(+e):"NOT_NUMBER":"FORMAT_ERROR"}},email:function(){var r=/^(([^<>()\[\]\\.,;:\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,}))$/;return t=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?(t+="",r.test(t)?/\@.*\@/.test(t)||/\@.*_/.test(t)?"WRONG_EMAIL":void 0:"WRONG_EMAIL"):"FORMAT_ERROR"}},equal_to_field:function(r){return(t,e)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?t!=e[r]?"FIELDS_NOT_EQUAL":void 0:"FORMAT_ERROR"}},url:function(){const r=new RegExp("^(?:(?:http|https)://)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[0-1]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-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,})))\\.?|localhost)(?::\\d{2,5})?(?:[/?#]\\S*)?$","i");return t=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if(!(t.length<2083&&r.test(t)))return"WRONG_URL"}}},iso_date:function(){return r=>{if(i.isNoValue(r))return;if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";const t=r.match(/^(\d{4})-([0-1][0-9])-([0-3][0-9])$/);if(t){const e=Date.parse(r);if(!e&&0!==e)return"WRONG_DATE";const i=new Date(e);if(i.setTime(i.getTime()+60*i.getTimezoneOffset()*1e3),i.getFullYear()==t[1]&&i.getMonth()+1==+t[2]&&i.getDate()==+t[3])return}return"WRONG_DATE"}},nested_object:function(r,t){const e=new u(r).registerRules(t).prepare();return(r,t,n)=>{if(i.isNoValue(r))return;if(!i.isObject(r))return"FORMAT_ERROR";const s=e.validate(r);return s?void n.push(s):e.getErrors()}},variable_object:function(r,t,e){const n={};for(const r in t){const i=new u(t[r]).registerRules(e).prepare();n[r]=i}return(t,e,s)=>{if(i.isNoValue(t))return;if(!i.isObject(t)||!t[r]||!n[t[r]])return"FORMAT_ERROR";const o=n[t[r]],u=o.validate(t);return u?void s.push(u):o.getErrors()}},list_of:function(r,t){Array.isArray(r)||(t=(r=Array.prototype.slice.call(arguments)).pop());const e={field:r},n=new u(e).registerRules(t).prepare();return(r,t,e)=>{if(i.isNoValue(r))return;if(!Array.isArray(r))return"FORMAT_ERROR";const s=[],o=[];let u=!1;for(const t of r){const r=n.validate({field:t});r?(s.push(r.field),o.push(null)):(u=!0,o.push(n.getErrors().field),s.push(null))}return u?o:void e.push(s)}},list_of_objects:function(r,t){const e=new u(r).registerRules(t).prepare();return(r,t,n)=>{if(i.isNoValue(r))return;if(!Array.isArray(r))return"FORMAT_ERROR";const s=[],o=[];let u=!1;for(const t of r){const r=e.validate(t);r?(s.push(r),o.push(null)):(u=!0,o.push(e.getErrors()),s.push(null))}return u?o:void n.push(s)}},or:function(){const r=Array.prototype.slice.call(arguments),t=r.pop(),e=r.map(r=>new u({field:r}).registerRules(t).prepare());return(r,t,i)=>{let n;for(const t of e){const e=t.validate({field:r});if(e)return void i.push(e.field);n=t.getErrors().field}return n}},list_of_different_objects:function(r,t,e){const n={};for(const r in t){const i=new u(t[r]).registerRules(e).prepare();n[r]=i}return(t,e,s)=>{if(i.isNoValue(t))return;if(!Array.isArray(t))return"FORMAT_ERROR";const o=[],u=[];let a=!1;for(const e of t){if("object"!=typeof e||!e[r]||!n[e[r]]){u.push("FORMAT_ERROR");continue}const t=n[e[r]],i=t.validate(e);i?(o.push(i),u.push(null)):(a=!0,u.push(t.getErrors()),o.push(null))}return a?u:void s.push(o)}},default:r=>(t,e,n)=>{i.isNoValue(t)&&n.push(r)},trim:function(){return(r,t,e)=>{i.isNoValue(r)||"object"==typeof r||(r+="",e.push(r.replace(/^\s*/,"").replace(/\s*$/,"")))}},to_lc:function(){return(r,t,e)=>{i.isNoValue(r)||"object"==typeof r||(r+="",e.push(r.toLowerCase()))}},to_uc:function(){return(r,t,e)=>{i.isNoValue(r)||"object"==typeof r||(r+="",e.push(r.toUpperCase()))}},remove:function(r){r=i.escapeRegExp(r);const t=new RegExp("["+r+"]","g");return(r,e,n)=>{i.isNoValue(r)||"object"==typeof r||(r+="",n.push(r.replace(t,"")))}},leave_only:function(r){r=i.escapeRegExp(r);const t=new RegExp("[^"+r+"]","g");return(r,e,n)=>{i.isNoValue(r)||"object"==typeof r||(r+="",n.push(r.replace(t,"")))}}};u.registerDefaultRules(a);var l={Validator:u,rules:a,util:i},c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},f="object"==typeof c&&c&&c.Object===Object&&c,h="object"==typeof self&&self&&self.Object===Object&&self,p=f||h||Function("return this")(),d=p.Symbol,v=Object.prototype,_=v.hasOwnProperty,R=v.toString,O=d?d.toStringTag:void 0;var g=function(r){var t=_.call(r,O),e=r[O];try{r[O]=void 0;var i=!0}catch(r){}var n=R.call(r);return i&&(t?r[O]=e:delete r[O]),n},y=Object.prototype.toString;var E=function(r){return y.call(r)},m=d?d.toStringTag:void 0;var b=function(r){return null==r?void 0===r?"[object Undefined]":"[object Null]":m&&m in Object(r)?g(r):E(r)};var A=function(r){var t=typeof r;return null!=r&&("object"==t||"function"==t)};var T,N=function(r){if(!A(r))return!1;var t=b(r);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},j=p["__core-js_shared__"],V=(T=/[^.]+$/.exec(j&&j.keys&&j.keys.IE_PROTO||""))?"Symbol(src)_1."+T:"";var $=function(r){return!!V&&V in r},w=Function.prototype.toString;var P=function(r){if(null!=r){try{return w.call(r)}catch(r){}try{return r+""}catch(r){}}return""},M=/^\[object .+?Constructor\]$/,F=Function.prototype,L=Object.prototype,I=F.toString,x=L.hasOwnProperty,D=RegExp("^"+I.call(x).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var k=function(r){return!(!A(r)||$(r))&&(N(r)?D:M).test(P(r))};var z=function(r,t){return null==r?void 0:r[t]};var S=function(r,t){var e=z(r,t);return k(e)?e:void 0},B=function(){try{var r=S(Object,"defineProperty");return r({},"",{}),r}catch(r){}}();var G=function(r,t,e){"__proto__"==t&&B?B(r,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):r[t]=e};var C=function(r,t){return r===t||r!=r&&t!=t},H=Object.prototype.hasOwnProperty;var U=function(r,t,e){var i=r[t];H.call(r,t)&&C(i,e)&&(void 0!==e||t in r)||G(r,t,e)},W=Array.isArray;var q=function(r){return null!=r&&"object"==typeof r};var Y=function(r){return"symbol"==typeof r||q(r)&&"[object Symbol]"==b(r)},Q=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Z=/^\w*$/;var J=function(r,t){if(W(r))return!1;var e=typeof r;return!("number"!=e&&"symbol"!=e&&"boolean"!=e&&null!=r&&!Y(r))||(Z.test(r)||!Q.test(r)||null!=t&&r in Object(t))},K=S(Object,"create");var X=function(){this.__data__=K?K(null):{},this.size=0};var rr=function(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t},tr=Object.prototype.hasOwnProperty;var er=function(r){var t=this.__data__;if(K){var e=t[r];return"__lodash_hash_undefined__"===e?void 0:e}return tr.call(t,r)?t[r]:void 0},ir=Object.prototype.hasOwnProperty;var nr=function(r){var t=this.__data__;return K?void 0!==t[r]:ir.call(t,r)};var sr=function(r,t){var e=this.__data__;return this.size+=this.has(r)?0:1,e[r]=K&&void 0===t?"__lodash_hash_undefined__":t,this};function or(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t<e;){var i=r[t];this.set(i[0],i[1])}}or.prototype.clear=X,or.prototype.delete=rr,or.prototype.get=er,or.prototype.has=nr,or.prototype.set=sr;var ur=or;var ar=function(){this.__data__=[],this.size=0};var lr=function(r,t){for(var e=r.length;e--;)if(C(r[e][0],t))return e;return-1},cr=Array.prototype.splice;var fr=function(r){var t=this.__data__,e=lr(t,r);return!(e<0)&&(e==t.length-1?t.pop():cr.call(t,e,1),--this.size,!0)};var hr=function(r){var t=this.__data__,e=lr(t,r);return e<0?void 0:t[e][1]};var pr=function(r){return lr(this.__data__,r)>-1};var dr=function(r,t){var e=this.__data__,i=lr(e,r);return i<0?(++this.size,e.push([r,t])):e[i][1]=t,this};function vr(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t<e;){var i=r[t];this.set(i[0],i[1])}}vr.prototype.clear=ar,vr.prototype.delete=fr,vr.prototype.get=hr,vr.prototype.has=pr,vr.prototype.set=dr;var _r=vr,Rr=S(p,"Map");var Or=function(){this.size=0,this.__data__={hash:new ur,map:new(Rr||_r),string:new ur}};var gr=function(r){var t=typeof r;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==r:null===r};var yr=function(r,t){var e=r.__data__;return gr(t)?e["string"==typeof t?"string":"hash"]:e.map};var Er=function(r){var t=yr(this,r).delete(r);return this.size-=t?1:0,t};var mr=function(r){return yr(this,r).get(r)};var br=function(r){return yr(this,r).has(r)};var Ar=function(r,t){var e=yr(this,r),i=e.size;return e.set(r,t),this.size+=e.size==i?0:1,this};function Tr(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t<e;){var i=r[t];this.set(i[0],i[1])}}Tr.prototype.clear=Or,Tr.prototype.delete=Er,Tr.prototype.get=mr,Tr.prototype.has=br,Tr.prototype.set=Ar;var Nr=Tr;function jr(r,t){if("function"!=typeof r||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var e=function(){var i=arguments,n=t?t.apply(this,i):i[0],s=e.cache;if(s.has(n))return s.get(n);var o=r.apply(this,i);return e.cache=s.set(n,o)||s,o};return e.cache=new(jr.Cache||Nr),e}jr.Cache=Nr;var Vr=jr;var $r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,wr=/\\(\\)?/g,Pr=function(r){var t=Vr(r,(function(r){return 500===e.size&&e.clear(),r})),e=t.cache;return t}((function(r){var t=[];return 46===r.charCodeAt(0)&&t.push(""),r.replace($r,(function(r,e,i,n){t.push(i?n.replace(wr,"$1"):e||r)})),t}));var Mr=function(r,t){for(var e=-1,i=null==r?0:r.length,n=Array(i);++e<i;)n[e]=t(r[e],e,r);return n},Fr=d?d.prototype:void 0,Lr=Fr?Fr.toString:void 0;var Ir=function r(t){if("string"==typeof t)return t;if(W(t))return Mr(t,r)+"";if(Y(t))return Lr?Lr.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e};var xr=function(r){return null==r?"":Ir(r)};var Dr=function(r,t){return W(r)?r:J(r,t)?[r]:Pr(xr(r))},kr=/^(?:0|[1-9]\d*)$/;var zr=function(r,t){var e=typeof r;return!!(t=null==t?9007199254740991:t)&&("number"==e||"symbol"!=e&&kr.test(r))&&r>-1&&r%1==0&&r<t};var Sr=function(r){if("string"==typeof r||Y(r))return r;var t=r+"";return"0"==t&&1/r==-1/0?"-0":t};var Br=function(r,t,e,i){if(!A(r))return r;for(var n=-1,s=(t=Dr(t,r)).length,o=s-1,u=r;null!=u&&++n<s;){var a=Sr(t[n]),l=e;if("__proto__"===a||"constructor"===a||"prototype"===a)return r;if(n!=o){var c=u[a];void 0===(l=i?i(c,a,u):void 0)&&(l=A(c)?c:zr(t[n+1])?[]:{})}U(u,a,l),u=u[a]}return r};var Gr=function(r,t,e){return null==r?r:Br(r,t,e)};var Cr=function(r,t){for(var e=0,i=(t=Dr(t,r)).length;null!=r&&e<i;)r=r[Sr(t[e++])];return e&&e==i?r:void 0};var Hr=function(r,t,e){var i=null==r?void 0:Cr(r,t);return void 0===i?e:i};const Ur=(r={},t,e,i)=>{const n=r[e];return n?n(t,i):""},Wr=(r,t,e=[])=>{const i=Array.isArray(r);return Object.entries(r).reduce((r,[n,s])=>{let o=[].concat(e);if(i||o.push(n),s&&s.code){const[[,r]]=Object.entries(s.rule);Object.assign(s,{msg:Ur(t,o.join("."),s.code,r)}),o=[]}else s&&Wr(s,t,o);return Object.assign(r,{[n]:s})},{})};class qr{constructor(r,t={}){this.errorHandlers=t.errorHandlers,this.extendedErrors=t.extendedErrors,this.msgPath=this.extendedErrors?"msg":"",this.allTouched=!1,r&&r instanceof qr?(this.items=r.items,this.touchedFields=r.touchedFields):(this.items={},this.touchedFields={})}setTouched(r){Gr(this.touchedFields,r,!0)}setAllTouched(r=!1){this.allTouched=r}setError(r,t){const e=this.extendedErrors?Wr(r,this.errorHandlers):r,i=t?this.items:{};if(this.items=Object.assign({},i,e),t){Hr(e,t,!1)||Gr(this.items,t,"")}}clearErrors(r=this.items){r&&Object.entries(r).forEach(([r,t])=>"object"==typeof t?this.clearErrors(t):this.clearError(r))}clearError(r){this.setError({},r)}getError(r,t=0){if(!this.hasError(r,t))return"";const e=this.getErrors(r);return this.getMessage(e[t])}getMessage(r){return this.msgPath&&r?r[this.msgPath]:r}getErrors(r){return[].concat(Hr(this.items,r,[]))}hasError(r,t=0){const e=this.allTouched||Hr(this.touchedFields,r,!1),i=this.getErrors(r);return e&&!(r=>null==r||""===r)(this.getMessage(i[t]))}}class Yr{constructor(r,e){this.extendedErrors=e.extendedErrors,this.aliasedRules=e.aliasedRules,this.aliasedRules.forEach(this.registerAliasedDefaultRule),l.Validator.registerDefaultRules(e.extraRules),this.errors=new qr(null,e),this.extendedErrors&&(()=>{const r=l.Validator.getDefaultRules(),e=Object.entries(r).reduce((r,[e,i])=>Object.assign(r,{[e]:t(e,i)}),{});l.Validator.registerDefaultRules(e)})(),this.fields={items:[]},this.$gzLivr=r||{_vm:{$emit:()=>{},$off:()=>{}}}}validate(r,t,e){const i=new l.Validator(r),n=i.validate(t),s=n||i.getErrors();return n?(this.errors.clearError(e),s):(this.errors.setError(Object.assign({},s),e),this.errors.setTouched(e),{errors:this.errors.items})}registerAliasedDefaultRule(r){l.Validator.registerAliasedDefaultRule(r)}validateAll(r,t){this.validator=new l.Validator(r);const e=this.validator.validate(t),i=e||this.validator.getErrors();return e?(this.errors.clearErrors(),i):(this.errors.setError(i),this.errors.setAllTouched(!0),{errors:this.errors.items})}clearErrors(){this.errors.clearErrors()}clearError(r){this.errors.clearError(r)}}let Qr=null;const Zr=()=>Qr;let Jr=Object.assign({},{errorBagName:"errors",fieldsBagName:"fields",inject:!0,extendedErrors:!1,extraRules:{},aliasedRules:[]});const Kr=()=>Jr,Xr=r=>{Jr=Object.assign({},Jr,r)};var rt={provide(){return this.$livr&&!e(this.$vnode)?{$livr:this.$livr}:{}},beforeCreate(){if(e(this.$vnode)||!1===this.$options.$__livrInject)return;this.$parent||Xr(this.$options.$_livr||{});const t=(r=>{const t=Hr(r,"$options.$_livr",{});return Object.assign({},Jr,t)})(this);(!this.$parent||this.$options.$_livr&&/new/.test(this.$options.$_livr.validator))&&(this.$livr=new Yr(Zr(),t));const i=(n=this.$options.inject,!(!r(n)||!n.$livr));var n;if(this.$livr||!t.inject||i||(this.$livr=new Yr(Zr(),t)),i||this.$livr){if(!i&&this.$livr){this.$options._base.util.defineReactive(this.$livr,"errors",this.$livr.errors)}this.$options.computed||(this.$options.computed={}),this.$options.computed[t.errorBagName||"errors"]=function(){return this.$livr.errors},this.$options.computed[t.fieldsBagName||"fields"]=function(){return this.$livr.fields.items.reduce((r,t)=>t.scope?(r["$"+t.scope]||(r["$"+t.scope]={}),r["$"+t.scope][t.name]=t.flags,r):(r[t.name]=t.flags,r),{})}}}};let tt,et;class it{constructor(r,t){var e;this.configure(r),et=this,t&&(tt=t),this.livrInstance=(e=new Yr(null,this.config),Qr=e,e),this.initVM(this.config)}static install(r,t={}){tt&&r===tt?"production"!==process.env.NODE_ENV&&console.warn("already installed, Vue.use(LivrPlugin) should only be called once."):(tt=r,et=new it(t),Yr.$livr=et,tt.mixin(rt))}initVM({errorBagName:r,fieldsBagName:t}){this._vm=new tt({data:()=>({[r]:this.livrInstance.errors,[t]:this.livrInstance.fields})})}configure(r){Xr(r)}get config(){return Kr()}static get config(){return Kr()}static get instance(){return et}}export default it; | ||
const r=r=>null!==r&&r&&"object"==typeof r&&!Array.isArray(r),t=(t,e)=>(...i)=>{const s=e(...i),n=i.splice(0,i.length-1);return(...e)=>{const i=s(...e);if(i){const e={[t]:n};return Array.isArray(i)||r(i)?i:{code:i,rule:e}}return""}},e=r=>{if(!r)return!1;const{tag:t}=r.componentOptions;return/^(keep-alive|transition|transition-group)$/.test(t)};var i={isPrimitiveValue:r=>"string"==typeof r||(!("number"!=typeof r||!isFinite(r))||"boolean"==typeof r),looksLikeNumber:r=>!isNaN(+r),isObject:r=>Object(r)===r&&Object.getPrototypeOf(r)===Object.prototype,isEmptyObject(r){for(const t in r)if(r.hasOwnProperty(t))return!1;return!0},escapeRegExp:r=>r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),isNoValue:r=>null==r||""===r};const s={};let n=0;class o{constructor(r,t){this.isPrepared=!1,this.livrRules=r,this.validators={},this.validatorBuilders={},this.errors=null,this.isAutoTrim=null!=t?t:n,this.registerRules(s)}static getDefaultRules(){return s}static registerAliasedDefaultRule(r){if(!r.name)throw"Alias name required";s[r.name]=this._buildAliasedRule(r.rules,r.error)}static registerDefaultRules(r){for(const t in r)s[t]=r[t]}static defaultAutoTrim(r){n=!!r}static _buildAliasedRule(r,t){if(!r)throw"Alias rules required";const e={value:r};return r=>{const i=new o(e).registerRules(r).prepare();return(r,e,s)=>{const n=i.validate({value:r});return n?void s.push(n.value):t||i.getErrors().value}}}prepare(){const r=this.livrRules;for(const t in r){let e=r[t];Array.isArray(e)||(e=[e]);const i=[];for(const r of e){const t=this._parseRule(r);i.push(this._buildValidator(t.name,t.args))}this.validators[t]=i}return this.isPrepared=!0,this}validate(r){if(this.isPrepared||this.prepare(),!i.isObject(r))return void(this.errors="FORMAT_ERROR");this.isAutoTrim&&(r=this._autoTrim(r));const t={},e={};for(const i in this.validators){const s=this.validators[i];if(!s||!s.length)continue;const n=r[i];for(const o of s){const s=[],u=o(e.hasOwnProperty(i)?e[i]:n,r,s);if(u){t[i]=u;break}s.length?e[i]=s[0]:r.hasOwnProperty(i)&&!e.hasOwnProperty(i)&&(e[i]=n)}}return i.isEmptyObject(t)?(this.errors=null,e):(this.errors=t,!1)}getErrors(){return this.errors}registerRules(r){for(const t in r)this.validatorBuilders[t]=r[t];return this}registerAliasedRule(r){if(!r.name)throw"Alias name required";return this.validatorBuilders[r.name]=this.constructor._buildAliasedRule(r.rules,r.error),this}getRules(){return this.validatorBuilders}_parseRule(r){let t,e;return i.isObject(r)?(t=Object.keys(r)[0],e=r[t],Array.isArray(e)||(e=[e])):(t=r,e=[]),{name:t,args:e}}_buildValidator(r,t){if(!this.validatorBuilders[r])throw"Rule ["+r+"] not registered";const e=[];return e.push.apply(e,t),e.push(this.getRules()),this.validatorBuilders[r].apply(null,e)}_autoTrim(r){const t=typeof r;if("object"!==t&&r)return r.replace?r.replace(/^\s*/,"").replace(/\s*$/,""):r;if("object"==t&&Array.isArray(r)){const t=[];for(const e of r)t.push(this._autoTrim(e));return t}if("object"==t&&i.isObject(r)){const t={};for(const e in r)r.hasOwnProperty(e)&&(t[e]=this._autoTrim(r[e]));return t}return r}}var u=o;const a={required:function(){return r=>{if(i.isNoValue(r))return"REQUIRED"}},not_empty:function(){return r=>{if(null!=r&&""===r)return"CANNOT_BE_EMPTY"}},not_empty_list:function(){return r=>void 0===r||""===r?"CANNOT_BE_EMPTY":Array.isArray(r)?r.length<1?"CANNOT_BE_EMPTY":void 0:"FORMAT_ERROR"},any_object:function(){return r=>{if(!i.isNoValue(r))return i.isObject(r)?void 0:"FORMAT_ERROR"}},string:function(){return(r,t,e)=>{if(!i.isNoValue(r))return i.isPrimitiveValue(r)?void e.push(r+""):"FORMAT_ERROR"}},eq:function(r){return(t,e,s)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if(t+""!=r+"")return"NOT_ALLOWED_VALUE";s.push(r)}}},one_of:function(r){return Array.isArray(r)||(r=Array.prototype.slice.call(arguments)).pop(),(t,e,s)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";for(const e of r)if(t+""==e+"")return void s.push(e);return"NOT_ALLOWED_VALUE"}}},max_length:function(r){return(t,e,s)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if((t+="").length>r)return"TOO_LONG";s.push(t)}}},min_length:function(r){return(t,e,s)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if((t+="").length<r)return"TOO_SHORT";s.push(t)}}},length_equal:function(r){return(t,e,s)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?(t+="").length<r?"TOO_SHORT":t.length>r?"TOO_LONG":void s.push(t):"FORMAT_ERROR"}},length_between:function(r,t){return(e,s,n)=>{if(!i.isNoValue(e))return i.isPrimitiveValue(e)?(e+="").length<r?"TOO_SHORT":e.length>t?"TOO_LONG":void n.push(e):"FORMAT_ERROR"}},like:function(r,t){const e=3===arguments.length&&t.match("i"),s=new RegExp(r,e?"i":"");return(r,t,e)=>{if(!i.isNoValue(r)){if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";if(!(r+="").match(s))return"WRONG_FORMAT";e.push(r)}}},integer:function(){return(r,t,e)=>{if(!i.isNoValue(r))return i.isPrimitiveValue(r)?i.looksLikeNumber(r)&&Number.isInteger(+r)?void e.push(+r):"NOT_INTEGER":"FORMAT_ERROR"}},positive_integer:function(){return(r,t,e)=>{if(!i.isNoValue(r))return i.isPrimitiveValue(r)?i.looksLikeNumber(r)?!Number.isInteger(+r)||+r<1?"NOT_POSITIVE_INTEGER":void e.push(+r):"NOT_POSITIVE_INTEGER":"FORMAT_ERROR"}},decimal:function(){return(r,t,e)=>{if(!i.isNoValue(r)){if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";if(!i.looksLikeNumber(r))return"NOT_DECIMAL";if(!/^(?:\-?(?:(?:[0-9]+\.[0-9]+)|(?:[0-9]+)))$/.test(r+=""))return"NOT_DECIMAL";e.push(+r)}}},positive_decimal:function(){return(r,t,e)=>{if(!i.isNoValue(r)){if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";if(!i.looksLikeNumber(r))return"NOT_POSITIVE_DECIMAL";if(!/^(?:(?:[0-9]*\.[0-9]+)|(?:[1-9][0-9]*))$/.test(r+=""))return"NOT_POSITIVE_DECIMAL";e.push(+r)}}},max_number:function(r){return(t,e,s)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?i.looksLikeNumber(t)?+t>+r?"TOO_HIGH":void s.push(+t):"NOT_NUMBER":"FORMAT_ERROR"}},min_number:function(r){return(t,e,s)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?i.looksLikeNumber(t)?+t<+r?"TOO_LOW":void s.push(+t):"NOT_NUMBER":"FORMAT_ERROR"}},number_between:function(r,t){return(e,s,n)=>{if(!i.isNoValue(e))return i.isPrimitiveValue(e)?i.looksLikeNumber(e)?+e<+r?"TOO_LOW":+e>+t?"TOO_HIGH":void n.push(+e):"NOT_NUMBER":"FORMAT_ERROR"}},email:function(){var r=/^(([^<>()\[\]\\.,;:\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,}))$/;return t=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?(t+="",r.test(t)?/\@.*\@/.test(t)||/\@.*_/.test(t)?"WRONG_EMAIL":void 0:"WRONG_EMAIL"):"FORMAT_ERROR"}},equal_to_field:function(r){return(t,e)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?t!=e[r]?"FIELDS_NOT_EQUAL":void 0:"FORMAT_ERROR"}},url:function(){const r=new RegExp("^(?:(?:http|https)://)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[0-1]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-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,})))\\.?|localhost)(?::\\d{2,5})?(?:[/?#]\\S*)?$","i");return t=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if(!(t.length<2083&&r.test(t)))return"WRONG_URL"}}},iso_date:function(){return r=>{if(i.isNoValue(r))return;if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";const t=r.match(/^(\d{4})-([0-1][0-9])-([0-3][0-9])$/);if(t){const e=Date.parse(r);if(!e&&0!==e)return"WRONG_DATE";const i=new Date(e);if(i.setTime(i.getTime()+60*i.getTimezoneOffset()*1e3),i.getFullYear()==t[1]&&i.getMonth()+1==+t[2]&&i.getDate()==+t[3])return}return"WRONG_DATE"}},nested_object:function(r,t){const e=new u(r).registerRules(t).prepare();return(r,t,s)=>{if(i.isNoValue(r))return;if(!i.isObject(r))return"FORMAT_ERROR";const n=e.validate(r);return n?void s.push(n):e.getErrors()}},variable_object:function(r,t,e){const s={};for(const r in t){const i=new u(t[r]).registerRules(e).prepare();s[r]=i}return(t,e,n)=>{if(i.isNoValue(t))return;if(!i.isObject(t)||!t[r]||!s[t[r]])return"FORMAT_ERROR";const o=s[t[r]],u=o.validate(t);return u?void n.push(u):o.getErrors()}},list_of:function(r,t){Array.isArray(r)||(t=(r=Array.prototype.slice.call(arguments)).pop());const e={field:r},s=new u(e).registerRules(t).prepare();return(r,t,e)=>{if(i.isNoValue(r))return;if(!Array.isArray(r))return"FORMAT_ERROR";const n=[],o=[];let u=!1;for(const t of r){const r=s.validate({field:t});r?(n.push(r.field),o.push(null)):(u=!0,o.push(s.getErrors().field),n.push(null))}return u?o:void e.push(n)}},list_of_objects:function(r,t){const e=new u(r).registerRules(t).prepare();return(r,t,s)=>{if(i.isNoValue(r))return;if(!Array.isArray(r))return"FORMAT_ERROR";const n=[],o=[];let u=!1;for(const t of r){const r=e.validate(t);r?(n.push(r),o.push(null)):(u=!0,o.push(e.getErrors()),n.push(null))}return u?o:void s.push(n)}},or:function(){const r=Array.prototype.slice.call(arguments),t=r.pop(),e=r.map(r=>new u({field:r}).registerRules(t).prepare());return(r,t,i)=>{let s;for(const t of e){const e=t.validate({field:r});if(e)return void i.push(e.field);s=t.getErrors().field}return s}},list_of_different_objects:function(r,t,e){const s={};for(const r in t){const i=new u(t[r]).registerRules(e).prepare();s[r]=i}return(t,e,n)=>{if(i.isNoValue(t))return;if(!Array.isArray(t))return"FORMAT_ERROR";const o=[],u=[];let a=!1;for(const e of t){if("object"!=typeof e||!e[r]||!s[e[r]]){u.push("FORMAT_ERROR");continue}const t=s[e[r]],i=t.validate(e);i?(o.push(i),u.push(null)):(a=!0,u.push(t.getErrors()),o.push(null))}return a?u:void n.push(o)}},default:r=>(t,e,s)=>{i.isNoValue(t)&&s.push(r)},trim:function(){return(r,t,e)=>{i.isNoValue(r)||"object"==typeof r||(r+="",e.push(r.replace(/^\s*/,"").replace(/\s*$/,"")))}},to_lc:function(){return(r,t,e)=>{i.isNoValue(r)||"object"==typeof r||(r+="",e.push(r.toLowerCase()))}},to_uc:function(){return(r,t,e)=>{i.isNoValue(r)||"object"==typeof r||(r+="",e.push(r.toUpperCase()))}},remove:function(r){r=i.escapeRegExp(r);const t=new RegExp("["+r+"]","g");return(r,e,s)=>{i.isNoValue(r)||"object"==typeof r||(r+="",s.push(r.replace(t,"")))}},leave_only:function(r){r=i.escapeRegExp(r);const t=new RegExp("[^"+r+"]","g");return(r,e,s)=>{i.isNoValue(r)||"object"==typeof r||(r+="",s.push(r.replace(t,"")))}}};u.registerDefaultRules(a);var l={Validator:u,rules:a,util:i},c="object"==typeof global&&global&&global.Object===Object&&global,f="object"==typeof self&&self&&self.Object===Object&&self,h=c||f||Function("return this")(),p=h.Symbol,d=Object.prototype,v=d.hasOwnProperty,_=d.toString,R=p?p.toStringTag:void 0;var O=function(r){var t=v.call(r,R),e=r[R];try{r[R]=void 0;var i=!0}catch(r){}var s=_.call(r);return i&&(t?r[R]=e:delete r[R]),s},g=Object.prototype.toString;var y=function(r){return g.call(r)},E=p?p.toStringTag:void 0;var m=function(r){return null==r?void 0===r?"[object Undefined]":"[object Null]":E&&E in Object(r)?O(r):y(r)};var b=function(r){var t=typeof r;return null!=r&&("object"==t||"function"==t)};var A,T=function(r){if(!b(r))return!1;var t=m(r);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},N=h["__core-js_shared__"],j=(A=/[^.]+$/.exec(N&&N.keys&&N.keys.IE_PROTO||""))?"Symbol(src)_1."+A:"";var V=function(r){return!!j&&j in r},$=Function.prototype.toString;var P=function(r){if(null!=r){try{return $.call(r)}catch(r){}try{return r+""}catch(r){}}return""},w=/^\[object .+?Constructor\]$/,M=Function.prototype,F=Object.prototype,L=M.toString,I=F.hasOwnProperty,x=RegExp("^"+L.call(I).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var D=function(r){return!(!b(r)||V(r))&&(T(r)?x:w).test(P(r))};var k=function(r,t){return null==r?void 0:r[t]};var z=function(r,t){var e=k(r,t);return D(e)?e:void 0},S=function(){try{var r=z(Object,"defineProperty");return r({},"",{}),r}catch(r){}}();var B=function(r,t,e){"__proto__"==t&&S?S(r,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):r[t]=e};var G=function(r,t){return r===t||r!=r&&t!=t},C=Object.prototype.hasOwnProperty;var H=function(r,t,e){var i=r[t];C.call(r,t)&&G(i,e)&&(void 0!==e||t in r)||B(r,t,e)},U=Array.isArray;var W=function(r){return null!=r&&"object"==typeof r};var q=function(r){return"symbol"==typeof r||W(r)&&"[object Symbol]"==m(r)},Y=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Q=/^\w*$/;var Z=function(r,t){if(U(r))return!1;var e=typeof r;return!("number"!=e&&"symbol"!=e&&"boolean"!=e&&null!=r&&!q(r))||(Q.test(r)||!Y.test(r)||null!=t&&r in Object(t))},J=z(Object,"create");var K=function(){this.__data__=J?J(null):{},this.size=0};var X=function(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t},rr=Object.prototype.hasOwnProperty;var tr=function(r){var t=this.__data__;if(J){var e=t[r];return"__lodash_hash_undefined__"===e?void 0:e}return rr.call(t,r)?t[r]:void 0},er=Object.prototype.hasOwnProperty;var ir=function(r){var t=this.__data__;return J?void 0!==t[r]:er.call(t,r)};var sr=function(r,t){var e=this.__data__;return this.size+=this.has(r)?0:1,e[r]=J&&void 0===t?"__lodash_hash_undefined__":t,this};function nr(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t<e;){var i=r[t];this.set(i[0],i[1])}}nr.prototype.clear=K,nr.prototype.delete=X,nr.prototype.get=tr,nr.prototype.has=ir,nr.prototype.set=sr;var or=nr;var ur=function(){this.__data__=[],this.size=0};var ar=function(r,t){for(var e=r.length;e--;)if(G(r[e][0],t))return e;return-1},lr=Array.prototype.splice;var cr=function(r){var t=this.__data__,e=ar(t,r);return!(e<0)&&(e==t.length-1?t.pop():lr.call(t,e,1),--this.size,!0)};var fr=function(r){var t=this.__data__,e=ar(t,r);return e<0?void 0:t[e][1]};var hr=function(r){return ar(this.__data__,r)>-1};var pr=function(r,t){var e=this.__data__,i=ar(e,r);return i<0?(++this.size,e.push([r,t])):e[i][1]=t,this};function dr(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t<e;){var i=r[t];this.set(i[0],i[1])}}dr.prototype.clear=ur,dr.prototype.delete=cr,dr.prototype.get=fr,dr.prototype.has=hr,dr.prototype.set=pr;var vr=dr,_r=z(h,"Map");var Rr=function(){this.size=0,this.__data__={hash:new or,map:new(_r||vr),string:new or}};var Or=function(r){var t=typeof r;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==r:null===r};var gr=function(r,t){var e=r.__data__;return Or(t)?e["string"==typeof t?"string":"hash"]:e.map};var yr=function(r){var t=gr(this,r).delete(r);return this.size-=t?1:0,t};var Er=function(r){return gr(this,r).get(r)};var mr=function(r){return gr(this,r).has(r)};var br=function(r,t){var e=gr(this,r),i=e.size;return e.set(r,t),this.size+=e.size==i?0:1,this};function Ar(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t<e;){var i=r[t];this.set(i[0],i[1])}}Ar.prototype.clear=Rr,Ar.prototype.delete=yr,Ar.prototype.get=Er,Ar.prototype.has=mr,Ar.prototype.set=br;var Tr=Ar;function Nr(r,t){if("function"!=typeof r||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var e=function(){var i=arguments,s=t?t.apply(this,i):i[0],n=e.cache;if(n.has(s))return n.get(s);var o=r.apply(this,i);return e.cache=n.set(s,o)||n,o};return e.cache=new(Nr.Cache||Tr),e}Nr.Cache=Tr;var jr=Nr;var Vr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,$r=/\\(\\)?/g,Pr=function(r){var t=jr(r,(function(r){return 500===e.size&&e.clear(),r})),e=t.cache;return t}((function(r){var t=[];return 46===r.charCodeAt(0)&&t.push(""),r.replace(Vr,(function(r,e,i,s){t.push(i?s.replace($r,"$1"):e||r)})),t}));var wr=function(r,t){for(var e=-1,i=null==r?0:r.length,s=Array(i);++e<i;)s[e]=t(r[e],e,r);return s},Mr=p?p.prototype:void 0,Fr=Mr?Mr.toString:void 0;var Lr=function r(t){if("string"==typeof t)return t;if(U(t))return wr(t,r)+"";if(q(t))return Fr?Fr.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e};var Ir=function(r){return null==r?"":Lr(r)};var xr=function(r,t){return U(r)?r:Z(r,t)?[r]:Pr(Ir(r))},Dr=/^(?:0|[1-9]\d*)$/;var kr=function(r,t){var e=typeof r;return!!(t=null==t?9007199254740991:t)&&("number"==e||"symbol"!=e&&Dr.test(r))&&r>-1&&r%1==0&&r<t};var zr=function(r){if("string"==typeof r||q(r))return r;var t=r+"";return"0"==t&&1/r==-1/0?"-0":t};var Sr=function(r,t,e,i){if(!b(r))return r;for(var s=-1,n=(t=xr(t,r)).length,o=n-1,u=r;null!=u&&++s<n;){var a=zr(t[s]),l=e;if("__proto__"===a||"constructor"===a||"prototype"===a)return r;if(s!=o){var c=u[a];void 0===(l=i?i(c,a,u):void 0)&&(l=b(c)?c:kr(t[s+1])?[]:{})}H(u,a,l),u=u[a]}return r};var Br=function(r,t,e){return null==r?r:Sr(r,t,e)};var Gr=function(r,t){for(var e=0,i=(t=xr(t,r)).length;null!=r&&e<i;)r=r[zr(t[e++])];return e&&e==i?r:void 0};var Cr=function(r,t,e){var i=null==r?void 0:Gr(r,t);return void 0===i?e:i};const Hr=(r={},t,e,i)=>{const s=r[e];return s?s(t,i):""},Ur=(r,t,e=[])=>{const i=Array.isArray(r);return Object.entries(r).reduce((r,[s,n])=>{let o=[].concat(e);if(i||o.push(s),n&&n.code){const[[,r]]=Object.entries(n.rule);Object.assign(n,{msg:Hr(t,o.join("."),n.code,r)}),o=[]}else n&&Ur(n,t,o);return Object.assign(r,{[s]:n})},{})};class Wr{constructor(r,t={}){this.errorHandlers=t.errorHandlers,this.extendedErrors=t.extendedErrors,this.msgPath=this.extendedErrors?"msg":"",this.allTouched=!1,r&&r instanceof Wr?(this.items=r.items,this.touchedFields=r.touchedFields):(this.items={},this.touchedFields={})}setTouched(r){Br(this.touchedFields,r,!0)}setAllTouched(r=!1){this.allTouched=r}setError(r,t){const e=this.extendedErrors?Ur(r,this.errorHandlers):r,i=t?this.items:{};if(this.items=Object.assign({},i,e),t){Cr(e,t,!1)||Br(this.items,t,"")}}clearErrors(r=this.items){r&&Object.entries(r).forEach(([r,t])=>"object"==typeof t?this.clearErrors(t):this.clearError(r))}clearError(r){this.setError({},r)}getError(r,t=0){if(!this.hasError(r,t))return"";const e=this.getErrors(r);return this.getMessage(e[t])}getMessage(r){return this.msgPath&&r?r[this.msgPath]:r}getErrors(r){return[].concat(Cr(this.items,r,[]))}hasError(r,t=0){const e=this.allTouched||Cr(this.touchedFields,r,!1),i=this.getErrors(r);return e&&!(r=>null==r||""===r)(this.getMessage(i[t]))}}class qr{constructor(r,e){this.extendedErrors=e.extendedErrors,this.aliasedRules=e.aliasedRules,this.aliasedRules.forEach(this.registerAliasedDefaultRule),l.Validator.registerDefaultRules(e.extraRules),this.errors=new Wr(null,e),this.extendedErrors&&(()=>{const r=l.Validator.getDefaultRules(),e=Object.entries(r).reduce((r,[e,i])=>Object.assign(r,{[e]:t(e,i)}),{});l.Validator.registerDefaultRules(e)})(),this.fields={items:[]},this.$gzLivr=r||{_vm:{$emit:()=>{},$off:()=>{}}}}validate(r,t,e){const i=new l.Validator(r),s=i.validate(t),n=s||i.getErrors();return s?(this.errors.clearError(e),n):(this.errors.setError(Object.assign({},n),e),this.errors.setTouched(e),{errors:this.errors.items})}registerAliasedDefaultRule(r){l.Validator.registerAliasedDefaultRule(r)}validateAll(r,t){this.validator=new l.Validator(r);const e=this.validator.validate(t),i=e||this.validator.getErrors();return e?(this.errors.clearErrors(),i):(this.errors.setError(i),this.errors.setAllTouched(!0),{errors:this.errors.items})}clearErrors(){this.errors.clearErrors()}clearError(r){this.errors.clearError(r)}}let Yr=null;const Qr=()=>Yr;let Zr=Object.assign({},{errorBagName:"errors",fieldsBagName:"fields",inject:!0,extendedErrors:!1,extraRules:{},aliasedRules:[]});const Jr=()=>Zr,Kr=r=>{Zr=Object.assign({},Zr,r)};var Xr={provide(){return this.$livr&&!e(this.$vnode)?{$livr:this.$livr}:{}},beforeCreate(){if(e(this.$vnode)||!1===this.$options.$__livrInject)return;this.$parent||Kr(this.$options.$_livr||{});const t=(r=>{const t=Cr(r,"$options.$_livr",{});return Object.assign({},Zr,t)})(this);(!this.$parent||this.$options.$_livr&&/new/.test(this.$options.$_livr.validator))&&(this.$livr=new qr(Qr(),t));const i=(s=this.$options.inject,!(!r(s)||!s.$livr));var s;if(this.$livr||!t.inject||i||(this.$livr=new qr(Qr(),t)),i||this.$livr){if(!i&&this.$livr){this.$options._base.util.defineReactive(this.$livr,"errors",this.$livr.errors)}this.$options.computed||(this.$options.computed={}),this.$options.computed[t.errorBagName||"errors"]=function(){return this.$livr.errors},this.$options.computed[t.fieldsBagName||"fields"]=function(){return this.$livr.fields.items.reduce((r,t)=>t.scope?(r["$"+t.scope]||(r["$"+t.scope]={}),r["$"+t.scope][t.name]=t.flags,r):(r[t.name]=t.flags,r),{})}}}};let rt,tt;class et{constructor(r,t){var e;this.configure(r),tt=this,t&&(rt=t),this.livrInstance=(e=new qr(null,this.config),Yr=e,e),this.initVM(this.config)}initVM({errorBagName:r,fieldsBagName:t}){this._vm=new rt({data:()=>({[r]:this.livrInstance.errors,[t]:this.livrInstance.fields})})}configure(r){Kr(r)}get config(){return Jr()}static get config(){return Jr()}static get instance(){return tt}}var it={install:function(r,t={}){rt&&r===rt?"production"!==process.env.NODE_ENV&&console.warn("already installed, Vue.use(LivrPlugin) should only be called once."):(rt=r,tt=new et(t),qr.$livr=tt,rt.mixin(Xr))}};export default it; |
@@ -1,1 +0,1 @@ | ||
var VueLivr=function(){"use strict";const r=r=>null!==r&&r&&"object"==typeof r&&!Array.isArray(r),t=(t,e)=>(...i)=>{const n=e(...i),s=i.splice(0,i.length-1);return(...e)=>{const i=n(...e);if(i){const e={[t]:s};return Array.isArray(i)||r(i)?i:{code:i,rule:e}}return""}},e=r=>{if(!r)return!1;const{tag:t}=r.componentOptions;return/^(keep-alive|transition|transition-group)$/.test(t)};var i={isPrimitiveValue:r=>"string"==typeof r||(!("number"!=typeof r||!isFinite(r))||"boolean"==typeof r),looksLikeNumber:r=>!isNaN(+r),isObject:r=>Object(r)===r&&Object.getPrototypeOf(r)===Object.prototype,isEmptyObject(r){for(const t in r)if(r.hasOwnProperty(t))return!1;return!0},escapeRegExp:r=>r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),isNoValue:r=>null==r||""===r};const n={};let s=0;class o{constructor(r,t){this.isPrepared=!1,this.livrRules=r,this.validators={},this.validatorBuilders={},this.errors=null,this.isAutoTrim=null!=t?t:s,this.registerRules(n)}static getDefaultRules(){return n}static registerAliasedDefaultRule(r){if(!r.name)throw"Alias name required";n[r.name]=this._buildAliasedRule(r.rules,r.error)}static registerDefaultRules(r){for(const t in r)n[t]=r[t]}static defaultAutoTrim(r){s=!!r}static _buildAliasedRule(r,t){if(!r)throw"Alias rules required";const e={value:r};return r=>{const i=new o(e).registerRules(r).prepare();return(r,e,n)=>{const s=i.validate({value:r});return s?void n.push(s.value):t||i.getErrors().value}}}prepare(){const r=this.livrRules;for(const t in r){let e=r[t];Array.isArray(e)||(e=[e]);const i=[];for(const r of e){const t=this._parseRule(r);i.push(this._buildValidator(t.name,t.args))}this.validators[t]=i}return this.isPrepared=!0,this}validate(r){if(this.isPrepared||this.prepare(),!i.isObject(r))return void(this.errors="FORMAT_ERROR");this.isAutoTrim&&(r=this._autoTrim(r));const t={},e={};for(const i in this.validators){const n=this.validators[i];if(!n||!n.length)continue;const s=r[i];for(const o of n){const n=[],u=o(e.hasOwnProperty(i)?e[i]:s,r,n);if(u){t[i]=u;break}n.length?e[i]=n[0]:r.hasOwnProperty(i)&&!e.hasOwnProperty(i)&&(e[i]=s)}}return i.isEmptyObject(t)?(this.errors=null,e):(this.errors=t,!1)}getErrors(){return this.errors}registerRules(r){for(const t in r)this.validatorBuilders[t]=r[t];return this}registerAliasedRule(r){if(!r.name)throw"Alias name required";return this.validatorBuilders[r.name]=this.constructor._buildAliasedRule(r.rules,r.error),this}getRules(){return this.validatorBuilders}_parseRule(r){let t,e;return i.isObject(r)?(t=Object.keys(r)[0],e=r[t],Array.isArray(e)||(e=[e])):(t=r,e=[]),{name:t,args:e}}_buildValidator(r,t){if(!this.validatorBuilders[r])throw"Rule ["+r+"] not registered";const e=[];return e.push.apply(e,t),e.push(this.getRules()),this.validatorBuilders[r].apply(null,e)}_autoTrim(r){const t=typeof r;if("object"!==t&&r)return r.replace?r.replace(/^\s*/,"").replace(/\s*$/,""):r;if("object"==t&&Array.isArray(r)){const t=[];for(const e of r)t.push(this._autoTrim(e));return t}if("object"==t&&i.isObject(r)){const t={};for(const e in r)r.hasOwnProperty(e)&&(t[e]=this._autoTrim(r[e]));return t}return r}}var u=o;const a={required:function(){return r=>{if(i.isNoValue(r))return"REQUIRED"}},not_empty:function(){return r=>{if(null!=r&&""===r)return"CANNOT_BE_EMPTY"}},not_empty_list:function(){return r=>void 0===r||""===r?"CANNOT_BE_EMPTY":Array.isArray(r)?r.length<1?"CANNOT_BE_EMPTY":void 0:"FORMAT_ERROR"},any_object:function(){return r=>{if(!i.isNoValue(r))return i.isObject(r)?void 0:"FORMAT_ERROR"}},string:function(){return(r,t,e)=>{if(!i.isNoValue(r))return i.isPrimitiveValue(r)?void e.push(r+""):"FORMAT_ERROR"}},eq:function(r){return(t,e,n)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if(t+""!=r+"")return"NOT_ALLOWED_VALUE";n.push(r)}}},one_of:function(r){return Array.isArray(r)||(r=Array.prototype.slice.call(arguments)).pop(),(t,e,n)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";for(const e of r)if(t+""==e+"")return void n.push(e);return"NOT_ALLOWED_VALUE"}}},max_length:function(r){return(t,e,n)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if((t+="").length>r)return"TOO_LONG";n.push(t)}}},min_length:function(r){return(t,e,n)=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if((t+="").length<r)return"TOO_SHORT";n.push(t)}}},length_equal:function(r){return(t,e,n)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?(t+="").length<r?"TOO_SHORT":t.length>r?"TOO_LONG":void n.push(t):"FORMAT_ERROR"}},length_between:function(r,t){return(e,n,s)=>{if(!i.isNoValue(e))return i.isPrimitiveValue(e)?(e+="").length<r?"TOO_SHORT":e.length>t?"TOO_LONG":void s.push(e):"FORMAT_ERROR"}},like:function(r,t){const e=3===arguments.length&&t.match("i"),n=new RegExp(r,e?"i":"");return(r,t,e)=>{if(!i.isNoValue(r)){if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";if(!(r+="").match(n))return"WRONG_FORMAT";e.push(r)}}},integer:function(){return(r,t,e)=>{if(!i.isNoValue(r))return i.isPrimitiveValue(r)?i.looksLikeNumber(r)&&Number.isInteger(+r)?void e.push(+r):"NOT_INTEGER":"FORMAT_ERROR"}},positive_integer:function(){return(r,t,e)=>{if(!i.isNoValue(r))return i.isPrimitiveValue(r)?i.looksLikeNumber(r)?!Number.isInteger(+r)||+r<1?"NOT_POSITIVE_INTEGER":void e.push(+r):"NOT_POSITIVE_INTEGER":"FORMAT_ERROR"}},decimal:function(){return(r,t,e)=>{if(!i.isNoValue(r)){if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";if(!i.looksLikeNumber(r))return"NOT_DECIMAL";if(!/^(?:\-?(?:(?:[0-9]+\.[0-9]+)|(?:[0-9]+)))$/.test(r+=""))return"NOT_DECIMAL";e.push(+r)}}},positive_decimal:function(){return(r,t,e)=>{if(!i.isNoValue(r)){if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";if(!i.looksLikeNumber(r))return"NOT_POSITIVE_DECIMAL";if(!/^(?:(?:[0-9]*\.[0-9]+)|(?:[1-9][0-9]*))$/.test(r+=""))return"NOT_POSITIVE_DECIMAL";e.push(+r)}}},max_number:function(r){return(t,e,n)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?i.looksLikeNumber(t)?+t>+r?"TOO_HIGH":void n.push(+t):"NOT_NUMBER":"FORMAT_ERROR"}},min_number:function(r){return(t,e,n)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?i.looksLikeNumber(t)?+t<+r?"TOO_LOW":void n.push(+t):"NOT_NUMBER":"FORMAT_ERROR"}},number_between:function(r,t){return(e,n,s)=>{if(!i.isNoValue(e))return i.isPrimitiveValue(e)?i.looksLikeNumber(e)?+e<+r?"TOO_LOW":+e>+t?"TOO_HIGH":void s.push(+e):"NOT_NUMBER":"FORMAT_ERROR"}},email:function(){var r=/^(([^<>()\[\]\\.,;:\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,}))$/;return t=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?(t+="",r.test(t)?/\@.*\@/.test(t)||/\@.*_/.test(t)?"WRONG_EMAIL":void 0:"WRONG_EMAIL"):"FORMAT_ERROR"}},equal_to_field:function(r){return(t,e)=>{if(!i.isNoValue(t))return i.isPrimitiveValue(t)?t!=e[r]?"FIELDS_NOT_EQUAL":void 0:"FORMAT_ERROR"}},url:function(){const r=new RegExp("^(?:(?:http|https)://)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[0-1]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-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,})))\\.?|localhost)(?::\\d{2,5})?(?:[/?#]\\S*)?$","i");return t=>{if(!i.isNoValue(t)){if(!i.isPrimitiveValue(t))return"FORMAT_ERROR";if(!(t.length<2083&&r.test(t)))return"WRONG_URL"}}},iso_date:function(){return r=>{if(i.isNoValue(r))return;if(!i.isPrimitiveValue(r))return"FORMAT_ERROR";const t=r.match(/^(\d{4})-([0-1][0-9])-([0-3][0-9])$/);if(t){const e=Date.parse(r);if(!e&&0!==e)return"WRONG_DATE";const i=new Date(e);if(i.setTime(i.getTime()+60*i.getTimezoneOffset()*1e3),i.getFullYear()==t[1]&&i.getMonth()+1==+t[2]&&i.getDate()==+t[3])return}return"WRONG_DATE"}},nested_object:function(r,t){const e=new u(r).registerRules(t).prepare();return(r,t,n)=>{if(i.isNoValue(r))return;if(!i.isObject(r))return"FORMAT_ERROR";const s=e.validate(r);return s?void n.push(s):e.getErrors()}},variable_object:function(r,t,e){const n={};for(const r in t){const i=new u(t[r]).registerRules(e).prepare();n[r]=i}return(t,e,s)=>{if(i.isNoValue(t))return;if(!i.isObject(t)||!t[r]||!n[t[r]])return"FORMAT_ERROR";const o=n[t[r]],u=o.validate(t);return u?void s.push(u):o.getErrors()}},list_of:function(r,t){Array.isArray(r)||(t=(r=Array.prototype.slice.call(arguments)).pop());const e={field:r},n=new u(e).registerRules(t).prepare();return(r,t,e)=>{if(i.isNoValue(r))return;if(!Array.isArray(r))return"FORMAT_ERROR";const s=[],o=[];let u=!1;for(const t of r){const r=n.validate({field:t});r?(s.push(r.field),o.push(null)):(u=!0,o.push(n.getErrors().field),s.push(null))}return u?o:void e.push(s)}},list_of_objects:function(r,t){const e=new u(r).registerRules(t).prepare();return(r,t,n)=>{if(i.isNoValue(r))return;if(!Array.isArray(r))return"FORMAT_ERROR";const s=[],o=[];let u=!1;for(const t of r){const r=e.validate(t);r?(s.push(r),o.push(null)):(u=!0,o.push(e.getErrors()),s.push(null))}return u?o:void n.push(s)}},or:function(){const r=Array.prototype.slice.call(arguments),t=r.pop(),e=r.map(r=>new u({field:r}).registerRules(t).prepare());return(r,t,i)=>{let n;for(const t of e){const e=t.validate({field:r});if(e)return void i.push(e.field);n=t.getErrors().field}return n}},list_of_different_objects:function(r,t,e){const n={};for(const r in t){const i=new u(t[r]).registerRules(e).prepare();n[r]=i}return(t,e,s)=>{if(i.isNoValue(t))return;if(!Array.isArray(t))return"FORMAT_ERROR";const o=[],u=[];let a=!1;for(const e of t){if("object"!=typeof e||!e[r]||!n[e[r]]){u.push("FORMAT_ERROR");continue}const t=n[e[r]],i=t.validate(e);i?(o.push(i),u.push(null)):(a=!0,u.push(t.getErrors()),o.push(null))}return a?u:void s.push(o)}},default:r=>(t,e,n)=>{i.isNoValue(t)&&n.push(r)},trim:function(){return(r,t,e)=>{i.isNoValue(r)||"object"==typeof r||(r+="",e.push(r.replace(/^\s*/,"").replace(/\s*$/,"")))}},to_lc:function(){return(r,t,e)=>{i.isNoValue(r)||"object"==typeof r||(r+="",e.push(r.toLowerCase()))}},to_uc:function(){return(r,t,e)=>{i.isNoValue(r)||"object"==typeof r||(r+="",e.push(r.toUpperCase()))}},remove:function(r){r=i.escapeRegExp(r);const t=new RegExp("["+r+"]","g");return(r,e,n)=>{i.isNoValue(r)||"object"==typeof r||(r+="",n.push(r.replace(t,"")))}},leave_only:function(r){r=i.escapeRegExp(r);const t=new RegExp("[^"+r+"]","g");return(r,e,n)=>{i.isNoValue(r)||"object"==typeof r||(r+="",n.push(r.replace(t,"")))}}};u.registerDefaultRules(a);var l={Validator:u,rules:a,util:i},c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},f="object"==typeof c&&c&&c.Object===Object&&c,h="object"==typeof self&&self&&self.Object===Object&&self,p=f||h||Function("return this")(),d=p.Symbol,v=Object.prototype,_=v.hasOwnProperty,R=v.toString,O=d?d.toStringTag:void 0;var g=function(r){var t=_.call(r,O),e=r[O];try{r[O]=void 0;var i=!0}catch(r){}var n=R.call(r);return i&&(t?r[O]=e:delete r[O]),n},y=Object.prototype.toString;var E=function(r){return y.call(r)},m=d?d.toStringTag:void 0;var b=function(r){return null==r?void 0===r?"[object Undefined]":"[object Null]":m&&m in Object(r)?g(r):E(r)};var A=function(r){var t=typeof r;return null!=r&&("object"==t||"function"==t)};var T,N=function(r){if(!A(r))return!1;var t=b(r);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},j=p["__core-js_shared__"],V=(T=/[^.]+$/.exec(j&&j.keys&&j.keys.IE_PROTO||""))?"Symbol(src)_1."+T:"";var $=function(r){return!!V&&V in r},w=Function.prototype.toString;var P=function(r){if(null!=r){try{return w.call(r)}catch(r){}try{return r+""}catch(r){}}return""},M=/^\[object .+?Constructor\]$/,F=Function.prototype,L=Object.prototype,I=F.toString,x=L.hasOwnProperty,D=RegExp("^"+I.call(x).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var k=function(r){return!(!A(r)||$(r))&&(N(r)?D:M).test(P(r))};var z=function(r,t){return null==r?void 0:r[t]};var S=function(r,t){var e=z(r,t);return k(e)?e:void 0},B=function(){try{var r=S(Object,"defineProperty");return r({},"",{}),r}catch(r){}}();var G=function(r,t,e){"__proto__"==t&&B?B(r,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):r[t]=e};var C=function(r,t){return r===t||r!=r&&t!=t},H=Object.prototype.hasOwnProperty;var U=function(r,t,e){var i=r[t];H.call(r,t)&&C(i,e)&&(void 0!==e||t in r)||G(r,t,e)},W=Array.isArray;var q=function(r){return null!=r&&"object"==typeof r};var Y=function(r){return"symbol"==typeof r||q(r)&&"[object Symbol]"==b(r)},Q=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Z=/^\w*$/;var J=function(r,t){if(W(r))return!1;var e=typeof r;return!("number"!=e&&"symbol"!=e&&"boolean"!=e&&null!=r&&!Y(r))||(Z.test(r)||!Q.test(r)||null!=t&&r in Object(t))},K=S(Object,"create");var X=function(){this.__data__=K?K(null):{},this.size=0};var rr=function(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t},tr=Object.prototype.hasOwnProperty;var er=function(r){var t=this.__data__;if(K){var e=t[r];return"__lodash_hash_undefined__"===e?void 0:e}return tr.call(t,r)?t[r]:void 0},ir=Object.prototype.hasOwnProperty;var nr=function(r){var t=this.__data__;return K?void 0!==t[r]:ir.call(t,r)};var sr=function(r,t){var e=this.__data__;return this.size+=this.has(r)?0:1,e[r]=K&&void 0===t?"__lodash_hash_undefined__":t,this};function or(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t<e;){var i=r[t];this.set(i[0],i[1])}}or.prototype.clear=X,or.prototype.delete=rr,or.prototype.get=er,or.prototype.has=nr,or.prototype.set=sr;var ur=or;var ar=function(){this.__data__=[],this.size=0};var lr=function(r,t){for(var e=r.length;e--;)if(C(r[e][0],t))return e;return-1},cr=Array.prototype.splice;var fr=function(r){var t=this.__data__,e=lr(t,r);return!(e<0)&&(e==t.length-1?t.pop():cr.call(t,e,1),--this.size,!0)};var hr=function(r){var t=this.__data__,e=lr(t,r);return e<0?void 0:t[e][1]};var pr=function(r){return lr(this.__data__,r)>-1};var dr=function(r,t){var e=this.__data__,i=lr(e,r);return i<0?(++this.size,e.push([r,t])):e[i][1]=t,this};function vr(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t<e;){var i=r[t];this.set(i[0],i[1])}}vr.prototype.clear=ar,vr.prototype.delete=fr,vr.prototype.get=hr,vr.prototype.has=pr,vr.prototype.set=dr;var _r=vr,Rr=S(p,"Map");var Or=function(){this.size=0,this.__data__={hash:new ur,map:new(Rr||_r),string:new ur}};var gr=function(r){var t=typeof r;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==r:null===r};var yr=function(r,t){var e=r.__data__;return gr(t)?e["string"==typeof t?"string":"hash"]:e.map};var Er=function(r){var t=yr(this,r).delete(r);return this.size-=t?1:0,t};var mr=function(r){return yr(this,r).get(r)};var br=function(r){return yr(this,r).has(r)};var Ar=function(r,t){var e=yr(this,r),i=e.size;return e.set(r,t),this.size+=e.size==i?0:1,this};function Tr(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t<e;){var i=r[t];this.set(i[0],i[1])}}Tr.prototype.clear=Or,Tr.prototype.delete=Er,Tr.prototype.get=mr,Tr.prototype.has=br,Tr.prototype.set=Ar;var Nr=Tr;function jr(r,t){if("function"!=typeof r||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var e=function(){var i=arguments,n=t?t.apply(this,i):i[0],s=e.cache;if(s.has(n))return s.get(n);var o=r.apply(this,i);return e.cache=s.set(n,o)||s,o};return e.cache=new(jr.Cache||Nr),e}jr.Cache=Nr;var Vr=jr;var $r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,wr=/\\(\\)?/g,Pr=function(r){var t=Vr(r,(function(r){return 500===e.size&&e.clear(),r})),e=t.cache;return t}((function(r){var t=[];return 46===r.charCodeAt(0)&&t.push(""),r.replace($r,(function(r,e,i,n){t.push(i?n.replace(wr,"$1"):e||r)})),t}));var Mr=function(r,t){for(var e=-1,i=null==r?0:r.length,n=Array(i);++e<i;)n[e]=t(r[e],e,r);return n},Fr=d?d.prototype:void 0,Lr=Fr?Fr.toString:void 0;var Ir=function r(t){if("string"==typeof t)return t;if(W(t))return Mr(t,r)+"";if(Y(t))return Lr?Lr.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e};var xr=function(r){return null==r?"":Ir(r)};var Dr=function(r,t){return W(r)?r:J(r,t)?[r]:Pr(xr(r))},kr=/^(?:0|[1-9]\d*)$/;var zr=function(r,t){var e=typeof r;return!!(t=null==t?9007199254740991:t)&&("number"==e||"symbol"!=e&&kr.test(r))&&r>-1&&r%1==0&&r<t};var Sr=function(r){if("string"==typeof r||Y(r))return r;var t=r+"";return"0"==t&&1/r==-1/0?"-0":t};var Br=function(r,t,e,i){if(!A(r))return r;for(var n=-1,s=(t=Dr(t,r)).length,o=s-1,u=r;null!=u&&++n<s;){var a=Sr(t[n]),l=e;if("__proto__"===a||"constructor"===a||"prototype"===a)return r;if(n!=o){var c=u[a];void 0===(l=i?i(c,a,u):void 0)&&(l=A(c)?c:zr(t[n+1])?[]:{})}U(u,a,l),u=u[a]}return r};var Gr=function(r,t,e){return null==r?r:Br(r,t,e)};var Cr=function(r,t){for(var e=0,i=(t=Dr(t,r)).length;null!=r&&e<i;)r=r[Sr(t[e++])];return e&&e==i?r:void 0};var Hr=function(r,t,e){var i=null==r?void 0:Cr(r,t);return void 0===i?e:i};const Ur=(r={},t,e,i)=>{const n=r[e];return n?n(t,i):""},Wr=(r,t,e=[])=>{const i=Array.isArray(r);return Object.entries(r).reduce((r,[n,s])=>{let o=[].concat(e);if(i||o.push(n),s&&s.code){const[[,r]]=Object.entries(s.rule);Object.assign(s,{msg:Ur(t,o.join("."),s.code,r)}),o=[]}else s&&Wr(s,t,o);return Object.assign(r,{[n]:s})},{})};class qr{constructor(r,t={}){this.errorHandlers=t.errorHandlers,this.extendedErrors=t.extendedErrors,this.msgPath=this.extendedErrors?"msg":"",this.allTouched=!1,r&&r instanceof qr?(this.items=r.items,this.touchedFields=r.touchedFields):(this.items={},this.touchedFields={})}setTouched(r){Gr(this.touchedFields,r,!0)}setAllTouched(r=!1){this.allTouched=r}setError(r,t){const e=this.extendedErrors?Wr(r,this.errorHandlers):r,i=t?this.items:{};if(this.items=Object.assign({},i,e),t){Hr(e,t,!1)||Gr(this.items,t,"")}}clearErrors(r=this.items){r&&Object.entries(r).forEach(([r,t])=>"object"==typeof t?this.clearErrors(t):this.clearError(r))}clearError(r){this.setError({},r)}getError(r,t=0){if(!this.hasError(r,t))return"";const e=this.getErrors(r);return this.getMessage(e[t])}getMessage(r){return this.msgPath&&r?r[this.msgPath]:r}getErrors(r){return[].concat(Hr(this.items,r,[]))}hasError(r,t=0){const e=this.allTouched||Hr(this.touchedFields,r,!1),i=this.getErrors(r);return e&&!(r=>null==r||""===r)(this.getMessage(i[t]))}}class Yr{constructor(r,e){this.extendedErrors=e.extendedErrors,this.aliasedRules=e.aliasedRules,this.aliasedRules.forEach(this.registerAliasedDefaultRule),l.Validator.registerDefaultRules(e.extraRules),this.errors=new qr(null,e),this.extendedErrors&&(()=>{const r=l.Validator.getDefaultRules(),e=Object.entries(r).reduce((r,[e,i])=>Object.assign(r,{[e]:t(e,i)}),{});l.Validator.registerDefaultRules(e)})(),this.fields={items:[]},this.$gzLivr=r||{_vm:{$emit:()=>{},$off:()=>{}}}}validate(r,t,e){const i=new l.Validator(r),n=i.validate(t),s=n||i.getErrors();return n?(this.errors.clearError(e),s):(this.errors.setError(Object.assign({},s),e),this.errors.setTouched(e),{errors:this.errors.items})}registerAliasedDefaultRule(r){l.Validator.registerAliasedDefaultRule(r)}validateAll(r,t){this.validator=new l.Validator(r);const e=this.validator.validate(t),i=e||this.validator.getErrors();return e?(this.errors.clearErrors(),i):(this.errors.setError(i),this.errors.setAllTouched(!0),{errors:this.errors.items})}clearErrors(){this.errors.clearErrors()}clearError(r){this.errors.clearError(r)}}let Qr=null;const Zr=()=>Qr;let Jr=Object.assign({},{errorBagName:"errors",fieldsBagName:"fields",inject:!0,extendedErrors:!1,extraRules:{},aliasedRules:[]});const Kr=()=>Jr,Xr=r=>{Jr=Object.assign({},Jr,r)};var rt={provide(){return this.$livr&&!e(this.$vnode)?{$livr:this.$livr}:{}},beforeCreate(){if(e(this.$vnode)||!1===this.$options.$__livrInject)return;this.$parent||Xr(this.$options.$_livr||{});const t=(r=>{const t=Hr(r,"$options.$_livr",{});return Object.assign({},Jr,t)})(this);(!this.$parent||this.$options.$_livr&&/new/.test(this.$options.$_livr.validator))&&(this.$livr=new Yr(Zr(),t));const i=(n=this.$options.inject,!(!r(n)||!n.$livr));var n;if(this.$livr||!t.inject||i||(this.$livr=new Yr(Zr(),t)),i||this.$livr){if(!i&&this.$livr){this.$options._base.util.defineReactive(this.$livr,"errors",this.$livr.errors)}this.$options.computed||(this.$options.computed={}),this.$options.computed[t.errorBagName||"errors"]=function(){return this.$livr.errors},this.$options.computed[t.fieldsBagName||"fields"]=function(){return this.$livr.fields.items.reduce((r,t)=>t.scope?(r["$"+t.scope]||(r["$"+t.scope]={}),r["$"+t.scope][t.name]=t.flags,r):(r[t.name]=t.flags,r),{})}}}};let tt,et;class it{constructor(r,t){var e;this.configure(r),et=this,t&&(tt=t),this.livrInstance=(e=new Yr(null,this.config),Qr=e,e),this.initVM(this.config)}static install(r,t={}){tt&&r===tt?"production"!==process.env.NODE_ENV&&console.warn("already installed, Vue.use(LivrPlugin) should only be called once."):(tt=r,et=new it(t),Yr.$livr=et,tt.mixin(rt))}initVM({errorBagName:r,fieldsBagName:t}){this._vm=new tt({data:()=>({[r]:this.livrInstance.errors,[t]:this.livrInstance.fields})})}configure(r){Xr(r)}get config(){return Kr()}static get config(){return Kr()}static get instance(){return et}}return it}(); | ||
var VueLIVR=function(r){"use strict";const t=r=>null!==r&&r&&"object"==typeof r&&!Array.isArray(r),e=(r,e)=>(...i)=>{const s=e(...i),n=i.splice(0,i.length-1);return(...e)=>{const i=s(...e);if(i){const e={[r]:n};return Array.isArray(i)||t(i)?i:{code:i,rule:e}}return""}},i=r=>{if(!r)return!1;const{tag:t}=r.componentOptions;return/^(keep-alive|transition|transition-group)$/.test(t)};var s={isPrimitiveValue:r=>"string"==typeof r||(!("number"!=typeof r||!isFinite(r))||"boolean"==typeof r),looksLikeNumber:r=>!isNaN(+r),isObject:r=>Object(r)===r&&Object.getPrototypeOf(r)===Object.prototype,isEmptyObject(r){for(const t in r)if(r.hasOwnProperty(t))return!1;return!0},escapeRegExp:r=>r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),isNoValue:r=>null==r||""===r};const n={};let o=0;class u{constructor(r,t){this.isPrepared=!1,this.livrRules=r,this.validators={},this.validatorBuilders={},this.errors=null,this.isAutoTrim=null!=t?t:o,this.registerRules(n)}static getDefaultRules(){return n}static registerAliasedDefaultRule(r){if(!r.name)throw"Alias name required";n[r.name]=this._buildAliasedRule(r.rules,r.error)}static registerDefaultRules(r){for(const t in r)n[t]=r[t]}static defaultAutoTrim(r){o=!!r}static _buildAliasedRule(r,t){if(!r)throw"Alias rules required";const e={value:r};return r=>{const i=new u(e).registerRules(r).prepare();return(r,e,s)=>{const n=i.validate({value:r});return n?void s.push(n.value):t||i.getErrors().value}}}prepare(){const r=this.livrRules;for(const t in r){let e=r[t];Array.isArray(e)||(e=[e]);const i=[];for(const r of e){const t=this._parseRule(r);i.push(this._buildValidator(t.name,t.args))}this.validators[t]=i}return this.isPrepared=!0,this}validate(r){if(this.isPrepared||this.prepare(),!s.isObject(r))return void(this.errors="FORMAT_ERROR");this.isAutoTrim&&(r=this._autoTrim(r));const t={},e={};for(const i in this.validators){const s=this.validators[i];if(!s||!s.length)continue;const n=r[i];for(const o of s){const s=[],u=o(e.hasOwnProperty(i)?e[i]:n,r,s);if(u){t[i]=u;break}s.length?e[i]=s[0]:r.hasOwnProperty(i)&&!e.hasOwnProperty(i)&&(e[i]=n)}}return s.isEmptyObject(t)?(this.errors=null,e):(this.errors=t,!1)}getErrors(){return this.errors}registerRules(r){for(const t in r)this.validatorBuilders[t]=r[t];return this}registerAliasedRule(r){if(!r.name)throw"Alias name required";return this.validatorBuilders[r.name]=this.constructor._buildAliasedRule(r.rules,r.error),this}getRules(){return this.validatorBuilders}_parseRule(r){let t,e;return s.isObject(r)?(t=Object.keys(r)[0],e=r[t],Array.isArray(e)||(e=[e])):(t=r,e=[]),{name:t,args:e}}_buildValidator(r,t){if(!this.validatorBuilders[r])throw"Rule ["+r+"] not registered";const e=[];return e.push.apply(e,t),e.push(this.getRules()),this.validatorBuilders[r].apply(null,e)}_autoTrim(r){const t=typeof r;if("object"!==t&&r)return r.replace?r.replace(/^\s*/,"").replace(/\s*$/,""):r;if("object"==t&&Array.isArray(r)){const t=[];for(const e of r)t.push(this._autoTrim(e));return t}if("object"==t&&s.isObject(r)){const t={};for(const e in r)r.hasOwnProperty(e)&&(t[e]=this._autoTrim(r[e]));return t}return r}}var a=u;const l={required:function(){return r=>{if(s.isNoValue(r))return"REQUIRED"}},not_empty:function(){return r=>{if(null!=r&&""===r)return"CANNOT_BE_EMPTY"}},not_empty_list:function(){return r=>void 0===r||""===r?"CANNOT_BE_EMPTY":Array.isArray(r)?r.length<1?"CANNOT_BE_EMPTY":void 0:"FORMAT_ERROR"},any_object:function(){return r=>{if(!s.isNoValue(r))return s.isObject(r)?void 0:"FORMAT_ERROR"}},string:function(){return(r,t,e)=>{if(!s.isNoValue(r))return s.isPrimitiveValue(r)?void e.push(r+""):"FORMAT_ERROR"}},eq:function(r){return(t,e,i)=>{if(!s.isNoValue(t)){if(!s.isPrimitiveValue(t))return"FORMAT_ERROR";if(t+""!=r+"")return"NOT_ALLOWED_VALUE";i.push(r)}}},one_of:function(r){return Array.isArray(r)||(r=Array.prototype.slice.call(arguments)).pop(),(t,e,i)=>{if(!s.isNoValue(t)){if(!s.isPrimitiveValue(t))return"FORMAT_ERROR";for(const e of r)if(t+""==e+"")return void i.push(e);return"NOT_ALLOWED_VALUE"}}},max_length:function(r){return(t,e,i)=>{if(!s.isNoValue(t)){if(!s.isPrimitiveValue(t))return"FORMAT_ERROR";if((t+="").length>r)return"TOO_LONG";i.push(t)}}},min_length:function(r){return(t,e,i)=>{if(!s.isNoValue(t)){if(!s.isPrimitiveValue(t))return"FORMAT_ERROR";if((t+="").length<r)return"TOO_SHORT";i.push(t)}}},length_equal:function(r){return(t,e,i)=>{if(!s.isNoValue(t))return s.isPrimitiveValue(t)?(t+="").length<r?"TOO_SHORT":t.length>r?"TOO_LONG":void i.push(t):"FORMAT_ERROR"}},length_between:function(r,t){return(e,i,n)=>{if(!s.isNoValue(e))return s.isPrimitiveValue(e)?(e+="").length<r?"TOO_SHORT":e.length>t?"TOO_LONG":void n.push(e):"FORMAT_ERROR"}},like:function(r,t){const e=3===arguments.length&&t.match("i"),i=new RegExp(r,e?"i":"");return(r,t,e)=>{if(!s.isNoValue(r)){if(!s.isPrimitiveValue(r))return"FORMAT_ERROR";if(!(r+="").match(i))return"WRONG_FORMAT";e.push(r)}}},integer:function(){return(r,t,e)=>{if(!s.isNoValue(r))return s.isPrimitiveValue(r)?s.looksLikeNumber(r)&&Number.isInteger(+r)?void e.push(+r):"NOT_INTEGER":"FORMAT_ERROR"}},positive_integer:function(){return(r,t,e)=>{if(!s.isNoValue(r))return s.isPrimitiveValue(r)?s.looksLikeNumber(r)?!Number.isInteger(+r)||+r<1?"NOT_POSITIVE_INTEGER":void e.push(+r):"NOT_POSITIVE_INTEGER":"FORMAT_ERROR"}},decimal:function(){return(r,t,e)=>{if(!s.isNoValue(r)){if(!s.isPrimitiveValue(r))return"FORMAT_ERROR";if(!s.looksLikeNumber(r))return"NOT_DECIMAL";if(!/^(?:\-?(?:(?:[0-9]+\.[0-9]+)|(?:[0-9]+)))$/.test(r+=""))return"NOT_DECIMAL";e.push(+r)}}},positive_decimal:function(){return(r,t,e)=>{if(!s.isNoValue(r)){if(!s.isPrimitiveValue(r))return"FORMAT_ERROR";if(!s.looksLikeNumber(r))return"NOT_POSITIVE_DECIMAL";if(!/^(?:(?:[0-9]*\.[0-9]+)|(?:[1-9][0-9]*))$/.test(r+=""))return"NOT_POSITIVE_DECIMAL";e.push(+r)}}},max_number:function(r){return(t,e,i)=>{if(!s.isNoValue(t))return s.isPrimitiveValue(t)?s.looksLikeNumber(t)?+t>+r?"TOO_HIGH":void i.push(+t):"NOT_NUMBER":"FORMAT_ERROR"}},min_number:function(r){return(t,e,i)=>{if(!s.isNoValue(t))return s.isPrimitiveValue(t)?s.looksLikeNumber(t)?+t<+r?"TOO_LOW":void i.push(+t):"NOT_NUMBER":"FORMAT_ERROR"}},number_between:function(r,t){return(e,i,n)=>{if(!s.isNoValue(e))return s.isPrimitiveValue(e)?s.looksLikeNumber(e)?+e<+r?"TOO_LOW":+e>+t?"TOO_HIGH":void n.push(+e):"NOT_NUMBER":"FORMAT_ERROR"}},email:function(){var r=/^(([^<>()\[\]\\.,;:\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,}))$/;return t=>{if(!s.isNoValue(t))return s.isPrimitiveValue(t)?(t+="",r.test(t)?/\@.*\@/.test(t)||/\@.*_/.test(t)?"WRONG_EMAIL":void 0:"WRONG_EMAIL"):"FORMAT_ERROR"}},equal_to_field:function(r){return(t,e)=>{if(!s.isNoValue(t))return s.isPrimitiveValue(t)?t!=e[r]?"FIELDS_NOT_EQUAL":void 0:"FORMAT_ERROR"}},url:function(){const r=new RegExp("^(?:(?:http|https)://)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[0-1]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-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,})))\\.?|localhost)(?::\\d{2,5})?(?:[/?#]\\S*)?$","i");return t=>{if(!s.isNoValue(t)){if(!s.isPrimitiveValue(t))return"FORMAT_ERROR";if(!(t.length<2083&&r.test(t)))return"WRONG_URL"}}},iso_date:function(){return r=>{if(s.isNoValue(r))return;if(!s.isPrimitiveValue(r))return"FORMAT_ERROR";const t=r.match(/^(\d{4})-([0-1][0-9])-([0-3][0-9])$/);if(t){const e=Date.parse(r);if(!e&&0!==e)return"WRONG_DATE";const i=new Date(e);if(i.setTime(i.getTime()+60*i.getTimezoneOffset()*1e3),i.getFullYear()==t[1]&&i.getMonth()+1==+t[2]&&i.getDate()==+t[3])return}return"WRONG_DATE"}},nested_object:function(r,t){const e=new a(r).registerRules(t).prepare();return(r,t,i)=>{if(s.isNoValue(r))return;if(!s.isObject(r))return"FORMAT_ERROR";const n=e.validate(r);return n?void i.push(n):e.getErrors()}},variable_object:function(r,t,e){const i={};for(const r in t){const s=new a(t[r]).registerRules(e).prepare();i[r]=s}return(t,e,n)=>{if(s.isNoValue(t))return;if(!s.isObject(t)||!t[r]||!i[t[r]])return"FORMAT_ERROR";const o=i[t[r]],u=o.validate(t);return u?void n.push(u):o.getErrors()}},list_of:function(r,t){Array.isArray(r)||(t=(r=Array.prototype.slice.call(arguments)).pop());const e={field:r},i=new a(e).registerRules(t).prepare();return(r,t,e)=>{if(s.isNoValue(r))return;if(!Array.isArray(r))return"FORMAT_ERROR";const n=[],o=[];let u=!1;for(const t of r){const r=i.validate({field:t});r?(n.push(r.field),o.push(null)):(u=!0,o.push(i.getErrors().field),n.push(null))}return u?o:void e.push(n)}},list_of_objects:function(r,t){const e=new a(r).registerRules(t).prepare();return(r,t,i)=>{if(s.isNoValue(r))return;if(!Array.isArray(r))return"FORMAT_ERROR";const n=[],o=[];let u=!1;for(const t of r){const r=e.validate(t);r?(n.push(r),o.push(null)):(u=!0,o.push(e.getErrors()),n.push(null))}return u?o:void i.push(n)}},or:function(){const r=Array.prototype.slice.call(arguments),t=r.pop(),e=r.map(r=>new a({field:r}).registerRules(t).prepare());return(r,t,i)=>{let s;for(const t of e){const e=t.validate({field:r});if(e)return void i.push(e.field);s=t.getErrors().field}return s}},list_of_different_objects:function(r,t,e){const i={};for(const r in t){const s=new a(t[r]).registerRules(e).prepare();i[r]=s}return(t,e,n)=>{if(s.isNoValue(t))return;if(!Array.isArray(t))return"FORMAT_ERROR";const o=[],u=[];let a=!1;for(const e of t){if("object"!=typeof e||!e[r]||!i[e[r]]){u.push("FORMAT_ERROR");continue}const t=i[e[r]],s=t.validate(e);s?(o.push(s),u.push(null)):(a=!0,u.push(t.getErrors()),o.push(null))}return a?u:void n.push(o)}},default:r=>(t,e,i)=>{s.isNoValue(t)&&i.push(r)},trim:function(){return(r,t,e)=>{s.isNoValue(r)||"object"==typeof r||(r+="",e.push(r.replace(/^\s*/,"").replace(/\s*$/,"")))}},to_lc:function(){return(r,t,e)=>{s.isNoValue(r)||"object"==typeof r||(r+="",e.push(r.toLowerCase()))}},to_uc:function(){return(r,t,e)=>{s.isNoValue(r)||"object"==typeof r||(r+="",e.push(r.toUpperCase()))}},remove:function(r){r=s.escapeRegExp(r);const t=new RegExp("["+r+"]","g");return(r,e,i)=>{s.isNoValue(r)||"object"==typeof r||(r+="",i.push(r.replace(t,"")))}},leave_only:function(r){r=s.escapeRegExp(r);const t=new RegExp("[^"+r+"]","g");return(r,e,i)=>{s.isNoValue(r)||"object"==typeof r||(r+="",i.push(r.replace(t,"")))}}};a.registerDefaultRules(l);var c={Validator:a,rules:l,util:s},f="object"==typeof global&&global&&global.Object===Object&&global,h="object"==typeof self&&self&&self.Object===Object&&self,p=f||h||Function("return this")(),d=p.Symbol,v=Object.prototype,_=v.hasOwnProperty,R=v.toString,O=d?d.toStringTag:void 0;var g=function(r){var t=_.call(r,O),e=r[O];try{r[O]=void 0;var i=!0}catch(r){}var s=R.call(r);return i&&(t?r[O]=e:delete r[O]),s},y=Object.prototype.toString;var E=function(r){return y.call(r)},m=d?d.toStringTag:void 0;var b=function(r){return null==r?void 0===r?"[object Undefined]":"[object Null]":m&&m in Object(r)?g(r):E(r)};var A=function(r){var t=typeof r;return null!=r&&("object"==t||"function"==t)};var T,N=function(r){if(!A(r))return!1;var t=b(r);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},V=p["__core-js_shared__"],j=(T=/[^.]+$/.exec(V&&V.keys&&V.keys.IE_PROTO||""))?"Symbol(src)_1."+T:"";var $=function(r){return!!j&&j in r},P=Function.prototype.toString;var w=function(r){if(null!=r){try{return P.call(r)}catch(r){}try{return r+""}catch(r){}}return""},M=/^\[object .+?Constructor\]$/,F=Function.prototype,L=Object.prototype,I=F.toString,x=L.hasOwnProperty,D=RegExp("^"+I.call(x).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var k=function(r){return!(!A(r)||$(r))&&(N(r)?D:M).test(w(r))};var z=function(r,t){return null==r?void 0:r[t]};var S=function(r,t){var e=z(r,t);return k(e)?e:void 0},B=function(){try{var r=S(Object,"defineProperty");return r({},"",{}),r}catch(r){}}();var G=function(r,t,e){"__proto__"==t&&B?B(r,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):r[t]=e};var C=function(r,t){return r===t||r!=r&&t!=t},H=Object.prototype.hasOwnProperty;var U=function(r,t,e){var i=r[t];H.call(r,t)&&C(i,e)&&(void 0!==e||t in r)||G(r,t,e)},W=Array.isArray;var q=function(r){return null!=r&&"object"==typeof r};var Y=function(r){return"symbol"==typeof r||q(r)&&"[object Symbol]"==b(r)},Q=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Z=/^\w*$/;var J=function(r,t){if(W(r))return!1;var e=typeof r;return!("number"!=e&&"symbol"!=e&&"boolean"!=e&&null!=r&&!Y(r))||(Z.test(r)||!Q.test(r)||null!=t&&r in Object(t))},K=S(Object,"create");var X=function(){this.__data__=K?K(null):{},this.size=0};var rr=function(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t},tr=Object.prototype.hasOwnProperty;var er=function(r){var t=this.__data__;if(K){var e=t[r];return"__lodash_hash_undefined__"===e?void 0:e}return tr.call(t,r)?t[r]:void 0},ir=Object.prototype.hasOwnProperty;var sr=function(r){var t=this.__data__;return K?void 0!==t[r]:ir.call(t,r)};var nr=function(r,t){var e=this.__data__;return this.size+=this.has(r)?0:1,e[r]=K&&void 0===t?"__lodash_hash_undefined__":t,this};function or(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t<e;){var i=r[t];this.set(i[0],i[1])}}or.prototype.clear=X,or.prototype.delete=rr,or.prototype.get=er,or.prototype.has=sr,or.prototype.set=nr;var ur=or;var ar=function(){this.__data__=[],this.size=0};var lr=function(r,t){for(var e=r.length;e--;)if(C(r[e][0],t))return e;return-1},cr=Array.prototype.splice;var fr=function(r){var t=this.__data__,e=lr(t,r);return!(e<0)&&(e==t.length-1?t.pop():cr.call(t,e,1),--this.size,!0)};var hr=function(r){var t=this.__data__,e=lr(t,r);return e<0?void 0:t[e][1]};var pr=function(r){return lr(this.__data__,r)>-1};var dr=function(r,t){var e=this.__data__,i=lr(e,r);return i<0?(++this.size,e.push([r,t])):e[i][1]=t,this};function vr(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t<e;){var i=r[t];this.set(i[0],i[1])}}vr.prototype.clear=ar,vr.prototype.delete=fr,vr.prototype.get=hr,vr.prototype.has=pr,vr.prototype.set=dr;var _r=vr,Rr=S(p,"Map");var Or=function(){this.size=0,this.__data__={hash:new ur,map:new(Rr||_r),string:new ur}};var gr=function(r){var t=typeof r;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==r:null===r};var yr=function(r,t){var e=r.__data__;return gr(t)?e["string"==typeof t?"string":"hash"]:e.map};var Er=function(r){var t=yr(this,r).delete(r);return this.size-=t?1:0,t};var mr=function(r){return yr(this,r).get(r)};var br=function(r){return yr(this,r).has(r)};var Ar=function(r,t){var e=yr(this,r),i=e.size;return e.set(r,t),this.size+=e.size==i?0:1,this};function Tr(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t<e;){var i=r[t];this.set(i[0],i[1])}}Tr.prototype.clear=Or,Tr.prototype.delete=Er,Tr.prototype.get=mr,Tr.prototype.has=br,Tr.prototype.set=Ar;var Nr=Tr;function Vr(r,t){if("function"!=typeof r||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var e=function(){var i=arguments,s=t?t.apply(this,i):i[0],n=e.cache;if(n.has(s))return n.get(s);var o=r.apply(this,i);return e.cache=n.set(s,o)||n,o};return e.cache=new(Vr.Cache||Nr),e}Vr.Cache=Nr;var jr=Vr;var $r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Pr=/\\(\\)?/g,wr=function(r){var t=jr(r,(function(r){return 500===e.size&&e.clear(),r})),e=t.cache;return t}((function(r){var t=[];return 46===r.charCodeAt(0)&&t.push(""),r.replace($r,(function(r,e,i,s){t.push(i?s.replace(Pr,"$1"):e||r)})),t}));var Mr=function(r,t){for(var e=-1,i=null==r?0:r.length,s=Array(i);++e<i;)s[e]=t(r[e],e,r);return s},Fr=d?d.prototype:void 0,Lr=Fr?Fr.toString:void 0;var Ir=function r(t){if("string"==typeof t)return t;if(W(t))return Mr(t,r)+"";if(Y(t))return Lr?Lr.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e};var xr=function(r){return null==r?"":Ir(r)};var Dr=function(r,t){return W(r)?r:J(r,t)?[r]:wr(xr(r))},kr=/^(?:0|[1-9]\d*)$/;var zr=function(r,t){var e=typeof r;return!!(t=null==t?9007199254740991:t)&&("number"==e||"symbol"!=e&&kr.test(r))&&r>-1&&r%1==0&&r<t};var Sr=function(r){if("string"==typeof r||Y(r))return r;var t=r+"";return"0"==t&&1/r==-1/0?"-0":t};var Br=function(r,t,e,i){if(!A(r))return r;for(var s=-1,n=(t=Dr(t,r)).length,o=n-1,u=r;null!=u&&++s<n;){var a=Sr(t[s]),l=e;if("__proto__"===a||"constructor"===a||"prototype"===a)return r;if(s!=o){var c=u[a];void 0===(l=i?i(c,a,u):void 0)&&(l=A(c)?c:zr(t[s+1])?[]:{})}U(u,a,l),u=u[a]}return r};var Gr=function(r,t,e){return null==r?r:Br(r,t,e)};var Cr=function(r,t){for(var e=0,i=(t=Dr(t,r)).length;null!=r&&e<i;)r=r[Sr(t[e++])];return e&&e==i?r:void 0};var Hr=function(r,t,e){var i=null==r?void 0:Cr(r,t);return void 0===i?e:i};const Ur=(r={},t,e,i)=>{const s=r[e];return s?s(t,i):""},Wr=(r,t,e=[])=>{const i=Array.isArray(r);return Object.entries(r).reduce((r,[s,n])=>{let o=[].concat(e);if(i||o.push(s),n&&n.code){const[[,r]]=Object.entries(n.rule);Object.assign(n,{msg:Ur(t,o.join("."),n.code,r)}),o=[]}else n&&Wr(n,t,o);return Object.assign(r,{[s]:n})},{})};class qr{constructor(r,t={}){this.errorHandlers=t.errorHandlers,this.extendedErrors=t.extendedErrors,this.msgPath=this.extendedErrors?"msg":"",this.allTouched=!1,r&&r instanceof qr?(this.items=r.items,this.touchedFields=r.touchedFields):(this.items={},this.touchedFields={})}setTouched(r){Gr(this.touchedFields,r,!0)}setAllTouched(r=!1){this.allTouched=r}setError(r,t){const e=this.extendedErrors?Wr(r,this.errorHandlers):r,i=t?this.items:{};if(this.items=Object.assign({},i,e),t){Hr(e,t,!1)||Gr(this.items,t,"")}}clearErrors(r=this.items){r&&Object.entries(r).forEach(([r,t])=>"object"==typeof t?this.clearErrors(t):this.clearError(r))}clearError(r){this.setError({},r)}getError(r,t=0){if(!this.hasError(r,t))return"";const e=this.getErrors(r);return this.getMessage(e[t])}getMessage(r){return this.msgPath&&r?r[this.msgPath]:r}getErrors(r){return[].concat(Hr(this.items,r,[]))}hasError(r,t=0){const e=this.allTouched||Hr(this.touchedFields,r,!1),i=this.getErrors(r);return e&&!(r=>null==r||""===r)(this.getMessage(i[t]))}}class Yr{constructor(r,t){this.extendedErrors=t.extendedErrors,this.aliasedRules=t.aliasedRules,this.aliasedRules.forEach(this.registerAliasedDefaultRule),c.Validator.registerDefaultRules(t.extraRules),this.errors=new qr(null,t),this.extendedErrors&&(()=>{const r=c.Validator.getDefaultRules(),t=Object.entries(r).reduce((r,[t,i])=>Object.assign(r,{[t]:e(t,i)}),{});c.Validator.registerDefaultRules(t)})(),this.fields={items:[]},this.$gzLivr=r||{_vm:{$emit:()=>{},$off:()=>{}}}}validate(r,t,e){const i=new c.Validator(r),s=i.validate(t),n=s||i.getErrors();return s?(this.errors.clearError(e),n):(this.errors.setError(Object.assign({},n),e),this.errors.setTouched(e),{errors:this.errors.items})}registerAliasedDefaultRule(r){c.Validator.registerAliasedDefaultRule(r)}validateAll(r,t){this.validator=new c.Validator(r);const e=this.validator.validate(t),i=e||this.validator.getErrors();return e?(this.errors.clearErrors(),i):(this.errors.setError(i),this.errors.setAllTouched(!0),{errors:this.errors.items})}clearErrors(){this.errors.clearErrors()}clearError(r){this.errors.clearError(r)}}let Qr=null;const Zr=()=>Qr;let Jr=Object.assign({},{errorBagName:"errors",fieldsBagName:"fields",inject:!0,extendedErrors:!1,extraRules:{},aliasedRules:[]});const Kr=()=>Jr,Xr=r=>{Jr=Object.assign({},Jr,r)};var rt={provide(){return this.$livr&&!i(this.$vnode)?{$livr:this.$livr}:{}},beforeCreate(){if(i(this.$vnode)||!1===this.$options.$__livrInject)return;this.$parent||Xr(this.$options.$_livr||{});const r=(r=>{const t=Hr(r,"$options.$_livr",{});return Object.assign({},Jr,t)})(this);(!this.$parent||this.$options.$_livr&&/new/.test(this.$options.$_livr.validator))&&(this.$livr=new Yr(Zr(),r));const e=(s=this.$options.inject,!(!t(s)||!s.$livr));var s;if(this.$livr||!r.inject||e||(this.$livr=new Yr(Zr(),r)),e||this.$livr){if(!e&&this.$livr){this.$options._base.util.defineReactive(this.$livr,"errors",this.$livr.errors)}this.$options.computed||(this.$options.computed={}),this.$options.computed[r.errorBagName||"errors"]=function(){return this.$livr.errors},this.$options.computed[r.fieldsBagName||"fields"]=function(){return this.$livr.fields.items.reduce((r,t)=>t.scope?(r["$"+t.scope]||(r["$"+t.scope]={}),r["$"+t.scope][t.name]=t.flags,r):(r[t.name]=t.flags,r),{})}}}};let tt,et;class it{constructor(r,t){var e;this.configure(r),et=this,t&&(tt=t),this.livrInstance=(e=new Yr(null,this.config),Qr=e,e),this.initVM(this.config)}initVM({errorBagName:r,fieldsBagName:t}){this._vm=new tt({data:()=>({[r]:this.livrInstance.errors,[t]:this.livrInstance.fields})})}configure(r){Xr(r)}get config(){return Kr()}static get config(){return Kr()}static get instance(){return et}}var st={install:function(r,t={}){tt&&r===tt?"production"!==process.env.NODE_ENV&&console.warn("already installed, Vue.use(LivrPlugin) should only be called once."):(tt=r,et=new it(t),Yr.$livr=et,tt.mixin(rt))}};return r.default=st,r}({}); |
{ | ||
"name": "vue-livr", | ||
"version": "0.2.2", | ||
"version": "0.2.4", | ||
"description": "Vue LIVR plugin", | ||
"author": "Jonatas Gusmão <js.gusmao@hotmail.com>", | ||
"license": "MIT", | ||
"main": "dist/index.js", | ||
"main": "dist/umd/index.js", | ||
"module": "dist/esm/index.js", | ||
"unpkg": "dist/index.js", | ||
"files": [ | ||
@@ -30,7 +31,7 @@ "dist", | ||
"dependencies": { | ||
"livr": "^2.3.1", | ||
"livr": "^2.3.2", | ||
"lodash": "^4.17.20" | ||
}, | ||
"devDependencies": { | ||
"@babel/preset-env": "^7.11.0", | ||
"@babel/preset-env": "^7.12.11", | ||
"babel-jest": "^24.9.0", | ||
@@ -41,9 +42,9 @@ "eslint": "5.16.0", | ||
"eslint-friendly-formatter": "^4.0.1", | ||
"eslint-import-resolver-babel-module": "^5.1.2", | ||
"eslint-import-resolver-babel-module": "^5.2.0", | ||
"eslint-import-resolver-webpack": "^0.11.1", | ||
"eslint-loader": "^2.2.1", | ||
"eslint-plugin-graphql": "^3.1.1", | ||
"eslint-plugin-import": "^2.22.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-module-resolver": "^0.9.0", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"eslint-plugin-vue": "^5.2.3", | ||
@@ -57,4 +58,4 @@ "husky": "^1.3.1", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-terser": "^5.3.0", | ||
"webpack": "^4.44.1", | ||
"rollup-plugin-terser": "^5.3.1", | ||
"webpack": "^4.46.0", | ||
"webpack-cli": "^3.3.12", | ||
@@ -61,0 +62,0 @@ "webpack-merge": "^4.2.2" |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
89726
7
325
2
Updatedlivr@^2.3.2