@regle/rules 0.5.7 → 0.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/regle-rules.cjs +35 -14
- package/dist/regle-rules.min.cjs +1 -1
- package/dist/regle-rules.min.mjs +1 -1
- package/dist/regle-rules.mjs +35 -14
- package/package.json +5 -5
package/dist/regle-rules.cjs
CHANGED
|
@@ -257,7 +257,7 @@ function and(...rules) {
|
|
|
257
257
|
} else {
|
|
258
258
|
const $params = rule._params;
|
|
259
259
|
if (!$params?.length) {
|
|
260
|
-
return [
|
|
260
|
+
return [];
|
|
261
261
|
} else {
|
|
262
262
|
return $params;
|
|
263
263
|
}
|
|
@@ -321,8 +321,15 @@ function and(...rules) {
|
|
|
321
321
|
validator,
|
|
322
322
|
message: "The value does not match all of the provided validators"
|
|
323
323
|
});
|
|
324
|
-
|
|
325
|
-
|
|
324
|
+
const newParams = [..._params ?? []];
|
|
325
|
+
newRule._params = newParams;
|
|
326
|
+
if (typeof newRule === "function") {
|
|
327
|
+
const executedRule = newRule(...newParams);
|
|
328
|
+
executedRule._message_patched = true;
|
|
329
|
+
return executedRule;
|
|
330
|
+
} else {
|
|
331
|
+
return newRule;
|
|
332
|
+
}
|
|
326
333
|
}
|
|
327
334
|
function or(...rules) {
|
|
328
335
|
const isAnyRuleAsync = rules.some((rule) => {
|
|
@@ -332,14 +339,14 @@ function or(...rules) {
|
|
|
332
339
|
return rule._async;
|
|
333
340
|
}
|
|
334
341
|
});
|
|
335
|
-
const
|
|
342
|
+
const _params = rules.map((rule) => {
|
|
336
343
|
if (typeof rule === "function") {
|
|
337
344
|
return null;
|
|
338
345
|
} else {
|
|
339
346
|
return rule._params;
|
|
340
347
|
}
|
|
341
348
|
}).flat().filter((param) => !!param);
|
|
342
|
-
function computeRules(rules2, value, ...
|
|
349
|
+
function computeRules(rules2, value, ...params) {
|
|
343
350
|
const $rules = [];
|
|
344
351
|
let paramIndex = 0;
|
|
345
352
|
for (let rule of rules2) {
|
|
@@ -348,7 +355,7 @@ function or(...rules) {
|
|
|
348
355
|
paramIndex++;
|
|
349
356
|
} else {
|
|
350
357
|
const paramsLength = rule._params?.length ?? 0;
|
|
351
|
-
$rules.push(rule.validator(value, ...
|
|
358
|
+
$rules.push(rule.validator(value, ...params.slice(paramIndex, paramsLength)));
|
|
352
359
|
if (paramsLength) {
|
|
353
360
|
paramIndex += paramsLength;
|
|
354
361
|
}
|
|
@@ -378,11 +385,11 @@ function or(...rules) {
|
|
|
378
385
|
return results.some((result) => !!result);
|
|
379
386
|
}
|
|
380
387
|
}
|
|
381
|
-
const validator = isAnyRuleAsync ? async (value, ...
|
|
382
|
-
const results = await Promise.all(computeRules(rules, value, ...
|
|
388
|
+
const validator = isAnyRuleAsync ? async (value, ...params) => {
|
|
389
|
+
const results = await Promise.all(computeRules(rules, value, ...params));
|
|
383
390
|
return computeMetadata(results);
|
|
384
|
-
} : (value, ...
|
|
385
|
-
const $rules = computeRules(rules, value, ...
|
|
391
|
+
} : (value, ...params) => {
|
|
392
|
+
const $rules = computeRules(rules, value, ...params);
|
|
386
393
|
return computeMetadata($rules);
|
|
387
394
|
};
|
|
388
395
|
const newRule = core.createRule({
|
|
@@ -390,8 +397,15 @@ function or(...rules) {
|
|
|
390
397
|
validator,
|
|
391
398
|
message: "The value does not match any of the provided validators"
|
|
392
399
|
});
|
|
393
|
-
|
|
394
|
-
|
|
400
|
+
const newParams = [..._params ?? []];
|
|
401
|
+
newRule._params = newParams;
|
|
402
|
+
if (typeof newRule === "function") {
|
|
403
|
+
const executedRule = newRule(...newParams);
|
|
404
|
+
executedRule._message_patched = true;
|
|
405
|
+
return executedRule;
|
|
406
|
+
} else {
|
|
407
|
+
return newRule;
|
|
408
|
+
}
|
|
395
409
|
}
|
|
396
410
|
function not(rule, message) {
|
|
397
411
|
let _type;
|
|
@@ -427,8 +441,15 @@ function not(rule, message) {
|
|
|
427
441
|
validator: newValidator,
|
|
428
442
|
message: message ?? "Error"
|
|
429
443
|
});
|
|
430
|
-
|
|
431
|
-
|
|
444
|
+
const newParams = [..._params ?? []];
|
|
445
|
+
newRule._params = newParams;
|
|
446
|
+
if (typeof newRule === "function") {
|
|
447
|
+
const executedRule = newRule(...newParams);
|
|
448
|
+
executedRule._message_patched = true;
|
|
449
|
+
return executedRule;
|
|
450
|
+
} else {
|
|
451
|
+
return newRule;
|
|
452
|
+
}
|
|
432
453
|
}
|
|
433
454
|
var required = core.createRule({
|
|
434
455
|
type: "required",
|
package/dist/regle-rules.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var core=require('@regle/core'),vue=require('vue');function $(e,t){let i,o,u,m;typeof e=="function"&&!("_validator"in e)?(i=core.InternalRuleType.Inline,o=e):{_type:i,validator:o,_active:u,_params:m}=e;let f=core.createRule({type:i,validator:o,active:u,message:t}),r=[...m??[]];if(f._params=r,f._message_patched=!0,typeof f=="function"){let s=f(...r);return s._message_patched=!0,s}else return f}function W(e,t){let i,o,u,m,f;typeof e=="function"&&!("_validator"in e)?(i=core.InternalRuleType.Inline,o=e):{_type:i,validator:o,_active:u,_params:m,_message:f}=e;let r=core.createRule({type:i,validator:o,active:u,message:f,tooltip:t}),s=[...m??[]];if(r._params=s,r._tooltip_patched=!0,typeof r=="function"){let n=r(...s);return r._tooltip_patched=!0,n}else return r}function N(e,t){let i=async(u,...m)=>e(u,...m),o=core.createRule({type:core.InternalRuleType.Async,validator:i,message:""});return o._params=o._params?.concat(t),o(...t??[])}function E(e,t){let i=(u,...m)=>e(u,...m),o=core.createRule({type:core.InternalRuleType.Inline,validator:i,message:""});return o._params=o._params?.concat(t),o(...t)}function S(e,t){let i,o,u=[],m="";typeof t=="function"?(i=core.InternalRuleType.Inline,o=t,u=[e]):({_type:i,validator:o,_message:m}=t,u=t._params?.concat([e]));function f(R,...c){let[g]=core.unwrapRuleParameters([e]);return g?o(R,...c):!0}function r(R){let[c]=core.unwrapRuleParameters([e]);return c}let s=core.createRule({type:i,validator:f,active:r,message:m}),n=[...u??[]];if(s._params=n,typeof s=="function"){let R=s(...n);return R._message_patched=!0,R}else return s}function l(e){return e==null?!0:e instanceof Date?isNaN(e.getTime()):Array.isArray(e)?!1:typeof e=="object"&&e!=null?Object.keys(e).length===0:!String(e).length}function a(e){return !l(typeof e=="string"?e.trim():e)}function p(e){return e==null||typeof e!="number"?!1:!isNaN(e)}function y(e,...t){if(l(e))return !0;let i=typeof e=="number"?e.toString():e;return t.every(o=>(o.lastIndex=0,o.test(i)))}function b(e){let t=vue.unref(e);return Array.isArray(t)?t.length:typeof t=="object"?Object.keys(t).length:typeof t=="number"?isNaN(t)?0:t:String(t).length}function x(e){if(l(e))return !1;try{let t=null;if(e instanceof Date)t=e;else if(typeof e=="number"&&!isNaN(e))t=new Date(e);else if(typeof e=="string"){let i=new Date(e);if(i.toString()==="Invalid Date")return !1;t=i;}return !!t}catch{return !1}}function T(e){let t=Object.prototype.toString.call(e);return e==null?new Date(NaN):e instanceof Date||typeof e=="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function d(e){return typeof e=="number"?e:e!=null?typeof e=="string"?e.trim()!==e?NaN:+e:NaN:NaN}function U(...e){let t=e.some(r=>typeof r=="function"?r.constructor.name==="AsyncFunction":r._async),i=e.map(r=>{if(typeof r=="function")return null;{let s=r._params;return s?.length?s:[null]}}).flat().filter(r=>!!r);function o(r,s,...n){let R=[],c=0;for(let g of r)if(typeof g=="function")R.push(g(s)),c++;else {let D=g._params?.length??0;R.push(g.validator(s,...n.slice(c,D))),D&&(c+=D);}return R}function u(r){return r?.some(n=>typeof n!="boolean")?{$valid:r.every(n=>typeof n=="boolean"?!!n:n.$valid),...r.reduce((n,R)=>{if(typeof R=="boolean")return n;let{$valid:c,...g}=R;return {...n,...g}},{})}:r.every(n=>!!n)}let m;e.length?m=t?async(r,...s)=>{let n=await Promise.all(o(e,r,...s));return u(n)}:(r,...s)=>{let n=o(e,r,...s);return u(n)}:m=r=>!1;let f=core.createRule({type:"and",validator:m,message:"The value does not match all of the provided validators"});return f._params=i,f}function G(...e){let t=e.some(r=>typeof r=="function"?r.constructor.name==="AsyncFunction":r._async),i=e.map(r=>typeof r=="function"?null:r._params).flat().filter(r=>!!r);function o(r,s,...n){let R=[],c=0;for(let g of r)if(typeof g=="function")R.push(g(s)),c++;else {let D=g._params?.length??0;R.push(g.validator(s,...n.slice(c,D))),D&&(c+=D);}return R}function u(r){return r.some(n=>typeof n!="boolean")?{$valid:r.some(n=>typeof n=="boolean"?!!n:n.$valid),...r.reduce((n,R)=>{if(typeof R=="boolean")return n;let{$valid:c,...g}=R;return {...n,...g}},{})}:r.some(n=>!!n)}let f=core.createRule({type:"or",validator:t?async(r,...s)=>{let n=await Promise.all(o(e,r,...s));return u(n)}:(r,...s)=>{let n=o(e,r,...s);return u(n)},message:"The value does not match any of the provided validators"});return f._params=i,f}function K(e,t){let i,o,u,m,f;typeof e=="function"?(o=e,f=e.constructor.name==="AsyncFunction"):({_type:i,validator:o,_params:m}=e,f=e._async),f?u=async(s,...n)=>a(s)?!await o(s,...n):!0:u=(s,...n)=>a(s)?!o(s,...n):!0;let r=core.createRule({type:"not",validator:u,message:t??"Error"});return r._params=m,r}var kt=core.createRule({type:"required",validator:e=>a(e),message:"This field is required"});var Lt=core.createRule({type:"maxLength",validator:(e,t)=>a(e)&&a(t)?p(t)?b(e)<=t:(console.warn(`[maxLength] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),!1):!0,message:({$value:e,$params:[t]})=>Array.isArray(e)?`This list should have maximum ${t} items`:`The maximum length allowed is ${t}`});var Ot=core.createRule({type:"required",validator(e,t){return t?a(e):!0},message:"This field is required",active({$params:[e]}){return e}});var J=/^[a-zA-Z]*$/,Zt=core.createRule({type:"alpha",validator(e){return l(e)?!0:y(e,J)},message:"The value is not alphabetical"});var X=/^[a-zA-Z0-9]*$/,Xt=core.createRule({type:"alpha",validator(e){return l(e)?!0:y(e,X)},message:"The value must be alpha-numeric"});var rr=core.createRule({type:"between",validator:(e,t,i)=>{if(a(e)&&a(t)&&a(i)){let o=d(e),u=d(t),m=d(i);return p(o)&&p(u)&&p(m)?o>=u&&o<=m:(console.warn(`[between] Value or parameters aren't numbers, got value: ${e}, min: ${t}, max: ${i}`),!1)}return !0},message:({$params:[e,t]})=>`The value must be between ${e} and ${t}`});var te=/^[-]?\d*(\.\d+)?$/,or=core.createRule({type:"decimal",validator(e){return l(e)?!0:y(e,te)},message:"Value must be decimal"});var ae=/^(?:[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,mr=core.createRule({type:"email",validator(e){return l(e)?!0:y(e,ae)},message:"Value must be an valid email address"});var ie=/(^[0-9]*$)|(^-[0-9]+$)/,yr=core.createRule({type:"integer",validator(e){return l(e)?!0:y(e,ie)},message:"Value must be an integer"});var Tr=core.createRule({type:"maxValue",validator:(e,t)=>a(e)&&a(t)?p(t)&&!isNaN(d(e))?d(e)<=t:(console.warn(`[maxValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),!0):!0,message:({$params:[e]})=>`The maximum value allowed is ${e}`});var Mr=core.createRule({type:"minLength",validator:(e,t)=>a(e)&&a(t)?p(t)?b(e)>=t:(console.warn(`[minLength] Parameter isn't a number, got parameter: ${t}`),!1):!0,message:({$value:e,$params:[t]})=>Array.isArray(e)?`This list should have at least ${t} items`:`This field should be at least ${t} characters long`});var $r=core.createRule({type:"minValue",validator:(e,t)=>a(e)&&a(t)?p(t)&&!isNaN(d(e))?d(e)>=t:(console.warn(`[minValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),!0):!0,message:({$params:[e]})=>`The minimum value allowed is ${e}`});var vr=core.createRule({type:"exactValue",validator:(e,t)=>a(e)&&a(t)?p(t)&&!isNaN(d(e))?d(e)===t:(console.warn(`[exactValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),!0):!0,message:({$params:[e]})=>`The value must be equal to ${e}`});var Ir=core.createRule({type:"exactLength",validator:(e,t)=>a(e)&&a(t)?p(t)?b(e)===t:(console.warn(`[minLength] Parameter isn't a number, got parameter: ${t}`),!1):!0,message:({$params:[e]})=>`This field should be exactly ${e} characters long`});var Re=/^\d*(\.\d+)?$/,Sr=core.createRule({type:"numeric",validator(e){return l(e)?!0:y(e,Re)},message:"This field must be numeric"});var qr=core.createRule({type:"required",validator(e,t){return t?!0:a(e)},message:"This field is required",active({$params:[e]}){return !e}});var jr=core.createRule({type:"sameAs",validator(e,t,i="other"){return l(e)?!0:e===t},message({$params:[e,t]}){return `Value must be equal to the ${t} value`}});var de=/^(?:(?:(?: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,Jr=core.createRule({type:"url",validator(e){return l(e)?!0:y(e,de)},message:"The value is not a valid URL address"});function ce(){return navigator.languages!=null?navigator.languages[0]:navigator.language}function M(e){return e?new Intl.DateTimeFormat(ce(),{dateStyle:"short"}).format(new Date(e)):"?"}var ra=core.createRule({type:"dateAfter",validator:(e,t)=>a(e)&&a(t)?x(e)&&x(t)?T(e).getTime()>T(t).getTime()?!0:{$valid:!1,error:"date-not-after"}:{$valid:!1,error:"value-or-paramater-not-a-date"}:!0,message:({$params:[e],error:t})=>t==="value-or-paramater-not-a-date"?"The inputs must be Dates":`The date must be after ${M(e)}`});var sa=core.createRule({type:"dateBefore",validator:(e,t)=>a(e)&&a(t)?x(e)&&x(t)?T(e).getTime()<T(t).getTime()?!0:{$valid:!1,error:"date-not-before"}:{$valid:!1,error:"value-or-paramater-not-a-date"}:!0,message:({$params:[e],error:t})=>t==="value-or-paramater-not-a-date"?"The fields must be Dates":`The date must be before ${M(e)}`});var Ra=core.createRule({type:"dateBetween",validator:(e,t,i)=>x(e)&&x(t)&&x(i)?T(e).getTime()>T(t).getTime()&&T(e).getTime()<T(i).getTime():!0,message:({$params:[e,t]})=>`The date must be between ${M(e)} and ${M(t)}`});function Me(e){if(e.length>3||e.length===0||e[0]==="0"&&e!=="0"||!e.match(/^\d+$/))return !1;let t=+e|0;return t>=0&&t<=255}var da=core.createRule({type:"ipAddress",validator(e){if(l(e))return !0;if(typeof e!="string")return !1;let t=e.split(".");return t.length===4&&t.every(Me)},message:"The value is not a valid IP address"});var ba=core.createRule({type:"macAddress",validator(e,t=":"){if(l(e))return !0;if(typeof e!="string")return !1;let i=typeof t=="string"&&t!==""?e.split(t):e.length===12||e.length===16?e.match(/.{2}/g):null;return i!==null&&(i.length===6||i.length===8)&&i.every(Pe)},message:"The value is not a valid MAC Address"}),Pe=e=>e.toLowerCase().match(/^[0-9a-f]{2}$/);var Pa=core.createRule({type:"checked",validator:e=>a(e)?e===!0:!0,message:"This field must be checked"});var Aa=core.createRule({type:"contains",validator(e,t){return a(e)&&a(t)?e.includes(t):!0},message({$params:[e]}){return `Field must contain ${e}`}});var Na=core.createRule({type:"startsWith",validator(e,t){return a(e)&&a(t)?e.startsWith(t):!0},message({$params:[e]}){return `Field must end with ${e}`}});var ka=core.createRule({type:"endsWith",validator(e,t){return a(e)&&a(t)?e.endsWith(t):!0},message({$params:[e]}){return `Field must end with ${e}`}});var La=core.createRule({type:"regex",validator(e,...t){return a(e)?y(e,...t):!0},message:"This field does not match the required pattern"});exports.alpha=Zt;exports.alphaNum=Xt;exports.and=U;exports.applyIf=S;exports.between=rr;exports.checked=Pa;exports.contains=Aa;exports.dateAfter=ra;exports.dateBefore=sa;exports.dateBetween=Ra;exports.decimal=or;exports.email=mr;exports.endsWith=ka;exports.exactLength=Ir;exports.exactValue=vr;exports.getSize=b;exports.integer=yr;exports.ipAddress=da;exports.isDate=x;exports.isEmpty=l;exports.isFilled=a;exports.isNumber=p;exports.macAddress=ba;exports.matchRegex=y;exports.maxLength=Lt;exports.maxValue=Tr;exports.minLength=Mr;exports.minValue=$r;exports.not=K;exports.numeric=Sr;exports.or=G;exports.regex=La;exports.required=kt;exports.requiredIf=Ot;exports.requiredUnless=qr;exports.sameAs=jr;exports.startsWith=Na;exports.toDate=T;exports.toNumber=d;exports.url=Jr;exports.withAsync=N;exports.withMessage=$;exports.withParams=E;exports.withTooltip=W;
|
|
1
|
+
'use strict';var core=require('@regle/core'),vue=require('vue');function V(e,t){let i,o,u,f;typeof e=="function"&&!("_validator"in e)?(i=core.InternalRuleType.Inline,o=e):{_type:i,validator:o,_active:u,_params:f}=e;let m=core.createRule({type:i,validator:o,active:u,message:t}),R=[...f??[]];if(m._params=R,m._message_patched=!0,typeof m=="function"){let r=m(...R);return r._message_patched=!0,r}else return m}function v(e,t){let i,o,u,f,m;typeof e=="function"&&!("_validator"in e)?(i=core.InternalRuleType.Inline,o=e):{_type:i,validator:o,_active:u,_params:f,_message:m}=e;let R=core.createRule({type:i,validator:o,active:u,message:m,tooltip:t}),r=[...f??[]];if(R._params=r,R._tooltip_patched=!0,typeof R=="function"){let s=R(...r);return R._tooltip_patched=!0,s}else return R}function N(e,t){let i=async(u,...f)=>e(u,...f),o=core.createRule({type:core.InternalRuleType.Async,validator:i,message:""});return o._params=o._params?.concat(t),o(...t??[])}function k(e,t){let i=(u,...f)=>e(u,...f),o=core.createRule({type:core.InternalRuleType.Inline,validator:i,message:""});return o._params=o._params?.concat(t),o(...t)}function C(e,t){let i,o,u=[],f="";typeof t=="function"?(i=core.InternalRuleType.Inline,o=t,u=[e]):({_type:i,validator:o,_message:f}=t,u=t._params?.concat([e]));function m(n,...p){let[b]=core.unwrapRuleParameters([e]);return b?o(n,...p):!0}function R(n){let[p]=core.unwrapRuleParameters([e]);return p}let r=core.createRule({type:i,validator:m,active:R,message:f}),s=[...u??[]];if(r._params=s,typeof r=="function"){let n=r(...s);return n._message_patched=!0,n}else return r}function l(e){return e==null?!0:e instanceof Date?isNaN(e.getTime()):Array.isArray(e)?!1:typeof e=="object"&&e!=null?Object.keys(e).length===0:!String(e).length}function a(e){return !l(typeof e=="string"?e.trim():e)}function y(e){return e==null||typeof e!="number"?!1:!isNaN(e)}function g(e,...t){if(l(e))return !0;let i=typeof e=="number"?e.toString():e;return t.every(o=>(o.lastIndex=0,o.test(i)))}function D(e){let t=vue.unref(e);return Array.isArray(t)?t.length:typeof t=="object"?Object.keys(t).length:typeof t=="number"?isNaN(t)?0:t:String(t).length}function x(e){if(l(e))return !1;try{let t=null;if(e instanceof Date)t=e;else if(typeof e=="number"&&!isNaN(e))t=new Date(e);else if(typeof e=="string"){let i=new Date(e);if(i.toString()==="Invalid Date")return !1;t=i;}return !!t}catch{return !1}}function T(e){let t=Object.prototype.toString.call(e);return e==null?new Date(NaN):e instanceof Date||typeof e=="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function d(e){return typeof e=="number"?e:e!=null?typeof e=="string"?e.trim()!==e?NaN:+e:NaN:NaN}function q(...e){let t=e.some(r=>typeof r=="function"?r.constructor.name==="AsyncFunction":r._async),i=e.map(r=>{if(typeof r=="function")return null;{let s=r._params;return s?.length?s:[]}}).flat().filter(r=>!!r);function o(r,s,...n){let p=[],b=0;for(let c of r)if(typeof c=="function")p.push(c(s)),b++;else {let M=c._params?.length??0;p.push(c.validator(s,...n.slice(b,M))),M&&(b+=M);}return p}function u(r){return r?.some(n=>typeof n!="boolean")?{$valid:r.every(n=>typeof n=="boolean"?!!n:n.$valid),...r.reduce((n,p)=>{if(typeof p=="boolean")return n;let{$valid:b,...c}=p;return {...n,...c}},{})}:r.every(n=>!!n)}let f;e.length?f=t?async(r,...s)=>{let n=await Promise.all(o(e,r,...s));return u(n)}:(r,...s)=>{let n=o(e,r,...s);return u(n)}:f=r=>!1;let m=core.createRule({type:"and",validator:f,message:"The value does not match all of the provided validators"}),R=[...i??[]];if(m._params=R,typeof m=="function"){let r=m(...R);return r._message_patched=!0,r}else return m}function O(...e){let t=e.some(r=>typeof r=="function"?r.constructor.name==="AsyncFunction":r._async),i=e.map(r=>typeof r=="function"?null:r._params).flat().filter(r=>!!r);function o(r,s,...n){let p=[],b=0;for(let c of r)if(typeof c=="function")p.push(c(s)),b++;else {let M=c._params?.length??0;p.push(c.validator(s,...n.slice(b,M))),M&&(b+=M);}return p}function u(r){return r.some(n=>typeof n!="boolean")?{$valid:r.some(n=>typeof n=="boolean"?!!n:n.$valid),...r.reduce((n,p)=>{if(typeof p=="boolean")return n;let{$valid:b,...c}=p;return {...n,...c}},{})}:r.some(n=>!!n)}let m=core.createRule({type:"or",validator:t?async(r,...s)=>{let n=await Promise.all(o(e,r,...s));return u(n)}:(r,...s)=>{let n=o(e,r,...s);return u(n)},message:"The value does not match any of the provided validators"}),R=[...i??[]];if(m._params=R,typeof m=="function"){let r=m(...R);return r._message_patched=!0,r}else return m}function j(e,t){let i,o,u,f,m;typeof e=="function"?(o=e,m=e.constructor.name==="AsyncFunction"):({_type:i,validator:o,_params:f}=e,m=e._async),m?u=async(s,...n)=>a(s)?!await o(s,...n):!0:u=(s,...n)=>a(s)?!o(s,...n):!0;let R=core.createRule({type:"not",validator:u,message:t??"Error"}),r=[...f??[]];if(R._params=r,typeof R=="function"){let s=R(...r);return s._message_patched=!0,s}else return R}var zt=core.createRule({type:"required",validator:e=>a(e),message:"This field is required"});var Ut=core.createRule({type:"maxLength",validator:(e,t)=>a(e)&&a(t)?y(t)?D(e)<=t:(console.warn(`[maxLength] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),!1):!0,message:({$value:e,$params:[t]})=>Array.isArray(e)?`This list should have maximum ${t} items`:`The maximum length allowed is ${t}`});var Kt=core.createRule({type:"required",validator(e,t){return t?a(e):!0},message:"This field is required",active({$params:[e]}){return e}});var Q=/^[a-zA-Z]*$/,Ht=core.createRule({type:"alpha",validator(e){return l(e)?!0:g(e,Q)},message:"The value is not alphabetical"});var Y=/^[a-zA-Z0-9]*$/,Yt=core.createRule({type:"alpha",validator(e){return l(e)?!0:g(e,Y)},message:"The value must be alpha-numeric"});var ar=core.createRule({type:"between",validator:(e,t,i)=>{if(a(e)&&a(t)&&a(i)){let o=d(e),u=d(t),f=d(i);return y(o)&&y(u)&&y(f)?o>=u&&o<=f:(console.warn(`[between] Value or parameters aren't numbers, got value: ${e}, min: ${t}, max: ${i}`),!1)}return !0},message:({$params:[e,t]})=>`The value must be between ${e} and ${t}`});var re=/^[-]?\d*(\.\d+)?$/,sr=core.createRule({type:"decimal",validator(e){return l(e)?!0:g(e,re)},message:"Value must be decimal"});var ne=/^(?:[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,fr=core.createRule({type:"email",validator(e){return l(e)?!0:g(e,ne)},message:"Value must be an valid email address"});var oe=/(^[0-9]*$)|(^-[0-9]+$)/,gr=core.createRule({type:"integer",validator(e){return l(e)?!0:g(e,oe)},message:"Value must be an integer"});var xr=core.createRule({type:"maxValue",validator:(e,t)=>a(e)&&a(t)?y(t)&&!isNaN(d(e))?d(e)<=t:(console.warn(`[maxValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),!0):!0,message:({$params:[e]})=>`The maximum value allowed is ${e}`});var hr=core.createRule({type:"minLength",validator:(e,t)=>a(e)&&a(t)?y(t)?D(e)>=t:(console.warn(`[minLength] Parameter isn't a number, got parameter: ${t}`),!1):!0,message:({$value:e,$params:[t]})=>Array.isArray(e)?`This list should have at least ${t} items`:`This field should be at least ${t} characters long`});var Vr=core.createRule({type:"minValue",validator:(e,t)=>a(e)&&a(t)?y(t)&&!isNaN(d(e))?d(e)>=t:(console.warn(`[minValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),!0):!0,message:({$params:[e]})=>`The minimum value allowed is ${e}`});var _r=core.createRule({type:"exactValue",validator:(e,t)=>a(e)&&a(t)?y(t)&&!isNaN(d(e))?d(e)===t:(console.warn(`[exactValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),!0):!0,message:({$params:[e]})=>`The value must be equal to ${e}`});var Er=core.createRule({type:"exactLength",validator:(e,t)=>a(e)&&a(t)?y(t)?D(e)===t:(console.warn(`[minLength] Parameter isn't a number, got parameter: ${t}`),!1):!0,message:({$params:[e]})=>`This field should be exactly ${e} characters long`});var pe=/^\d*(\.\d+)?$/,Cr=core.createRule({type:"numeric",validator(e){return l(e)?!0:g(e,pe)},message:"This field must be numeric"});var Gr=core.createRule({type:"required",validator(e,t){return t?!0:a(e)},message:"This field is required",active({$params:[e]}){return !e}});var Br=core.createRule({type:"sameAs",validator(e,t,i="other"){return l(e)?!0:e===t},message({$params:[e,t]}){return `Value must be equal to the ${t} value`}});var ce=/^(?:(?:(?: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,Qr=core.createRule({type:"url",validator(e){return l(e)?!0:g(e,ce)},message:"The value is not a valid URL address"});function Te(){return navigator.languages!=null?navigator.languages[0]:navigator.language}function h(e){return e?new Intl.DateTimeFormat(Te(),{dateStyle:"short"}).format(new Date(e)):"?"}var aa=core.createRule({type:"dateAfter",validator:(e,t)=>a(e)&&a(t)?x(e)&&x(t)?T(e).getTime()>T(t).getTime()?!0:{$valid:!1,error:"date-not-after"}:{$valid:!1,error:"value-or-paramater-not-a-date"}:!0,message:({$params:[e],error:t})=>t==="value-or-paramater-not-a-date"?"The inputs must be Dates":`The date must be after ${h(e)}`});var la=core.createRule({type:"dateBefore",validator:(e,t)=>a(e)&&a(t)?x(e)&&x(t)?T(e).getTime()<T(t).getTime()?!0:{$valid:!1,error:"date-not-before"}:{$valid:!1,error:"value-or-paramater-not-a-date"}:!0,message:({$params:[e],error:t})=>t==="value-or-paramater-not-a-date"?"The fields must be Dates":`The date must be before ${h(e)}`});var pa=core.createRule({type:"dateBetween",validator:(e,t,i)=>x(e)&&x(t)&&x(i)?T(e).getTime()>T(t).getTime()&&T(e).getTime()<T(i).getTime():!0,message:({$params:[e,t]})=>`The date must be between ${h(e)} and ${h(t)}`});function he(e){if(e.length>3||e.length===0||e[0]==="0"&&e!=="0"||!e.match(/^\d+$/))return !1;let t=+e|0;return t>=0&&t<=255}var ca=core.createRule({type:"ipAddress",validator(e){if(l(e))return !0;if(typeof e!="string")return !1;let t=e.split(".");return t.length===4&&t.every(he)},message:"The value is not a valid IP address"});var Da=core.createRule({type:"macAddress",validator(e,t=":"){if(l(e))return !0;if(typeof e!="string")return !1;let i=typeof t=="string"&&t!==""?e.split(t):e.length===12||e.length===16?e.match(/.{2}/g):null;return i!==null&&(i.length===6||i.length===8)&&i.every(we)},message:"The value is not a valid MAC Address"}),we=e=>e.toLowerCase().match(/^[0-9a-f]{2}$/);var wa=core.createRule({type:"checked",validator:e=>a(e)?e===!0:!0,message:"This field must be checked"});var Wa=core.createRule({type:"contains",validator(e,t){return a(e)&&a(t)?e.includes(t):!0},message({$params:[e]}){return `Field must contain ${e}`}});var Na=core.createRule({type:"startsWith",validator(e,t){return a(e)&&a(t)?e.startsWith(t):!0},message({$params:[e]}){return `Field must end with ${e}`}});var za=core.createRule({type:"endsWith",validator(e,t){return a(e)&&a(t)?e.endsWith(t):!0},message({$params:[e]}){return `Field must end with ${e}`}});var Ua=core.createRule({type:"regex",validator(e,...t){return a(e)?g(e,...t):!0},message:"This field does not match the required pattern"});exports.alpha=Ht;exports.alphaNum=Yt;exports.and=q;exports.applyIf=C;exports.between=ar;exports.checked=wa;exports.contains=Wa;exports.dateAfter=aa;exports.dateBefore=la;exports.dateBetween=pa;exports.decimal=sr;exports.email=fr;exports.endsWith=za;exports.exactLength=Er;exports.exactValue=_r;exports.getSize=D;exports.integer=gr;exports.ipAddress=ca;exports.isDate=x;exports.isEmpty=l;exports.isFilled=a;exports.isNumber=y;exports.macAddress=Da;exports.matchRegex=g;exports.maxLength=Ut;exports.maxValue=xr;exports.minLength=hr;exports.minValue=Vr;exports.not=j;exports.numeric=Cr;exports.or=O;exports.regex=Ua;exports.required=zt;exports.requiredIf=Kt;exports.requiredUnless=Gr;exports.sameAs=Br;exports.startsWith=Na;exports.toDate=T;exports.toNumber=d;exports.url=Qr;exports.withAsync=N;exports.withMessage=V;exports.withParams=k;exports.withTooltip=v;
|
package/dist/regle-rules.min.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {createRule,InternalRuleType,unwrapRuleParameters}from'@regle/core';import {unref}from'vue';function $(e,t){let i,o,u,m;typeof e=="function"&&!("_validator"in e)?(i=InternalRuleType.Inline,o=e):{_type:i,validator:o,_active:u,_params:m}=e;let f=createRule({type:i,validator:o,active:u,message:t}),r=[...m??[]];if(f._params=r,f._message_patched=!0,typeof f=="function"){let s=f(...r);return s._message_patched=!0,s}else return f}function W(e,t){let i,o,u,m,f;typeof e=="function"&&!("_validator"in e)?(i=InternalRuleType.Inline,o=e):{_type:i,validator:o,_active:u,_params:m,_message:f}=e;let r=createRule({type:i,validator:o,active:u,message:f,tooltip:t}),s=[...m??[]];if(r._params=s,r._tooltip_patched=!0,typeof r=="function"){let n=r(...s);return r._tooltip_patched=!0,n}else return r}function N(e,t){let i=async(u,...m)=>e(u,...m),o=createRule({type:InternalRuleType.Async,validator:i,message:""});return o._params=o._params?.concat(t),o(...t??[])}function E(e,t){let i=(u,...m)=>e(u,...m),o=createRule({type:InternalRuleType.Inline,validator:i,message:""});return o._params=o._params?.concat(t),o(...t)}function S(e,t){let i,o,u=[],m="";typeof t=="function"?(i=InternalRuleType.Inline,o=t,u=[e]):({_type:i,validator:o,_message:m}=t,u=t._params?.concat([e]));function f(R,...c){let[g]=unwrapRuleParameters([e]);return g?o(R,...c):!0}function r(R){let[c]=unwrapRuleParameters([e]);return c}let s=createRule({type:i,validator:f,active:r,message:m}),n=[...u??[]];if(s._params=n,typeof s=="function"){let R=s(...n);return R._message_patched=!0,R}else return s}function l(e){return e==null?!0:e instanceof Date?isNaN(e.getTime()):Array.isArray(e)?!1:typeof e=="object"&&e!=null?Object.keys(e).length===0:!String(e).length}function a(e){return !l(typeof e=="string"?e.trim():e)}function p(e){return e==null||typeof e!="number"?!1:!isNaN(e)}function y(e,...t){if(l(e))return !0;let i=typeof e=="number"?e.toString():e;return t.every(o=>(o.lastIndex=0,o.test(i)))}function b(e){let t=unref(e);return Array.isArray(t)?t.length:typeof t=="object"?Object.keys(t).length:typeof t=="number"?isNaN(t)?0:t:String(t).length}function x(e){if(l(e))return !1;try{let t=null;if(e instanceof Date)t=e;else if(typeof e=="number"&&!isNaN(e))t=new Date(e);else if(typeof e=="string"){let i=new Date(e);if(i.toString()==="Invalid Date")return !1;t=i;}return !!t}catch{return !1}}function T(e){let t=Object.prototype.toString.call(e);return e==null?new Date(NaN):e instanceof Date||typeof e=="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function d(e){return typeof e=="number"?e:e!=null?typeof e=="string"?e.trim()!==e?NaN:+e:NaN:NaN}function U(...e){let t=e.some(r=>typeof r=="function"?r.constructor.name==="AsyncFunction":r._async),i=e.map(r=>{if(typeof r=="function")return null;{let s=r._params;return s?.length?s:[null]}}).flat().filter(r=>!!r);function o(r,s,...n){let R=[],c=0;for(let g of r)if(typeof g=="function")R.push(g(s)),c++;else {let D=g._params?.length??0;R.push(g.validator(s,...n.slice(c,D))),D&&(c+=D);}return R}function u(r){return r?.some(n=>typeof n!="boolean")?{$valid:r.every(n=>typeof n=="boolean"?!!n:n.$valid),...r.reduce((n,R)=>{if(typeof R=="boolean")return n;let{$valid:c,...g}=R;return {...n,...g}},{})}:r.every(n=>!!n)}let m;e.length?m=t?async(r,...s)=>{let n=await Promise.all(o(e,r,...s));return u(n)}:(r,...s)=>{let n=o(e,r,...s);return u(n)}:m=r=>!1;let f=createRule({type:"and",validator:m,message:"The value does not match all of the provided validators"});return f._params=i,f}function G(...e){let t=e.some(r=>typeof r=="function"?r.constructor.name==="AsyncFunction":r._async),i=e.map(r=>typeof r=="function"?null:r._params).flat().filter(r=>!!r);function o(r,s,...n){let R=[],c=0;for(let g of r)if(typeof g=="function")R.push(g(s)),c++;else {let D=g._params?.length??0;R.push(g.validator(s,...n.slice(c,D))),D&&(c+=D);}return R}function u(r){return r.some(n=>typeof n!="boolean")?{$valid:r.some(n=>typeof n=="boolean"?!!n:n.$valid),...r.reduce((n,R)=>{if(typeof R=="boolean")return n;let{$valid:c,...g}=R;return {...n,...g}},{})}:r.some(n=>!!n)}let f=createRule({type:"or",validator:t?async(r,...s)=>{let n=await Promise.all(o(e,r,...s));return u(n)}:(r,...s)=>{let n=o(e,r,...s);return u(n)},message:"The value does not match any of the provided validators"});return f._params=i,f}function K(e,t){let i,o,u,m,f;typeof e=="function"?(o=e,f=e.constructor.name==="AsyncFunction"):({_type:i,validator:o,_params:m}=e,f=e._async),f?u=async(s,...n)=>a(s)?!await o(s,...n):!0:u=(s,...n)=>a(s)?!o(s,...n):!0;let r=createRule({type:"not",validator:u,message:t??"Error"});return r._params=m,r}var kt=createRule({type:"required",validator:e=>a(e),message:"This field is required"});var Lt=createRule({type:"maxLength",validator:(e,t)=>a(e)&&a(t)?p(t)?b(e)<=t:(console.warn(`[maxLength] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),!1):!0,message:({$value:e,$params:[t]})=>Array.isArray(e)?`This list should have maximum ${t} items`:`The maximum length allowed is ${t}`});var Ot=createRule({type:"required",validator(e,t){return t?a(e):!0},message:"This field is required",active({$params:[e]}){return e}});var J=/^[a-zA-Z]*$/,Zt=createRule({type:"alpha",validator(e){return l(e)?!0:y(e,J)},message:"The value is not alphabetical"});var X=/^[a-zA-Z0-9]*$/,Xt=createRule({type:"alpha",validator(e){return l(e)?!0:y(e,X)},message:"The value must be alpha-numeric"});var rr=createRule({type:"between",validator:(e,t,i)=>{if(a(e)&&a(t)&&a(i)){let o=d(e),u=d(t),m=d(i);return p(o)&&p(u)&&p(m)?o>=u&&o<=m:(console.warn(`[between] Value or parameters aren't numbers, got value: ${e}, min: ${t}, max: ${i}`),!1)}return !0},message:({$params:[e,t]})=>`The value must be between ${e} and ${t}`});var te=/^[-]?\d*(\.\d+)?$/,or=createRule({type:"decimal",validator(e){return l(e)?!0:y(e,te)},message:"Value must be decimal"});var ae=/^(?:[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,mr=createRule({type:"email",validator(e){return l(e)?!0:y(e,ae)},message:"Value must be an valid email address"});var ie=/(^[0-9]*$)|(^-[0-9]+$)/,yr=createRule({type:"integer",validator(e){return l(e)?!0:y(e,ie)},message:"Value must be an integer"});var Tr=createRule({type:"maxValue",validator:(e,t)=>a(e)&&a(t)?p(t)&&!isNaN(d(e))?d(e)<=t:(console.warn(`[maxValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),!0):!0,message:({$params:[e]})=>`The maximum value allowed is ${e}`});var Mr=createRule({type:"minLength",validator:(e,t)=>a(e)&&a(t)?p(t)?b(e)>=t:(console.warn(`[minLength] Parameter isn't a number, got parameter: ${t}`),!1):!0,message:({$value:e,$params:[t]})=>Array.isArray(e)?`This list should have at least ${t} items`:`This field should be at least ${t} characters long`});var $r=createRule({type:"minValue",validator:(e,t)=>a(e)&&a(t)?p(t)&&!isNaN(d(e))?d(e)>=t:(console.warn(`[minValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),!0):!0,message:({$params:[e]})=>`The minimum value allowed is ${e}`});var vr=createRule({type:"exactValue",validator:(e,t)=>a(e)&&a(t)?p(t)&&!isNaN(d(e))?d(e)===t:(console.warn(`[exactValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),!0):!0,message:({$params:[e]})=>`The value must be equal to ${e}`});var Ir=createRule({type:"exactLength",validator:(e,t)=>a(e)&&a(t)?p(t)?b(e)===t:(console.warn(`[minLength] Parameter isn't a number, got parameter: ${t}`),!1):!0,message:({$params:[e]})=>`This field should be exactly ${e} characters long`});var Re=/^\d*(\.\d+)?$/,Sr=createRule({type:"numeric",validator(e){return l(e)?!0:y(e,Re)},message:"This field must be numeric"});var qr=createRule({type:"required",validator(e,t){return t?!0:a(e)},message:"This field is required",active({$params:[e]}){return !e}});var jr=createRule({type:"sameAs",validator(e,t,i="other"){return l(e)?!0:e===t},message({$params:[e,t]}){return `Value must be equal to the ${t} value`}});var de=/^(?:(?:(?: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,Jr=createRule({type:"url",validator(e){return l(e)?!0:y(e,de)},message:"The value is not a valid URL address"});function ce(){return navigator.languages!=null?navigator.languages[0]:navigator.language}function M(e){return e?new Intl.DateTimeFormat(ce(),{dateStyle:"short"}).format(new Date(e)):"?"}var ra=createRule({type:"dateAfter",validator:(e,t)=>a(e)&&a(t)?x(e)&&x(t)?T(e).getTime()>T(t).getTime()?!0:{$valid:!1,error:"date-not-after"}:{$valid:!1,error:"value-or-paramater-not-a-date"}:!0,message:({$params:[e],error:t})=>t==="value-or-paramater-not-a-date"?"The inputs must be Dates":`The date must be after ${M(e)}`});var sa=createRule({type:"dateBefore",validator:(e,t)=>a(e)&&a(t)?x(e)&&x(t)?T(e).getTime()<T(t).getTime()?!0:{$valid:!1,error:"date-not-before"}:{$valid:!1,error:"value-or-paramater-not-a-date"}:!0,message:({$params:[e],error:t})=>t==="value-or-paramater-not-a-date"?"The fields must be Dates":`The date must be before ${M(e)}`});var Ra=createRule({type:"dateBetween",validator:(e,t,i)=>x(e)&&x(t)&&x(i)?T(e).getTime()>T(t).getTime()&&T(e).getTime()<T(i).getTime():!0,message:({$params:[e,t]})=>`The date must be between ${M(e)} and ${M(t)}`});function Me(e){if(e.length>3||e.length===0||e[0]==="0"&&e!=="0"||!e.match(/^\d+$/))return !1;let t=+e|0;return t>=0&&t<=255}var da=createRule({type:"ipAddress",validator(e){if(l(e))return !0;if(typeof e!="string")return !1;let t=e.split(".");return t.length===4&&t.every(Me)},message:"The value is not a valid IP address"});var ba=createRule({type:"macAddress",validator(e,t=":"){if(l(e))return !0;if(typeof e!="string")return !1;let i=typeof t=="string"&&t!==""?e.split(t):e.length===12||e.length===16?e.match(/.{2}/g):null;return i!==null&&(i.length===6||i.length===8)&&i.every(Pe)},message:"The value is not a valid MAC Address"}),Pe=e=>e.toLowerCase().match(/^[0-9a-f]{2}$/);var Pa=createRule({type:"checked",validator:e=>a(e)?e===!0:!0,message:"This field must be checked"});var Aa=createRule({type:"contains",validator(e,t){return a(e)&&a(t)?e.includes(t):!0},message({$params:[e]}){return `Field must contain ${e}`}});var Na=createRule({type:"startsWith",validator(e,t){return a(e)&&a(t)?e.startsWith(t):!0},message({$params:[e]}){return `Field must end with ${e}`}});var ka=createRule({type:"endsWith",validator(e,t){return a(e)&&a(t)?e.endsWith(t):!0},message({$params:[e]}){return `Field must end with ${e}`}});var La=createRule({type:"regex",validator(e,...t){return a(e)?y(e,...t):!0},message:"This field does not match the required pattern"});export{Zt as alpha,Xt as alphaNum,U as and,S as applyIf,rr as between,Pa as checked,Aa as contains,ra as dateAfter,sa as dateBefore,Ra as dateBetween,or as decimal,mr as email,ka as endsWith,Ir as exactLength,vr as exactValue,b as getSize,yr as integer,da as ipAddress,x as isDate,l as isEmpty,a as isFilled,p as isNumber,ba as macAddress,y as matchRegex,Lt as maxLength,Tr as maxValue,Mr as minLength,$r as minValue,K as not,Sr as numeric,G as or,La as regex,kt as required,Ot as requiredIf,qr as requiredUnless,jr as sameAs,Na as startsWith,T as toDate,d as toNumber,Jr as url,N as withAsync,$ as withMessage,E as withParams,W as withTooltip};
|
|
1
|
+
import {createRule,InternalRuleType,unwrapRuleParameters}from'@regle/core';import {unref}from'vue';function V(e,t){let i,o,u,f;typeof e=="function"&&!("_validator"in e)?(i=InternalRuleType.Inline,o=e):{_type:i,validator:o,_active:u,_params:f}=e;let m=createRule({type:i,validator:o,active:u,message:t}),R=[...f??[]];if(m._params=R,m._message_patched=!0,typeof m=="function"){let r=m(...R);return r._message_patched=!0,r}else return m}function v(e,t){let i,o,u,f,m;typeof e=="function"&&!("_validator"in e)?(i=InternalRuleType.Inline,o=e):{_type:i,validator:o,_active:u,_params:f,_message:m}=e;let R=createRule({type:i,validator:o,active:u,message:m,tooltip:t}),r=[...f??[]];if(R._params=r,R._tooltip_patched=!0,typeof R=="function"){let s=R(...r);return R._tooltip_patched=!0,s}else return R}function N(e,t){let i=async(u,...f)=>e(u,...f),o=createRule({type:InternalRuleType.Async,validator:i,message:""});return o._params=o._params?.concat(t),o(...t??[])}function k(e,t){let i=(u,...f)=>e(u,...f),o=createRule({type:InternalRuleType.Inline,validator:i,message:""});return o._params=o._params?.concat(t),o(...t)}function C(e,t){let i,o,u=[],f="";typeof t=="function"?(i=InternalRuleType.Inline,o=t,u=[e]):({_type:i,validator:o,_message:f}=t,u=t._params?.concat([e]));function m(n,...p){let[b]=unwrapRuleParameters([e]);return b?o(n,...p):!0}function R(n){let[p]=unwrapRuleParameters([e]);return p}let r=createRule({type:i,validator:m,active:R,message:f}),s=[...u??[]];if(r._params=s,typeof r=="function"){let n=r(...s);return n._message_patched=!0,n}else return r}function l(e){return e==null?!0:e instanceof Date?isNaN(e.getTime()):Array.isArray(e)?!1:typeof e=="object"&&e!=null?Object.keys(e).length===0:!String(e).length}function a(e){return !l(typeof e=="string"?e.trim():e)}function y(e){return e==null||typeof e!="number"?!1:!isNaN(e)}function g(e,...t){if(l(e))return !0;let i=typeof e=="number"?e.toString():e;return t.every(o=>(o.lastIndex=0,o.test(i)))}function D(e){let t=unref(e);return Array.isArray(t)?t.length:typeof t=="object"?Object.keys(t).length:typeof t=="number"?isNaN(t)?0:t:String(t).length}function x(e){if(l(e))return !1;try{let t=null;if(e instanceof Date)t=e;else if(typeof e=="number"&&!isNaN(e))t=new Date(e);else if(typeof e=="string"){let i=new Date(e);if(i.toString()==="Invalid Date")return !1;t=i;}return !!t}catch{return !1}}function T(e){let t=Object.prototype.toString.call(e);return e==null?new Date(NaN):e instanceof Date||typeof e=="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function d(e){return typeof e=="number"?e:e!=null?typeof e=="string"?e.trim()!==e?NaN:+e:NaN:NaN}function q(...e){let t=e.some(r=>typeof r=="function"?r.constructor.name==="AsyncFunction":r._async),i=e.map(r=>{if(typeof r=="function")return null;{let s=r._params;return s?.length?s:[]}}).flat().filter(r=>!!r);function o(r,s,...n){let p=[],b=0;for(let c of r)if(typeof c=="function")p.push(c(s)),b++;else {let M=c._params?.length??0;p.push(c.validator(s,...n.slice(b,M))),M&&(b+=M);}return p}function u(r){return r?.some(n=>typeof n!="boolean")?{$valid:r.every(n=>typeof n=="boolean"?!!n:n.$valid),...r.reduce((n,p)=>{if(typeof p=="boolean")return n;let{$valid:b,...c}=p;return {...n,...c}},{})}:r.every(n=>!!n)}let f;e.length?f=t?async(r,...s)=>{let n=await Promise.all(o(e,r,...s));return u(n)}:(r,...s)=>{let n=o(e,r,...s);return u(n)}:f=r=>!1;let m=createRule({type:"and",validator:f,message:"The value does not match all of the provided validators"}),R=[...i??[]];if(m._params=R,typeof m=="function"){let r=m(...R);return r._message_patched=!0,r}else return m}function O(...e){let t=e.some(r=>typeof r=="function"?r.constructor.name==="AsyncFunction":r._async),i=e.map(r=>typeof r=="function"?null:r._params).flat().filter(r=>!!r);function o(r,s,...n){let p=[],b=0;for(let c of r)if(typeof c=="function")p.push(c(s)),b++;else {let M=c._params?.length??0;p.push(c.validator(s,...n.slice(b,M))),M&&(b+=M);}return p}function u(r){return r.some(n=>typeof n!="boolean")?{$valid:r.some(n=>typeof n=="boolean"?!!n:n.$valid),...r.reduce((n,p)=>{if(typeof p=="boolean")return n;let{$valid:b,...c}=p;return {...n,...c}},{})}:r.some(n=>!!n)}let m=createRule({type:"or",validator:t?async(r,...s)=>{let n=await Promise.all(o(e,r,...s));return u(n)}:(r,...s)=>{let n=o(e,r,...s);return u(n)},message:"The value does not match any of the provided validators"}),R=[...i??[]];if(m._params=R,typeof m=="function"){let r=m(...R);return r._message_patched=!0,r}else return m}function j(e,t){let i,o,u,f,m;typeof e=="function"?(o=e,m=e.constructor.name==="AsyncFunction"):({_type:i,validator:o,_params:f}=e,m=e._async),m?u=async(s,...n)=>a(s)?!await o(s,...n):!0:u=(s,...n)=>a(s)?!o(s,...n):!0;let R=createRule({type:"not",validator:u,message:t??"Error"}),r=[...f??[]];if(R._params=r,typeof R=="function"){let s=R(...r);return s._message_patched=!0,s}else return R}var zt=createRule({type:"required",validator:e=>a(e),message:"This field is required"});var Ut=createRule({type:"maxLength",validator:(e,t)=>a(e)&&a(t)?y(t)?D(e)<=t:(console.warn(`[maxLength] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),!1):!0,message:({$value:e,$params:[t]})=>Array.isArray(e)?`This list should have maximum ${t} items`:`The maximum length allowed is ${t}`});var Kt=createRule({type:"required",validator(e,t){return t?a(e):!0},message:"This field is required",active({$params:[e]}){return e}});var Q=/^[a-zA-Z]*$/,Ht=createRule({type:"alpha",validator(e){return l(e)?!0:g(e,Q)},message:"The value is not alphabetical"});var Y=/^[a-zA-Z0-9]*$/,Yt=createRule({type:"alpha",validator(e){return l(e)?!0:g(e,Y)},message:"The value must be alpha-numeric"});var ar=createRule({type:"between",validator:(e,t,i)=>{if(a(e)&&a(t)&&a(i)){let o=d(e),u=d(t),f=d(i);return y(o)&&y(u)&&y(f)?o>=u&&o<=f:(console.warn(`[between] Value or parameters aren't numbers, got value: ${e}, min: ${t}, max: ${i}`),!1)}return !0},message:({$params:[e,t]})=>`The value must be between ${e} and ${t}`});var re=/^[-]?\d*(\.\d+)?$/,sr=createRule({type:"decimal",validator(e){return l(e)?!0:g(e,re)},message:"Value must be decimal"});var ne=/^(?:[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,fr=createRule({type:"email",validator(e){return l(e)?!0:g(e,ne)},message:"Value must be an valid email address"});var oe=/(^[0-9]*$)|(^-[0-9]+$)/,gr=createRule({type:"integer",validator(e){return l(e)?!0:g(e,oe)},message:"Value must be an integer"});var xr=createRule({type:"maxValue",validator:(e,t)=>a(e)&&a(t)?y(t)&&!isNaN(d(e))?d(e)<=t:(console.warn(`[maxValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),!0):!0,message:({$params:[e]})=>`The maximum value allowed is ${e}`});var hr=createRule({type:"minLength",validator:(e,t)=>a(e)&&a(t)?y(t)?D(e)>=t:(console.warn(`[minLength] Parameter isn't a number, got parameter: ${t}`),!1):!0,message:({$value:e,$params:[t]})=>Array.isArray(e)?`This list should have at least ${t} items`:`This field should be at least ${t} characters long`});var Vr=createRule({type:"minValue",validator:(e,t)=>a(e)&&a(t)?y(t)&&!isNaN(d(e))?d(e)>=t:(console.warn(`[minValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),!0):!0,message:({$params:[e]})=>`The minimum value allowed is ${e}`});var _r=createRule({type:"exactValue",validator:(e,t)=>a(e)&&a(t)?y(t)&&!isNaN(d(e))?d(e)===t:(console.warn(`[exactValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),!0):!0,message:({$params:[e]})=>`The value must be equal to ${e}`});var Er=createRule({type:"exactLength",validator:(e,t)=>a(e)&&a(t)?y(t)?D(e)===t:(console.warn(`[minLength] Parameter isn't a number, got parameter: ${t}`),!1):!0,message:({$params:[e]})=>`This field should be exactly ${e} characters long`});var pe=/^\d*(\.\d+)?$/,Cr=createRule({type:"numeric",validator(e){return l(e)?!0:g(e,pe)},message:"This field must be numeric"});var Gr=createRule({type:"required",validator(e,t){return t?!0:a(e)},message:"This field is required",active({$params:[e]}){return !e}});var Br=createRule({type:"sameAs",validator(e,t,i="other"){return l(e)?!0:e===t},message({$params:[e,t]}){return `Value must be equal to the ${t} value`}});var ce=/^(?:(?:(?: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,Qr=createRule({type:"url",validator(e){return l(e)?!0:g(e,ce)},message:"The value is not a valid URL address"});function Te(){return navigator.languages!=null?navigator.languages[0]:navigator.language}function h(e){return e?new Intl.DateTimeFormat(Te(),{dateStyle:"short"}).format(new Date(e)):"?"}var aa=createRule({type:"dateAfter",validator:(e,t)=>a(e)&&a(t)?x(e)&&x(t)?T(e).getTime()>T(t).getTime()?!0:{$valid:!1,error:"date-not-after"}:{$valid:!1,error:"value-or-paramater-not-a-date"}:!0,message:({$params:[e],error:t})=>t==="value-or-paramater-not-a-date"?"The inputs must be Dates":`The date must be after ${h(e)}`});var la=createRule({type:"dateBefore",validator:(e,t)=>a(e)&&a(t)?x(e)&&x(t)?T(e).getTime()<T(t).getTime()?!0:{$valid:!1,error:"date-not-before"}:{$valid:!1,error:"value-or-paramater-not-a-date"}:!0,message:({$params:[e],error:t})=>t==="value-or-paramater-not-a-date"?"The fields must be Dates":`The date must be before ${h(e)}`});var pa=createRule({type:"dateBetween",validator:(e,t,i)=>x(e)&&x(t)&&x(i)?T(e).getTime()>T(t).getTime()&&T(e).getTime()<T(i).getTime():!0,message:({$params:[e,t]})=>`The date must be between ${h(e)} and ${h(t)}`});function he(e){if(e.length>3||e.length===0||e[0]==="0"&&e!=="0"||!e.match(/^\d+$/))return !1;let t=+e|0;return t>=0&&t<=255}var ca=createRule({type:"ipAddress",validator(e){if(l(e))return !0;if(typeof e!="string")return !1;let t=e.split(".");return t.length===4&&t.every(he)},message:"The value is not a valid IP address"});var Da=createRule({type:"macAddress",validator(e,t=":"){if(l(e))return !0;if(typeof e!="string")return !1;let i=typeof t=="string"&&t!==""?e.split(t):e.length===12||e.length===16?e.match(/.{2}/g):null;return i!==null&&(i.length===6||i.length===8)&&i.every(we)},message:"The value is not a valid MAC Address"}),we=e=>e.toLowerCase().match(/^[0-9a-f]{2}$/);var wa=createRule({type:"checked",validator:e=>a(e)?e===!0:!0,message:"This field must be checked"});var Wa=createRule({type:"contains",validator(e,t){return a(e)&&a(t)?e.includes(t):!0},message({$params:[e]}){return `Field must contain ${e}`}});var Na=createRule({type:"startsWith",validator(e,t){return a(e)&&a(t)?e.startsWith(t):!0},message({$params:[e]}){return `Field must end with ${e}`}});var za=createRule({type:"endsWith",validator(e,t){return a(e)&&a(t)?e.endsWith(t):!0},message({$params:[e]}){return `Field must end with ${e}`}});var Ua=createRule({type:"regex",validator(e,...t){return a(e)?g(e,...t):!0},message:"This field does not match the required pattern"});export{Ht as alpha,Yt as alphaNum,q as and,C as applyIf,ar as between,wa as checked,Wa as contains,aa as dateAfter,la as dateBefore,pa as dateBetween,sr as decimal,fr as email,za as endsWith,Er as exactLength,_r as exactValue,D as getSize,gr as integer,ca as ipAddress,x as isDate,l as isEmpty,a as isFilled,y as isNumber,Da as macAddress,g as matchRegex,Ut as maxLength,xr as maxValue,hr as minLength,Vr as minValue,j as not,Cr as numeric,O as or,Ua as regex,zt as required,Kt as requiredIf,Gr as requiredUnless,Br as sameAs,Na as startsWith,T as toDate,d as toNumber,Qr as url,N as withAsync,V as withMessage,k as withParams,v as withTooltip};
|
package/dist/regle-rules.mjs
CHANGED
|
@@ -255,7 +255,7 @@ function and(...rules) {
|
|
|
255
255
|
} else {
|
|
256
256
|
const $params = rule._params;
|
|
257
257
|
if (!$params?.length) {
|
|
258
|
-
return [
|
|
258
|
+
return [];
|
|
259
259
|
} else {
|
|
260
260
|
return $params;
|
|
261
261
|
}
|
|
@@ -319,8 +319,15 @@ function and(...rules) {
|
|
|
319
319
|
validator,
|
|
320
320
|
message: "The value does not match all of the provided validators"
|
|
321
321
|
});
|
|
322
|
-
|
|
323
|
-
|
|
322
|
+
const newParams = [..._params ?? []];
|
|
323
|
+
newRule._params = newParams;
|
|
324
|
+
if (typeof newRule === "function") {
|
|
325
|
+
const executedRule = newRule(...newParams);
|
|
326
|
+
executedRule._message_patched = true;
|
|
327
|
+
return executedRule;
|
|
328
|
+
} else {
|
|
329
|
+
return newRule;
|
|
330
|
+
}
|
|
324
331
|
}
|
|
325
332
|
function or(...rules) {
|
|
326
333
|
const isAnyRuleAsync = rules.some((rule) => {
|
|
@@ -330,14 +337,14 @@ function or(...rules) {
|
|
|
330
337
|
return rule._async;
|
|
331
338
|
}
|
|
332
339
|
});
|
|
333
|
-
const
|
|
340
|
+
const _params = rules.map((rule) => {
|
|
334
341
|
if (typeof rule === "function") {
|
|
335
342
|
return null;
|
|
336
343
|
} else {
|
|
337
344
|
return rule._params;
|
|
338
345
|
}
|
|
339
346
|
}).flat().filter((param) => !!param);
|
|
340
|
-
function computeRules(rules2, value, ...
|
|
347
|
+
function computeRules(rules2, value, ...params) {
|
|
341
348
|
const $rules = [];
|
|
342
349
|
let paramIndex = 0;
|
|
343
350
|
for (let rule of rules2) {
|
|
@@ -346,7 +353,7 @@ function or(...rules) {
|
|
|
346
353
|
paramIndex++;
|
|
347
354
|
} else {
|
|
348
355
|
const paramsLength = rule._params?.length ?? 0;
|
|
349
|
-
$rules.push(rule.validator(value, ...
|
|
356
|
+
$rules.push(rule.validator(value, ...params.slice(paramIndex, paramsLength)));
|
|
350
357
|
if (paramsLength) {
|
|
351
358
|
paramIndex += paramsLength;
|
|
352
359
|
}
|
|
@@ -376,11 +383,11 @@ function or(...rules) {
|
|
|
376
383
|
return results.some((result) => !!result);
|
|
377
384
|
}
|
|
378
385
|
}
|
|
379
|
-
const validator = isAnyRuleAsync ? async (value, ...
|
|
380
|
-
const results = await Promise.all(computeRules(rules, value, ...
|
|
386
|
+
const validator = isAnyRuleAsync ? async (value, ...params) => {
|
|
387
|
+
const results = await Promise.all(computeRules(rules, value, ...params));
|
|
381
388
|
return computeMetadata(results);
|
|
382
|
-
} : (value, ...
|
|
383
|
-
const $rules = computeRules(rules, value, ...
|
|
389
|
+
} : (value, ...params) => {
|
|
390
|
+
const $rules = computeRules(rules, value, ...params);
|
|
384
391
|
return computeMetadata($rules);
|
|
385
392
|
};
|
|
386
393
|
const newRule = createRule({
|
|
@@ -388,8 +395,15 @@ function or(...rules) {
|
|
|
388
395
|
validator,
|
|
389
396
|
message: "The value does not match any of the provided validators"
|
|
390
397
|
});
|
|
391
|
-
|
|
392
|
-
|
|
398
|
+
const newParams = [..._params ?? []];
|
|
399
|
+
newRule._params = newParams;
|
|
400
|
+
if (typeof newRule === "function") {
|
|
401
|
+
const executedRule = newRule(...newParams);
|
|
402
|
+
executedRule._message_patched = true;
|
|
403
|
+
return executedRule;
|
|
404
|
+
} else {
|
|
405
|
+
return newRule;
|
|
406
|
+
}
|
|
393
407
|
}
|
|
394
408
|
function not(rule, message) {
|
|
395
409
|
let _type;
|
|
@@ -425,8 +439,15 @@ function not(rule, message) {
|
|
|
425
439
|
validator: newValidator,
|
|
426
440
|
message: message ?? "Error"
|
|
427
441
|
});
|
|
428
|
-
|
|
429
|
-
|
|
442
|
+
const newParams = [..._params ?? []];
|
|
443
|
+
newRule._params = newParams;
|
|
444
|
+
if (typeof newRule === "function") {
|
|
445
|
+
const executedRule = newRule(...newParams);
|
|
446
|
+
executedRule._message_patched = true;
|
|
447
|
+
return executedRule;
|
|
448
|
+
} else {
|
|
449
|
+
return newRule;
|
|
450
|
+
}
|
|
430
451
|
}
|
|
431
452
|
var required = createRule({
|
|
432
453
|
type: "required",
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regle/rules",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.8",
|
|
4
4
|
"description": "Collection of rules and helpers for Regle",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@regle/core": "0.5.
|
|
6
|
+
"@regle/core": "0.5.8"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
10
|
-
"@typescript-eslint/parser": "8.
|
|
9
|
+
"@typescript-eslint/eslint-plugin": "8.19.0",
|
|
10
|
+
"@typescript-eslint/parser": "8.19.0",
|
|
11
11
|
"@vue/reactivity": "3.5.13",
|
|
12
12
|
"@vue/test-utils": "2.4.6",
|
|
13
13
|
"bumpp": "9.9.2",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"eslint-plugin-vue": "9.31.0",
|
|
19
19
|
"prettier": "3.3.3",
|
|
20
20
|
"tsup": "8.3.5",
|
|
21
|
-
"type-fest": "4.
|
|
21
|
+
"type-fest": "4.31.0",
|
|
22
22
|
"typescript": "5.6.3",
|
|
23
23
|
"vitest": "2.1.8",
|
|
24
24
|
"vue": "3.5.13",
|