(function(c,y){typeof exports=="object"&&typeof module!="undefined"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(c=typeof globalThis!="undefined"?globalThis:c||self,y(c["true-react-kit-validator"]={}))})(this,function(c){"use strict";function y(t,e){if(e.length1?"s":"")+" required, but only "+e.length+" present")}function G(t){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?G=function(r){return typeof r}:G=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},G(t)}function B(t){y(1,arguments);var e=Object.prototype.toString.call(t);return t instanceof Date||G(t)==="object"&&e==="[object Date]"?new Date(t.getTime()):typeof t=="number"||e==="[object Number]"?new Date(t):((typeof t=="string"||e==="[object String]")&&typeof console!="undefined"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function We(t){return y(1,arguments),B(t).getTime()>Date.now()}function Je(t){return y(1,arguments),B(t).getTime()t!=null&&t!==""&&t!==!1,St=t=>!t||tr.test(t),$t=t=>Array.isArray(t)?t.some(e=>wt(e)):wt(t),Pt=t=>t&&typeof t=="object"&&Object.keys(t).some(e=>t[e]),zt=(t,e)=>!t||t.length>=e,Et=(t,e)=>!t||t.length<=e,Dt=(t,e)=>!t||t.length===e,It=t=>!t||E.name.test(t),Ft=t=>!t||E.surname.test(t),Mt=t=>!t||E.digits.test(t),Ct=t=>!t||E.docNumber.test(t),Vt=t=>!t||We(t),Nt=t=>!t||Je(t)||xe(t),Ut=t=>!t||ke(t),Rt={required:$t,minLength:zt,maxLength:Et,exactLength:Dt,name:It,surname:Ft,emptyObject:Pt,email:St,digits:Mt,futureDate:Vt,pastDateOrToday:Nt,lettersAndDigits:Ct,validDate:Ut};function nt(t,e){const r=[];return t&&Object.entries(t).map(([n,o])=>{Rt[n](e,typeof o!="boolean"&&o!==void 0?o.value:void 0)||r.push(typeof o!="boolean"&&(o==null?void 0:o.message)!==void 0?o.message:n)}),r}function Lt(t,e,r,n){const o=[],{commonValidators:i,validators:u}=r;if(i&&nt(i,e).forEach(a=>o.push(a)),u){for(const a in u)if(!u[a].validate({...t,[n]:e})){const s=u[a].message;o.push(s!==void 0?s:a)}}return o}function er(t,e,r){return Object.entries(t).reduce((n,[o,i])=>{if(r){if(r.includes(o))return{...n,[o]:{errors:i==null?void 0:i.errors,shouldShowErrors:e}}}else return{...n,[o]:{errors:i==null?void 0:i.errors,shouldShowErrors:e}};return{...n,[o]:i}},{})}function rr(t){return Object.values(t).every(e=>(e==null?void 0:e.errors.length)===0)}function nr(t,e){return Object.entries(e).reduce((r,[n,o])=>({...r,[n]:{errors:Lt(t,t[n],o,n),shouldShowErrors:!1}}),{})}const or=t=>typeof t=="function",D=t=>t!=null,ar=(t,...e)=>or(t)?t(...e):t,H=t=>!D(t);function ir(){this.__data__=[],this.size=0}function q(t,e){return t===e||t!=t&&e!=e}function K(t,e){for(var r=t.length;r--;)if(q(t[r][0],e))return r;return-1}var ur=Array.prototype,sr=ur.splice;function cr(t){var e=this.__data__,r=K(e,t);return!(r<0)&&(r==e.length-1?e.pop():sr.call(e,r,1),--this.size,!0)}function fr(t){var e=this.__data__,r=K(e,t);return r<0?void 0:e[r][1]}function lr(t){return K(this.__data__,t)>-1}function pr(t,e){var r=this.__data__,n=K(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}function g(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e-1&&t%1==0&&t<=An}function lt(t){return t!=null&&ee(t.length)&&!ot(t)}function Tn(t){return M(t)&<(t)}function wn(){return!1}var re=typeof c=="object"&&c&&!c.nodeType&&c,ne=re&&typeof module=="object"&&module&&!module.nodeType&&module,Sn=ne&&ne.exports===re,oe=Sn?T.Buffer:void 0,$n=oe?oe.isBuffer:void 0,ae=$n||wn,Pn="[object Object]",zn=Function.prototype,En=Object.prototype,ie=zn.toString,Dn=En.hasOwnProperty,In=ie.call(Object);function Fn(t){if(!M(t)||W(t)!=Pn)return!1;var e=xt(t);if(e===null)return!0;var r=Dn.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&ie.call(r)==In}var Mn="[object Arguments]",Cn="[object Array]",Vn="[object Boolean]",Nn="[object Date]",Un="[object Error]",Rn="[object Function]",Ln="[object Map]",Gn="[object Number]",Bn="[object Object]",Zn="[object RegExp]",Hn="[object Set]",qn="[object String]",Kn="[object WeakMap]",Xn="[object ArrayBuffer]",Wn="[object DataView]",Jn="[object Float32Array]",Yn="[object Float64Array]",xn="[object Int8Array]",Qn="[object Int16Array]",kn="[object Int32Array]",to="[object Uint8Array]",eo="[object Uint8ClampedArray]",ro="[object Uint16Array]",no="[object Uint32Array]",p={};function oo(t){return M(t)&&ee(t.length)&&!!p[W(t)]}function ao(t){return function(e){return t(e)}}p[Jn]=p[Yn]=p[xn]=p[Qn]=p[kn]=p[to]=p[eo]=p[ro]=p[no]=!0,p[Mn]=p[Cn]=p[Xn]=p[Vn]=p[Wn]=p[Nn]=p[Un]=p[Rn]=p[Ln]=p[Gn]=p[Bn]=p[Zn]=p[Hn]=p[qn]=p[Kn]=!1;var ue=typeof c=="object"&&c&&!c.nodeType&&c,C=ue&&typeof module=="object"&&module&&!module.nodeType&&module,io=C&&C.exports===ue,pt=io&&Gt.process,se=function(){try{return C&&C.require&&C.require("util").types||pt&&pt.binding&&pt.binding("util")}catch{}}(),ce=se&&se.isTypedArray,fe=ce?ao(ce):oo;function dt(t,e){if((e!=="constructor"||typeof t[e]!="function")&&e!="__proto__")return t[e]}var uo=Object.prototype,so=uo.hasOwnProperty;function co(t,e,r){var n=t[e];(!so.call(t,e)||!q(n,r)||r===void 0&&!(e in t))&&ut(t,e,r)}function fo(t,e,r,n){var o=!r;r||(r={});for(var i=-1,u=e.length;++i-1&&t%1==0&&t0){if(++e>=So)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var Eo=zo(wo);function Do(t,e){return Eo(Ao(t,e,he),t+"")}function Io(t,e,r){if(!v(r))return!1;var n=typeof e;return!!(n=="number"?lt(r)&&le(e,r.length):n=="string"&&e in r)&&q(r[e],t)}function Fo(t){return Do(function(e,r){var n=-1,o=r.length,i=o>1?r[o-1]:void 0,u=o>2?r[2]:void 0;for(i=t.length>3&&typeof i=="function"?(o--,i):void 0,u&&Io(r[0],r[1],u)&&(i=o<3?void 0:i,o=1),e=Object(e);++n-1}function Lo(t,e){var r=this.__data__,n=Q(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}function _(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e-1&&t%1==0&&t<=ci}function jt(t){return t!=null&&De(t.length)&&!ht(t)}function fi(t){return U(t)&&jt(t)}function li(){return!1}var Ie=typeof c=="object"&&c&&!c.nodeType&&c,Fe=Ie&&typeof module=="object"&&module&&!module.nodeType&&module,pi=Fe&&Fe.exports===Ie,Me=pi?$.Buffer:void 0,di=Me?Me.isBuffer:void 0,hi=di||li;const Ce=hi;var yi="[object Object]",bi=Function.prototype,gi=Object.prototype,Ve=bi.toString,_i=gi.hasOwnProperty,vi=Ve.call(Object);function mi(t){if(!U(t)||tt(t)!=yi)return!1;var e=$e(t);if(e===null)return!0;var r=_i.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&Ve.call(r)==vi}var ji="[object Arguments]",Oi="[object Array]",Ai="[object Boolean]",Ti="[object Date]",wi="[object Error]",Si="[object Function]",$i="[object Map]",Pi="[object Number]",zi="[object Object]",Ei="[object RegExp]",Di="[object Set]",Ii="[object String]",Fi="[object WeakMap]",Mi="[object ArrayBuffer]",Ci="[object DataView]",Vi="[object Float32Array]",Ni="[object Float64Array]",Ui="[object Int8Array]",Ri="[object Int16Array]",Li="[object Int32Array]",Gi="[object Uint8Array]",Bi="[object Uint8ClampedArray]",Zi="[object Uint16Array]",Hi="[object Uint32Array]",d={};d[Vi]=d[Ni]=d[Ui]=d[Ri]=d[Li]=d[Gi]=d[Bi]=d[Zi]=d[Hi]=!0,d[ji]=d[Oi]=d[Mi]=d[Ai]=d[Ci]=d[Ti]=d[wi]=d[Si]=d[$i]=d[Pi]=d[zi]=d[Ei]=d[Di]=d[Ii]=d[Fi]=!1;function qi(t){return U(t)&&De(t.length)&&!!d[tt(t)]}function Ki(t){return function(e){return t(e)}}var Ne=typeof c=="object"&&c&&!c.nodeType&&c,R=Ne&&typeof module=="object"&&module&&!module.nodeType&&module,Xi=R&&R.exports===Ne,Ot=Xi&&be.process,Wi=function(){try{var t=R&&R.require&&R.require("util").types;return t||Ot&&Ot.binding&&Ot.binding("util")}catch{}}();const Ue=Wi;var Re=Ue&&Ue.isTypedArray,Ji=Re?Ki(Re):qi;const Le=Ji;function At(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var Yi=Object.prototype,xi=Yi.hasOwnProperty;function Qi(t,e,r){var n=t[e];(!(xi.call(t,e)&&x(n,r))||r===void 0&&!(e in t))&>(t,e,r)}function ki(t,e,r,n){var o=!r;r||(r={});for(var i=-1,u=e.length;++i-1&&t%1==0&&t0){if(++e>=gu)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var ju=mu(bu);const Ou=ju;function Au(t,e){return Ou(du(t,e,He),t+"")}function Tu(t,e,r){if(!j(r))return!1;var n=typeof e;return(n=="number"?jt(r)&&Ge(e,r.length):n=="string"&&e in r)?x(r[e],t):!1}function wu(t){return Au(function(e,r){var n=-1,o=r.length,i=o>1?r[o-1]:void 0,u=o>2?r[2]:void 0;for(i=t.length>3&&typeof i=="function"?(o--,i):void 0,u&&Tu(r[0],r[1],u)&&(i=o<3?void 0:i,o=1),e=Object(e);++nr==="errors"&&Array.isArray(t)&&Array.isArray(e)?t.concat(e):void 0,zu=(t,e)=>H(t)||H(e)?t!=null?t:e:$u(t,e,Pu),Ke=(t,e,{validators:r,commonValidators:n},o,i)=>{var a;const u=n?nt(n,e):[];if(r)for(const s in r)r[s].validate(e,t,o,i)||u.push((a=r[s].message)!=null?a:s);return u},Xe=(t,e,r,n,o)=>{const i={},u=ar(r,e,t,n,o);if(H(u))return i;const{validators:a,commonValidators:s,itemConfig:l}=u;(D(a)||D(s))&&(i.errors=Ke(t,e,u,n,o));const f=(h,b)=>Xe(t,e==null?void 0:e[h],b,h,{value:e,fieldName:n,parent:o});return D(l)&&D(e)&&Object.keys(e).forEach(h=>{i[h]=f(h,l)}),Object.entries(u).forEach(([h,b])=>{H(b)||h==="itemConfig"||h==="validators"||h==="commonValidators"||(i[h]=zu(i[h],f(h,b)))}),i},Eu=(t,e)=>Xe(t,t,e);c.CommonValidatorsMap=Rt,c.SMART_INPUT_REGEX_MAP=E,c.getErrors=Lt,c.getNestedErrors=Ke,c.isDigitsOnly=Mt,c.isEmailValid=St,c.isExactLengthValid=Dt,c.isFormValid=rr,c.isInFuture=Vt,c.isInPastOrToday=Nt,c.isLettersAndDigits=Ct,c.isMaxLengthValid=Et,c.isMinLengthValid=zt,c.isNameValid=It,c.isObjNotEmpty=Pt,c.isRequiredValid=$t,c.isSurnameValid=Ft,c.isValidDate=Ut,c.setShowErrors=er,c.validateCommon=nt,c.validateForm=nr,c.validateNestedForm=Eu,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});