@vee-validate/rules
Advanced tools
Comparing version 4.0.0-alpha.2 to 4.0.0-beta.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [4.0.0-beta.0](https://github.com/logaretm/vee-validate/compare/@vee-validate/rules@4.0.0-alpha.2...@vee-validate/rules@4.0.0-beta.0) (2020-10-01) | ||
### Bug Fixes | ||
* handle empty files in files rules ([8e2f3d4](https://github.com/logaretm/vee-validate/commit/8e2f3d41fb6ff7cf6e9db593c8a5168fe53afada)) | ||
# [4.0.0-alpha.2](https://github.com/logaretm/vee-validate/compare/@vee-validate/rules@4.0.0-alpha.1...@vee-validate/rules@4.0.0-alpha.2) (2020-07-27) | ||
@@ -8,0 +19,0 @@ |
@@ -15,3 +15,3 @@ declare const alphaValidator: (value: any, params?: any[] | Record<string, any>) => boolean; | ||
declare const dimensionsValidator: (files: any, params?: any[] | Record<string, any>) => Promise<boolean>; | ||
declare const dimensionsValidator: (files: any, params?: any[] | Record<string, any>) => true | Promise<boolean>; | ||
@@ -18,0 +18,0 @@ declare const emailValidator: (value: any) => boolean; |
/** | ||
* vee-validate vundefined | ||
* vee-validate v4.0.0-beta.0 | ||
* (c) 2020 Abdelrahman Awad | ||
@@ -217,2 +217,5 @@ * @license MIT | ||
const dimensionsValidator = (files, params) => { | ||
if (!files) { | ||
return true; | ||
} | ||
const { width, height } = getParams$1(params); | ||
@@ -246,2 +249,5 @@ const list = []; | ||
} | ||
if (!files) { | ||
return true; | ||
} | ||
const regex = new RegExp(`.(${extensions.join('|')})$`, 'i'); | ||
@@ -256,2 +262,5 @@ if (Array.isArray(files)) { | ||
const regex = /\.(jpg|svg|jpeg|png|bmp|gif|webp)$/i; | ||
if (!files) { | ||
return true; | ||
} | ||
if (Array.isArray(files)) { | ||
@@ -325,2 +334,5 @@ return files.every(file => regex.test(file.name)); | ||
const mimesValidator = (files, mimes) => { | ||
if (!files) { | ||
return true; | ||
} | ||
if (!mimes) { | ||
@@ -404,2 +416,5 @@ mimes = []; | ||
const sizeValidator = (files, params) => { | ||
if (!files) { | ||
return true; | ||
} | ||
let size = getSingleParam(params, 'size'); | ||
@@ -406,0 +421,0 @@ size = Number(size); |
/** | ||
* vee-validate vundefined | ||
* vee-validate v4.0.0-beta.0 | ||
* (c) 2020 Abdelrahman Awad | ||
@@ -223,2 +223,5 @@ * @license MIT | ||
const dimensionsValidator = (files, params) => { | ||
if (!files) { | ||
return true; | ||
} | ||
const { width, height } = getParams$1(params); | ||
@@ -252,2 +255,5 @@ const list = []; | ||
} | ||
if (!files) { | ||
return true; | ||
} | ||
const regex = new RegExp(`.(${extensions.join('|')})$`, 'i'); | ||
@@ -262,2 +268,5 @@ if (Array.isArray(files)) { | ||
const regex = /\.(jpg|svg|jpeg|png|bmp|gif|webp)$/i; | ||
if (!files) { | ||
return true; | ||
} | ||
if (Array.isArray(files)) { | ||
@@ -331,2 +340,5 @@ return files.every(file => regex.test(file.name)); | ||
const mimesValidator = (files, mimes) => { | ||
if (!files) { | ||
return true; | ||
} | ||
if (!mimes) { | ||
@@ -410,2 +422,5 @@ mimes = []; | ||
const sizeValidator = (files, params) => { | ||
if (!files) { | ||
return true; | ||
} | ||
let size = getSingleParam(params, 'size'); | ||
@@ -412,0 +427,0 @@ size = Number(size); |
/** | ||
* vee-validate vundefined | ||
* vee-validate v4.0.0-beta.0 | ||
* (c) 2020 Abdelrahman Awad | ||
* @license MIT | ||
*/ | ||
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self).VeeValidateRules={})}(this,(function(r){"use strict";const e={en:/^[A-Z]*$/i,cs:/^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]*$/i,da:/^[A-ZÆØÅ]*$/i,de:/^[A-ZÄÖÜß]*$/i,es:/^[A-ZÁÉÍÑÓÚÜ]*$/i,fr:/^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]*$/i,it:/^[A-Z\xC0-\xFF]*$/i,lt:/^[A-ZĄČĘĖĮŠŲŪŽ]*$/i,nl:/^[A-ZÉËÏÓÖÜ]*$/i,hu:/^[A-ZÁÉÍÓÖŐÚÜŰ]*$/i,pl:/^[A-ZĄĆĘŚŁŃÓŻŹ]*$/i,pt:/^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]*$/i,ru:/^[А-ЯЁ]*$/i,sk:/^[A-ZÁÄČĎÉÍĹĽŇÓŔŠŤÚÝŽ]*$/i,sr:/^[A-ZČĆŽŠĐ]*$/i,sv:/^[A-ZÅÄÖ]*$/i,tr:/^[A-ZÇĞİıÖŞÜ]*$/i,uk:/^[А-ЩЬЮЯЄІЇҐ]*$/i,ar:/^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]*$/,az:/^[A-ZÇƏĞİıÖŞÜ]*$/i},t={en:/^[A-Z\s]*$/i,cs:/^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ\s]*$/i,da:/^[A-ZÆØÅ\s]*$/i,de:/^[A-ZÄÖÜß\s]*$/i,es:/^[A-ZÁÉÍÑÓÚÜ\s]*$/i,fr:/^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ\s]*$/i,it:/^[A-Z\xC0-\xFF\s]*$/i,lt:/^[A-ZĄČĘĖĮŠŲŪŽ\s]*$/i,nl:/^[A-ZÉËÏÓÖÜ\s]*$/i,hu:/^[A-ZÁÉÍÓÖŐÚÜŰ\s]*$/i,pl:/^[A-ZĄĆĘŚŁŃÓŻŹ\s]*$/i,pt:/^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ\s]*$/i,ru:/^[А-ЯЁ\s]*$/i,sk:/^[A-ZÁÄČĎÉÍĹĽŇÓŔŠŤÚÝŽ\s]*$/i,sr:/^[A-ZČĆŽŠĐ\s]*$/i,sv:/^[A-ZÅÄÖ\s]*$/i,tr:/^[A-ZÇĞİıÖŞÜ\s]*$/i,uk:/^[А-ЩЬЮЯЄІЇҐ\s]*$/i,ar:/^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ\s]*$/,az:/^[A-ZÇƏĞİıÖŞÜ\s]*$/i},i={en:/^[0-9A-Z]*$/i,cs:/^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]*$/i,da:/^[0-9A-ZÆØÅ]$/i,de:/^[0-9A-ZÄÖÜß]*$/i,es:/^[0-9A-ZÁÉÍÑÓÚÜ]*$/i,fr:/^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]*$/i,it:/^[0-9A-Z\xC0-\xFF]*$/i,lt:/^[0-9A-ZĄČĘĖĮŠŲŪŽ]*$/i,hu:/^[0-9A-ZÁÉÍÓÖŐÚÜŰ]*$/i,nl:/^[0-9A-ZÉËÏÓÖÜ]*$/i,pl:/^[0-9A-ZĄĆĘŚŁŃÓŻŹ]*$/i,pt:/^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]*$/i,ru:/^[0-9А-ЯЁ]*$/i,sk:/^[0-9A-ZÁÄČĎÉÍĹĽŇÓŔŠŤÚÝŽ]*$/i,sr:/^[0-9A-ZČĆŽŠĐ]*$/i,sv:/^[0-9A-ZÅÄÖ]*$/i,tr:/^[0-9A-ZÇĞİıÖŞÜ]*$/i,uk:/^[0-9А-ЩЬЮЯЄІЇҐ]*$/i,ar:/^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]*$/,az:/^[0-9A-ZÇƏĞİıÖŞÜ]*$/i},n={en:/^[0-9A-Z_-]*$/i,cs:/^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ_-]*$/i,da:/^[0-9A-ZÆØÅ_-]*$/i,de:/^[0-9A-ZÄÖÜß_-]*$/i,es:/^[0-9A-ZÁÉÍÑÓÚÜ_-]*$/i,fr:/^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ_-]*$/i,it:/^[0-9A-Z\xC0-\xFF_-]*$/i,lt:/^[0-9A-ZĄČĘĖĮŠŲŪŽ_-]*$/i,nl:/^[0-9A-ZÉËÏÓÖÜ_-]*$/i,hu:/^[0-9A-ZÁÉÍÓÖŐÚÜŰ_-]*$/i,pl:/^[0-9A-ZĄĆĘŚŁŃÓŻŹ_-]*$/i,pt:/^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ_-]*$/i,ru:/^[0-9А-ЯЁ_-]*$/i,sk:/^[0-9A-ZÁÄČĎÉÍĹĽŇÓŔŠŤÚÝŽ_-]*$/i,sr:/^[0-9A-ZČĆŽŠĐ_-]*$/i,sv:/^[0-9A-ZÅÄÖ_-]*$/i,tr:/^[0-9A-ZÇĞİıÖŞÜ_-]*$/i,uk:/^[0-9А-ЩЬЮЯЄІЇҐ_-]*$/i,ar:/^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ_-]*$/,az:/^[0-9A-ZÇƏĞİıÖŞÜ_-]*$/i},s=r=>{if(r)return Array.isArray(r)?r[0]:r.locale},A=(r,t)=>{const i=s(t);return Array.isArray(r)?r.every(r=>A(r,{locale:i})):i?(e[i]||e.en).test(r):Object.keys(e).some(t=>e[t].test(r))},a=(r,e)=>{const t=s(e);return Array.isArray(r)?r.every(r=>a(r,{locale:t})):t?(n[t]||n.en).test(r):Object.keys(n).some(e=>n[e].test(r))},$=(r,e)=>{const t=s(e);return Array.isArray(r)?r.every(r=>$(r,{locale:t})):t?(i[t]||i.en).test(r):Object.keys(i).some(e=>i[e].test(r))},o=(r,e)=>{const i=s(e);return Array.isArray(r)?r.every(r=>o(r,{locale:i})):i?(t[i]||t.en).test(r):Object.keys(t).some(e=>t[e].test(r))};const y=(r,e)=>{const{min:t,max:i}=function(r){return r?Array.isArray(r)?{min:r[0],max:r[1]}:r:{min:0,max:0}}(e);return Array.isArray(r)?r.every(r=>!!y(r,{min:t,max:i})):Number(t)<=r&&Number(i)>=r};function u(r,e){if(r)return Array.isArray(r)?r[0]:r[e]}const Z=(r,e)=>{const t=u(e,"length");if(Array.isArray(r))return r.every(r=>Z(r,{length:t}));const i=String(r);return/^[0-9]*$/.test(i)&&i.length===t};function l(r){return null==r}const g=(r,e)=>{const t=u(e,"length");return l(r)?t>=0:Array.isArray(r)?r.every(r=>g(r,{length:t})):String(r).length<=Number(t)},m=(r,e)=>{const t=u(e,"max");return!l(r)&&""!==r&&(Array.isArray(r)?r.length>0&&r.every(r=>m(r,{max:t})):Number(r)<=Number(t))},c=(r,e)=>{const t=u(e,"length");return!l(r)&&(Array.isArray(r)?r.every(r=>c(r,{length:t})):String(r).length>=Number(t))},h=(r,e)=>{const t=u(e,"min");return!l(r)&&""!==r&&(Array.isArray(r)?r.length>0&&r.every(r=>h(r,{min:t})):Number(r)>=Number(t))},f=(r,e)=>Array.isArray(r)?r.every(r=>f(r,e)):Array.from(e).some(e=>e==r),p=/^[٠١٢٣٤٥٦٧٨٩]+$/,d=/^[0-9]+$/,_=(r,e)=>{let t=u(e,"regex");return"string"==typeof t&&(t=new RegExp(r)),Array.isArray(r)?r.every(r=>_(r,{regex:t})):t.test(String(r))};r.alpha=A,r.alpha_dash=a,r.alpha_num=$,r.alpha_spaces=o,r.between=y,r.confirmed=(r,e)=>{const t=u(e,"target");return String(r)===String(t)},r.digits=Z,r.dimensions=(r,e)=>{const{width:t,height:i}=function(r){return r?Array.isArray(r)?{width:Number(r[0]),height:Number(r[1])}:{width:Number(r.width),height:Number(r.height)}:{width:0,height:0}}(e),n=[];r=Array.isArray(r)?r:[r];for(let e=0;e<r.length;e++){if(!/\.(jpg|svg|jpeg|png|bmp|gif)$/i.test(r[e].name))return Promise.resolve(!1);n.push(r[e])}return Promise.all(n.map(r=>((r,e,t)=>{const i=window.URL||window.webkitURL;return new Promise(n=>{const s=new Image;s.onerror=()=>n(!1),s.onload=()=>n(s.width===e&&s.height===t),s.src=i.createObjectURL(r)})})(r,t,i))).then(r=>r.every(r=>r))},r.email=r=>{const e=/^(([^<>()\[\]\\.,;:\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 Array.isArray(r)?r.every(r=>e.test(String(r))):e.test(String(r))},r.ext=(r,e)=>{e||(e=[]);const t=new RegExp(`.(${e.join("|")})$`,"i");return Array.isArray(r)?r.every(r=>t.test(r.name)):t.test(r.name)},r.image=r=>{const e=/\.(jpg|svg|jpeg|png|bmp|gif|webp)$/i;return Array.isArray(r)?r.every(r=>e.test(r.name)):e.test(r.name)},r.integer=r=>Array.isArray(r)?r.every(r=>/^-?[0-9]+$/.test(String(r))):/^-?[0-9]+$/.test(String(r)),r.is=(r,e)=>r===u(e,"other"),r.is_not=(r,e)=>r!==u(e,"other"),r.length=(r,e)=>{const t=u(e,"length");return!l(r)&&("number"==typeof r&&(r=String(r)),r.length||(r=Array.from(r)),r.length===Number(t))},r.max=g,r.max_value=m,r.mimes=(r,e)=>{e||(e=[]);const t=new RegExp(e.join("|").replace("*",".+")+"$","i");return Array.isArray(r)?r.every(r=>t.test(r.type)):t.test(r.type)},r.min=c,r.min_value=h,r.not_one_of=(r,e)=>!f(r,e),r.numeric=r=>{const e=r=>{const e=String(r);return d.test(e)||p.test(e)};return Array.isArray(r)?r.every(e):e(r)},r.one_of=f,r.regex=_,r.required=r=>{return!l(r)&&(e=r,!Array.isArray(e)||0!==e.length)&&!1!==r&&!!String(r).trim().length;var e},r.size=(r,e)=>{let t=u(e,"size");if(t=Number(t),isNaN(t))return!1;const i=1024*t;if(!Array.isArray(r))return r.size<=i;for(let e=0;e<r.length;e++)if(r[e].size>i)return!1;return!0},Object.defineProperty(r,"__esModule",{value:!0})})); | ||
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self).VeeValidateRules={})}(this,(function(r){"use strict";const e={en:/^[A-Z]*$/i,cs:/^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]*$/i,da:/^[A-ZÆØÅ]*$/i,de:/^[A-ZÄÖÜß]*$/i,es:/^[A-ZÁÉÍÑÓÚÜ]*$/i,fr:/^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]*$/i,it:/^[A-Z\xC0-\xFF]*$/i,lt:/^[A-ZĄČĘĖĮŠŲŪŽ]*$/i,nl:/^[A-ZÉËÏÓÖÜ]*$/i,hu:/^[A-ZÁÉÍÓÖŐÚÜŰ]*$/i,pl:/^[A-ZĄĆĘŚŁŃÓŻŹ]*$/i,pt:/^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]*$/i,ru:/^[А-ЯЁ]*$/i,sk:/^[A-ZÁÄČĎÉÍĹĽŇÓŔŠŤÚÝŽ]*$/i,sr:/^[A-ZČĆŽŠĐ]*$/i,sv:/^[A-ZÅÄÖ]*$/i,tr:/^[A-ZÇĞİıÖŞÜ]*$/i,uk:/^[А-ЩЬЮЯЄІЇҐ]*$/i,ar:/^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]*$/,az:/^[A-ZÇƏĞİıÖŞÜ]*$/i},t={en:/^[A-Z\s]*$/i,cs:/^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ\s]*$/i,da:/^[A-ZÆØÅ\s]*$/i,de:/^[A-ZÄÖÜß\s]*$/i,es:/^[A-ZÁÉÍÑÓÚÜ\s]*$/i,fr:/^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ\s]*$/i,it:/^[A-Z\xC0-\xFF\s]*$/i,lt:/^[A-ZĄČĘĖĮŠŲŪŽ\s]*$/i,nl:/^[A-ZÉËÏÓÖÜ\s]*$/i,hu:/^[A-ZÁÉÍÓÖŐÚÜŰ\s]*$/i,pl:/^[A-ZĄĆĘŚŁŃÓŻŹ\s]*$/i,pt:/^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ\s]*$/i,ru:/^[А-ЯЁ\s]*$/i,sk:/^[A-ZÁÄČĎÉÍĹĽŇÓŔŠŤÚÝŽ\s]*$/i,sr:/^[A-ZČĆŽŠĐ\s]*$/i,sv:/^[A-ZÅÄÖ\s]*$/i,tr:/^[A-ZÇĞİıÖŞÜ\s]*$/i,uk:/^[А-ЩЬЮЯЄІЇҐ\s]*$/i,ar:/^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ\s]*$/,az:/^[A-ZÇƏĞİıÖŞÜ\s]*$/i},i={en:/^[0-9A-Z]*$/i,cs:/^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]*$/i,da:/^[0-9A-ZÆØÅ]$/i,de:/^[0-9A-ZÄÖÜß]*$/i,es:/^[0-9A-ZÁÉÍÑÓÚÜ]*$/i,fr:/^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]*$/i,it:/^[0-9A-Z\xC0-\xFF]*$/i,lt:/^[0-9A-ZĄČĘĖĮŠŲŪŽ]*$/i,hu:/^[0-9A-ZÁÉÍÓÖŐÚÜŰ]*$/i,nl:/^[0-9A-ZÉËÏÓÖÜ]*$/i,pl:/^[0-9A-ZĄĆĘŚŁŃÓŻŹ]*$/i,pt:/^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]*$/i,ru:/^[0-9А-ЯЁ]*$/i,sk:/^[0-9A-ZÁÄČĎÉÍĹĽŇÓŔŠŤÚÝŽ]*$/i,sr:/^[0-9A-ZČĆŽŠĐ]*$/i,sv:/^[0-9A-ZÅÄÖ]*$/i,tr:/^[0-9A-ZÇĞİıÖŞÜ]*$/i,uk:/^[0-9А-ЩЬЮЯЄІЇҐ]*$/i,ar:/^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]*$/,az:/^[0-9A-ZÇƏĞİıÖŞÜ]*$/i},n={en:/^[0-9A-Z_-]*$/i,cs:/^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ_-]*$/i,da:/^[0-9A-ZÆØÅ_-]*$/i,de:/^[0-9A-ZÄÖÜß_-]*$/i,es:/^[0-9A-ZÁÉÍÑÓÚÜ_-]*$/i,fr:/^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ_-]*$/i,it:/^[0-9A-Z\xC0-\xFF_-]*$/i,lt:/^[0-9A-ZĄČĘĖĮŠŲŪŽ_-]*$/i,nl:/^[0-9A-ZÉËÏÓÖÜ_-]*$/i,hu:/^[0-9A-ZÁÉÍÓÖŐÚÜŰ_-]*$/i,pl:/^[0-9A-ZĄĆĘŚŁŃÓŻŹ_-]*$/i,pt:/^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ_-]*$/i,ru:/^[0-9А-ЯЁ_-]*$/i,sk:/^[0-9A-ZÁÄČĎÉÍĹĽŇÓŔŠŤÚÝŽ_-]*$/i,sr:/^[0-9A-ZČĆŽŠĐ_-]*$/i,sv:/^[0-9A-ZÅÄÖ_-]*$/i,tr:/^[0-9A-ZÇĞİıÖŞÜ_-]*$/i,uk:/^[0-9А-ЩЬЮЯЄІЇҐ_-]*$/i,ar:/^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ_-]*$/,az:/^[0-9A-ZÇƏĞİıÖŞÜ_-]*$/i},s=r=>{if(r)return Array.isArray(r)?r[0]:r.locale},A=(r,t)=>{const i=s(t);return Array.isArray(r)?r.every((r=>A(r,{locale:i}))):i?(e[i]||e.en).test(r):Object.keys(e).some((t=>e[t].test(r)))},a=(r,e)=>{const t=s(e);return Array.isArray(r)?r.every((r=>a(r,{locale:t}))):t?(n[t]||n.en).test(r):Object.keys(n).some((e=>n[e].test(r)))},$=(r,e)=>{const t=s(e);return Array.isArray(r)?r.every((r=>$(r,{locale:t}))):t?(i[t]||i.en).test(r):Object.keys(i).some((e=>i[e].test(r)))},o=(r,e)=>{const i=s(e);return Array.isArray(r)?r.every((r=>o(r,{locale:i}))):i?(t[i]||t.en).test(r):Object.keys(t).some((e=>t[e].test(r)))};const u=(r,e)=>{const{min:t,max:i}=function(r){return r?Array.isArray(r)?{min:r[0],max:r[1]}:r:{min:0,max:0}}(e);return Array.isArray(r)?r.every((r=>!!u(r,{min:t,max:i}))):Number(t)<=r&&Number(i)>=r};function y(r,e){if(r)return Array.isArray(r)?r[0]:r[e]}const Z=(r,e)=>{const t=y(e,"length");if(Array.isArray(r))return r.every((r=>Z(r,{length:t})));const i=String(r);return/^[0-9]*$/.test(i)&&i.length===t};function l(r){return null==r}const g=(r,e)=>{const t=y(e,"length");return l(r)?t>=0:Array.isArray(r)?r.every((r=>g(r,{length:t}))):String(r).length<=Number(t)},m=(r,e)=>{const t=y(e,"max");return!l(r)&&""!==r&&(Array.isArray(r)?r.length>0&&r.every((r=>m(r,{max:t}))):Number(r)<=Number(t))},c=(r,e)=>{const t=y(e,"length");return!l(r)&&(Array.isArray(r)?r.every((r=>c(r,{length:t}))):String(r).length>=Number(t))},h=(r,e)=>{const t=y(e,"min");return!l(r)&&""!==r&&(Array.isArray(r)?r.length>0&&r.every((r=>h(r,{min:t}))):Number(r)>=Number(t))},f=(r,e)=>Array.isArray(r)?r.every((r=>f(r,e))):Array.from(e).some((e=>e==r)),p=/^[٠١٢٣٤٥٦٧٨٩]+$/,d=/^[0-9]+$/,_=(r,e)=>{let t=y(e,"regex");return"string"==typeof t&&(t=new RegExp(r)),Array.isArray(r)?r.every((r=>_(r,{regex:t}))):t.test(String(r))};r.alpha=A,r.alpha_dash=a,r.alpha_num=$,r.alpha_spaces=o,r.between=u,r.confirmed=(r,e)=>{const t=y(e,"target");return String(r)===String(t)},r.digits=Z,r.dimensions=(r,e)=>{if(!r)return!0;const{width:t,height:i}=function(r){return r?Array.isArray(r)?{width:Number(r[0]),height:Number(r[1])}:{width:Number(r.width),height:Number(r.height)}:{width:0,height:0}}(e),n=[];r=Array.isArray(r)?r:[r];for(let e=0;e<r.length;e++){if(!/\.(jpg|svg|jpeg|png|bmp|gif)$/i.test(r[e].name))return Promise.resolve(!1);n.push(r[e])}return Promise.all(n.map((r=>((r,e,t)=>{const i=window.URL||window.webkitURL;return new Promise((n=>{const s=new Image;s.onerror=()=>n(!1),s.onload=()=>n(s.width===e&&s.height===t),s.src=i.createObjectURL(r)}))})(r,t,i)))).then((r=>r.every((r=>r))))},r.email=r=>{const e=/^(([^<>()\[\]\\.,;:\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 Array.isArray(r)?r.every((r=>e.test(String(r)))):e.test(String(r))},r.ext=(r,e)=>{if(e||(e=[]),!r)return!0;const t=new RegExp(`.(${e.join("|")})$`,"i");return Array.isArray(r)?r.every((r=>t.test(r.name))):t.test(r.name)},r.image=r=>{const e=/\.(jpg|svg|jpeg|png|bmp|gif|webp)$/i;return!r||(Array.isArray(r)?r.every((r=>e.test(r.name))):e.test(r.name))},r.integer=r=>Array.isArray(r)?r.every((r=>/^-?[0-9]+$/.test(String(r)))):/^-?[0-9]+$/.test(String(r)),r.is=(r,e)=>r===y(e,"other"),r.is_not=(r,e)=>r!==y(e,"other"),r.length=(r,e)=>{const t=y(e,"length");return!l(r)&&("number"==typeof r&&(r=String(r)),r.length||(r=Array.from(r)),r.length===Number(t))},r.max=g,r.max_value=m,r.mimes=(r,e)=>{if(!r)return!0;e||(e=[]);const t=new RegExp(e.join("|").replace("*",".+")+"$","i");return Array.isArray(r)?r.every((r=>t.test(r.type))):t.test(r.type)},r.min=c,r.min_value=h,r.not_one_of=(r,e)=>!f(r,e),r.numeric=r=>{const e=r=>{const e=String(r);return d.test(e)||p.test(e)};return Array.isArray(r)?r.every(e):e(r)},r.one_of=f,r.regex=_,r.required=r=>{return!l(r)&&(e=r,!Array.isArray(e)||0!==e.length)&&!1!==r&&!!String(r).trim().length;var e},r.size=(r,e)=>{if(!r)return!0;let t=y(e,"size");if(t=Number(t),isNaN(t))return!1;const i=1024*t;if(!Array.isArray(r))return r.size<=i;for(let e=0;e<r.length;e++)if(r[e].size>i)return!1;return!0},Object.defineProperty(r,"__esModule",{value:!0})})); |
{ | ||
"name": "@vee-validate/rules", | ||
"version": "4.0.0-alpha.2", | ||
"version": "4.0.0-beta.0", | ||
"description": "Template Based Validation Framework for Vue.js", | ||
@@ -26,3 +26,3 @@ "author": "Abdelrahman Awad <logaretm1@gmail.com>", | ||
], | ||
"gitHead": "ce1719b0cb5f6ef5c5cd72f5befd01a601dd715f" | ||
"gitHead": "18fb60ec23bd704e99c7cacdabd76d6d1708d0dc" | ||
} |
@@ -1,11 +0,84 @@ | ||
# `rules` | ||
# @vee-validate/rules | ||
> TODO: description | ||
<p align="center"> | ||
<a href="https://logaretm.github.io/vee-validate/" target="_blank"> | ||
<img width="150" src="https://github.com/logaretm/vee-validate/blob/master/logo.png"> | ||
</a> | ||
</p> | ||
> Common Laravel-Like rules module for vee-validate | ||
## What's this | ||
VeeValidate v4 breaks up the parts that made it a popular solution for form validation into it isolated parts. The core `vee-validate` package no longer includes the rules that came by default in previous releases, the built-in rules were rebranded as **global validators**, | ||
This is where this package comes in, It includes the most common validators you will use in most of your applications, vee-validate allows you to express global rules just like Laravel's validation syntax. | ||
## Installation | ||
```bash | ||
yarn add @vee-validate/rules | ||
# or with npm | ||
npm install @vee-validate/rules | ||
``` | ||
## Usage | ||
Use the `defineRule` function from `vee-validate` core library to add rules exported by this library: | ||
```js | ||
import { defineRule } from 'vee-validate'; | ||
import { required, email, min } from '@vee-validate/rules'; | ||
defineRule('required', required); | ||
defineRule('email', email); | ||
defineRule('min', min); | ||
``` | ||
const rules = require('rules'); | ||
// TODO: DEMONSTRATE API | ||
Or you can globally define all the available rules in the `@vee-validate/rules` package: | ||
```js | ||
import { defineRule } from 'vee-validate'; | ||
import * as rules from '@vee-validate/rules'; | ||
Object.keys(rules).forEach(rule => { | ||
defineRule(rule, rules[rule]); | ||
}); | ||
``` | ||
### Available Rules | ||
- alpha | ||
- alpha_dash | ||
- alpha_num | ||
- alpha_spaces | ||
- between | ||
- confirmed | ||
- digits | ||
- dimensions | ||
- excluded | ||
- ext | ||
- image | ||
- oneOf | ||
- integer | ||
- is | ||
- is_not | ||
- length | ||
- max | ||
- max_value | ||
- mimes | ||
- min | ||
- min_value | ||
- numeric | ||
- regex | ||
- required | ||
- required_if | ||
- size | ||
For more information about each rules, check the [documentation for global validators](https://vee-validate.logaretm.com/v4/guide/global-validators) | ||
## Credits | ||
- Inspired by Laravel's [validation syntax](https://laravel.com/docs/5.4/validation) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45634
874
85