@regle/rules 0.7.2 → 0.7.3

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.
@@ -128,7 +128,7 @@ function applyIf(_condition, rule) {
128
128
  }
129
129
 
130
130
  // ../shared/utils/isEmpty.ts
131
- function isEmpty(value) {
131
+ function isEmpty(value, considerEmptyArrayInvalid = true) {
132
132
  if (value === undefined || value === null) {
133
133
  return true;
134
134
  }
@@ -136,6 +136,9 @@ function isEmpty(value) {
136
136
  return isNaN(value.getTime());
137
137
  }
138
138
  if (Array.isArray(value)) {
139
+ if (considerEmptyArrayInvalid) {
140
+ return value.length === 0;
141
+ }
139
142
  return false;
140
143
  }
141
144
  if (typeof value === "object" && value != null) {
@@ -183,8 +186,8 @@ function toDate(argument) {
183
186
  }
184
187
 
185
188
  // src/helpers/ruleHelpers/isFilled.ts
186
- function isFilled(value) {
187
- return !isEmpty(typeof value === "string" ? value.trim() : value);
189
+ function isFilled(value, considerEmptyArrayInvalid = true) {
190
+ return !isEmpty(typeof value === "string" ? value.trim() : value, considerEmptyArrayInvalid);
188
191
  }
189
192
 
190
193
  // src/helpers/ruleHelpers/isNumber.ts
@@ -459,7 +462,7 @@ var required = core.createRule({
459
462
  var maxLength = core.createRule({
460
463
  type: "maxLength",
461
464
  validator: (value, count) => {
462
- if (isFilled(value) && isFilled(count)) {
465
+ if (isFilled(value, false) && isFilled(count)) {
463
466
  if (isNumber(count)) {
464
467
  return getSize(value) <= count;
465
468
  }
@@ -581,7 +584,7 @@ var maxValue = core.createRule({
581
584
  var minLength = core.createRule({
582
585
  type: "minLength",
583
586
  validator: (value, count) => {
584
- if (isFilled(value) && isFilled(count)) {
587
+ if (isFilled(value, false) && isFilled(count)) {
585
588
  if (isNumber(count)) {
586
589
  return getSize(value) >= count;
587
590
  }
@@ -632,7 +635,7 @@ var exactValue = core.createRule({
632
635
  var exactLength = core.createRule({
633
636
  type: "exactLength",
634
637
  validator: (value, count) => {
635
- if (isFilled(value) && isFilled(count)) {
638
+ if (isFilled(value, false) && isFilled(count)) {
636
639
  if (isNumber(count)) {
637
640
  return getSize(value) === count;
638
641
  }
@@ -78,10 +78,13 @@ declare function applyIf<TValue extends any, TParams extends any[], TReturn exte
78
78
 
79
79
  /**
80
80
  * This is almost a must have for optional fields. It checks if any value you provided is defined (including arrays and objects). You can base your validator result on this.
81
-
82
- isFilled also acts as a type guard.
81
+ *
82
+ * isFilled also acts as a type guard.
83
+ *
84
+ * @param value - the target value
85
+ * @param [considerEmptyArrayInvalid=true] - will return true if set to `false`. (default: `true`)
83
86
  */
84
- declare function isFilled<T extends unknown>(value: T): value is NonNullable<T>;
87
+ declare function isFilled<T extends unknown>(value: T, considerEmptyArrayInvalid?: boolean): value is NonNullable<T>;
85
88
 
86
89
  /**
87
90
  * This is a type guard that will check if the passed value is a real Number. This also returns false for NaN, so this is better than typeof value === "number".
@@ -144,10 +147,13 @@ type EmptyObject$1 = {[emptyObjectSymbol$1]?: never};
144
147
 
145
148
  /**
146
149
  * This is the inverse of isFilled. It will check if the value is in any way empty (including arrays and objects)
147
-
148
- isEmpty also acts as a type guard.
150
+ *
151
+ * isEmpty also acts as a type guard.
152
+ *
153
+ * @param value - the target value
154
+ * @param [considerEmptyArrayInvalid=true] - will return false if set to `false`. (default: `true`)
149
155
  */
150
- declare function isEmpty(value: unknown): value is null | undefined | [] | EmptyObject$1;
156
+ declare function isEmpty(value: unknown, considerEmptyArrayInvalid?: boolean): value is null | undefined | [] | EmptyObject$1;
151
157
 
152
158
  /**
153
159
  * This is a useful helper that can check if the provided value is a Date, it is used internally for date rules. This can also check strings.
@@ -78,10 +78,13 @@ declare function applyIf<TValue extends any, TParams extends any[], TReturn exte
78
78
 
79
79
  /**
80
80
  * This is almost a must have for optional fields. It checks if any value you provided is defined (including arrays and objects). You can base your validator result on this.
81
-
82
- isFilled also acts as a type guard.
81
+ *
82
+ * isFilled also acts as a type guard.
83
+ *
84
+ * @param value - the target value
85
+ * @param [considerEmptyArrayInvalid=true] - will return true if set to `false`. (default: `true`)
83
86
  */
84
- declare function isFilled<T extends unknown>(value: T): value is NonNullable<T>;
87
+ declare function isFilled<T extends unknown>(value: T, considerEmptyArrayInvalid?: boolean): value is NonNullable<T>;
85
88
 
86
89
  /**
87
90
  * This is a type guard that will check if the passed value is a real Number. This also returns false for NaN, so this is better than typeof value === "number".
@@ -144,10 +147,13 @@ type EmptyObject$1 = {[emptyObjectSymbol$1]?: never};
144
147
 
145
148
  /**
146
149
  * This is the inverse of isFilled. It will check if the value is in any way empty (including arrays and objects)
147
-
148
- isEmpty also acts as a type guard.
150
+ *
151
+ * isEmpty also acts as a type guard.
152
+ *
153
+ * @param value - the target value
154
+ * @param [considerEmptyArrayInvalid=true] - will return false if set to `false`. (default: `true`)
149
155
  */
150
- declare function isEmpty(value: unknown): value is null | undefined | [] | EmptyObject$1;
156
+ declare function isEmpty(value: unknown, considerEmptyArrayInvalid?: boolean): value is null | undefined | [] | EmptyObject$1;
151
157
 
152
158
  /**
153
159
  * This is a useful helper that can check if the provided value is a Date, it is used internally for date rules. This can also check strings.
@@ -1 +1 @@
1
- 'use strict';var core=require('@regle/core'),vue=require('vue');function P(e,t){let i,n,s,m;typeof e=="function"&&!("_validator"in e)?(i=core.InternalRuleType.Inline,n=e):{_type:i,validator:n,_active:s,_params:m}=e;let f=core.createRule({type:i,validator:n,active:s,message:t}),R=[...m??[]];if(f._params=R,f._message_patched=true,typeof f=="function"){let r=f(...R);return r._message_patched=true,r}else return f}function _(e,t){let i,n,s,m,f;typeof e=="function"&&!("_validator"in e)?(i=core.InternalRuleType.Inline,n=e):{_type:i,validator:n,_active:s,_params:m,_message:f}=e;let R=core.createRule({type:i,validator:n,active:s,message:f,tooltip:t}),r=[...m??[]];if(R._params=r,R._tooltip_patched=true,typeof R=="function"){let l=R(...r);return R._tooltip_patched=true,l}else return R}function I(e,t){let i=async(s,...m)=>e(s,...m),n=core.createRule({type:core.InternalRuleType.Async,validator:i,message:""});return n._params=n._params?.concat(t),n(...t??[])}function w(e,t){let i=(s,...m)=>e(s,...m),n=core.createRule({type:core.InternalRuleType.Inline,validator:i,message:""});return n._params=n._params?.concat(t),n(...t)}function C(e,t){let i,n,s=[],m="";typeof t=="function"?(i=core.InternalRuleType.Inline,n=t,s=[e]):({_type:i,validator:n,_message:m}=t,s=t._params?.concat([e]));function f(o,...p){let[b]=core.unwrapRuleParameters([e]);return b?n(o,...p):true}function R(o){let[p]=core.unwrapRuleParameters([e]);return p}let r=core.createRule({type:i,validator:f,active:R,message:m}),l=[...s??[]];if(r._params=l,typeof r=="function"){let o=r(...l);return o._message_patched=true,o}else return r}function u(e){return e==null?true:e instanceof Date?isNaN(e.getTime()):Array.isArray(e)?false:typeof e=="object"&&e!=null?Object.keys(e).length===0:!String(e).length}function T(e){if(u(e))return false;try{let t=null;if(e instanceof Date)t=e;else if(typeof e=="string"){let i=new Date(e);if(i.toString()==="Invalid Date")return !1;t=i;}return !!t}catch{return false}}function x(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 a(e){return !u(typeof e=="string"?e.trim():e)}function y(e){return e==null||typeof e!="number"?false:!isNaN(e)}function g(e,...t){if(u(e))return true;let i=typeof e=="number"?e.toString():e;return t.every(n=>(n.lastIndex=0,n.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 c(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 l=r._params;return l?.length?l:[]}}).flat().filter(r=>!!r);function n(r,l,...o){let p=[],b=0;for(let d of r)if(typeof d=="function")p.push(d(l)),b++;else {let M=d._params?.length??0;p.push(d.validator(l,...o.slice(b,M))),M&&(b+=M);}return p}function s(r){return r?.some(o=>typeof o!="boolean")?{$valid:r.every(o=>typeof o=="boolean"?!!o:o.$valid),...r.reduce((o,p)=>{if(typeof p=="boolean")return o;let{$valid:b,...d}=p;return {...o,...d}},{})}:r.every(o=>!!o)}let m;e.length?m=t?async(r,...l)=>{let o=await Promise.all(n(e,r,...l));return s(o)}:(r,...l)=>{let o=n(e,r,...l);return s(o)}:m=r=>false;let f=core.createRule({type:"and",validator:m,message:"The value does not match all of the provided validators"}),R=[...i??[]];if(f._params=R,typeof f=="function"){let r=f(...R);return r._message_patched=true,r}else return f}function q(...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 n(r,l,...o){let p=[],b=0;for(let d of r)if(typeof d=="function")p.push(d(l)),b++;else {let M=d._params?.length??0;p.push(d.validator(l,...o.slice(b,M))),M&&(b+=M);}return p}function s(r){return r.some(o=>typeof o!="boolean")?{$valid:r.some(o=>typeof o=="boolean"?!!o:o.$valid),...r.reduce((o,p)=>{if(typeof p=="boolean")return o;let{$valid:b,...d}=p;return {...o,...d}},{})}:r.some(o=>!!o)}let f=core.createRule({type:"or",validator:t?async(r,...l)=>{let o=await Promise.all(n(e,r,...l));return s(o)}:(r,...l)=>{let o=n(e,r,...l);return s(o)},message:"The value does not match any of the provided validators"}),R=[...i??[]];if(f._params=R,typeof f=="function"){let r=f(...R);return r._message_patched=true,r}else return f}function B(e,t){let i,n,s,m,f;typeof e=="function"?(n=e,f=e.constructor.name==="AsyncFunction"):({_type:i,validator:n,_params:m}=e,f=e._async),f?s=async(l,...o)=>a(l)?!await n(l,...o):true:s=(l,...o)=>a(l)?!n(l,...o):true;let R=core.createRule({type:"not",validator:s,message:t??"Error"}),r=[...m??[]];if(R._params=r,typeof R=="function"){let l=R(...r);return l._message_patched=true,l}else return R}var qt=core.createRule({type:"required",validator:e=>a(e),message:"This field is required"});var Ht=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}`),false):true,message:({$value:e,$params:[t]})=>Array.isArray(e)?`This list should have maximum ${t} items`:`The maximum length allowed is ${t}`});var Yt=core.createRule({type:"required",validator(e,t){return t?a(e):true},message:"This field is required",active({$params:[e]}){return e}});var X=/^[a-zA-Z]*$/,rr=core.createRule({type:"alpha",validator(e){return u(e)?true:g(e,X)},message:"The value is not alphabetical"});var j=/^[a-zA-Z0-9]*$/,or=core.createRule({type:"alpha",validator(e){return u(e)?true:g(e,j)},message:"The value must be alpha-numeric"});var mr=core.createRule({type:"between",validator:(e,t,i)=>{if(a(e)&&a(t)&&a(i)){let n=c(e),s=c(t),m=c(i);return y(n)&&y(s)&&y(m)?n>=s&&n<=m:(console.warn(`[between] Value or parameters aren't numbers, got value: ${e}, min: ${t}, max: ${i}`),false)}return true},message:({$params:[e,t]})=>`The value must be between ${e} and ${t}`});var re=/^[-]?\d*(\.\d+)?$/,yr=core.createRule({type:"decimal",validator(e){return u(e)?true: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,xr=core.createRule({type:"email",validator(e){return u(e)?true:g(e,ne)},message:"Value must be an valid email address"});var oe=/(^[0-9]*$)|(^-[0-9]+$)/,Mr=core.createRule({type:"integer",validator(e){return u(e)?true:g(e,oe)},message:"Value must be an integer"});var $r=core.createRule({type:"maxValue",validator:(e,t)=>a(e)&&a(t)?y(t)&&!isNaN(c(e))?c(e)<=t:(console.warn(`[maxValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),true):true,message:({$params:[e]})=>`The maximum value allowed is ${e}`});var Wr=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}`),false):true,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 Ir=core.createRule({type:"minValue",validator:(e,t)=>a(e)&&a(t)?y(t)&&!isNaN(c(e))?c(e)>=t:(console.warn(`[minValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),true):true,message:({$params:[e]})=>`The minimum value allowed is ${e}`});var Sr=core.createRule({type:"exactValue",validator:(e,t)=>a(e)&&a(t)?y(t)&&!isNaN(c(e))?c(e)===t:(console.warn(`[exactValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),true):true,message:({$params:[e]})=>`The value must be equal to ${e}`});var Ur=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}`),false):true,message:({$params:[e]})=>`This field should be exactly ${e} characters long`});var pe=/^\d*(\.\d+)?$/,Br=core.createRule({type:"numeric",validator(e){return u(e)?true:g(e,pe)},message:"This field must be numeric"});var Qr=core.createRule({type:"required",validator(e,t){return t?true:a(e)},message:"This field is required",active({$params:[e]}){return !e}});var ea=core.createRule({type:"sameAs",validator(e,t,i="other"){return u(e)?true: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,na=core.createRule({type:"url",validator(e){return u(e)?true:g(e,de)},message:"The value is not a valid URL address"});function xe(){return navigator.languages!=null?navigator.languages[0]:navigator.language}function h(e){return e?new Intl.DateTimeFormat(xe(),{dateStyle:"short"}).format(new Date(e)):"?"}var ma=core.createRule({type:"dateAfter",validator:(e,t)=>a(e)&&a(t)?T(e)&&T(t)?x(e).getTime()>x(t).getTime()?true:{$valid:false,error:"date-not-after"}:{$valid:false,error:"value-or-paramater-not-a-date"}:true,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 ga=core.createRule({type:"dateBefore",validator:(e,t)=>a(e)&&a(t)?T(e)&&T(t)?x(e).getTime()<x(t).getTime()?true:{$valid:false,error:"date-not-before"}:{$valid:false,error:"value-or-paramater-not-a-date"}:true,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 ba=core.createRule({type:"dateBetween",validator:(e,t,i)=>T(e)&&T(t)&&T(i)?x(e).getTime()>x(t).getTime()&&x(e).getTime()<x(i).getTime():true,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 false;let t=+e|0;return t>=0&&t<=255}var Pa=core.createRule({type:"ipAddress",validator(e){if(u(e))return true;if(typeof e!="string")return false;let t=e.split(".");return t.length===4&&t.every(he)},message:"The value is not a valid IP address"});var va=core.createRule({type:"macAddress",validator(e,t=":"){if(u(e))return true;if(typeof e!="string")return false;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 Fa=core.createRule({type:"checked",validator:e=>a(e)?e===true:true,message:"This field must be checked"});var ka=core.createRule({type:"contains",validator(e,t){return a(e)&&a(t)?e.includes(t):true},message({$params:[e]}){return `Field must contain ${e}`}});var La=core.createRule({type:"startsWith",validator(e,t){return a(e)&&a(t)?e.startsWith(t):true},message({$params:[e]}){return `Field must end with ${e}`}});var qa=core.createRule({type:"endsWith",validator(e,t){return a(e)&&a(t)?e.endsWith(t):true},message({$params:[e]}){return `Field must end with ${e}`}});var Ha=core.createRule({type:"regex",validator(e,...t){return a(e)?g(e,...t):true},message:"This field does not match the required pattern"});function Ya(e){let t=vue.computed(()=>vue.toValue(e));return P(w((n,s)=>a(n)&&a(s)?s.includes(n):true,[t]),({$params:[n]})=>`Value should be one of those options: ${n.join(", ")}.`)}function Ee(e){let t=Object.keys(e).filter(n=>typeof e[e[n]]!="number"),i={};for(let n of t)i[n]=e[n];return Object.values(i)}function rn(e){let t=vue.computed(()=>vue.toValue(e));return P(w((n,s)=>a(n)&&!u(s)?Ee(s).includes(n):true,[t]),({$params:[n]})=>`Value should be one of those options: ${Object.values(n).join(", ")}.`)}exports.alpha=rr;exports.alphaNum=or;exports.and=U;exports.applyIf=C;exports.between=mr;exports.checked=Fa;exports.contains=ka;exports.dateAfter=ma;exports.dateBefore=ga;exports.dateBetween=ba;exports.decimal=yr;exports.email=xr;exports.endsWith=qa;exports.exactLength=Ur;exports.exactValue=Sr;exports.getSize=D;exports.integer=Mr;exports.ipAddress=Pa;exports.isDate=T;exports.isEmpty=u;exports.isFilled=a;exports.isNumber=y;exports.macAddress=va;exports.matchRegex=g;exports.maxLength=Ht;exports.maxValue=$r;exports.minLength=Wr;exports.minValue=Ir;exports.nativeEnum=rn;exports.not=B;exports.numeric=Br;exports.oneOf=Ya;exports.or=q;exports.regex=Ha;exports.required=qt;exports.requiredIf=Yt;exports.requiredUnless=Qr;exports.sameAs=ea;exports.startsWith=La;exports.toDate=x;exports.toNumber=c;exports.url=na;exports.withAsync=I;exports.withMessage=P;exports.withParams=w;exports.withTooltip=_;
1
+ 'use strict';var core=require('@regle/core'),vue=require('vue');function P(e,t){let i,n,s,m;typeof e=="function"&&!("_validator"in e)?(i=core.InternalRuleType.Inline,n=e):{_type:i,validator:n,_active:s,_params:m}=e;let f=core.createRule({type:i,validator:n,active:s,message:t}),R=[...m??[]];if(f._params=R,f._message_patched=true,typeof f=="function"){let r=f(...R);return r._message_patched=true,r}else return f}function _(e,t){let i,n,s,m,f;typeof e=="function"&&!("_validator"in e)?(i=core.InternalRuleType.Inline,n=e):{_type:i,validator:n,_active:s,_params:m,_message:f}=e;let R=core.createRule({type:i,validator:n,active:s,message:f,tooltip:t}),r=[...m??[]];if(R._params=r,R._tooltip_patched=true,typeof R=="function"){let l=R(...r);return R._tooltip_patched=true,l}else return R}function I(e,t){let i=async(s,...m)=>e(s,...m),n=core.createRule({type:core.InternalRuleType.Async,validator:i,message:""});return n._params=n._params?.concat(t),n(...t??[])}function w(e,t){let i=(s,...m)=>e(s,...m),n=core.createRule({type:core.InternalRuleType.Inline,validator:i,message:""});return n._params=n._params?.concat(t),n(...t)}function C(e,t){let i,n,s=[],m="";typeof t=="function"?(i=core.InternalRuleType.Inline,n=t,s=[e]):({_type:i,validator:n,_message:m}=t,s=t._params?.concat([e]));function f(o,...p){let[b]=core.unwrapRuleParameters([e]);return b?n(o,...p):true}function R(o){let[p]=core.unwrapRuleParameters([e]);return p}let r=core.createRule({type:i,validator:f,active:R,message:m}),l=[...s??[]];if(r._params=l,typeof r=="function"){let o=r(...l);return o._message_patched=true,o}else return r}function u(e,t=true){return e==null?true:e instanceof Date?isNaN(e.getTime()):Array.isArray(e)?t?e.length===0:false:typeof e=="object"&&e!=null?Object.keys(e).length===0:!String(e).length}function T(e){if(u(e))return false;try{let t=null;if(e instanceof Date)t=e;else if(typeof e=="string"){let i=new Date(e);if(i.toString()==="Invalid Date")return !1;t=i;}return !!t}catch{return false}}function x(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 a(e,t=true){return !u(typeof e=="string"?e.trim():e,t)}function y(e){return e==null||typeof e!="number"?false:!isNaN(e)}function g(e,...t){if(u(e))return true;let i=typeof e=="number"?e.toString():e;return t.every(n=>(n.lastIndex=0,n.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 c(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 l=r._params;return l?.length?l:[]}}).flat().filter(r=>!!r);function n(r,l,...o){let p=[],b=0;for(let d of r)if(typeof d=="function")p.push(d(l)),b++;else {let h=d._params?.length??0;p.push(d.validator(l,...o.slice(b,h))),h&&(b+=h);}return p}function s(r){return r?.some(o=>typeof o!="boolean")?{$valid:r.every(o=>typeof o=="boolean"?!!o:o.$valid),...r.reduce((o,p)=>{if(typeof p=="boolean")return o;let{$valid:b,...d}=p;return {...o,...d}},{})}:r.every(o=>!!o)}let m;e.length?m=t?async(r,...l)=>{let o=await Promise.all(n(e,r,...l));return s(o)}:(r,...l)=>{let o=n(e,r,...l);return s(o)}:m=r=>false;let f=core.createRule({type:"and",validator:m,message:"The value does not match all of the provided validators"}),R=[...i??[]];if(f._params=R,typeof f=="function"){let r=f(...R);return r._message_patched=true,r}else return f}function q(...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 n(r,l,...o){let p=[],b=0;for(let d of r)if(typeof d=="function")p.push(d(l)),b++;else {let h=d._params?.length??0;p.push(d.validator(l,...o.slice(b,h))),h&&(b+=h);}return p}function s(r){return r.some(o=>typeof o!="boolean")?{$valid:r.some(o=>typeof o=="boolean"?!!o:o.$valid),...r.reduce((o,p)=>{if(typeof p=="boolean")return o;let{$valid:b,...d}=p;return {...o,...d}},{})}:r.some(o=>!!o)}let f=core.createRule({type:"or",validator:t?async(r,...l)=>{let o=await Promise.all(n(e,r,...l));return s(o)}:(r,...l)=>{let o=n(e,r,...l);return s(o)},message:"The value does not match any of the provided validators"}),R=[...i??[]];if(f._params=R,typeof f=="function"){let r=f(...R);return r._message_patched=true,r}else return f}function B(e,t){let i,n,s,m,f;typeof e=="function"?(n=e,f=e.constructor.name==="AsyncFunction"):({_type:i,validator:n,_params:m}=e,f=e._async),f?s=async(l,...o)=>a(l)?!await n(l,...o):true:s=(l,...o)=>a(l)?!n(l,...o):true;let R=core.createRule({type:"not",validator:s,message:t??"Error"}),r=[...m??[]];if(R._params=r,typeof R=="function"){let l=R(...r);return l._message_patched=true,l}else return R}var qt=core.createRule({type:"required",validator:e=>a(e),message:"This field is required"});var Ht=core.createRule({type:"maxLength",validator:(e,t)=>a(e,false)&&a(t)?y(t)?D(e)<=t:(console.warn(`[maxLength] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),false):true,message:({$value:e,$params:[t]})=>Array.isArray(e)?`This list should have maximum ${t} items`:`The maximum length allowed is ${t}`});var Yt=core.createRule({type:"required",validator(e,t){return t?a(e):true},message:"This field is required",active({$params:[e]}){return e}});var X=/^[a-zA-Z]*$/,rr=core.createRule({type:"alpha",validator(e){return u(e)?true:g(e,X)},message:"The value is not alphabetical"});var j=/^[a-zA-Z0-9]*$/,or=core.createRule({type:"alpha",validator(e){return u(e)?true:g(e,j)},message:"The value must be alpha-numeric"});var mr=core.createRule({type:"between",validator:(e,t,i)=>{if(a(e)&&a(t)&&a(i)){let n=c(e),s=c(t),m=c(i);return y(n)&&y(s)&&y(m)?n>=s&&n<=m:(console.warn(`[between] Value or parameters aren't numbers, got value: ${e}, min: ${t}, max: ${i}`),false)}return true},message:({$params:[e,t]})=>`The value must be between ${e} and ${t}`});var re=/^[-]?\d*(\.\d+)?$/,yr=core.createRule({type:"decimal",validator(e){return u(e)?true: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,xr=core.createRule({type:"email",validator(e){return u(e)?true:g(e,ne)},message:"Value must be an valid email address"});var oe=/(^[0-9]*$)|(^-[0-9]+$)/,hr=core.createRule({type:"integer",validator(e){return u(e)?true:g(e,oe)},message:"Value must be an integer"});var $r=core.createRule({type:"maxValue",validator:(e,t)=>a(e)&&a(t)?y(t)&&!isNaN(c(e))?c(e)<=t:(console.warn(`[maxValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),true):true,message:({$params:[e]})=>`The maximum value allowed is ${e}`});var Wr=core.createRule({type:"minLength",validator:(e,t)=>a(e,false)&&a(t)?y(t)?D(e)>=t:(console.warn(`[minLength] Parameter isn't a number, got parameter: ${t}`),false):true,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 Ir=core.createRule({type:"minValue",validator:(e,t)=>a(e)&&a(t)?y(t)&&!isNaN(c(e))?c(e)>=t:(console.warn(`[minValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),true):true,message:({$params:[e]})=>`The minimum value allowed is ${e}`});var Sr=core.createRule({type:"exactValue",validator:(e,t)=>a(e)&&a(t)?y(t)&&!isNaN(c(e))?c(e)===t:(console.warn(`[exactValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),true):true,message:({$params:[e]})=>`The value must be equal to ${e}`});var Ur=core.createRule({type:"exactLength",validator:(e,t)=>a(e,false)&&a(t)?y(t)?D(e)===t:(console.warn(`[minLength] Parameter isn't a number, got parameter: ${t}`),false):true,message:({$params:[e]})=>`This field should be exactly ${e} characters long`});var pe=/^\d*(\.\d+)?$/,Br=core.createRule({type:"numeric",validator(e){return u(e)?true:g(e,pe)},message:"This field must be numeric"});var Qr=core.createRule({type:"required",validator(e,t){return t?true:a(e)},message:"This field is required",active({$params:[e]}){return !e}});var ea=core.createRule({type:"sameAs",validator(e,t,i="other"){return u(e)?true: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,na=core.createRule({type:"url",validator(e){return u(e)?true:g(e,de)},message:"The value is not a valid URL address"});function xe(){return navigator.languages!=null?navigator.languages[0]:navigator.language}function M(e){return e?new Intl.DateTimeFormat(xe(),{dateStyle:"short"}).format(new Date(e)):"?"}var ma=core.createRule({type:"dateAfter",validator:(e,t)=>a(e)&&a(t)?T(e)&&T(t)?x(e).getTime()>x(t).getTime()?true:{$valid:false,error:"date-not-after"}:{$valid:false,error:"value-or-paramater-not-a-date"}:true,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 ga=core.createRule({type:"dateBefore",validator:(e,t)=>a(e)&&a(t)?T(e)&&T(t)?x(e).getTime()<x(t).getTime()?true:{$valid:false,error:"date-not-before"}:{$valid:false,error:"value-or-paramater-not-a-date"}:true,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 ba=core.createRule({type:"dateBetween",validator:(e,t,i)=>T(e)&&T(t)&&T(i)?x(e).getTime()>x(t).getTime()&&x(e).getTime()<x(i).getTime():true,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 false;let t=+e|0;return t>=0&&t<=255}var Pa=core.createRule({type:"ipAddress",validator(e){if(u(e))return true;if(typeof e!="string")return false;let t=e.split(".");return t.length===4&&t.every(Me)},message:"The value is not a valid IP address"});var va=core.createRule({type:"macAddress",validator(e,t=":"){if(u(e))return true;if(typeof e!="string")return false;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 Fa=core.createRule({type:"checked",validator:e=>a(e)?e===true:true,message:"This field must be checked"});var ka=core.createRule({type:"contains",validator(e,t){return a(e)&&a(t)?e.includes(t):true},message({$params:[e]}){return `Field must contain ${e}`}});var La=core.createRule({type:"startsWith",validator(e,t){return a(e)&&a(t)?e.startsWith(t):true},message({$params:[e]}){return `Field must end with ${e}`}});var qa=core.createRule({type:"endsWith",validator(e,t){return a(e)&&a(t)?e.endsWith(t):true},message({$params:[e]}){return `Field must end with ${e}`}});var Ha=core.createRule({type:"regex",validator(e,...t){return a(e)?g(e,...t):true},message:"This field does not match the required pattern"});function Ya(e){let t=vue.computed(()=>vue.toValue(e));return P(w((n,s)=>a(n)&&a(s)?s.includes(n):true,[t]),({$params:[n]})=>`Value should be one of those options: ${n.join(", ")}.`)}function Ee(e){let t=Object.keys(e).filter(n=>typeof e[e[n]]!="number"),i={};for(let n of t)i[n]=e[n];return Object.values(i)}function rn(e){let t=vue.computed(()=>vue.toValue(e));return P(w((n,s)=>a(n)&&!u(s)?Ee(s).includes(n):true,[t]),({$params:[n]})=>`Value should be one of those options: ${Object.values(n).join(", ")}.`)}exports.alpha=rr;exports.alphaNum=or;exports.and=U;exports.applyIf=C;exports.between=mr;exports.checked=Fa;exports.contains=ka;exports.dateAfter=ma;exports.dateBefore=ga;exports.dateBetween=ba;exports.decimal=yr;exports.email=xr;exports.endsWith=qa;exports.exactLength=Ur;exports.exactValue=Sr;exports.getSize=D;exports.integer=hr;exports.ipAddress=Pa;exports.isDate=T;exports.isEmpty=u;exports.isFilled=a;exports.isNumber=y;exports.macAddress=va;exports.matchRegex=g;exports.maxLength=Ht;exports.maxValue=$r;exports.minLength=Wr;exports.minValue=Ir;exports.nativeEnum=rn;exports.not=B;exports.numeric=Br;exports.oneOf=Ya;exports.or=q;exports.regex=Ha;exports.required=qt;exports.requiredIf=Yt;exports.requiredUnless=Qr;exports.sameAs=ea;exports.startsWith=La;exports.toDate=x;exports.toNumber=c;exports.url=na;exports.withAsync=I;exports.withMessage=P;exports.withParams=w;exports.withTooltip=_;
@@ -1 +1 @@
1
- import {createRule,InternalRuleType,unwrapRuleParameters}from'@regle/core';import {unref,computed,toValue}from'vue';function P(e,t){let i,n,s,m;typeof e=="function"&&!("_validator"in e)?(i=InternalRuleType.Inline,n=e):{_type:i,validator:n,_active:s,_params:m}=e;let f=createRule({type:i,validator:n,active:s,message:t}),R=[...m??[]];if(f._params=R,f._message_patched=true,typeof f=="function"){let r=f(...R);return r._message_patched=true,r}else return f}function _(e,t){let i,n,s,m,f;typeof e=="function"&&!("_validator"in e)?(i=InternalRuleType.Inline,n=e):{_type:i,validator:n,_active:s,_params:m,_message:f}=e;let R=createRule({type:i,validator:n,active:s,message:f,tooltip:t}),r=[...m??[]];if(R._params=r,R._tooltip_patched=true,typeof R=="function"){let l=R(...r);return R._tooltip_patched=true,l}else return R}function I(e,t){let i=async(s,...m)=>e(s,...m),n=createRule({type:InternalRuleType.Async,validator:i,message:""});return n._params=n._params?.concat(t),n(...t??[])}function w(e,t){let i=(s,...m)=>e(s,...m),n=createRule({type:InternalRuleType.Inline,validator:i,message:""});return n._params=n._params?.concat(t),n(...t)}function C(e,t){let i,n,s=[],m="";typeof t=="function"?(i=InternalRuleType.Inline,n=t,s=[e]):({_type:i,validator:n,_message:m}=t,s=t._params?.concat([e]));function f(o,...p){let[b]=unwrapRuleParameters([e]);return b?n(o,...p):true}function R(o){let[p]=unwrapRuleParameters([e]);return p}let r=createRule({type:i,validator:f,active:R,message:m}),l=[...s??[]];if(r._params=l,typeof r=="function"){let o=r(...l);return o._message_patched=true,o}else return r}function u(e){return e==null?true:e instanceof Date?isNaN(e.getTime()):Array.isArray(e)?false:typeof e=="object"&&e!=null?Object.keys(e).length===0:!String(e).length}function T(e){if(u(e))return false;try{let t=null;if(e instanceof Date)t=e;else if(typeof e=="string"){let i=new Date(e);if(i.toString()==="Invalid Date")return !1;t=i;}return !!t}catch{return false}}function x(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 a(e){return !u(typeof e=="string"?e.trim():e)}function y(e){return e==null||typeof e!="number"?false:!isNaN(e)}function g(e,...t){if(u(e))return true;let i=typeof e=="number"?e.toString():e;return t.every(n=>(n.lastIndex=0,n.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 c(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 l=r._params;return l?.length?l:[]}}).flat().filter(r=>!!r);function n(r,l,...o){let p=[],b=0;for(let d of r)if(typeof d=="function")p.push(d(l)),b++;else {let M=d._params?.length??0;p.push(d.validator(l,...o.slice(b,M))),M&&(b+=M);}return p}function s(r){return r?.some(o=>typeof o!="boolean")?{$valid:r.every(o=>typeof o=="boolean"?!!o:o.$valid),...r.reduce((o,p)=>{if(typeof p=="boolean")return o;let{$valid:b,...d}=p;return {...o,...d}},{})}:r.every(o=>!!o)}let m;e.length?m=t?async(r,...l)=>{let o=await Promise.all(n(e,r,...l));return s(o)}:(r,...l)=>{let o=n(e,r,...l);return s(o)}:m=r=>false;let f=createRule({type:"and",validator:m,message:"The value does not match all of the provided validators"}),R=[...i??[]];if(f._params=R,typeof f=="function"){let r=f(...R);return r._message_patched=true,r}else return f}function q(...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 n(r,l,...o){let p=[],b=0;for(let d of r)if(typeof d=="function")p.push(d(l)),b++;else {let M=d._params?.length??0;p.push(d.validator(l,...o.slice(b,M))),M&&(b+=M);}return p}function s(r){return r.some(o=>typeof o!="boolean")?{$valid:r.some(o=>typeof o=="boolean"?!!o:o.$valid),...r.reduce((o,p)=>{if(typeof p=="boolean")return o;let{$valid:b,...d}=p;return {...o,...d}},{})}:r.some(o=>!!o)}let f=createRule({type:"or",validator:t?async(r,...l)=>{let o=await Promise.all(n(e,r,...l));return s(o)}:(r,...l)=>{let o=n(e,r,...l);return s(o)},message:"The value does not match any of the provided validators"}),R=[...i??[]];if(f._params=R,typeof f=="function"){let r=f(...R);return r._message_patched=true,r}else return f}function B(e,t){let i,n,s,m,f;typeof e=="function"?(n=e,f=e.constructor.name==="AsyncFunction"):({_type:i,validator:n,_params:m}=e,f=e._async),f?s=async(l,...o)=>a(l)?!await n(l,...o):true:s=(l,...o)=>a(l)?!n(l,...o):true;let R=createRule({type:"not",validator:s,message:t??"Error"}),r=[...m??[]];if(R._params=r,typeof R=="function"){let l=R(...r);return l._message_patched=true,l}else return R}var qt=createRule({type:"required",validator:e=>a(e),message:"This field is required"});var Ht=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}`),false):true,message:({$value:e,$params:[t]})=>Array.isArray(e)?`This list should have maximum ${t} items`:`The maximum length allowed is ${t}`});var Yt=createRule({type:"required",validator(e,t){return t?a(e):true},message:"This field is required",active({$params:[e]}){return e}});var X=/^[a-zA-Z]*$/,rr=createRule({type:"alpha",validator(e){return u(e)?true:g(e,X)},message:"The value is not alphabetical"});var j=/^[a-zA-Z0-9]*$/,or=createRule({type:"alpha",validator(e){return u(e)?true:g(e,j)},message:"The value must be alpha-numeric"});var mr=createRule({type:"between",validator:(e,t,i)=>{if(a(e)&&a(t)&&a(i)){let n=c(e),s=c(t),m=c(i);return y(n)&&y(s)&&y(m)?n>=s&&n<=m:(console.warn(`[between] Value or parameters aren't numbers, got value: ${e}, min: ${t}, max: ${i}`),false)}return true},message:({$params:[e,t]})=>`The value must be between ${e} and ${t}`});var re=/^[-]?\d*(\.\d+)?$/,yr=createRule({type:"decimal",validator(e){return u(e)?true: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,xr=createRule({type:"email",validator(e){return u(e)?true:g(e,ne)},message:"Value must be an valid email address"});var oe=/(^[0-9]*$)|(^-[0-9]+$)/,Mr=createRule({type:"integer",validator(e){return u(e)?true:g(e,oe)},message:"Value must be an integer"});var $r=createRule({type:"maxValue",validator:(e,t)=>a(e)&&a(t)?y(t)&&!isNaN(c(e))?c(e)<=t:(console.warn(`[maxValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),true):true,message:({$params:[e]})=>`The maximum value allowed is ${e}`});var Wr=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}`),false):true,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 Ir=createRule({type:"minValue",validator:(e,t)=>a(e)&&a(t)?y(t)&&!isNaN(c(e))?c(e)>=t:(console.warn(`[minValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),true):true,message:({$params:[e]})=>`The minimum value allowed is ${e}`});var Sr=createRule({type:"exactValue",validator:(e,t)=>a(e)&&a(t)?y(t)&&!isNaN(c(e))?c(e)===t:(console.warn(`[exactValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),true):true,message:({$params:[e]})=>`The value must be equal to ${e}`});var Ur=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}`),false):true,message:({$params:[e]})=>`This field should be exactly ${e} characters long`});var pe=/^\d*(\.\d+)?$/,Br=createRule({type:"numeric",validator(e){return u(e)?true:g(e,pe)},message:"This field must be numeric"});var Qr=createRule({type:"required",validator(e,t){return t?true:a(e)},message:"This field is required",active({$params:[e]}){return !e}});var ea=createRule({type:"sameAs",validator(e,t,i="other"){return u(e)?true: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,na=createRule({type:"url",validator(e){return u(e)?true:g(e,de)},message:"The value is not a valid URL address"});function xe(){return navigator.languages!=null?navigator.languages[0]:navigator.language}function h(e){return e?new Intl.DateTimeFormat(xe(),{dateStyle:"short"}).format(new Date(e)):"?"}var ma=createRule({type:"dateAfter",validator:(e,t)=>a(e)&&a(t)?T(e)&&T(t)?x(e).getTime()>x(t).getTime()?true:{$valid:false,error:"date-not-after"}:{$valid:false,error:"value-or-paramater-not-a-date"}:true,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 ga=createRule({type:"dateBefore",validator:(e,t)=>a(e)&&a(t)?T(e)&&T(t)?x(e).getTime()<x(t).getTime()?true:{$valid:false,error:"date-not-before"}:{$valid:false,error:"value-or-paramater-not-a-date"}:true,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 ba=createRule({type:"dateBetween",validator:(e,t,i)=>T(e)&&T(t)&&T(i)?x(e).getTime()>x(t).getTime()&&x(e).getTime()<x(i).getTime():true,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 false;let t=+e|0;return t>=0&&t<=255}var Pa=createRule({type:"ipAddress",validator(e){if(u(e))return true;if(typeof e!="string")return false;let t=e.split(".");return t.length===4&&t.every(he)},message:"The value is not a valid IP address"});var va=createRule({type:"macAddress",validator(e,t=":"){if(u(e))return true;if(typeof e!="string")return false;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 Fa=createRule({type:"checked",validator:e=>a(e)?e===true:true,message:"This field must be checked"});var ka=createRule({type:"contains",validator(e,t){return a(e)&&a(t)?e.includes(t):true},message({$params:[e]}){return `Field must contain ${e}`}});var La=createRule({type:"startsWith",validator(e,t){return a(e)&&a(t)?e.startsWith(t):true},message({$params:[e]}){return `Field must end with ${e}`}});var qa=createRule({type:"endsWith",validator(e,t){return a(e)&&a(t)?e.endsWith(t):true},message({$params:[e]}){return `Field must end with ${e}`}});var Ha=createRule({type:"regex",validator(e,...t){return a(e)?g(e,...t):true},message:"This field does not match the required pattern"});function Ya(e){let t=computed(()=>toValue(e));return P(w((n,s)=>a(n)&&a(s)?s.includes(n):true,[t]),({$params:[n]})=>`Value should be one of those options: ${n.join(", ")}.`)}function Ee(e){let t=Object.keys(e).filter(n=>typeof e[e[n]]!="number"),i={};for(let n of t)i[n]=e[n];return Object.values(i)}function rn(e){let t=computed(()=>toValue(e));return P(w((n,s)=>a(n)&&!u(s)?Ee(s).includes(n):true,[t]),({$params:[n]})=>`Value should be one of those options: ${Object.values(n).join(", ")}.`)}export{rr as alpha,or as alphaNum,U as and,C as applyIf,mr as between,Fa as checked,ka as contains,ma as dateAfter,ga as dateBefore,ba as dateBetween,yr as decimal,xr as email,qa as endsWith,Ur as exactLength,Sr as exactValue,D as getSize,Mr as integer,Pa as ipAddress,T as isDate,u as isEmpty,a as isFilled,y as isNumber,va as macAddress,g as matchRegex,Ht as maxLength,$r as maxValue,Wr as minLength,Ir as minValue,rn as nativeEnum,B as not,Br as numeric,Ya as oneOf,q as or,Ha as regex,qt as required,Yt as requiredIf,Qr as requiredUnless,ea as sameAs,La as startsWith,x as toDate,c as toNumber,na as url,I as withAsync,P as withMessage,w as withParams,_ as withTooltip};
1
+ import {createRule,InternalRuleType,unwrapRuleParameters}from'@regle/core';import {unref,computed,toValue}from'vue';function P(e,t){let i,n,s,m;typeof e=="function"&&!("_validator"in e)?(i=InternalRuleType.Inline,n=e):{_type:i,validator:n,_active:s,_params:m}=e;let f=createRule({type:i,validator:n,active:s,message:t}),R=[...m??[]];if(f._params=R,f._message_patched=true,typeof f=="function"){let r=f(...R);return r._message_patched=true,r}else return f}function _(e,t){let i,n,s,m,f;typeof e=="function"&&!("_validator"in e)?(i=InternalRuleType.Inline,n=e):{_type:i,validator:n,_active:s,_params:m,_message:f}=e;let R=createRule({type:i,validator:n,active:s,message:f,tooltip:t}),r=[...m??[]];if(R._params=r,R._tooltip_patched=true,typeof R=="function"){let l=R(...r);return R._tooltip_patched=true,l}else return R}function I(e,t){let i=async(s,...m)=>e(s,...m),n=createRule({type:InternalRuleType.Async,validator:i,message:""});return n._params=n._params?.concat(t),n(...t??[])}function w(e,t){let i=(s,...m)=>e(s,...m),n=createRule({type:InternalRuleType.Inline,validator:i,message:""});return n._params=n._params?.concat(t),n(...t)}function C(e,t){let i,n,s=[],m="";typeof t=="function"?(i=InternalRuleType.Inline,n=t,s=[e]):({_type:i,validator:n,_message:m}=t,s=t._params?.concat([e]));function f(o,...p){let[b]=unwrapRuleParameters([e]);return b?n(o,...p):true}function R(o){let[p]=unwrapRuleParameters([e]);return p}let r=createRule({type:i,validator:f,active:R,message:m}),l=[...s??[]];if(r._params=l,typeof r=="function"){let o=r(...l);return o._message_patched=true,o}else return r}function u(e,t=true){return e==null?true:e instanceof Date?isNaN(e.getTime()):Array.isArray(e)?t?e.length===0:false:typeof e=="object"&&e!=null?Object.keys(e).length===0:!String(e).length}function T(e){if(u(e))return false;try{let t=null;if(e instanceof Date)t=e;else if(typeof e=="string"){let i=new Date(e);if(i.toString()==="Invalid Date")return !1;t=i;}return !!t}catch{return false}}function x(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 a(e,t=true){return !u(typeof e=="string"?e.trim():e,t)}function y(e){return e==null||typeof e!="number"?false:!isNaN(e)}function g(e,...t){if(u(e))return true;let i=typeof e=="number"?e.toString():e;return t.every(n=>(n.lastIndex=0,n.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 c(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 l=r._params;return l?.length?l:[]}}).flat().filter(r=>!!r);function n(r,l,...o){let p=[],b=0;for(let d of r)if(typeof d=="function")p.push(d(l)),b++;else {let h=d._params?.length??0;p.push(d.validator(l,...o.slice(b,h))),h&&(b+=h);}return p}function s(r){return r?.some(o=>typeof o!="boolean")?{$valid:r.every(o=>typeof o=="boolean"?!!o:o.$valid),...r.reduce((o,p)=>{if(typeof p=="boolean")return o;let{$valid:b,...d}=p;return {...o,...d}},{})}:r.every(o=>!!o)}let m;e.length?m=t?async(r,...l)=>{let o=await Promise.all(n(e,r,...l));return s(o)}:(r,...l)=>{let o=n(e,r,...l);return s(o)}:m=r=>false;let f=createRule({type:"and",validator:m,message:"The value does not match all of the provided validators"}),R=[...i??[]];if(f._params=R,typeof f=="function"){let r=f(...R);return r._message_patched=true,r}else return f}function q(...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 n(r,l,...o){let p=[],b=0;for(let d of r)if(typeof d=="function")p.push(d(l)),b++;else {let h=d._params?.length??0;p.push(d.validator(l,...o.slice(b,h))),h&&(b+=h);}return p}function s(r){return r.some(o=>typeof o!="boolean")?{$valid:r.some(o=>typeof o=="boolean"?!!o:o.$valid),...r.reduce((o,p)=>{if(typeof p=="boolean")return o;let{$valid:b,...d}=p;return {...o,...d}},{})}:r.some(o=>!!o)}let f=createRule({type:"or",validator:t?async(r,...l)=>{let o=await Promise.all(n(e,r,...l));return s(o)}:(r,...l)=>{let o=n(e,r,...l);return s(o)},message:"The value does not match any of the provided validators"}),R=[...i??[]];if(f._params=R,typeof f=="function"){let r=f(...R);return r._message_patched=true,r}else return f}function B(e,t){let i,n,s,m,f;typeof e=="function"?(n=e,f=e.constructor.name==="AsyncFunction"):({_type:i,validator:n,_params:m}=e,f=e._async),f?s=async(l,...o)=>a(l)?!await n(l,...o):true:s=(l,...o)=>a(l)?!n(l,...o):true;let R=createRule({type:"not",validator:s,message:t??"Error"}),r=[...m??[]];if(R._params=r,typeof R=="function"){let l=R(...r);return l._message_patched=true,l}else return R}var qt=createRule({type:"required",validator:e=>a(e),message:"This field is required"});var Ht=createRule({type:"maxLength",validator:(e,t)=>a(e,false)&&a(t)?y(t)?D(e)<=t:(console.warn(`[maxLength] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),false):true,message:({$value:e,$params:[t]})=>Array.isArray(e)?`This list should have maximum ${t} items`:`The maximum length allowed is ${t}`});var Yt=createRule({type:"required",validator(e,t){return t?a(e):true},message:"This field is required",active({$params:[e]}){return e}});var X=/^[a-zA-Z]*$/,rr=createRule({type:"alpha",validator(e){return u(e)?true:g(e,X)},message:"The value is not alphabetical"});var j=/^[a-zA-Z0-9]*$/,or=createRule({type:"alpha",validator(e){return u(e)?true:g(e,j)},message:"The value must be alpha-numeric"});var mr=createRule({type:"between",validator:(e,t,i)=>{if(a(e)&&a(t)&&a(i)){let n=c(e),s=c(t),m=c(i);return y(n)&&y(s)&&y(m)?n>=s&&n<=m:(console.warn(`[between] Value or parameters aren't numbers, got value: ${e}, min: ${t}, max: ${i}`),false)}return true},message:({$params:[e,t]})=>`The value must be between ${e} and ${t}`});var re=/^[-]?\d*(\.\d+)?$/,yr=createRule({type:"decimal",validator(e){return u(e)?true: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,xr=createRule({type:"email",validator(e){return u(e)?true:g(e,ne)},message:"Value must be an valid email address"});var oe=/(^[0-9]*$)|(^-[0-9]+$)/,hr=createRule({type:"integer",validator(e){return u(e)?true:g(e,oe)},message:"Value must be an integer"});var $r=createRule({type:"maxValue",validator:(e,t)=>a(e)&&a(t)?y(t)&&!isNaN(c(e))?c(e)<=t:(console.warn(`[maxValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),true):true,message:({$params:[e]})=>`The maximum value allowed is ${e}`});var Wr=createRule({type:"minLength",validator:(e,t)=>a(e,false)&&a(t)?y(t)?D(e)>=t:(console.warn(`[minLength] Parameter isn't a number, got parameter: ${t}`),false):true,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 Ir=createRule({type:"minValue",validator:(e,t)=>a(e)&&a(t)?y(t)&&!isNaN(c(e))?c(e)>=t:(console.warn(`[minValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),true):true,message:({$params:[e]})=>`The minimum value allowed is ${e}`});var Sr=createRule({type:"exactValue",validator:(e,t)=>a(e)&&a(t)?y(t)&&!isNaN(c(e))?c(e)===t:(console.warn(`[exactValue] Value or parameter isn't a number, got value: ${e}, parameter: ${t}`),true):true,message:({$params:[e]})=>`The value must be equal to ${e}`});var Ur=createRule({type:"exactLength",validator:(e,t)=>a(e,false)&&a(t)?y(t)?D(e)===t:(console.warn(`[minLength] Parameter isn't a number, got parameter: ${t}`),false):true,message:({$params:[e]})=>`This field should be exactly ${e} characters long`});var pe=/^\d*(\.\d+)?$/,Br=createRule({type:"numeric",validator(e){return u(e)?true:g(e,pe)},message:"This field must be numeric"});var Qr=createRule({type:"required",validator(e,t){return t?true:a(e)},message:"This field is required",active({$params:[e]}){return !e}});var ea=createRule({type:"sameAs",validator(e,t,i="other"){return u(e)?true: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,na=createRule({type:"url",validator(e){return u(e)?true:g(e,de)},message:"The value is not a valid URL address"});function xe(){return navigator.languages!=null?navigator.languages[0]:navigator.language}function M(e){return e?new Intl.DateTimeFormat(xe(),{dateStyle:"short"}).format(new Date(e)):"?"}var ma=createRule({type:"dateAfter",validator:(e,t)=>a(e)&&a(t)?T(e)&&T(t)?x(e).getTime()>x(t).getTime()?true:{$valid:false,error:"date-not-after"}:{$valid:false,error:"value-or-paramater-not-a-date"}:true,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 ga=createRule({type:"dateBefore",validator:(e,t)=>a(e)&&a(t)?T(e)&&T(t)?x(e).getTime()<x(t).getTime()?true:{$valid:false,error:"date-not-before"}:{$valid:false,error:"value-or-paramater-not-a-date"}:true,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 ba=createRule({type:"dateBetween",validator:(e,t,i)=>T(e)&&T(t)&&T(i)?x(e).getTime()>x(t).getTime()&&x(e).getTime()<x(i).getTime():true,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 false;let t=+e|0;return t>=0&&t<=255}var Pa=createRule({type:"ipAddress",validator(e){if(u(e))return true;if(typeof e!="string")return false;let t=e.split(".");return t.length===4&&t.every(Me)},message:"The value is not a valid IP address"});var va=createRule({type:"macAddress",validator(e,t=":"){if(u(e))return true;if(typeof e!="string")return false;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 Fa=createRule({type:"checked",validator:e=>a(e)?e===true:true,message:"This field must be checked"});var ka=createRule({type:"contains",validator(e,t){return a(e)&&a(t)?e.includes(t):true},message({$params:[e]}){return `Field must contain ${e}`}});var La=createRule({type:"startsWith",validator(e,t){return a(e)&&a(t)?e.startsWith(t):true},message({$params:[e]}){return `Field must end with ${e}`}});var qa=createRule({type:"endsWith",validator(e,t){return a(e)&&a(t)?e.endsWith(t):true},message({$params:[e]}){return `Field must end with ${e}`}});var Ha=createRule({type:"regex",validator(e,...t){return a(e)?g(e,...t):true},message:"This field does not match the required pattern"});function Ya(e){let t=computed(()=>toValue(e));return P(w((n,s)=>a(n)&&a(s)?s.includes(n):true,[t]),({$params:[n]})=>`Value should be one of those options: ${n.join(", ")}.`)}function Ee(e){let t=Object.keys(e).filter(n=>typeof e[e[n]]!="number"),i={};for(let n of t)i[n]=e[n];return Object.values(i)}function rn(e){let t=computed(()=>toValue(e));return P(w((n,s)=>a(n)&&!u(s)?Ee(s).includes(n):true,[t]),({$params:[n]})=>`Value should be one of those options: ${Object.values(n).join(", ")}.`)}export{rr as alpha,or as alphaNum,U as and,C as applyIf,mr as between,Fa as checked,ka as contains,ma as dateAfter,ga as dateBefore,ba as dateBetween,yr as decimal,xr as email,qa as endsWith,Ur as exactLength,Sr as exactValue,D as getSize,hr as integer,Pa as ipAddress,T as isDate,u as isEmpty,a as isFilled,y as isNumber,va as macAddress,g as matchRegex,Ht as maxLength,$r as maxValue,Wr as minLength,Ir as minValue,rn as nativeEnum,B as not,Br as numeric,Ya as oneOf,q as or,Ha as regex,qt as required,Yt as requiredIf,Qr as requiredUnless,ea as sameAs,La as startsWith,x as toDate,c as toNumber,na as url,I as withAsync,P as withMessage,w as withParams,_ as withTooltip};
@@ -126,7 +126,7 @@ function applyIf(_condition, rule) {
126
126
  }
127
127
 
128
128
  // ../shared/utils/isEmpty.ts
129
- function isEmpty(value) {
129
+ function isEmpty(value, considerEmptyArrayInvalid = true) {
130
130
  if (value === undefined || value === null) {
131
131
  return true;
132
132
  }
@@ -134,6 +134,9 @@ function isEmpty(value) {
134
134
  return isNaN(value.getTime());
135
135
  }
136
136
  if (Array.isArray(value)) {
137
+ if (considerEmptyArrayInvalid) {
138
+ return value.length === 0;
139
+ }
137
140
  return false;
138
141
  }
139
142
  if (typeof value === "object" && value != null) {
@@ -181,8 +184,8 @@ function toDate(argument) {
181
184
  }
182
185
 
183
186
  // src/helpers/ruleHelpers/isFilled.ts
184
- function isFilled(value) {
185
- return !isEmpty(typeof value === "string" ? value.trim() : value);
187
+ function isFilled(value, considerEmptyArrayInvalid = true) {
188
+ return !isEmpty(typeof value === "string" ? value.trim() : value, considerEmptyArrayInvalid);
186
189
  }
187
190
 
188
191
  // src/helpers/ruleHelpers/isNumber.ts
@@ -457,7 +460,7 @@ var required = createRule({
457
460
  var maxLength = createRule({
458
461
  type: "maxLength",
459
462
  validator: (value, count) => {
460
- if (isFilled(value) && isFilled(count)) {
463
+ if (isFilled(value, false) && isFilled(count)) {
461
464
  if (isNumber(count)) {
462
465
  return getSize(value) <= count;
463
466
  }
@@ -579,7 +582,7 @@ var maxValue = createRule({
579
582
  var minLength = createRule({
580
583
  type: "minLength",
581
584
  validator: (value, count) => {
582
- if (isFilled(value) && isFilled(count)) {
585
+ if (isFilled(value, false) && isFilled(count)) {
583
586
  if (isNumber(count)) {
584
587
  return getSize(value) >= count;
585
588
  }
@@ -630,7 +633,7 @@ var exactValue = createRule({
630
633
  var exactLength = createRule({
631
634
  type: "exactLength",
632
635
  validator: (value, count) => {
633
- if (isFilled(value) && isFilled(count)) {
636
+ if (isFilled(value, false) && isFilled(count)) {
634
637
  if (isNumber(count)) {
635
638
  return getSize(value) === count;
636
639
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@regle/rules",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Collection of rules and helpers for Regle",
5
5
  "dependencies": {
6
- "@regle/core": "0.7.2"
6
+ "@regle/core": "0.7.3"
7
7
  },
8
8
  "devDependencies": {
9
9
  "@typescript-eslint/eslint-plugin": "8.19.1",