index.iife.min.js 10 KB

1
  1. var VuelidateValidators=function(e,r){"use strict";function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,a)}return t}function a(e){for(var r=1;r<arguments.length;r++){var a=null!=arguments[r]?arguments[r]:{};r%2?t(Object(a),!0).forEach((function(r){n(e,r,a[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):t(Object(a)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(a,r))}))}return e}function n(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function i(e){return"function"==typeof e}function o(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function s(e){return i(e.$validator)?a({},e):{$validator:e}}function u(e){return"object"==typeof e?e.$valid:e}function l(e){return e.$validator||e}function d(e,r){if(!o(e))throw new Error('[@vuelidate/validators]: First parameter to "withParams" should be an object, provided '+typeof e);if(!o(r)&&!i(r))throw new Error("[@vuelidate/validators]: Validator must be a function or object with $validator parameter");const t=s(r);return t.$params=a(a({},t.$params||{}),e),t}function c(e,t){if(!i(e)&&"string"!=typeof r.unref(e))throw new Error('[@vuelidate/validators]: First parameter to "withMessage" should be string or a function returning a string, provided '+typeof e);if(!o(t)&&!i(t))throw new Error("[@vuelidate/validators]: Validator must be a function or object with $validator parameter");const a=s(t);return a.$message=e,a}const $=e=>{if(e=r.unref(e),Array.isArray(e))return!!e.length;if(null==e)return!1;if(!1===e)return!0;if(e instanceof Date)return!isNaN(e.getTime());if("object"==typeof e){for(let r in e)return!0;return!1}return!!String(e).length},f=e=>(e=r.unref(e),Array.isArray(e)?e.length:"object"==typeof e?Object.keys(e).length:String(e).length);function m(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return e=>(e=r.unref(e),!$(e)||t.every((r=>(r.lastIndex=0,r.test(e)))))}var p=Object.freeze({__proto__:null,forEach:function(e){return{$validator(t){for(var a=arguments.length,n=new Array(a>1?a-1:0),i=1;i<a;i++)n[i-1]=arguments[i];return r.unref(t).reduce(((r,t,a)=>{const i=Object.entries(t).reduce(((r,i)=>{let[o,s]=i;const d=e[o]||{},c=Object.entries(d).reduce(((e,r)=>{let[i,d]=r;const c=l(d).call(this,s,t,a,...n),$=u(c);if(e.$data[i]=c,e.$data.$invalid=!$||!!e.$data.$invalid,e.$data.$error=e.$data.$invalid,!$){let r=d.$message||"";const t=d.$params||{};"function"==typeof r&&(r=r({$pending:!1,$invalid:!$,$params:t,$model:s,$response:c})),e.$errors.push({$property:o,$message:r,$params:t,$response:c,$model:s,$pending:!1,$validator:i})}return{$valid:e.$valid&&$,$data:e.$data,$errors:e.$errors}}),{$valid:!0,$data:{},$errors:[]});return r.$data[o]=c.$data,r.$errors[o]=c.$errors,{$valid:r.$valid&&c.$valid,$data:r.$data,$errors:r.$errors}}),{$valid:!0,$data:{},$errors:{}});return{$valid:r.$valid&&i.$valid,$data:r.$data.concat(i.$data),$errors:r.$errors.concat(i.$errors)}}),{$valid:!0,$data:[],$errors:[]})},$message:e=>{let{$response:r}=e;return r?r.$errors.map((e=>Object.values(e).map((e=>e.map((e=>e.$message)))).reduce(((e,r)=>e.concat(r)),[]))):[]}}},len:f,normalizeValidatorObject:s,regex:m,req:$,unwrap:r.unref,unwrapNormalizedValidator:l,unwrapValidatorResponse:u,withAsync:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return a(a({},s(e)),{},{$async:!0,$watchTargets:r})},withMessage:c,withParams:d}),v={$validator:m(/^[a-zA-Z]*$/),$message:"The value is not alphabetical",$params:{type:"alpha"}},h={$validator:m(/^[a-zA-Z0-9]*$/),$message:"The value must be alpha-numeric",$params:{type:"alphaNum"}},g={$validator:m(/^\d*(\.\d+)?$/),$message:"Value must be numeric",$params:{type:"numeric"}};function y(e,t){return a=>!$(a)||(!/\s/.test(a)||a instanceof Date)&&+r.unref(e)<=+a&&+r.unref(t)>=+a}var b={$validator:m(/^(?:[A-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9]{2,}(?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i),$message:"Value is not a valid email address",$params:{type:"email"}};const w=e=>{if(e.length>3||0===e.length)return!1;if("0"===e[0]&&"0"!==e)return!1;if(!e.match(/^\d+$/))return!1;const r=0|+e;return r>=0&&r<=255};var x={$validator:function(e){if(!$(e))return!0;if("string"!=typeof e)return!1;const r=e.split(".");return 4===r.length&&r.every(w)},$message:"The value is not a valid IP address",$params:{type:"ipAddress"}};function A(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:":";return t=>{if(e=r.unref(e),!$(t))return!0;if("string"!=typeof t)return!1;const a="string"==typeof e&&""!==e?t.split(e):12===t.length||16===t.length?t.match(/.{2}/g):null;return null!==a&&(6===a.length||8===a.length)&&a.every(j)}}const j=e=>e.toLowerCase().match(/^[0-9a-f]{2}$/);var T={$validator:function(e){return"string"==typeof e&&(e=e.trim()),$(e)},$message:"Value is required",$params:{type:"required"}};const O=(e,r)=>!e||$("string"==typeof r?r.trim():r);const P=(e,r)=>!!e||$("string"==typeof r?r.trim():r);function z(e){return t=>r.unref(t)===r.unref(e)}var V={$validator:m(/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i),$message:"The value is not a valid URL address",$params:{type:"url"}};function q(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];const a=r.some((e=>e.$async)),n=r.reduce(((e,r)=>r.$watchTargets?e.concat(r.$watchTargets):e),[]);let i=()=>!1;return r.length&&(i=a?function(e){return function(){for(var r=arguments.length,t=new Array(r),a=0;a<r;a++)t[a]=arguments[a];return e.reduce((async(e,r)=>{const a=await e;return u(a)?a:l(r).apply(this,t)}),Promise.resolve(!1))}}(r):function(e){return function(){for(var r=arguments.length,t=new Array(r),a=0;a<r;a++)t[a]=arguments[a];return e.reduce(((e,r)=>u(e)?e:l(r).apply(this,t)),!1)}}(r)),{$async:a,$validator:i,$watchTargets:n}}function D(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];const a=r.some((e=>e.$async)),n=r.reduce(((e,r)=>r.$watchTargets?e.concat(r.$watchTargets):e),[]);let i=()=>!1;return r.length&&(i=a?function(e){return function(){for(var r=arguments.length,t=new Array(r),a=0;a<r;a++)t[a]=arguments[a];return e.reduce((async(e,r)=>{const a=await e;return u(a)?l(r).apply(this,t):a}),Promise.resolve(!0))}}(r):function(e){return function(){for(var r=arguments.length,t=new Array(r),a=0;a<r;a++)t[a]=arguments[a];return e.reduce(((e,r)=>u(e)?l(r).apply(this,t):e),!0)}}(r)),{$async:a,$validator:i,$watchTargets:n}}function E(e){return function(r,t){if(!$(r))return!0;const a=l(e).call(this,r,t);return o(n=a)&&i(n.then)?a.then((e=>!u(e))):!u(a);var n}}function S(e){return t=>!$(t)||(!/\s/.test(t)||t instanceof Date)&&+t>=+r.unref(e)}function _(e){return t=>!$(t)||(!/\s/.test(t)||t instanceof Date)&&+t<=+r.unref(e)}var L={$validator:m(/(^[0-9]*$)|(^-[0-9]+$)/),$message:"Value is not an integer",$params:{type:"integer"}},N={$validator:m(/^[-]?\d*(\.\d+)?$/),$message:"Value must be decimal",$params:{type:"decimal"}};return e.alpha=v,e.alphaNum=h,e.and=function(){return d({type:"and"},c("The value does not match all of the provided validators",D(...arguments)))},e.between=function(e,r){return{$validator:y(e,r),$message:e=>{let{$params:r}=e;return`The value must be between ${r.min} and ${r.max}`},$params:{min:e,max:r,type:"between"}}},e.createI18nMessage=function(e){let{t:r,messagePath:t=(e=>{let{$validator:r}=e;return`validations.${r}`}),messageParams:n=(e=>e)}=e;return function(e){let{withArguments:i=!1,messagePath:o=t,messageParams:s=n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};function u(e){return r(o(e),s(a({model:e.$model,property:e.$property,pending:e.$pending,invalid:e.$invalid,response:e.$response,validator:e.$validator,propertyPath:e.$propertyPath},e.$params)))}return i&&"function"==typeof e?function(){return c(u,e(...arguments))}:c(u,e)}},e.decimal=N,e.email=b,e.helpers=p,e.integer=L,e.ipAddress=x,e.macAddress=function(e){return{$validator:A(e),$message:"The value is not a valid MAC Address",$params:{type:"macAddress"}}},e.maxLength=function(e){return{$validator:(t=e,e=>!$(e)||f(e)<=r.unref(t)),$message:e=>{let{$params:r}=e;return`The maximum length allowed is ${r.max}`},$params:{max:e,type:"maxLength"}};var t},e.maxValue=e=>({$validator:_(e),$message:e=>{let{$params:r}=e;return`The maximum value allowed is ${r.max}`},$params:{max:e,type:"maxValue"}}),e.minLength=function(e){return{$validator:(t=e,e=>!$(e)||f(e)>=r.unref(t)),$message:e=>{let{$params:r}=e;return`This field should be at least ${r.min} characters long`},$params:{min:e,type:"minLength"}};var t},e.minValue=function(e){return{$validator:S(e),$message:e=>{let{$params:r}=e;return`The minimum value allowed is ${r.min}`},$params:{min:e,type:"minValue"}}},e.not=function(e){return{$validator:E(e),$message:"The value does not match the provided validator",$params:{type:"not"}}},e.numeric=g,e.or=function(){return d({type:"or"},c("The value does not match any of the provided validators",q(...arguments)))},e.required=T,e.requiredIf=function(e){return{$validator:(t=e,function(e,a){if("function"!=typeof t)return O(r.unref(t),e);const n=t.call(this,e,a);return O(n,e)}),$message:"The value is required",$params:{type:"requiredIf",prop:e}};var t},e.requiredUnless=function(e){return{$validator:(t=e,function(e,a){if("function"!=typeof t)return P(r.unref(t),e);const n=t.call(this,e,a);return P(n,e)}),$message:"The value is required",$params:{type:"requiredUnless",prop:e}};var t},e.sameAs=function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"other";return{$validator:z(e),$message:e=>`The value must be equal to the ${r} value`,$params:{equalTo:e,otherName:r,type:"sameAs"}}},e.url=V,e}({},VueDemi);