class-validator.umd.js 613 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  3. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  4. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ClassValidator = {}));
  5. })(this, (function (exports) { 'use strict';
  6. /**
  7. * This metadata contains validation rules.
  8. */
  9. var ValidationMetadata = /** @class */ (function () {
  10. // -------------------------------------------------------------------------
  11. // Constructor
  12. // -------------------------------------------------------------------------
  13. function ValidationMetadata(args) {
  14. /**
  15. * Validation groups used for this validation.
  16. */
  17. this.groups = [];
  18. /**
  19. * Specifies if validated value is an array and each of its item must be validated.
  20. */
  21. this.each = false;
  22. /*
  23. * A transient set of data passed through to the validation result for response mapping
  24. */
  25. this.context = undefined;
  26. this.type = args.type;
  27. this.name = args.name;
  28. this.target = args.target;
  29. this.propertyName = args.propertyName;
  30. this.constraints = args === null || args === void 0 ? void 0 : args.constraints;
  31. this.constraintCls = args.constraintCls;
  32. this.validationTypeOptions = args.validationTypeOptions;
  33. if (args.validationOptions) {
  34. this.message = args.validationOptions.message;
  35. this.groups = args.validationOptions.groups;
  36. this.always = args.validationOptions.always;
  37. this.each = args.validationOptions.each;
  38. this.context = args.validationOptions.context;
  39. }
  40. }
  41. return ValidationMetadata;
  42. }());
  43. /**
  44. * Used to transform validation schemas to validation metadatas.
  45. */
  46. var ValidationSchemaToMetadataTransformer = /** @class */ (function () {
  47. function ValidationSchemaToMetadataTransformer() {
  48. }
  49. ValidationSchemaToMetadataTransformer.prototype.transform = function (schema) {
  50. var metadatas = [];
  51. Object.keys(schema.properties).forEach(function (property) {
  52. schema.properties[property].forEach(function (validation) {
  53. var validationOptions = {
  54. message: validation.message,
  55. groups: validation.groups,
  56. always: validation.always,
  57. each: validation.each,
  58. };
  59. var args = {
  60. type: validation.type,
  61. name: validation.name,
  62. target: schema.name,
  63. propertyName: property,
  64. constraints: validation.constraints,
  65. validationTypeOptions: validation.options,
  66. validationOptions: validationOptions,
  67. };
  68. metadatas.push(new ValidationMetadata(args));
  69. });
  70. });
  71. return metadatas;
  72. };
  73. return ValidationSchemaToMetadataTransformer;
  74. }());
  75. /**
  76. * Convert Map, Set to Array
  77. */
  78. function convertToArray(val) {
  79. if (val instanceof Map) {
  80. return Array.from(val.values());
  81. }
  82. return Array.isArray(val) ? val : Array.from(val);
  83. }
  84. /**
  85. * This function returns the global object across Node and browsers.
  86. *
  87. * Note: `globalThis` is the standardized approach however it has been added to
  88. * Node.js in version 12. We need to include this snippet until Node 12 EOL.
  89. */
  90. function getGlobal() {
  91. if (typeof globalThis !== 'undefined') {
  92. return globalThis;
  93. }
  94. if (typeof global !== 'undefined') {
  95. return global;
  96. }
  97. // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  98. // @ts-ignore: Cannot find name 'window'.
  99. if (typeof window !== 'undefined') {
  100. // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  101. // @ts-ignore: Cannot find name 'window'.
  102. return window;
  103. }
  104. // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  105. // @ts-ignore: Cannot find name 'self'.
  106. if (typeof self !== 'undefined') {
  107. // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  108. // @ts-ignore: Cannot find name 'self'.
  109. return self;
  110. }
  111. }
  112. // https://github.com/TylorS/typed-is-promise/blob/abf1514e1b6961adfc75765476b0debb96b2c3ae/src/index.ts
  113. function isPromise(p) {
  114. return p !== null && typeof p === 'object' && typeof p.then === 'function';
  115. }
  116. var __values = (undefined && undefined.__values) || function(o) {
  117. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  118. if (m) return m.call(o);
  119. if (o && typeof o.length === "number") return {
  120. next: function () {
  121. if (o && i >= o.length) o = void 0;
  122. return { value: o && o[i++], done: !o };
  123. }
  124. };
  125. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  126. };
  127. var __read$2 = (undefined && undefined.__read) || function (o, n) {
  128. var m = typeof Symbol === "function" && o[Symbol.iterator];
  129. if (!m) return o;
  130. var i = m.call(o), r, ar = [], e;
  131. try {
  132. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  133. }
  134. catch (error) { e = { error: error }; }
  135. finally {
  136. try {
  137. if (r && !r.done && (m = i["return"])) m.call(i);
  138. }
  139. finally { if (e) throw e.error; }
  140. }
  141. return ar;
  142. };
  143. var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
  144. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  145. if (ar || !(i in from)) {
  146. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  147. ar[i] = from[i];
  148. }
  149. }
  150. return to.concat(ar || Array.prototype.slice.call(from));
  151. };
  152. /**
  153. * Storage all metadatas.
  154. */
  155. var MetadataStorage = /** @class */ (function () {
  156. function MetadataStorage() {
  157. // -------------------------------------------------------------------------
  158. // Private properties
  159. // -------------------------------------------------------------------------
  160. this.validationMetadatas = new Map();
  161. this.constraintMetadatas = new Map();
  162. }
  163. Object.defineProperty(MetadataStorage.prototype, "hasValidationMetaData", {
  164. get: function () {
  165. return !!this.validationMetadatas.size;
  166. },
  167. enumerable: false,
  168. configurable: true
  169. });
  170. // -------------------------------------------------------------------------
  171. // Public Methods
  172. // -------------------------------------------------------------------------
  173. /**
  174. * Adds a new validation metadata.
  175. */
  176. MetadataStorage.prototype.addValidationSchema = function (schema) {
  177. var _this = this;
  178. var validationMetadatas = new ValidationSchemaToMetadataTransformer().transform(schema);
  179. validationMetadatas.forEach(function (validationMetadata) { return _this.addValidationMetadata(validationMetadata); });
  180. };
  181. /**
  182. * Adds a new validation metadata.
  183. */
  184. MetadataStorage.prototype.addValidationMetadata = function (metadata) {
  185. var existingMetadata = this.validationMetadatas.get(metadata.target);
  186. if (existingMetadata) {
  187. existingMetadata.push(metadata);
  188. }
  189. else {
  190. this.validationMetadatas.set(metadata.target, [metadata]);
  191. }
  192. };
  193. /**
  194. * Adds a new constraint metadata.
  195. */
  196. MetadataStorage.prototype.addConstraintMetadata = function (metadata) {
  197. var existingMetadata = this.constraintMetadatas.get(metadata.target);
  198. if (existingMetadata) {
  199. existingMetadata.push(metadata);
  200. }
  201. else {
  202. this.constraintMetadatas.set(metadata.target, [metadata]);
  203. }
  204. };
  205. /**
  206. * Groups metadata by their property names.
  207. */
  208. MetadataStorage.prototype.groupByPropertyName = function (metadata) {
  209. var grouped = {};
  210. metadata.forEach(function (metadata) {
  211. if (!grouped[metadata.propertyName])
  212. grouped[metadata.propertyName] = [];
  213. grouped[metadata.propertyName].push(metadata);
  214. });
  215. return grouped;
  216. };
  217. /**
  218. * Gets all validation metadatas for the given object with the given groups.
  219. */
  220. MetadataStorage.prototype.getTargetValidationMetadatas = function (targetConstructor, targetSchema, always, strictGroups, groups) {
  221. var e_1, _a;
  222. var includeMetadataBecauseOfAlwaysOption = function (metadata) {
  223. // `metadata.always` overrides global default.
  224. if (typeof metadata.always !== 'undefined')
  225. return metadata.always;
  226. // `metadata.groups` overrides global default.
  227. if (metadata.groups && metadata.groups.length)
  228. return false;
  229. // Use global default.
  230. return always;
  231. };
  232. var excludeMetadataBecauseOfStrictGroupsOption = function (metadata) {
  233. if (strictGroups) {
  234. // Validation is not using groups.
  235. if (!groups || !groups.length) {
  236. // `metadata.groups` has at least one group.
  237. if (metadata.groups && metadata.groups.length)
  238. return true;
  239. }
  240. }
  241. return false;
  242. };
  243. // get directly related to a target metadatas
  244. var filteredForOriginalMetadatasSearch = this.validationMetadatas.get(targetConstructor) || [];
  245. var originalMetadatas = filteredForOriginalMetadatasSearch.filter(function (metadata) {
  246. if (metadata.target !== targetConstructor && metadata.target !== targetSchema)
  247. return false;
  248. if (includeMetadataBecauseOfAlwaysOption(metadata))
  249. return true;
  250. if (excludeMetadataBecauseOfStrictGroupsOption(metadata))
  251. return false;
  252. if (groups && groups.length > 0)
  253. return metadata.groups && !!metadata.groups.find(function (group) { return groups.indexOf(group) !== -1; });
  254. return true;
  255. });
  256. // get metadatas for inherited classes
  257. var filteredForInheritedMetadatasSearch = [];
  258. try {
  259. for (var _b = __values(this.validationMetadatas.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
  260. var _d = __read$2(_c.value, 2), key = _d[0], value = _d[1];
  261. if (targetConstructor.prototype instanceof key) {
  262. filteredForInheritedMetadatasSearch.push.apply(filteredForInheritedMetadatasSearch, __spreadArray([], __read$2(value), false));
  263. }
  264. }
  265. }
  266. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  267. finally {
  268. try {
  269. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  270. }
  271. finally { if (e_1) throw e_1.error; }
  272. }
  273. var inheritedMetadatas = filteredForInheritedMetadatasSearch.filter(function (metadata) {
  274. // if target is a string it's means we validate against a schema, and there is no inheritance support for schemas
  275. if (typeof metadata.target === 'string')
  276. return false;
  277. if (metadata.target === targetConstructor)
  278. return false;
  279. if (metadata.target instanceof Function && !(targetConstructor.prototype instanceof metadata.target))
  280. return false;
  281. if (includeMetadataBecauseOfAlwaysOption(metadata))
  282. return true;
  283. if (excludeMetadataBecauseOfStrictGroupsOption(metadata))
  284. return false;
  285. if (groups && groups.length > 0)
  286. return metadata.groups && !!metadata.groups.find(function (group) { return groups.indexOf(group) !== -1; });
  287. return true;
  288. });
  289. // filter out duplicate metadatas, prefer original metadatas instead of inherited metadatas
  290. var uniqueInheritedMetadatas = inheritedMetadatas.filter(function (inheritedMetadata) {
  291. return !originalMetadatas.find(function (originalMetadata) {
  292. return (originalMetadata.propertyName === inheritedMetadata.propertyName &&
  293. originalMetadata.type === inheritedMetadata.type);
  294. });
  295. });
  296. return originalMetadatas.concat(uniqueInheritedMetadatas);
  297. };
  298. /**
  299. * Gets all validator constraints for the given object.
  300. */
  301. MetadataStorage.prototype.getTargetValidatorConstraints = function (target) {
  302. return this.constraintMetadatas.get(target) || [];
  303. };
  304. return MetadataStorage;
  305. }());
  306. /**
  307. * Gets metadata storage.
  308. * Metadata storage follows the best practices and stores metadata in a global variable.
  309. */
  310. function getMetadataStorage() {
  311. var global = getGlobal();
  312. if (!global.classValidatorMetadataStorage) {
  313. global.classValidatorMetadataStorage = new MetadataStorage();
  314. }
  315. return global.classValidatorMetadataStorage;
  316. }
  317. /**
  318. * Validation error description.
  319. */
  320. var ValidationError = /** @class */ (function () {
  321. function ValidationError() {
  322. }
  323. /**
  324. *
  325. * @param shouldDecorate decorate the message with ANSI formatter escape codes for better readability
  326. * @param hasParent true when the error is a child of an another one
  327. * @param parentPath path as string to the parent of this property
  328. * @param showConstraintMessages show constraint messages instead of constraint names
  329. */
  330. ValidationError.prototype.toString = function (shouldDecorate, hasParent, parentPath, showConstraintMessages) {
  331. var _this = this;
  332. if (shouldDecorate === void 0) { shouldDecorate = false; }
  333. if (hasParent === void 0) { hasParent = false; }
  334. if (parentPath === void 0) { parentPath = ""; }
  335. if (showConstraintMessages === void 0) { showConstraintMessages = false; }
  336. var boldStart = shouldDecorate ? "\u001B[1m" : "";
  337. var boldEnd = shouldDecorate ? "\u001B[22m" : "";
  338. var constraintsToString = function () { var _a; return (showConstraintMessages ? Object.values : Object.keys)((_a = _this.constraints) !== null && _a !== void 0 ? _a : {}).join(", "); };
  339. var propConstraintFailed = function (propertyName) {
  340. return " - property ".concat(boldStart).concat(parentPath).concat(propertyName).concat(boldEnd, " has failed the following constraints: ").concat(boldStart).concat(constraintsToString()).concat(boldEnd, " \n");
  341. };
  342. if (!hasParent) {
  343. return ("An instance of ".concat(boldStart).concat(this.target ? this.target.constructor.name : 'an object').concat(boldEnd, " has failed the validation:\n") +
  344. (this.constraints ? propConstraintFailed(this.property) : "") +
  345. (this.children
  346. ? this.children
  347. .map(function (childError) { return childError.toString(shouldDecorate, true, _this.property, showConstraintMessages); })
  348. .join("")
  349. : ""));
  350. }
  351. else {
  352. // we format numbers as array indexes for better readability.
  353. var formattedProperty_1 = Number.isInteger(+this.property)
  354. ? "[".concat(this.property, "]")
  355. : "".concat(parentPath ? "." : "").concat(this.property);
  356. if (this.constraints) {
  357. return propConstraintFailed(formattedProperty_1);
  358. }
  359. else {
  360. return this.children
  361. ? this.children
  362. .map(function (childError) {
  363. return childError.toString(shouldDecorate, true, "".concat(parentPath).concat(formattedProperty_1), showConstraintMessages);
  364. })
  365. .join("")
  366. : "";
  367. }
  368. }
  369. };
  370. return ValidationError;
  371. }());
  372. /**
  373. * Validation types.
  374. */
  375. var ValidationTypes = /** @class */ (function () {
  376. function ValidationTypes() {
  377. }
  378. /**
  379. * Checks if validation type is valid.
  380. */
  381. ValidationTypes.isValid = function (type) {
  382. var _this = this;
  383. return (type !== 'isValid' &&
  384. type !== 'getMessage' &&
  385. Object.keys(this)
  386. .map(function (key) { return _this[key]; })
  387. .indexOf(type) !== -1);
  388. };
  389. /* system */
  390. ValidationTypes.CUSTOM_VALIDATION = 'customValidation'; // done
  391. ValidationTypes.NESTED_VALIDATION = 'nestedValidation'; // done
  392. ValidationTypes.PROMISE_VALIDATION = 'promiseValidation'; // done
  393. ValidationTypes.CONDITIONAL_VALIDATION = 'conditionalValidation'; // done
  394. ValidationTypes.WHITELIST = 'whitelistValidation'; // done
  395. ValidationTypes.IS_DEFINED = 'isDefined'; // done
  396. return ValidationTypes;
  397. }());
  398. /**
  399. * Convert the constraint to a string to be shown in an error
  400. */
  401. function constraintToString(constraint) {
  402. if (Array.isArray(constraint)) {
  403. return constraint.join(', ');
  404. }
  405. if (typeof constraint === 'symbol') {
  406. constraint = constraint.description;
  407. }
  408. return "".concat(constraint);
  409. }
  410. var ValidationUtils = /** @class */ (function () {
  411. function ValidationUtils() {
  412. }
  413. ValidationUtils.replaceMessageSpecialTokens = function (message, validationArguments) {
  414. var messageString;
  415. if (message instanceof Function) {
  416. messageString = message(validationArguments);
  417. }
  418. else if (typeof message === 'string') {
  419. messageString = message;
  420. }
  421. if (messageString && Array.isArray(validationArguments.constraints)) {
  422. validationArguments.constraints.forEach(function (constraint, index) {
  423. messageString = messageString.replace(new RegExp("\\$constraint".concat(index + 1), 'g'), constraintToString(constraint));
  424. });
  425. }
  426. if (messageString &&
  427. validationArguments.value !== undefined &&
  428. validationArguments.value !== null &&
  429. typeof validationArguments.value === 'string')
  430. messageString = messageString.replace(/\$value/g, validationArguments.value);
  431. if (messageString)
  432. messageString = messageString.replace(/\$property/g, validationArguments.property);
  433. if (messageString)
  434. messageString = messageString.replace(/\$target/g, validationArguments.targetName);
  435. return messageString;
  436. };
  437. return ValidationUtils;
  438. }());
  439. var __read$1 = (undefined && undefined.__read) || function (o, n) {
  440. var m = typeof Symbol === "function" && o[Symbol.iterator];
  441. if (!m) return o;
  442. var i = m.call(o), r, ar = [], e;
  443. try {
  444. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  445. }
  446. catch (error) { e = { error: error }; }
  447. finally {
  448. try {
  449. if (r && !r.done && (m = i["return"])) m.call(i);
  450. }
  451. finally { if (e) throw e.error; }
  452. }
  453. return ar;
  454. };
  455. /**
  456. * Executes validation over given object.
  457. */
  458. var ValidationExecutor = /** @class */ (function () {
  459. // -------------------------------------------------------------------------
  460. // Constructor
  461. // -------------------------------------------------------------------------
  462. function ValidationExecutor(validator, validatorOptions) {
  463. this.validator = validator;
  464. this.validatorOptions = validatorOptions;
  465. // -------------------------------------------------------------------------
  466. // Properties
  467. // -------------------------------------------------------------------------
  468. this.awaitingPromises = [];
  469. this.ignoreAsyncValidations = false;
  470. // -------------------------------------------------------------------------
  471. // Private Properties
  472. // -------------------------------------------------------------------------
  473. this.metadataStorage = getMetadataStorage();
  474. }
  475. // -------------------------------------------------------------------------
  476. // Public Methods
  477. // -------------------------------------------------------------------------
  478. ValidationExecutor.prototype.execute = function (object, targetSchema, validationErrors) {
  479. var _this = this;
  480. var _a, _b;
  481. /**
  482. * If there is no metadata registered it means possibly the dependencies are not flatterned and
  483. * more than one instance is used.
  484. *
  485. * TODO: This needs proper handling, forcing to use the same container or some other proper solution.
  486. */
  487. if (!this.metadataStorage.hasValidationMetaData && ((_a = this.validatorOptions) === null || _a === void 0 ? void 0 : _a.enableDebugMessages) === true) {
  488. console.warn("No validation metadata found. No validation will be performed. There are multiple possible reasons:\n" +
  489. " - There may be multiple class-validator versions installed. You will need to flatten your dependencies to fix the issue.\n" +
  490. " - This validation runs before any file with validation decorator was parsed by NodeJS.");
  491. }
  492. var groups = this.validatorOptions ? this.validatorOptions.groups : undefined;
  493. var strictGroups = (this.validatorOptions && this.validatorOptions.strictGroups) || false;
  494. var always = (this.validatorOptions && this.validatorOptions.always) || false;
  495. /** Forbid unknown values are turned on by default and any other value than false will enable it. */
  496. var forbidUnknownValues = ((_b = this.validatorOptions) === null || _b === void 0 ? void 0 : _b.forbidUnknownValues) === undefined || this.validatorOptions.forbidUnknownValues !== false;
  497. var targetMetadatas = this.metadataStorage.getTargetValidationMetadatas(object.constructor, targetSchema, always, strictGroups, groups);
  498. var groupedMetadatas = this.metadataStorage.groupByPropertyName(targetMetadatas);
  499. if (this.validatorOptions && forbidUnknownValues && !targetMetadatas.length) {
  500. var validationError = new ValidationError();
  501. if (!this.validatorOptions ||
  502. !this.validatorOptions.validationError ||
  503. this.validatorOptions.validationError.target === undefined ||
  504. this.validatorOptions.validationError.target === true)
  505. validationError.target = object;
  506. validationError.value = undefined;
  507. validationError.property = undefined;
  508. validationError.children = [];
  509. validationError.constraints = { unknownValue: 'an unknown value was passed to the validate function' };
  510. validationErrors.push(validationError);
  511. return;
  512. }
  513. if (this.validatorOptions && this.validatorOptions.whitelist)
  514. this.whitelist(object, groupedMetadatas, validationErrors);
  515. // General validation
  516. Object.keys(groupedMetadatas).forEach(function (propertyName) {
  517. var value = object[propertyName];
  518. var definedMetadatas = groupedMetadatas[propertyName].filter(function (metadata) { return metadata.type === ValidationTypes.IS_DEFINED; });
  519. var metadatas = groupedMetadatas[propertyName].filter(function (metadata) { return metadata.type !== ValidationTypes.IS_DEFINED && metadata.type !== ValidationTypes.WHITELIST; });
  520. if (value instanceof Promise &&
  521. metadatas.find(function (metadata) { return metadata.type === ValidationTypes.PROMISE_VALIDATION; })) {
  522. _this.awaitingPromises.push(value.then(function (resolvedValue) {
  523. _this.performValidations(object, resolvedValue, propertyName, definedMetadatas, metadatas, validationErrors);
  524. }));
  525. }
  526. else {
  527. _this.performValidations(object, value, propertyName, definedMetadatas, metadatas, validationErrors);
  528. }
  529. });
  530. };
  531. ValidationExecutor.prototype.whitelist = function (object, groupedMetadatas, validationErrors) {
  532. var _this = this;
  533. var notAllowedProperties = [];
  534. Object.keys(object).forEach(function (propertyName) {
  535. // does this property have no metadata?
  536. if (!groupedMetadatas[propertyName] || groupedMetadatas[propertyName].length === 0)
  537. notAllowedProperties.push(propertyName);
  538. });
  539. if (notAllowedProperties.length > 0) {
  540. if (this.validatorOptions && this.validatorOptions.forbidNonWhitelisted) {
  541. // throw errors
  542. notAllowedProperties.forEach(function (property) {
  543. var _a;
  544. var validationError = _this.generateValidationError(object, object[property], property);
  545. validationError.constraints = (_a = {}, _a[ValidationTypes.WHITELIST] = "property ".concat(property, " should not exist"), _a);
  546. validationError.children = undefined;
  547. validationErrors.push(validationError);
  548. });
  549. }
  550. else {
  551. // strip non allowed properties
  552. notAllowedProperties.forEach(function (property) { return delete object[property]; });
  553. }
  554. }
  555. };
  556. ValidationExecutor.prototype.stripEmptyErrors = function (errors) {
  557. var _this = this;
  558. return errors.filter(function (error) {
  559. if (error.children) {
  560. error.children = _this.stripEmptyErrors(error.children);
  561. }
  562. if (Object.keys(error.constraints).length === 0) {
  563. if (error.children.length === 0) {
  564. return false;
  565. }
  566. else {
  567. delete error.constraints;
  568. }
  569. }
  570. return true;
  571. });
  572. };
  573. // -------------------------------------------------------------------------
  574. // Private Methods
  575. // -------------------------------------------------------------------------
  576. ValidationExecutor.prototype.performValidations = function (object, value, propertyName, definedMetadatas, metadatas, validationErrors) {
  577. var customValidationMetadatas = metadatas.filter(function (metadata) { return metadata.type === ValidationTypes.CUSTOM_VALIDATION; });
  578. var nestedValidationMetadatas = metadatas.filter(function (metadata) { return metadata.type === ValidationTypes.NESTED_VALIDATION; });
  579. var conditionalValidationMetadatas = metadatas.filter(function (metadata) { return metadata.type === ValidationTypes.CONDITIONAL_VALIDATION; });
  580. var validationError = this.generateValidationError(object, value, propertyName);
  581. validationErrors.push(validationError);
  582. var canValidate = this.conditionalValidations(object, value, conditionalValidationMetadatas);
  583. if (!canValidate) {
  584. return;
  585. }
  586. // handle IS_DEFINED validation type the special way - it should work no matter skipUndefinedProperties/skipMissingProperties is set or not
  587. this.customValidations(object, value, definedMetadatas, validationError);
  588. this.mapContexts(object, value, definedMetadatas, validationError);
  589. if (value === undefined && this.validatorOptions && this.validatorOptions.skipUndefinedProperties === true) {
  590. return;
  591. }
  592. if (value === null && this.validatorOptions && this.validatorOptions.skipNullProperties === true) {
  593. return;
  594. }
  595. if ((value === null || value === undefined) &&
  596. this.validatorOptions &&
  597. this.validatorOptions.skipMissingProperties === true) {
  598. return;
  599. }
  600. this.customValidations(object, value, customValidationMetadatas, validationError);
  601. this.nestedValidations(value, nestedValidationMetadatas, validationError);
  602. this.mapContexts(object, value, metadatas, validationError);
  603. this.mapContexts(object, value, customValidationMetadatas, validationError);
  604. };
  605. ValidationExecutor.prototype.generateValidationError = function (object, value, propertyName) {
  606. var validationError = new ValidationError();
  607. if (!this.validatorOptions ||
  608. !this.validatorOptions.validationError ||
  609. this.validatorOptions.validationError.target === undefined ||
  610. this.validatorOptions.validationError.target === true)
  611. validationError.target = object;
  612. if (!this.validatorOptions ||
  613. !this.validatorOptions.validationError ||
  614. this.validatorOptions.validationError.value === undefined ||
  615. this.validatorOptions.validationError.value === true)
  616. validationError.value = value;
  617. validationError.property = propertyName;
  618. validationError.children = [];
  619. validationError.constraints = {};
  620. return validationError;
  621. };
  622. ValidationExecutor.prototype.conditionalValidations = function (object, value, metadatas) {
  623. return metadatas
  624. .map(function (metadata) { return metadata.constraints[0](object, value); })
  625. .reduce(function (resultA, resultB) { return resultA && resultB; }, true);
  626. };
  627. ValidationExecutor.prototype.customValidations = function (object, value, metadatas, error) {
  628. var _this = this;
  629. metadatas.forEach(function (metadata) {
  630. _this.metadataStorage.getTargetValidatorConstraints(metadata.constraintCls).forEach(function (customConstraintMetadata) {
  631. if (customConstraintMetadata.async && _this.ignoreAsyncValidations)
  632. return;
  633. if (_this.validatorOptions &&
  634. _this.validatorOptions.stopAtFirstError &&
  635. Object.keys(error.constraints || {}).length > 0)
  636. return;
  637. var validationArguments = {
  638. targetName: object.constructor ? object.constructor.name : undefined,
  639. property: metadata.propertyName,
  640. object: object,
  641. value: value,
  642. constraints: metadata.constraints,
  643. };
  644. if (!metadata.each || !(Array.isArray(value) || value instanceof Set || value instanceof Map)) {
  645. var validatedValue = customConstraintMetadata.instance.validate(value, validationArguments);
  646. if (isPromise(validatedValue)) {
  647. var promise = validatedValue.then(function (isValid) {
  648. if (!isValid) {
  649. var _a = __read$1(_this.createValidationError(object, value, metadata, customConstraintMetadata), 2), type = _a[0], message = _a[1];
  650. error.constraints[type] = message;
  651. if (metadata.context) {
  652. if (!error.contexts) {
  653. error.contexts = {};
  654. }
  655. error.contexts[type] = Object.assign(error.contexts[type] || {}, metadata.context);
  656. }
  657. }
  658. });
  659. _this.awaitingPromises.push(promise);
  660. }
  661. else {
  662. if (!validatedValue) {
  663. var _a = __read$1(_this.createValidationError(object, value, metadata, customConstraintMetadata), 2), type = _a[0], message = _a[1];
  664. error.constraints[type] = message;
  665. }
  666. }
  667. return;
  668. }
  669. // convert set and map into array
  670. var arrayValue = convertToArray(value);
  671. // Validation needs to be applied to each array item
  672. var validatedSubValues = arrayValue.map(function (subValue) {
  673. return customConstraintMetadata.instance.validate(subValue, validationArguments);
  674. });
  675. var validationIsAsync = validatedSubValues.some(function (validatedSubValue) {
  676. return isPromise(validatedSubValue);
  677. });
  678. if (validationIsAsync) {
  679. // Wrap plain values (if any) in promises, so that all are async
  680. var asyncValidatedSubValues = validatedSubValues.map(function (validatedSubValue) {
  681. return isPromise(validatedSubValue) ? validatedSubValue : Promise.resolve(validatedSubValue);
  682. });
  683. var asyncValidationIsFinishedPromise = Promise.all(asyncValidatedSubValues).then(function (flatValidatedValues) {
  684. var validationResult = flatValidatedValues.every(function (isValid) { return isValid; });
  685. if (!validationResult) {
  686. var _a = __read$1(_this.createValidationError(object, value, metadata, customConstraintMetadata), 2), type = _a[0], message = _a[1];
  687. error.constraints[type] = message;
  688. if (metadata.context) {
  689. if (!error.contexts) {
  690. error.contexts = {};
  691. }
  692. error.contexts[type] = Object.assign(error.contexts[type] || {}, metadata.context);
  693. }
  694. }
  695. });
  696. _this.awaitingPromises.push(asyncValidationIsFinishedPromise);
  697. return;
  698. }
  699. var validationResult = validatedSubValues.every(function (isValid) { return isValid; });
  700. if (!validationResult) {
  701. var _b = __read$1(_this.createValidationError(object, value, metadata, customConstraintMetadata), 2), type = _b[0], message = _b[1];
  702. error.constraints[type] = message;
  703. }
  704. });
  705. });
  706. };
  707. ValidationExecutor.prototype.nestedValidations = function (value, metadatas, error) {
  708. var _this = this;
  709. if (value === void 0) {
  710. return;
  711. }
  712. metadatas.forEach(function (metadata) {
  713. if (metadata.type !== ValidationTypes.NESTED_VALIDATION && metadata.type !== ValidationTypes.PROMISE_VALIDATION) {
  714. return;
  715. }
  716. else if (_this.validatorOptions &&
  717. _this.validatorOptions.stopAtFirstError &&
  718. Object.keys(error.constraints || {}).length > 0) {
  719. return;
  720. }
  721. if (Array.isArray(value) || value instanceof Set || value instanceof Map) {
  722. // Treats Set as an array - as index of Set value is value itself and it is common case to have Object as value
  723. var arrayLikeValue = value instanceof Set ? Array.from(value) : value;
  724. arrayLikeValue.forEach(function (subValue, index) {
  725. _this.performValidations(value, subValue, index.toString(), [], metadatas, error.children);
  726. });
  727. }
  728. else if (value instanceof Object) {
  729. var targetSchema = typeof metadata.target === 'string' ? metadata.target : metadata.target.name;
  730. _this.execute(value, targetSchema, error.children);
  731. }
  732. else {
  733. var _a = __read$1(_this.createValidationError(metadata.target, value, metadata), 2), type = _a[0], message = _a[1];
  734. error.constraints[type] = message;
  735. }
  736. });
  737. };
  738. ValidationExecutor.prototype.mapContexts = function (object, value, metadatas, error) {
  739. var _this = this;
  740. return metadatas.forEach(function (metadata) {
  741. if (metadata.context) {
  742. var customConstraint = void 0;
  743. if (metadata.type === ValidationTypes.CUSTOM_VALIDATION) {
  744. var customConstraints = _this.metadataStorage.getTargetValidatorConstraints(metadata.constraintCls);
  745. customConstraint = customConstraints[0];
  746. }
  747. var type = _this.getConstraintType(metadata, customConstraint);
  748. if (error.constraints[type]) {
  749. if (!error.contexts) {
  750. error.contexts = {};
  751. }
  752. error.contexts[type] = Object.assign(error.contexts[type] || {}, metadata.context);
  753. }
  754. }
  755. });
  756. };
  757. ValidationExecutor.prototype.createValidationError = function (object, value, metadata, customValidatorMetadata) {
  758. var targetName = object.constructor ? object.constructor.name : undefined;
  759. var type = this.getConstraintType(metadata, customValidatorMetadata);
  760. var validationArguments = {
  761. targetName: targetName,
  762. property: metadata.propertyName,
  763. object: object,
  764. value: value,
  765. constraints: metadata.constraints,
  766. };
  767. var message = metadata.message || '';
  768. if (!metadata.message &&
  769. (!this.validatorOptions || (this.validatorOptions && !this.validatorOptions.dismissDefaultMessages))) {
  770. if (customValidatorMetadata && customValidatorMetadata.instance.defaultMessage instanceof Function) {
  771. message = customValidatorMetadata.instance.defaultMessage(validationArguments);
  772. }
  773. }
  774. var messageString = ValidationUtils.replaceMessageSpecialTokens(message, validationArguments);
  775. return [type, messageString];
  776. };
  777. ValidationExecutor.prototype.getConstraintType = function (metadata, customValidatorMetadata) {
  778. var type = customValidatorMetadata && customValidatorMetadata.name ? customValidatorMetadata.name : metadata.type;
  779. return type;
  780. };
  781. return ValidationExecutor;
  782. }());
  783. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  784. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  785. return new (P || (P = Promise))(function (resolve, reject) {
  786. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  787. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  788. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  789. step((generator = generator.apply(thisArg, _arguments || [])).next());
  790. });
  791. };
  792. var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
  793. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  794. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  795. function verb(n) { return function (v) { return step([n, v]); }; }
  796. function step(op) {
  797. if (f) throw new TypeError("Generator is already executing.");
  798. while (g && (g = 0, op[0] && (_ = 0)), _) try {
  799. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  800. if (y = 0, t) op = [op[0] & 2, t.value];
  801. switch (op[0]) {
  802. case 0: case 1: t = op; break;
  803. case 4: _.label++; return { value: op[1], done: false };
  804. case 5: _.label++; y = op[1]; op = [0]; continue;
  805. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  806. default:
  807. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  808. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  809. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  810. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  811. if (t[2]) _.ops.pop();
  812. _.trys.pop(); continue;
  813. }
  814. op = body.call(thisArg, _);
  815. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  816. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  817. }
  818. };
  819. /**
  820. * Validator performs validation of the given object based on its metadata.
  821. */
  822. var Validator = /** @class */ (function () {
  823. function Validator() {
  824. }
  825. /**
  826. * Performs validation of the given object based on decorators or validation schema.
  827. */
  828. Validator.prototype.validate = function (objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions) {
  829. return this.coreValidate(objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions);
  830. };
  831. /**
  832. * Performs validation of the given object based on decorators or validation schema and reject on error.
  833. */
  834. Validator.prototype.validateOrReject = function (objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions) {
  835. return __awaiter(this, void 0, void 0, function () {
  836. var errors;
  837. return __generator(this, function (_a) {
  838. switch (_a.label) {
  839. case 0: return [4 /*yield*/, this.coreValidate(objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions)];
  840. case 1:
  841. errors = _a.sent();
  842. if (errors.length)
  843. return [2 /*return*/, Promise.reject(errors)];
  844. return [2 /*return*/];
  845. }
  846. });
  847. });
  848. };
  849. /**
  850. * Performs validation of the given object based on decorators or validation schema.
  851. */
  852. Validator.prototype.validateSync = function (objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions) {
  853. var object = typeof objectOrSchemaName === 'string' ? objectOrValidationOptions : objectOrSchemaName;
  854. var options = typeof objectOrSchemaName === 'string' ? maybeValidatorOptions : objectOrValidationOptions;
  855. var schema = typeof objectOrSchemaName === 'string' ? objectOrSchemaName : undefined;
  856. var executor = new ValidationExecutor(this, options);
  857. executor.ignoreAsyncValidations = true;
  858. var validationErrors = [];
  859. executor.execute(object, schema, validationErrors);
  860. return executor.stripEmptyErrors(validationErrors);
  861. };
  862. // -------------------------------------------------------------------------
  863. // Private Properties
  864. // -------------------------------------------------------------------------
  865. /**
  866. * Performs validation of the given object based on decorators or validation schema.
  867. * Common method for `validateOrReject` and `validate` methods.
  868. */
  869. Validator.prototype.coreValidate = function (objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions) {
  870. var object = typeof objectOrSchemaName === 'string' ? objectOrValidationOptions : objectOrSchemaName;
  871. var options = typeof objectOrSchemaName === 'string' ? maybeValidatorOptions : objectOrValidationOptions;
  872. var schema = typeof objectOrSchemaName === 'string' ? objectOrSchemaName : undefined;
  873. var executor = new ValidationExecutor(this, options);
  874. var validationErrors = [];
  875. executor.execute(object, schema, validationErrors);
  876. return Promise.all(executor.awaitingPromises).then(function () {
  877. return executor.stripEmptyErrors(validationErrors);
  878. });
  879. };
  880. return Validator;
  881. }());
  882. /**
  883. * Container to be used by this library for inversion control. If container was not implicitly set then by default
  884. * container simply creates a new instance of the given class.
  885. */
  886. var defaultContainer = new (/** @class */ (function () {
  887. function class_1() {
  888. this.instances = [];
  889. }
  890. class_1.prototype.get = function (someClass) {
  891. var instance = this.instances.find(function (instance) { return instance.type === someClass; });
  892. if (!instance) {
  893. instance = { type: someClass, object: new someClass() };
  894. this.instances.push(instance);
  895. }
  896. return instance.object;
  897. };
  898. return class_1;
  899. }()))();
  900. var userContainer;
  901. var userContainerOptions;
  902. /**
  903. * Sets container to be used by this library.
  904. */
  905. function useContainer(iocContainer, options) {
  906. userContainer = iocContainer;
  907. userContainerOptions = options;
  908. }
  909. /**
  910. * Gets the IOC container used by this library.
  911. */
  912. function getFromContainer(someClass) {
  913. if (userContainer) {
  914. try {
  915. var instance = userContainer.get(someClass);
  916. if (instance)
  917. return instance;
  918. if (!userContainerOptions || !userContainerOptions.fallback)
  919. return instance;
  920. }
  921. catch (error) {
  922. if (!userContainerOptions || !userContainerOptions.fallbackOnErrors)
  923. throw error;
  924. }
  925. }
  926. return defaultContainer.get(someClass);
  927. }
  928. /**
  929. * If object has both allowed and not allowed properties a validation error will be thrown.
  930. */
  931. function Allow(validationOptions) {
  932. return function (object, propertyName) {
  933. var args = {
  934. type: ValidationTypes.WHITELIST,
  935. target: object.constructor,
  936. propertyName: propertyName,
  937. validationOptions: validationOptions,
  938. };
  939. getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
  940. };
  941. }
  942. /**
  943. * This metadata interface contains information for custom validators.
  944. */
  945. var ConstraintMetadata = /** @class */ (function () {
  946. // -------------------------------------------------------------------------
  947. // Constructor
  948. // -------------------------------------------------------------------------
  949. function ConstraintMetadata(target, name, async) {
  950. if (async === void 0) { async = false; }
  951. this.target = target;
  952. this.name = name;
  953. this.async = async;
  954. }
  955. Object.defineProperty(ConstraintMetadata.prototype, "instance", {
  956. // -------------------------------------------------------------------------
  957. // Accessors
  958. // -------------------------------------------------------------------------
  959. /**
  960. * Instance of the target custom validation class which performs validation.
  961. */
  962. get: function () {
  963. return getFromContainer(this.target);
  964. },
  965. enumerable: false,
  966. configurable: true
  967. });
  968. return ConstraintMetadata;
  969. }());
  970. /**
  971. * Registers a custom validation decorator.
  972. */
  973. function registerDecorator(options) {
  974. var constraintCls;
  975. if (options.validator instanceof Function) {
  976. constraintCls = options.validator;
  977. var constraintClasses = getFromContainer(MetadataStorage).getTargetValidatorConstraints(options.validator);
  978. if (constraintClasses.length > 1) {
  979. throw "More than one implementation of ValidatorConstraintInterface found for validator on: ".concat(options.target.name, ":").concat(options.propertyName);
  980. }
  981. }
  982. else {
  983. var validator_1 = options.validator;
  984. constraintCls = /** @class */ (function () {
  985. function CustomConstraint() {
  986. }
  987. CustomConstraint.prototype.validate = function (value, validationArguments) {
  988. return validator_1.validate(value, validationArguments);
  989. };
  990. CustomConstraint.prototype.defaultMessage = function (validationArguments) {
  991. if (validator_1.defaultMessage) {
  992. return validator_1.defaultMessage(validationArguments);
  993. }
  994. return '';
  995. };
  996. return CustomConstraint;
  997. }());
  998. getMetadataStorage().addConstraintMetadata(new ConstraintMetadata(constraintCls, options.name, options.async));
  999. }
  1000. var validationMetadataArgs = {
  1001. type: options.name && ValidationTypes.isValid(options.name) ? options.name : ValidationTypes.CUSTOM_VALIDATION,
  1002. name: options.name,
  1003. target: options.target,
  1004. propertyName: options.propertyName,
  1005. validationOptions: options.options,
  1006. constraintCls: constraintCls,
  1007. constraints: options.constraints,
  1008. };
  1009. getMetadataStorage().addValidationMetadata(new ValidationMetadata(validationMetadataArgs));
  1010. }
  1011. function buildMessage(impl, validationOptions) {
  1012. return function (validationArguments) {
  1013. var eachPrefix = validationOptions && validationOptions.each ? 'each value in ' : '';
  1014. return impl(eachPrefix, validationArguments);
  1015. };
  1016. }
  1017. function ValidateBy(options, validationOptions) {
  1018. return function (object, propertyName) {
  1019. registerDecorator({
  1020. name: options.name,
  1021. target: object.constructor,
  1022. propertyName: propertyName,
  1023. options: validationOptions,
  1024. constraints: options.constraints,
  1025. validator: options.validator,
  1026. });
  1027. };
  1028. }
  1029. // isDefined is (yet) a special case
  1030. var IS_DEFINED = ValidationTypes.IS_DEFINED;
  1031. /**
  1032. * Checks if value is defined (!== undefined, !== null).
  1033. */
  1034. function isDefined(value) {
  1035. return value !== undefined && value !== null;
  1036. }
  1037. /**
  1038. * Checks if value is defined (!== undefined, !== null).
  1039. */
  1040. function IsDefined(validationOptions) {
  1041. return ValidateBy({
  1042. name: IS_DEFINED,
  1043. validator: {
  1044. validate: function (value) { return isDefined(value); },
  1045. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property should not be null or undefined'; }, validationOptions),
  1046. },
  1047. }, validationOptions);
  1048. }
  1049. /**
  1050. * Checks if value is missing and if so, ignores all validators.
  1051. */
  1052. function IsOptional(validationOptions) {
  1053. return function (object, propertyName) {
  1054. var args = {
  1055. type: ValidationTypes.CONDITIONAL_VALIDATION,
  1056. target: object.constructor,
  1057. propertyName: propertyName,
  1058. constraints: [
  1059. function (object, value) {
  1060. return object[propertyName] !== null && object[propertyName] !== undefined;
  1061. },
  1062. ],
  1063. validationOptions: validationOptions,
  1064. };
  1065. getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
  1066. };
  1067. }
  1068. /**
  1069. * Registers custom validator class.
  1070. */
  1071. function ValidatorConstraint(options) {
  1072. return function (target) {
  1073. var isAsync = options && options.async;
  1074. var name = options && options.name ? options.name : '';
  1075. if (!name) {
  1076. name = target.name;
  1077. if (!name)
  1078. // generate name if it was not given
  1079. name = name.replace(/\.?([A-Z]+)/g, function (x, y) { return '_' + y.toLowerCase(); }).replace(/^_/, '');
  1080. }
  1081. var metadata = new ConstraintMetadata(target, name, isAsync);
  1082. getMetadataStorage().addConstraintMetadata(metadata);
  1083. };
  1084. }
  1085. function Validate(constraintClass, constraintsOrValidationOptions, maybeValidationOptions) {
  1086. return function (object, propertyName) {
  1087. var args = {
  1088. type: ValidationTypes.CUSTOM_VALIDATION,
  1089. target: object.constructor,
  1090. propertyName: propertyName,
  1091. constraintCls: constraintClass,
  1092. constraints: Array.isArray(constraintsOrValidationOptions) ? constraintsOrValidationOptions : undefined,
  1093. validationOptions: !Array.isArray(constraintsOrValidationOptions)
  1094. ? constraintsOrValidationOptions
  1095. : maybeValidationOptions,
  1096. };
  1097. getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
  1098. };
  1099. }
  1100. /**
  1101. * Ignores the other validators on a property when the provided condition function returns false.
  1102. */
  1103. function ValidateIf(condition, validationOptions) {
  1104. return function (object, propertyName) {
  1105. var args = {
  1106. type: ValidationTypes.CONDITIONAL_VALIDATION,
  1107. target: object.constructor,
  1108. propertyName: propertyName,
  1109. constraints: [condition],
  1110. validationOptions: validationOptions,
  1111. };
  1112. getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
  1113. };
  1114. }
  1115. var __assign = (undefined && undefined.__assign) || function () {
  1116. __assign = Object.assign || function(t) {
  1117. for (var s, i = 1, n = arguments.length; i < n; i++) {
  1118. s = arguments[i];
  1119. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  1120. t[p] = s[p];
  1121. }
  1122. return t;
  1123. };
  1124. return __assign.apply(this, arguments);
  1125. };
  1126. /**
  1127. * Objects / object arrays marked with this decorator will also be validated.
  1128. */
  1129. function ValidateNested(validationOptions) {
  1130. var opts = __assign({}, validationOptions);
  1131. var eachPrefix = opts.each ? 'each value in ' : '';
  1132. opts.message = opts.message || eachPrefix + 'nested property $property must be either object or array';
  1133. return function (object, propertyName) {
  1134. var args = {
  1135. type: ValidationTypes.NESTED_VALIDATION,
  1136. target: object.constructor,
  1137. propertyName: propertyName,
  1138. validationOptions: opts,
  1139. };
  1140. getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
  1141. };
  1142. }
  1143. /**
  1144. * Resolve promise before validation
  1145. */
  1146. function ValidatePromise(validationOptions) {
  1147. return function (object, propertyName) {
  1148. var args = {
  1149. type: ValidationTypes.PROMISE_VALIDATION,
  1150. target: object.constructor,
  1151. propertyName: propertyName,
  1152. validationOptions: validationOptions,
  1153. };
  1154. getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
  1155. };
  1156. }
  1157. function getDefaultExportFromCjs (x) {
  1158. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  1159. }
  1160. var isLatLong$1 = {exports: {}};
  1161. var assertString = {exports: {}};
  1162. (function (module, exports) {
  1163. Object.defineProperty(exports, "__esModule", {
  1164. value: true
  1165. });
  1166. exports.default = assertString;
  1167. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1168. function assertString(input) {
  1169. var isString = typeof input === 'string' || input instanceof String;
  1170. if (!isString) {
  1171. var invalidType = _typeof(input);
  1172. if (input === null) invalidType = 'null';else if (invalidType === 'object') invalidType = input.constructor.name;
  1173. throw new TypeError("Expected a string but received a ".concat(invalidType));
  1174. }
  1175. }
  1176. module.exports = exports.default;
  1177. module.exports.default = exports.default;
  1178. } (assertString, assertString.exports));
  1179. var merge = {exports: {}};
  1180. (function (module, exports) {
  1181. Object.defineProperty(exports, "__esModule", {
  1182. value: true
  1183. });
  1184. exports.default = merge;
  1185. function merge() {
  1186. var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1187. var defaults = arguments.length > 1 ? arguments[1] : undefined;
  1188. for (var key in defaults) {
  1189. if (typeof obj[key] === 'undefined') {
  1190. obj[key] = defaults[key];
  1191. }
  1192. }
  1193. return obj;
  1194. }
  1195. module.exports = exports.default;
  1196. module.exports.default = exports.default;
  1197. } (merge, merge.exports));
  1198. (function (module, exports) {
  1199. Object.defineProperty(exports, "__esModule", {
  1200. value: true
  1201. });
  1202. exports.default = isLatLong;
  1203. var _assertString = _interopRequireDefault(assertString.exports);
  1204. var _merge = _interopRequireDefault(merge.exports);
  1205. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1206. var lat = /^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/;
  1207. var long = /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/;
  1208. var latDMS = /^(([1-8]?\d)\D+([1-5]?\d|60)\D+([1-5]?\d|60)(\.\d+)?|90\D+0\D+0)\D+[NSns]?$/i;
  1209. var longDMS = /^\s*([1-7]?\d{1,2}\D+([1-5]?\d|60)\D+([1-5]?\d|60)(\.\d+)?|180\D+0\D+0)\D+[EWew]?$/i;
  1210. var defaultLatLongOptions = {
  1211. checkDMS: false
  1212. };
  1213. function isLatLong(str, options) {
  1214. (0, _assertString.default)(str);
  1215. options = (0, _merge.default)(options, defaultLatLongOptions);
  1216. if (!str.includes(',')) return false;
  1217. var pair = str.split(',');
  1218. if (pair[0].startsWith('(') && !pair[1].endsWith(')') || pair[1].endsWith(')') && !pair[0].startsWith('(')) return false;
  1219. if (options.checkDMS) {
  1220. return latDMS.test(pair[0]) && longDMS.test(pair[1]);
  1221. }
  1222. return lat.test(pair[0]) && long.test(pair[1]);
  1223. }
  1224. module.exports = exports.default;
  1225. module.exports.default = exports.default;
  1226. } (isLatLong$1, isLatLong$1.exports));
  1227. var isLatLongValidator = /*@__PURE__*/getDefaultExportFromCjs(isLatLong$1.exports);
  1228. var IS_LATLONG = 'isLatLong';
  1229. /**
  1230. * Checks if a value is string in format a "latitude,longitude".
  1231. */
  1232. function isLatLong(value) {
  1233. return typeof value === 'string' && isLatLongValidator(value);
  1234. }
  1235. /**
  1236. * Checks if a value is string in format a "latitude,longitude".
  1237. */
  1238. function IsLatLong(validationOptions) {
  1239. return ValidateBy({
  1240. name: IS_LATLONG,
  1241. validator: {
  1242. validate: function (value, args) { return isLatLong(value); },
  1243. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a latitude,longitude string'; }, validationOptions),
  1244. },
  1245. }, validationOptions);
  1246. }
  1247. var IS_LATITUDE = 'isLatitude';
  1248. /**
  1249. * Checks if a given value is a latitude.
  1250. */
  1251. function isLatitude(value) {
  1252. return (typeof value === 'number' || typeof value === 'string') && isLatLong("".concat(value, ",0"));
  1253. }
  1254. /**
  1255. * Checks if a given value is a latitude.
  1256. */
  1257. function IsLatitude(validationOptions) {
  1258. return ValidateBy({
  1259. name: IS_LATITUDE,
  1260. validator: {
  1261. validate: function (value, args) { return isLatitude(value); },
  1262. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a latitude string or number'; }, validationOptions),
  1263. },
  1264. }, validationOptions);
  1265. }
  1266. var IS_LONGITUDE = 'isLongitude';
  1267. /**
  1268. * Checks if a given value is a longitude.
  1269. */
  1270. function isLongitude(value) {
  1271. return (typeof value === 'number' || typeof value === 'string') && isLatLong("0,".concat(value));
  1272. }
  1273. /**
  1274. * Checks if a given value is a longitude.
  1275. */
  1276. function IsLongitude(validationOptions) {
  1277. return ValidateBy({
  1278. name: IS_LONGITUDE,
  1279. validator: {
  1280. validate: function (value, args) { return isLongitude(value); },
  1281. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a longitude string or number'; }, validationOptions),
  1282. },
  1283. }, validationOptions);
  1284. }
  1285. var EQUALS = 'equals';
  1286. /**
  1287. * Checks if value matches ("===") the comparison.
  1288. */
  1289. function equals$1(value, comparison) {
  1290. return value === comparison;
  1291. }
  1292. /**
  1293. * Checks if value matches ("===") the comparison.
  1294. */
  1295. function Equals(comparison, validationOptions) {
  1296. return ValidateBy({
  1297. name: EQUALS,
  1298. constraints: [comparison],
  1299. validator: {
  1300. validate: function (value, args) { return equals$1(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  1301. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be equal to $constraint1'; }, validationOptions),
  1302. },
  1303. }, validationOptions);
  1304. }
  1305. var NOT_EQUALS = 'notEquals';
  1306. /**
  1307. * Checks if value does not match ("!==") the comparison.
  1308. */
  1309. function notEquals(value, comparison) {
  1310. return value !== comparison;
  1311. }
  1312. /**
  1313. * Checks if value does not match ("!==") the comparison.
  1314. */
  1315. function NotEquals(comparison, validationOptions) {
  1316. return ValidateBy({
  1317. name: NOT_EQUALS,
  1318. constraints: [comparison],
  1319. validator: {
  1320. validate: function (value, args) { return notEquals(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  1321. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property should not be equal to $constraint1'; }, validationOptions),
  1322. },
  1323. }, validationOptions);
  1324. }
  1325. var IS_EMPTY = 'isEmpty';
  1326. /**
  1327. * Checks if given value is empty (=== '', === null, === undefined).
  1328. */
  1329. function isEmpty$1(value) {
  1330. return value === '' || value === null || value === undefined;
  1331. }
  1332. /**
  1333. * Checks if given value is empty (=== '', === null, === undefined).
  1334. */
  1335. function IsEmpty(validationOptions) {
  1336. return ValidateBy({
  1337. name: IS_EMPTY,
  1338. validator: {
  1339. validate: function (value, args) { return isEmpty$1(value); },
  1340. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be empty'; }, validationOptions),
  1341. },
  1342. }, validationOptions);
  1343. }
  1344. var IS_NOT_EMPTY = 'isNotEmpty';
  1345. /**
  1346. * Checks if given value is not empty (!== '', !== null, !== undefined).
  1347. */
  1348. function isNotEmpty(value) {
  1349. return value !== '' && value !== null && value !== undefined;
  1350. }
  1351. /**
  1352. * Checks if given value is not empty (!== '', !== null, !== undefined).
  1353. */
  1354. function IsNotEmpty(validationOptions) {
  1355. return ValidateBy({
  1356. name: IS_NOT_EMPTY,
  1357. validator: {
  1358. validate: function (value, args) { return isNotEmpty(value); },
  1359. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property should not be empty'; }, validationOptions),
  1360. },
  1361. }, validationOptions);
  1362. }
  1363. var IS_IN = 'isIn';
  1364. /**
  1365. * Checks if given value is in a array of allowed values.
  1366. */
  1367. function isIn$1(value, possibleValues) {
  1368. return !Array.isArray(possibleValues) || possibleValues.some(function (possibleValue) { return possibleValue === value; });
  1369. }
  1370. /**
  1371. * Checks if given value is in a array of allowed values.
  1372. */
  1373. function IsIn(values, validationOptions) {
  1374. return ValidateBy({
  1375. name: IS_IN,
  1376. constraints: [values],
  1377. validator: {
  1378. validate: function (value, args) { return isIn$1(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  1379. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be one of the following values: $constraint1'; }, validationOptions),
  1380. },
  1381. }, validationOptions);
  1382. }
  1383. var IS_NOT_IN = 'isNotIn';
  1384. /**
  1385. * Checks if given value not in a array of allowed values.
  1386. */
  1387. function isNotIn(value, possibleValues) {
  1388. return !Array.isArray(possibleValues) || !possibleValues.some(function (possibleValue) { return possibleValue === value; });
  1389. }
  1390. /**
  1391. * Checks if given value not in a array of allowed values.
  1392. */
  1393. function IsNotIn(values, validationOptions) {
  1394. return ValidateBy({
  1395. name: IS_NOT_IN,
  1396. constraints: [values],
  1397. validator: {
  1398. validate: function (value, args) { return isNotIn(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  1399. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property should not be one of the following values: $constraint1'; }, validationOptions),
  1400. },
  1401. }, validationOptions);
  1402. }
  1403. var isDivisibleBy$1 = {exports: {}};
  1404. var toFloat = {exports: {}};
  1405. var isFloat$1 = {};
  1406. var alpha$1 = {};
  1407. Object.defineProperty(alpha$1, "__esModule", {
  1408. value: true
  1409. });
  1410. alpha$1.commaDecimal = alpha$1.dotDecimal = alpha$1.farsiLocales = alpha$1.arabicLocales = alpha$1.englishLocales = alpha$1.decimal = alpha$1.alphanumeric = alpha$1.alpha = void 0;
  1411. var alpha = {
  1412. 'en-US': /^[A-Z]+$/i,
  1413. 'az-AZ': /^[A-VXYZÇƏĞİıÖŞÜ]+$/i,
  1414. 'bg-BG': /^[А-Я]+$/i,
  1415. 'cs-CZ': /^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,
  1416. 'da-DK': /^[A-ZÆØÅ]+$/i,
  1417. 'de-DE': /^[A-ZÄÖÜß]+$/i,
  1418. 'el-GR': /^[Α-ώ]+$/i,
  1419. 'es-ES': /^[A-ZÁÉÍÑÓÚÜ]+$/i,
  1420. 'fa-IR': /^[ابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی]+$/i,
  1421. 'fi-FI': /^[A-ZÅÄÖ]+$/i,
  1422. 'fr-FR': /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
  1423. 'it-IT': /^[A-ZÀÉÈÌÎÓÒÙ]+$/i,
  1424. 'nb-NO': /^[A-ZÆØÅ]+$/i,
  1425. 'nl-NL': /^[A-ZÁÉËÏÓÖÜÚ]+$/i,
  1426. 'nn-NO': /^[A-ZÆØÅ]+$/i,
  1427. 'hu-HU': /^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i,
  1428. 'pl-PL': /^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,
  1429. 'pt-PT': /^[A-ZÃÁÀÂÄÇÉÊËÍÏÕÓÔÖÚÜ]+$/i,
  1430. 'ru-RU': /^[А-ЯЁ]+$/i,
  1431. 'sl-SI': /^[A-ZČĆĐŠŽ]+$/i,
  1432. 'sk-SK': /^[A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,
  1433. 'sr-RS@latin': /^[A-ZČĆŽŠĐ]+$/i,
  1434. 'sr-RS': /^[А-ЯЂЈЉЊЋЏ]+$/i,
  1435. 'sv-SE': /^[A-ZÅÄÖ]+$/i,
  1436. 'th-TH': /^[ก-๐\s]+$/i,
  1437. 'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i,
  1438. 'uk-UA': /^[А-ЩЬЮЯЄIЇҐі]+$/i,
  1439. 'vi-VN': /^[A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$/i,
  1440. 'ku-IQ': /^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
  1441. ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
  1442. he: /^[א-ת]+$/,
  1443. fa: /^['آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی']+$/i,
  1444. 'hi-IN': /^[\u0900-\u0961]+[\u0972-\u097F]*$/i
  1445. };
  1446. alpha$1.alpha = alpha;
  1447. var alphanumeric = {
  1448. 'en-US': /^[0-9A-Z]+$/i,
  1449. 'az-AZ': /^[0-9A-VXYZÇƏĞİıÖŞÜ]+$/i,
  1450. 'bg-BG': /^[0-9А-Я]+$/i,
  1451. 'cs-CZ': /^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,
  1452. 'da-DK': /^[0-9A-ZÆØÅ]+$/i,
  1453. 'de-DE': /^[0-9A-ZÄÖÜß]+$/i,
  1454. 'el-GR': /^[0-9Α-ω]+$/i,
  1455. 'es-ES': /^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,
  1456. 'fi-FI': /^[0-9A-ZÅÄÖ]+$/i,
  1457. 'fr-FR': /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
  1458. 'it-IT': /^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i,
  1459. 'hu-HU': /^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i,
  1460. 'nb-NO': /^[0-9A-ZÆØÅ]+$/i,
  1461. 'nl-NL': /^[0-9A-ZÁÉËÏÓÖÜÚ]+$/i,
  1462. 'nn-NO': /^[0-9A-ZÆØÅ]+$/i,
  1463. 'pl-PL': /^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i,
  1464. 'pt-PT': /^[0-9A-ZÃÁÀÂÄÇÉÊËÍÏÕÓÔÖÚÜ]+$/i,
  1465. 'ru-RU': /^[0-9А-ЯЁ]+$/i,
  1466. 'sl-SI': /^[0-9A-ZČĆĐŠŽ]+$/i,
  1467. 'sk-SK': /^[0-9A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,
  1468. 'sr-RS@latin': /^[0-9A-ZČĆŽŠĐ]+$/i,
  1469. 'sr-RS': /^[0-9А-ЯЂЈЉЊЋЏ]+$/i,
  1470. 'sv-SE': /^[0-9A-ZÅÄÖ]+$/i,
  1471. 'th-TH': /^[ก-๙\s]+$/i,
  1472. 'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i,
  1473. 'uk-UA': /^[0-9А-ЩЬЮЯЄIЇҐі]+$/i,
  1474. 'ku-IQ': /^[٠١٢٣٤٥٦٧٨٩0-9ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
  1475. 'vi-VN': /^[0-9A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$/i,
  1476. ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
  1477. he: /^[0-9א-ת]+$/,
  1478. fa: /^['0-9آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی۱۲۳۴۵۶۷۸۹۰']+$/i,
  1479. 'hi-IN': /^[\u0900-\u0963]+[\u0966-\u097F]*$/i
  1480. };
  1481. alpha$1.alphanumeric = alphanumeric;
  1482. var decimal = {
  1483. 'en-US': '.',
  1484. ar: '٫'
  1485. };
  1486. alpha$1.decimal = decimal;
  1487. var englishLocales = ['AU', 'GB', 'HK', 'IN', 'NZ', 'ZA', 'ZM'];
  1488. alpha$1.englishLocales = englishLocales;
  1489. for (var locale, i = 0; i < englishLocales.length; i++) {
  1490. locale = "en-".concat(englishLocales[i]);
  1491. alpha[locale] = alpha['en-US'];
  1492. alphanumeric[locale] = alphanumeric['en-US'];
  1493. decimal[locale] = decimal['en-US'];
  1494. } // Source: http://www.localeplanet.com/java/
  1495. var arabicLocales = ['AE', 'BH', 'DZ', 'EG', 'IQ', 'JO', 'KW', 'LB', 'LY', 'MA', 'QM', 'QA', 'SA', 'SD', 'SY', 'TN', 'YE'];
  1496. alpha$1.arabicLocales = arabicLocales;
  1497. for (var _locale, _i = 0; _i < arabicLocales.length; _i++) {
  1498. _locale = "ar-".concat(arabicLocales[_i]);
  1499. alpha[_locale] = alpha.ar;
  1500. alphanumeric[_locale] = alphanumeric.ar;
  1501. decimal[_locale] = decimal.ar;
  1502. }
  1503. var farsiLocales = ['IR', 'AF'];
  1504. alpha$1.farsiLocales = farsiLocales;
  1505. for (var _locale2, _i2 = 0; _i2 < farsiLocales.length; _i2++) {
  1506. _locale2 = "fa-".concat(farsiLocales[_i2]);
  1507. alphanumeric[_locale2] = alphanumeric.fa;
  1508. decimal[_locale2] = decimal.ar;
  1509. } // Source: https://en.wikipedia.org/wiki/Decimal_mark
  1510. var dotDecimal = ['ar-EG', 'ar-LB', 'ar-LY'];
  1511. alpha$1.dotDecimal = dotDecimal;
  1512. var commaDecimal = ['bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-ZM', 'es-ES', 'fr-CA', 'fr-FR', 'id-ID', 'it-IT', 'ku-IQ', 'hi-IN', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-PL', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA', 'vi-VN'];
  1513. alpha$1.commaDecimal = commaDecimal;
  1514. for (var _i3 = 0; _i3 < dotDecimal.length; _i3++) {
  1515. decimal[dotDecimal[_i3]] = decimal['en-US'];
  1516. }
  1517. for (var _i4 = 0; _i4 < commaDecimal.length; _i4++) {
  1518. decimal[commaDecimal[_i4]] = ',';
  1519. }
  1520. alpha['fr-CA'] = alpha['fr-FR'];
  1521. alphanumeric['fr-CA'] = alphanumeric['fr-FR'];
  1522. alpha['pt-BR'] = alpha['pt-PT'];
  1523. alphanumeric['pt-BR'] = alphanumeric['pt-PT'];
  1524. decimal['pt-BR'] = decimal['pt-PT']; // see #862
  1525. alpha['pl-Pl'] = alpha['pl-PL'];
  1526. alphanumeric['pl-Pl'] = alphanumeric['pl-PL'];
  1527. decimal['pl-Pl'] = decimal['pl-PL']; // see #1455
  1528. alpha['fa-AF'] = alpha.fa;
  1529. Object.defineProperty(isFloat$1, "__esModule", {
  1530. value: true
  1531. });
  1532. isFloat$1.default = isFloat;
  1533. isFloat$1.locales = void 0;
  1534. var _assertString$a = _interopRequireDefault$a(assertString.exports);
  1535. var _alpha$2 = alpha$1;
  1536. function _interopRequireDefault$a(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1537. function isFloat(str, options) {
  1538. (0, _assertString$a.default)(str);
  1539. options = options || {};
  1540. var float = new RegExp("^(?:[-+])?(?:[0-9]+)?(?:\\".concat(options.locale ? _alpha$2.decimal[options.locale] : '.', "[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$"));
  1541. if (str === '' || str === '.' || str === '-' || str === '+') {
  1542. return false;
  1543. }
  1544. var value = parseFloat(str.replace(',', '.'));
  1545. return float.test(str) && (!options.hasOwnProperty('min') || value >= options.min) && (!options.hasOwnProperty('max') || value <= options.max) && (!options.hasOwnProperty('lt') || value < options.lt) && (!options.hasOwnProperty('gt') || value > options.gt);
  1546. }
  1547. var locales$5 = Object.keys(_alpha$2.decimal);
  1548. isFloat$1.locales = locales$5;
  1549. (function (module, exports) {
  1550. Object.defineProperty(exports, "__esModule", {
  1551. value: true
  1552. });
  1553. exports.default = toFloat;
  1554. var _isFloat = _interopRequireDefault(isFloat$1);
  1555. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1556. function toFloat(str) {
  1557. if (!(0, _isFloat.default)(str)) return NaN;
  1558. return parseFloat(str);
  1559. }
  1560. module.exports = exports.default;
  1561. module.exports.default = exports.default;
  1562. } (toFloat, toFloat.exports));
  1563. (function (module, exports) {
  1564. Object.defineProperty(exports, "__esModule", {
  1565. value: true
  1566. });
  1567. exports.default = isDivisibleBy;
  1568. var _assertString = _interopRequireDefault(assertString.exports);
  1569. var _toFloat = _interopRequireDefault(toFloat.exports);
  1570. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1571. function isDivisibleBy(str, num) {
  1572. (0, _assertString.default)(str);
  1573. return (0, _toFloat.default)(str) % parseInt(num, 10) === 0;
  1574. }
  1575. module.exports = exports.default;
  1576. module.exports.default = exports.default;
  1577. } (isDivisibleBy$1, isDivisibleBy$1.exports));
  1578. var isDivisibleByValidator = /*@__PURE__*/getDefaultExportFromCjs(isDivisibleBy$1.exports);
  1579. var IS_DIVISIBLE_BY = 'isDivisibleBy';
  1580. /**
  1581. * Checks if value is a number that's divisible by another.
  1582. */
  1583. function isDivisibleBy(value, num) {
  1584. return typeof value === 'number' && typeof num === 'number' && isDivisibleByValidator(String(value), num);
  1585. }
  1586. /**
  1587. * Checks if value is a number that's divisible by another.
  1588. */
  1589. function IsDivisibleBy(num, validationOptions) {
  1590. return ValidateBy({
  1591. name: IS_DIVISIBLE_BY,
  1592. constraints: [num],
  1593. validator: {
  1594. validate: function (value, args) { return isDivisibleBy(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  1595. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be divisible by $constraint1'; }, validationOptions),
  1596. },
  1597. }, validationOptions);
  1598. }
  1599. var IS_POSITIVE = 'isPositive';
  1600. /**
  1601. * Checks if the value is a positive number greater than zero.
  1602. */
  1603. function isPositive(value) {
  1604. return typeof value === 'number' && value > 0;
  1605. }
  1606. /**
  1607. * Checks if the value is a positive number greater than zero.
  1608. */
  1609. function IsPositive(validationOptions) {
  1610. return ValidateBy({
  1611. name: IS_POSITIVE,
  1612. validator: {
  1613. validate: function (value, args) { return isPositive(value); },
  1614. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a positive number'; }, validationOptions),
  1615. },
  1616. }, validationOptions);
  1617. }
  1618. var IS_NEGATIVE = 'isNegative';
  1619. /**
  1620. * Checks if the value is a negative number smaller than zero.
  1621. */
  1622. function isNegative(value) {
  1623. return typeof value === 'number' && value < 0;
  1624. }
  1625. /**
  1626. * Checks if the value is a negative number smaller than zero.
  1627. */
  1628. function IsNegative(validationOptions) {
  1629. return ValidateBy({
  1630. name: IS_NEGATIVE,
  1631. validator: {
  1632. validate: function (value, args) { return isNegative(value); },
  1633. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a negative number'; }, validationOptions),
  1634. },
  1635. }, validationOptions);
  1636. }
  1637. var MAX = 'max';
  1638. /**
  1639. * Checks if the first number is less than or equal to the second.
  1640. */
  1641. function max(num, max) {
  1642. return typeof num === 'number' && typeof max === 'number' && num <= max;
  1643. }
  1644. /**
  1645. * Checks if the value is less than or equal to the allowed maximum value.
  1646. */
  1647. function Max(maxValue, validationOptions) {
  1648. return ValidateBy({
  1649. name: MAX,
  1650. constraints: [maxValue],
  1651. validator: {
  1652. validate: function (value, args) { return max(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  1653. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must not be greater than $constraint1'; }, validationOptions),
  1654. },
  1655. }, validationOptions);
  1656. }
  1657. var MIN = 'min';
  1658. /**
  1659. * Checks if the first number is greater than or equal to the second.
  1660. */
  1661. function min(num, min) {
  1662. return typeof num === 'number' && typeof min === 'number' && num >= min;
  1663. }
  1664. /**
  1665. * Checks if the value is greater than or equal to the allowed minimum value.
  1666. */
  1667. function Min(minValue, validationOptions) {
  1668. return ValidateBy({
  1669. name: MIN,
  1670. constraints: [minValue],
  1671. validator: {
  1672. validate: function (value, args) { return min(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  1673. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must not be less than $constraint1'; }, validationOptions),
  1674. },
  1675. }, validationOptions);
  1676. }
  1677. var MIN_DATE = 'minDate';
  1678. /**
  1679. * Checks if the value is a date that's after the specified date.
  1680. */
  1681. function minDate(date, minDate) {
  1682. return date instanceof Date && date.getTime() >= (minDate instanceof Date ? minDate : minDate()).getTime();
  1683. }
  1684. /**
  1685. * Checks if the value is a date that's after the specified date.
  1686. */
  1687. function MinDate(date, validationOptions) {
  1688. return ValidateBy({
  1689. name: MIN_DATE,
  1690. constraints: [date],
  1691. validator: {
  1692. validate: function (value, args) { return minDate(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  1693. defaultMessage: buildMessage(function (eachPrefix) { return 'minimal allowed date for ' + eachPrefix + '$property is $constraint1'; }, validationOptions),
  1694. },
  1695. }, validationOptions);
  1696. }
  1697. var MAX_DATE = 'maxDate';
  1698. /**
  1699. * Checks if the value is a date that's before the specified date.
  1700. */
  1701. function maxDate(date, maxDate) {
  1702. return date instanceof Date && date.getTime() <= (maxDate instanceof Date ? maxDate : maxDate()).getTime();
  1703. }
  1704. /**
  1705. * Checks if the value is a date that's after the specified date.
  1706. */
  1707. function MaxDate(date, validationOptions) {
  1708. return ValidateBy({
  1709. name: MAX_DATE,
  1710. constraints: [date],
  1711. validator: {
  1712. validate: function (value, args) { return maxDate(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  1713. defaultMessage: buildMessage(function (eachPrefix) { return 'maximal allowed date for ' + eachPrefix + '$property is $constraint1'; }, validationOptions),
  1714. },
  1715. }, validationOptions);
  1716. }
  1717. var contains$1 = {exports: {}};
  1718. var toString$1 = {exports: {}};
  1719. (function (module, exports) {
  1720. Object.defineProperty(exports, "__esModule", {
  1721. value: true
  1722. });
  1723. exports.default = toString;
  1724. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1725. function toString(input) {
  1726. if (_typeof(input) === 'object' && input !== null) {
  1727. if (typeof input.toString === 'function') {
  1728. input = input.toString();
  1729. } else {
  1730. input = '[object Object]';
  1731. }
  1732. } else if (input === null || typeof input === 'undefined' || isNaN(input) && !input.length) {
  1733. input = '';
  1734. }
  1735. return String(input);
  1736. }
  1737. module.exports = exports.default;
  1738. module.exports.default = exports.default;
  1739. } (toString$1, toString$1.exports));
  1740. (function (module, exports) {
  1741. Object.defineProperty(exports, "__esModule", {
  1742. value: true
  1743. });
  1744. exports.default = contains;
  1745. var _assertString = _interopRequireDefault(assertString.exports);
  1746. var _toString = _interopRequireDefault(toString$1.exports);
  1747. var _merge = _interopRequireDefault(merge.exports);
  1748. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1749. var defaulContainsOptions = {
  1750. ignoreCase: false,
  1751. minOccurrences: 1
  1752. };
  1753. function contains(str, elem, options) {
  1754. (0, _assertString.default)(str);
  1755. options = (0, _merge.default)(options, defaulContainsOptions);
  1756. if (options.ignoreCase) {
  1757. return str.toLowerCase().split((0, _toString.default)(elem).toLowerCase()).length > options.minOccurrences;
  1758. }
  1759. return str.split((0, _toString.default)(elem)).length > options.minOccurrences;
  1760. }
  1761. module.exports = exports.default;
  1762. module.exports.default = exports.default;
  1763. } (contains$1, contains$1.exports));
  1764. var containsValidator = /*@__PURE__*/getDefaultExportFromCjs(contains$1.exports);
  1765. var CONTAINS = 'contains';
  1766. /**
  1767. * Checks if the string contains the seed.
  1768. * If given value is not a string, then it returns false.
  1769. */
  1770. function contains(value, seed) {
  1771. return typeof value === 'string' && containsValidator(value, seed);
  1772. }
  1773. /**
  1774. * Checks if the string contains the seed.
  1775. * If given value is not a string, then it returns false.
  1776. */
  1777. function Contains(seed, validationOptions) {
  1778. return ValidateBy({
  1779. name: CONTAINS,
  1780. constraints: [seed],
  1781. validator: {
  1782. validate: function (value, args) { return contains(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  1783. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must contain a $constraint1 string'; }, validationOptions),
  1784. },
  1785. }, validationOptions);
  1786. }
  1787. var NOT_CONTAINS = 'notContains';
  1788. /**
  1789. * Checks if the string does not contain the seed.
  1790. * If given value is not a string, then it returns false.
  1791. */
  1792. function notContains(value, seed) {
  1793. return typeof value === 'string' && !containsValidator(value, seed);
  1794. }
  1795. /**
  1796. * Checks if the string does not contain the seed.
  1797. * If given value is not a string, then it returns false.
  1798. */
  1799. function NotContains(seed, validationOptions) {
  1800. return ValidateBy({
  1801. name: NOT_CONTAINS,
  1802. constraints: [seed],
  1803. validator: {
  1804. validate: function (value, args) { return notContains(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  1805. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property should not contain a $constraint1 string'; }, validationOptions),
  1806. },
  1807. }, validationOptions);
  1808. }
  1809. var isAlpha$2 = {};
  1810. Object.defineProperty(isAlpha$2, "__esModule", {
  1811. value: true
  1812. });
  1813. var _default$8 = isAlpha$2.default = isAlpha$1;
  1814. isAlpha$2.locales = void 0;
  1815. var _assertString$9 = _interopRequireDefault$9(assertString.exports);
  1816. var _alpha$1 = alpha$1;
  1817. function _interopRequireDefault$9(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1818. function isAlpha$1(_str) {
  1819. var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US';
  1820. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  1821. (0, _assertString$9.default)(_str);
  1822. var str = _str;
  1823. var ignore = options.ignore;
  1824. if (ignore) {
  1825. if (ignore instanceof RegExp) {
  1826. str = str.replace(ignore, '');
  1827. } else if (typeof ignore === 'string') {
  1828. str = str.replace(new RegExp("[".concat(ignore.replace(/[-[\]{}()*+?.,\\^$|#\\s]/g, '\\$&'), "]"), 'g'), ''); // escape regex for ignore
  1829. } else {
  1830. throw new Error('ignore should be instance of a String or RegExp');
  1831. }
  1832. }
  1833. if (locale in _alpha$1.alpha) {
  1834. return _alpha$1.alpha[locale].test(str);
  1835. }
  1836. throw new Error("Invalid locale '".concat(locale, "'"));
  1837. }
  1838. var locales$4 = Object.keys(_alpha$1.alpha);
  1839. isAlpha$2.locales = locales$4;
  1840. var IS_ALPHA = 'isAlpha';
  1841. /**
  1842. * Checks if the string contains only letters (a-zA-Z).
  1843. * If given value is not a string, then it returns false.
  1844. */
  1845. function isAlpha(value, locale) {
  1846. return typeof value === 'string' && _default$8(value, locale);
  1847. }
  1848. /**
  1849. * Checks if the string contains only letters (a-zA-Z).
  1850. * If given value is not a string, then it returns false.
  1851. */
  1852. function IsAlpha(locale, validationOptions) {
  1853. return ValidateBy({
  1854. name: IS_ALPHA,
  1855. constraints: [locale],
  1856. validator: {
  1857. validate: function (value, args) { return isAlpha(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  1858. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must contain only letters (a-zA-Z)'; }, validationOptions),
  1859. },
  1860. }, validationOptions);
  1861. }
  1862. var isAlphanumeric$2 = {};
  1863. Object.defineProperty(isAlphanumeric$2, "__esModule", {
  1864. value: true
  1865. });
  1866. var _default$7 = isAlphanumeric$2.default = isAlphanumeric$1;
  1867. isAlphanumeric$2.locales = void 0;
  1868. var _assertString$8 = _interopRequireDefault$8(assertString.exports);
  1869. var _alpha = alpha$1;
  1870. function _interopRequireDefault$8(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1871. function isAlphanumeric$1(_str) {
  1872. var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US';
  1873. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  1874. (0, _assertString$8.default)(_str);
  1875. var str = _str;
  1876. var ignore = options.ignore;
  1877. if (ignore) {
  1878. if (ignore instanceof RegExp) {
  1879. str = str.replace(ignore, '');
  1880. } else if (typeof ignore === 'string') {
  1881. str = str.replace(new RegExp("[".concat(ignore.replace(/[-[\]{}()*+?.,\\^$|#\\s]/g, '\\$&'), "]"), 'g'), ''); // escape regex for ignore
  1882. } else {
  1883. throw new Error('ignore should be instance of a String or RegExp');
  1884. }
  1885. }
  1886. if (locale in _alpha.alphanumeric) {
  1887. return _alpha.alphanumeric[locale].test(str);
  1888. }
  1889. throw new Error("Invalid locale '".concat(locale, "'"));
  1890. }
  1891. var locales$3 = Object.keys(_alpha.alphanumeric);
  1892. isAlphanumeric$2.locales = locales$3;
  1893. var IS_ALPHANUMERIC = 'isAlphanumeric';
  1894. /**
  1895. * Checks if the string contains only letters and numbers.
  1896. * If given value is not a string, then it returns false.
  1897. */
  1898. function isAlphanumeric(value, locale) {
  1899. return typeof value === 'string' && _default$7(value, locale);
  1900. }
  1901. /**
  1902. * Checks if the string contains only letters and numbers.
  1903. * If given value is not a string, then it returns false.
  1904. */
  1905. function IsAlphanumeric(locale, validationOptions) {
  1906. return ValidateBy({
  1907. name: IS_ALPHANUMERIC,
  1908. constraints: [locale],
  1909. validator: {
  1910. validate: function (value, args) { return isAlphanumeric(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  1911. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must contain only letters and numbers'; }, validationOptions),
  1912. },
  1913. }, validationOptions);
  1914. }
  1915. var isDecimal$1 = {exports: {}};
  1916. var includes = {exports: {}};
  1917. (function (module, exports) {
  1918. Object.defineProperty(exports, "__esModule", {
  1919. value: true
  1920. });
  1921. exports.default = void 0;
  1922. var includes = function includes(arr, val) {
  1923. return arr.some(function (arrVal) {
  1924. return val === arrVal;
  1925. });
  1926. };
  1927. var _default = includes;
  1928. exports.default = _default;
  1929. module.exports = exports.default;
  1930. module.exports.default = exports.default;
  1931. } (includes, includes.exports));
  1932. (function (module, exports) {
  1933. Object.defineProperty(exports, "__esModule", {
  1934. value: true
  1935. });
  1936. exports.default = isDecimal;
  1937. var _merge = _interopRequireDefault(merge.exports);
  1938. var _assertString = _interopRequireDefault(assertString.exports);
  1939. var _includes = _interopRequireDefault(includes.exports);
  1940. var _alpha = alpha$1;
  1941. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1942. function decimalRegExp(options) {
  1943. var regExp = new RegExp("^[-+]?([0-9]+)?(\\".concat(_alpha.decimal[options.locale], "[0-9]{").concat(options.decimal_digits, "})").concat(options.force_decimal ? '' : '?', "$"));
  1944. return regExp;
  1945. }
  1946. var default_decimal_options = {
  1947. force_decimal: false,
  1948. decimal_digits: '1,',
  1949. locale: 'en-US'
  1950. };
  1951. var blacklist = ['', '-', '+'];
  1952. function isDecimal(str, options) {
  1953. (0, _assertString.default)(str);
  1954. options = (0, _merge.default)(options, default_decimal_options);
  1955. if (options.locale in _alpha.decimal) {
  1956. return !(0, _includes.default)(blacklist, str.replace(/ /g, '')) && decimalRegExp(options).test(str);
  1957. }
  1958. throw new Error("Invalid locale '".concat(options.locale, "'"));
  1959. }
  1960. module.exports = exports.default;
  1961. module.exports.default = exports.default;
  1962. } (isDecimal$1, isDecimal$1.exports));
  1963. var isDecimalValidator = /*@__PURE__*/getDefaultExportFromCjs(isDecimal$1.exports);
  1964. var IS_DECIMAL = 'isDecimal';
  1965. /**
  1966. * Checks if the string is a valid decimal.
  1967. * If given value is not a string, then it returns false.
  1968. */
  1969. function isDecimal(value, options) {
  1970. return typeof value === 'string' && isDecimalValidator(value, options);
  1971. }
  1972. /**
  1973. * Checks if the string is a valid decimal.
  1974. * If given value is not a string, then it returns false.
  1975. */
  1976. function IsDecimal(options, validationOptions) {
  1977. return ValidateBy({
  1978. name: IS_DECIMAL,
  1979. constraints: [options],
  1980. validator: {
  1981. validate: function (value, args) { return isDecimal(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  1982. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property is not a valid decimal number.'; }, validationOptions),
  1983. },
  1984. }, validationOptions);
  1985. }
  1986. var isAscii$1 = {exports: {}};
  1987. (function (module, exports) {
  1988. Object.defineProperty(exports, "__esModule", {
  1989. value: true
  1990. });
  1991. exports.default = isAscii;
  1992. var _assertString = _interopRequireDefault(assertString.exports);
  1993. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1994. /* eslint-disable no-control-regex */
  1995. var ascii = /^[\x00-\x7F]+$/;
  1996. /* eslint-enable no-control-regex */
  1997. function isAscii(str) {
  1998. (0, _assertString.default)(str);
  1999. return ascii.test(str);
  2000. }
  2001. module.exports = exports.default;
  2002. module.exports.default = exports.default;
  2003. } (isAscii$1, isAscii$1.exports));
  2004. var isAsciiValidator = /*@__PURE__*/getDefaultExportFromCjs(isAscii$1.exports);
  2005. var IS_ASCII = 'isAscii';
  2006. /**
  2007. * Checks if the string contains ASCII chars only.
  2008. * If given value is not a string, then it returns false.
  2009. */
  2010. function isAscii(value) {
  2011. return typeof value === 'string' && isAsciiValidator(value);
  2012. }
  2013. /**
  2014. * Checks if the string contains ASCII chars only.
  2015. * If given value is not a string, then it returns false.
  2016. */
  2017. function IsAscii(validationOptions) {
  2018. return ValidateBy({
  2019. name: IS_ASCII,
  2020. validator: {
  2021. validate: function (value, args) { return isAscii(value); },
  2022. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must contain only ASCII characters'; }, validationOptions),
  2023. },
  2024. }, validationOptions);
  2025. }
  2026. var isBase64$1 = {exports: {}};
  2027. (function (module, exports) {
  2028. Object.defineProperty(exports, "__esModule", {
  2029. value: true
  2030. });
  2031. exports.default = isBase64;
  2032. var _assertString = _interopRequireDefault(assertString.exports);
  2033. var _merge = _interopRequireDefault(merge.exports);
  2034. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2035. var notBase64 = /[^A-Z0-9+\/=]/i;
  2036. var urlSafeBase64 = /^[A-Z0-9_\-]*$/i;
  2037. var defaultBase64Options = {
  2038. urlSafe: false
  2039. };
  2040. function isBase64(str, options) {
  2041. (0, _assertString.default)(str);
  2042. options = (0, _merge.default)(options, defaultBase64Options);
  2043. var len = str.length;
  2044. if (options.urlSafe) {
  2045. return urlSafeBase64.test(str);
  2046. }
  2047. if (len % 4 !== 0 || notBase64.test(str)) {
  2048. return false;
  2049. }
  2050. var firstPaddingChar = str.indexOf('=');
  2051. return firstPaddingChar === -1 || firstPaddingChar === len - 1 || firstPaddingChar === len - 2 && str[len - 1] === '=';
  2052. }
  2053. module.exports = exports.default;
  2054. module.exports.default = exports.default;
  2055. } (isBase64$1, isBase64$1.exports));
  2056. var isBase64Validator = /*@__PURE__*/getDefaultExportFromCjs(isBase64$1.exports);
  2057. var IS_BASE64 = 'isBase64';
  2058. /**
  2059. * Checks if a string is base64 encoded.
  2060. * If given value is not a string, then it returns false.
  2061. */
  2062. function isBase64(value) {
  2063. return typeof value === 'string' && isBase64Validator(value);
  2064. }
  2065. /**
  2066. * Checks if a string is base64 encoded.
  2067. * If given value is not a string, then it returns false.
  2068. */
  2069. function IsBase64(validationOptions) {
  2070. return ValidateBy({
  2071. name: IS_BASE64,
  2072. validator: {
  2073. validate: function (value, args) { return isBase64(value); },
  2074. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be base64 encoded'; }, validationOptions),
  2075. },
  2076. }, validationOptions);
  2077. }
  2078. var isByteLength$1 = {exports: {}};
  2079. (function (module, exports) {
  2080. Object.defineProperty(exports, "__esModule", {
  2081. value: true
  2082. });
  2083. exports.default = isByteLength;
  2084. var _assertString = _interopRequireDefault(assertString.exports);
  2085. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2086. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2087. /* eslint-disable prefer-rest-params */
  2088. function isByteLength(str, options) {
  2089. (0, _assertString.default)(str);
  2090. var min;
  2091. var max;
  2092. if (_typeof(options) === 'object') {
  2093. min = options.min || 0;
  2094. max = options.max;
  2095. } else {
  2096. // backwards compatibility: isByteLength(str, min [, max])
  2097. min = arguments[1];
  2098. max = arguments[2];
  2099. }
  2100. var len = encodeURI(str).split(/%..|./).length - 1;
  2101. return len >= min && (typeof max === 'undefined' || len <= max);
  2102. }
  2103. module.exports = exports.default;
  2104. module.exports.default = exports.default;
  2105. } (isByteLength$1, isByteLength$1.exports));
  2106. var isByteLengthValidator = /*@__PURE__*/getDefaultExportFromCjs(isByteLength$1.exports);
  2107. var IS_BYTE_LENGTH = 'isByteLength';
  2108. /**
  2109. * Checks if the string's length (in bytes) falls in a range.
  2110. * If given value is not a string, then it returns false.
  2111. */
  2112. function isByteLength(value, min, max) {
  2113. return typeof value === 'string' && isByteLengthValidator(value, { min: min, max: max });
  2114. }
  2115. /**
  2116. * Checks if the string's length (in bytes) falls in a range.
  2117. * If given value is not a string, then it returns false.
  2118. */
  2119. function IsByteLength(min, max, validationOptions) {
  2120. return ValidateBy({
  2121. name: IS_BYTE_LENGTH,
  2122. constraints: [min, max],
  2123. validator: {
  2124. validate: function (value, args) { return isByteLength(value, args === null || args === void 0 ? void 0 : args.constraints[0], args === null || args === void 0 ? void 0 : args.constraints[1]); },
  2125. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + "$property's byte length must fall into ($constraint1, $constraint2) range"; }, validationOptions),
  2126. },
  2127. }, validationOptions);
  2128. }
  2129. var isCreditCard$1 = {exports: {}};
  2130. (function (module, exports) {
  2131. Object.defineProperty(exports, "__esModule", {
  2132. value: true
  2133. });
  2134. exports.default = isCreditCard;
  2135. var _assertString = _interopRequireDefault(assertString.exports);
  2136. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2137. /* eslint-disable max-len */
  2138. var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/;
  2139. /* eslint-enable max-len */
  2140. function isCreditCard(str) {
  2141. (0, _assertString.default)(str);
  2142. var sanitized = str.replace(/[- ]+/g, '');
  2143. if (!creditCard.test(sanitized)) {
  2144. return false;
  2145. }
  2146. var sum = 0;
  2147. var digit;
  2148. var tmpNum;
  2149. var shouldDouble;
  2150. for (var i = sanitized.length - 1; i >= 0; i--) {
  2151. digit = sanitized.substring(i, i + 1);
  2152. tmpNum = parseInt(digit, 10);
  2153. if (shouldDouble) {
  2154. tmpNum *= 2;
  2155. if (tmpNum >= 10) {
  2156. sum += tmpNum % 10 + 1;
  2157. } else {
  2158. sum += tmpNum;
  2159. }
  2160. } else {
  2161. sum += tmpNum;
  2162. }
  2163. shouldDouble = !shouldDouble;
  2164. }
  2165. return !!(sum % 10 === 0 ? sanitized : false);
  2166. }
  2167. module.exports = exports.default;
  2168. module.exports.default = exports.default;
  2169. } (isCreditCard$1, isCreditCard$1.exports));
  2170. var isCreditCardValidator = /*@__PURE__*/getDefaultExportFromCjs(isCreditCard$1.exports);
  2171. var IS_CREDIT_CARD = 'isCreditCard';
  2172. /**
  2173. * Checks if the string is a credit card.
  2174. * If given value is not a string, then it returns false.
  2175. */
  2176. function isCreditCard(value) {
  2177. return typeof value === 'string' && isCreditCardValidator(value);
  2178. }
  2179. /**
  2180. * Checks if the string is a credit card.
  2181. * If given value is not a string, then it returns false.
  2182. */
  2183. function IsCreditCard(validationOptions) {
  2184. return ValidateBy({
  2185. name: IS_CREDIT_CARD,
  2186. validator: {
  2187. validate: function (value, args) { return isCreditCard(value); },
  2188. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a credit card'; }, validationOptions),
  2189. },
  2190. }, validationOptions);
  2191. }
  2192. var isCurrency$1 = {exports: {}};
  2193. (function (module, exports) {
  2194. Object.defineProperty(exports, "__esModule", {
  2195. value: true
  2196. });
  2197. exports.default = isCurrency;
  2198. var _merge = _interopRequireDefault(merge.exports);
  2199. var _assertString = _interopRequireDefault(assertString.exports);
  2200. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2201. function currencyRegex(options) {
  2202. var decimal_digits = "\\d{".concat(options.digits_after_decimal[0], "}");
  2203. options.digits_after_decimal.forEach(function (digit, index) {
  2204. if (index !== 0) decimal_digits = "".concat(decimal_digits, "|\\d{").concat(digit, "}");
  2205. });
  2206. var symbol = "(".concat(options.symbol.replace(/\W/, function (m) {
  2207. return "\\".concat(m);
  2208. }), ")").concat(options.require_symbol ? '' : '?'),
  2209. negative = '-?',
  2210. whole_dollar_amount_without_sep = '[1-9]\\d*',
  2211. whole_dollar_amount_with_sep = "[1-9]\\d{0,2}(\\".concat(options.thousands_separator, "\\d{3})*"),
  2212. valid_whole_dollar_amounts = ['0', whole_dollar_amount_without_sep, whole_dollar_amount_with_sep],
  2213. whole_dollar_amount = "(".concat(valid_whole_dollar_amounts.join('|'), ")?"),
  2214. decimal_amount = "(\\".concat(options.decimal_separator, "(").concat(decimal_digits, "))").concat(options.require_decimal ? '' : '?');
  2215. var pattern = whole_dollar_amount + (options.allow_decimal || options.require_decimal ? decimal_amount : ''); // default is negative sign before symbol, but there are two other options (besides parens)
  2216. if (options.allow_negatives && !options.parens_for_negatives) {
  2217. if (options.negative_sign_after_digits) {
  2218. pattern += negative;
  2219. } else if (options.negative_sign_before_digits) {
  2220. pattern = negative + pattern;
  2221. }
  2222. } // South African Rand, for example, uses R 123 (space) and R-123 (no space)
  2223. if (options.allow_negative_sign_placeholder) {
  2224. pattern = "( (?!\\-))?".concat(pattern);
  2225. } else if (options.allow_space_after_symbol) {
  2226. pattern = " ?".concat(pattern);
  2227. } else if (options.allow_space_after_digits) {
  2228. pattern += '( (?!$))?';
  2229. }
  2230. if (options.symbol_after_digits) {
  2231. pattern += symbol;
  2232. } else {
  2233. pattern = symbol + pattern;
  2234. }
  2235. if (options.allow_negatives) {
  2236. if (options.parens_for_negatives) {
  2237. pattern = "(\\(".concat(pattern, "\\)|").concat(pattern, ")");
  2238. } else if (!(options.negative_sign_before_digits || options.negative_sign_after_digits)) {
  2239. pattern = negative + pattern;
  2240. }
  2241. } // ensure there's a dollar and/or decimal amount, and that
  2242. // it doesn't start with a space or a negative sign followed by a space
  2243. return new RegExp("^(?!-? )(?=.*\\d)".concat(pattern, "$"));
  2244. }
  2245. var default_currency_options = {
  2246. symbol: '$',
  2247. require_symbol: false,
  2248. allow_space_after_symbol: false,
  2249. symbol_after_digits: false,
  2250. allow_negatives: true,
  2251. parens_for_negatives: false,
  2252. negative_sign_before_digits: false,
  2253. negative_sign_after_digits: false,
  2254. allow_negative_sign_placeholder: false,
  2255. thousands_separator: ',',
  2256. decimal_separator: '.',
  2257. allow_decimal: true,
  2258. require_decimal: false,
  2259. digits_after_decimal: [2],
  2260. allow_space_after_digits: false
  2261. };
  2262. function isCurrency(str, options) {
  2263. (0, _assertString.default)(str);
  2264. options = (0, _merge.default)(options, default_currency_options);
  2265. return currencyRegex(options).test(str);
  2266. }
  2267. module.exports = exports.default;
  2268. module.exports.default = exports.default;
  2269. } (isCurrency$1, isCurrency$1.exports));
  2270. var isCurrencyValidator = /*@__PURE__*/getDefaultExportFromCjs(isCurrency$1.exports);
  2271. var IS_CURRENCY = 'isCurrency';
  2272. /**
  2273. * Checks if the string is a valid currency amount.
  2274. * If given value is not a string, then it returns false.
  2275. */
  2276. function isCurrency(value, options) {
  2277. return typeof value === 'string' && isCurrencyValidator(value, options);
  2278. }
  2279. /**
  2280. * Checks if the string is a valid currency amount.
  2281. * If given value is not a string, then it returns false.
  2282. */
  2283. function IsCurrency(options, validationOptions) {
  2284. return ValidateBy({
  2285. name: IS_CURRENCY,
  2286. constraints: [options],
  2287. validator: {
  2288. validate: function (value, args) { return isCurrency(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  2289. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a currency'; }, validationOptions),
  2290. },
  2291. }, validationOptions);
  2292. }
  2293. var isEmail$1 = {exports: {}};
  2294. var isFQDN$1 = {exports: {}};
  2295. (function (module, exports) {
  2296. Object.defineProperty(exports, "__esModule", {
  2297. value: true
  2298. });
  2299. exports.default = isFQDN;
  2300. var _assertString = _interopRequireDefault(assertString.exports);
  2301. var _merge = _interopRequireDefault(merge.exports);
  2302. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2303. var default_fqdn_options = {
  2304. require_tld: true,
  2305. allow_underscores: false,
  2306. allow_trailing_dot: false,
  2307. allow_numeric_tld: false,
  2308. allow_wildcard: false
  2309. };
  2310. function isFQDN(str, options) {
  2311. (0, _assertString.default)(str);
  2312. options = (0, _merge.default)(options, default_fqdn_options);
  2313. /* Remove the optional trailing dot before checking validity */
  2314. if (options.allow_trailing_dot && str[str.length - 1] === '.') {
  2315. str = str.substring(0, str.length - 1);
  2316. }
  2317. /* Remove the optional wildcard before checking validity */
  2318. if (options.allow_wildcard === true && str.indexOf('*.') === 0) {
  2319. str = str.substring(2);
  2320. }
  2321. var parts = str.split('.');
  2322. var tld = parts[parts.length - 1];
  2323. if (options.require_tld) {
  2324. // disallow fqdns without tld
  2325. if (parts.length < 2) {
  2326. return false;
  2327. }
  2328. if (!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
  2329. return false;
  2330. } // disallow spaces
  2331. if (/\s/.test(tld)) {
  2332. return false;
  2333. }
  2334. } // reject numeric TLDs
  2335. if (!options.allow_numeric_tld && /^\d+$/.test(tld)) {
  2336. return false;
  2337. }
  2338. return parts.every(function (part) {
  2339. if (part.length > 63) {
  2340. return false;
  2341. }
  2342. if (!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(part)) {
  2343. return false;
  2344. } // disallow full-width chars
  2345. if (/[\uff01-\uff5e]/.test(part)) {
  2346. return false;
  2347. } // disallow parts starting or ending with hyphen
  2348. if (/^-|-$/.test(part)) {
  2349. return false;
  2350. }
  2351. if (!options.allow_underscores && /_/.test(part)) {
  2352. return false;
  2353. }
  2354. return true;
  2355. });
  2356. }
  2357. module.exports = exports.default;
  2358. module.exports.default = exports.default;
  2359. } (isFQDN$1, isFQDN$1.exports));
  2360. var isFqdnValidator = /*@__PURE__*/getDefaultExportFromCjs(isFQDN$1.exports);
  2361. var isIP$1 = {exports: {}};
  2362. (function (module, exports) {
  2363. Object.defineProperty(exports, "__esModule", {
  2364. value: true
  2365. });
  2366. exports.default = isIP;
  2367. var _assertString = _interopRequireDefault(assertString.exports);
  2368. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2369. /**
  2370. 11.3. Examples
  2371. The following addresses
  2372. fe80::1234 (on the 1st link of the node)
  2373. ff02::5678 (on the 5th link of the node)
  2374. ff08::9abc (on the 10th organization of the node)
  2375. would be represented as follows:
  2376. fe80::1234%1
  2377. ff02::5678%5
  2378. ff08::9abc%10
  2379. (Here we assume a natural translation from a zone index to the
  2380. <zone_id> part, where the Nth zone of any scope is translated into
  2381. "N".)
  2382. If we use interface names as <zone_id>, those addresses could also be
  2383. represented as follows:
  2384. fe80::1234%ne0
  2385. ff02::5678%pvc1.3
  2386. ff08::9abc%interface10
  2387. where the interface "ne0" belongs to the 1st link, "pvc1.3" belongs
  2388. to the 5th link, and "interface10" belongs to the 10th organization.
  2389. * * */
  2390. var IPv4SegmentFormat = '(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
  2391. var IPv4AddressFormat = "(".concat(IPv4SegmentFormat, "[.]){3}").concat(IPv4SegmentFormat);
  2392. var IPv4AddressRegExp = new RegExp("^".concat(IPv4AddressFormat, "$"));
  2393. var IPv6SegmentFormat = '(?:[0-9a-fA-F]{1,4})';
  2394. var IPv6AddressRegExp = new RegExp('^(' + "(?:".concat(IPv6SegmentFormat, ":){7}(?:").concat(IPv6SegmentFormat, "|:)|") + "(?:".concat(IPv6SegmentFormat, ":){6}(?:").concat(IPv4AddressFormat, "|:").concat(IPv6SegmentFormat, "|:)|") + "(?:".concat(IPv6SegmentFormat, ":){5}(?::").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,2}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){4}(?:(:").concat(IPv6SegmentFormat, "){0,1}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,3}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){3}(?:(:").concat(IPv6SegmentFormat, "){0,2}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,4}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){2}(?:(:").concat(IPv6SegmentFormat, "){0,3}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,5}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){1}(?:(:").concat(IPv6SegmentFormat, "){0,4}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,6}|:)|") + "(?::((?::".concat(IPv6SegmentFormat, "){0,5}:").concat(IPv4AddressFormat, "|(?::").concat(IPv6SegmentFormat, "){1,7}|:))") + ')(%[0-9a-zA-Z-.:]{1,})?$');
  2395. function isIP(str) {
  2396. var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  2397. (0, _assertString.default)(str);
  2398. version = String(version);
  2399. if (!version) {
  2400. return isIP(str, 4) || isIP(str, 6);
  2401. }
  2402. if (version === '4') {
  2403. if (!IPv4AddressRegExp.test(str)) {
  2404. return false;
  2405. }
  2406. var parts = str.split('.').sort(function (a, b) {
  2407. return a - b;
  2408. });
  2409. return parts[3] <= 255;
  2410. }
  2411. if (version === '6') {
  2412. return !!IPv6AddressRegExp.test(str);
  2413. }
  2414. return false;
  2415. }
  2416. module.exports = exports.default;
  2417. module.exports.default = exports.default;
  2418. } (isIP$1, isIP$1.exports));
  2419. var isIPValidator = /*@__PURE__*/getDefaultExportFromCjs(isIP$1.exports);
  2420. (function (module, exports) {
  2421. Object.defineProperty(exports, "__esModule", {
  2422. value: true
  2423. });
  2424. exports.default = isEmail;
  2425. var _assertString = _interopRequireDefault(assertString.exports);
  2426. var _merge = _interopRequireDefault(merge.exports);
  2427. var _isByteLength = _interopRequireDefault(isByteLength$1.exports);
  2428. var _isFQDN = _interopRequireDefault(isFQDN$1.exports);
  2429. var _isIP = _interopRequireDefault(isIP$1.exports);
  2430. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2431. var default_email_options = {
  2432. allow_display_name: false,
  2433. require_display_name: false,
  2434. allow_utf8_local_part: true,
  2435. require_tld: true,
  2436. blacklisted_chars: '',
  2437. ignore_max_length: false,
  2438. host_blacklist: []
  2439. };
  2440. /* eslint-disable max-len */
  2441. /* eslint-disable no-control-regex */
  2442. var splitNameAddress = /^([^\x00-\x1F\x7F-\x9F\cX]+)</i;
  2443. var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i;
  2444. var gmailUserPart = /^[a-z\d]+$/;
  2445. var quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i;
  2446. var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i;
  2447. var quotedEmailUserUtf8 = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i;
  2448. var defaultMaxEmailLength = 254;
  2449. /* eslint-enable max-len */
  2450. /* eslint-enable no-control-regex */
  2451. /**
  2452. * Validate display name according to the RFC2822: https://tools.ietf.org/html/rfc2822#appendix-A.1.2
  2453. * @param {String} display_name
  2454. */
  2455. function validateDisplayName(display_name) {
  2456. var display_name_without_quotes = display_name.replace(/^"(.+)"$/, '$1'); // display name with only spaces is not valid
  2457. if (!display_name_without_quotes.trim()) {
  2458. return false;
  2459. } // check whether display name contains illegal character
  2460. var contains_illegal = /[\.";<>]/.test(display_name_without_quotes);
  2461. if (contains_illegal) {
  2462. // if contains illegal characters,
  2463. // must to be enclosed in double-quotes, otherwise it's not a valid display name
  2464. if (display_name_without_quotes === display_name) {
  2465. return false;
  2466. } // the quotes in display name must start with character symbol \
  2467. var all_start_with_back_slash = display_name_without_quotes.split('"').length === display_name_without_quotes.split('\\"').length;
  2468. if (!all_start_with_back_slash) {
  2469. return false;
  2470. }
  2471. }
  2472. return true;
  2473. }
  2474. function isEmail(str, options) {
  2475. (0, _assertString.default)(str);
  2476. options = (0, _merge.default)(options, default_email_options);
  2477. if (options.require_display_name || options.allow_display_name) {
  2478. var display_email = str.match(splitNameAddress);
  2479. if (display_email) {
  2480. var display_name = display_email[1]; // Remove display name and angle brackets to get email address
  2481. // Can be done in the regex but will introduce a ReDOS (See #1597 for more info)
  2482. str = str.replace(display_name, '').replace(/(^<|>$)/g, ''); // sometimes need to trim the last space to get the display name
  2483. // because there may be a space between display name and email address
  2484. // eg. myname <address@gmail.com>
  2485. // the display name is `myname` instead of `myname `, so need to trim the last space
  2486. if (display_name.endsWith(' ')) {
  2487. display_name = display_name.substr(0, display_name.length - 1);
  2488. }
  2489. if (!validateDisplayName(display_name)) {
  2490. return false;
  2491. }
  2492. } else if (options.require_display_name) {
  2493. return false;
  2494. }
  2495. }
  2496. if (!options.ignore_max_length && str.length > defaultMaxEmailLength) {
  2497. return false;
  2498. }
  2499. var parts = str.split('@');
  2500. var domain = parts.pop();
  2501. var lower_domain = domain.toLowerCase();
  2502. if (options.host_blacklist.includes(lower_domain)) {
  2503. return false;
  2504. }
  2505. var user = parts.join('@');
  2506. if (options.domain_specific_validation && (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com')) {
  2507. /*
  2508. Previously we removed dots for gmail addresses before validating.
  2509. This was removed because it allows `multiple..dots@gmail.com`
  2510. to be reported as valid, but it is not.
  2511. Gmail only normalizes single dots, removing them from here is pointless,
  2512. should be done in normalizeEmail
  2513. */
  2514. user = user.toLowerCase(); // Removing sub-address from username before gmail validation
  2515. var username = user.split('+')[0]; // Dots are not included in gmail length restriction
  2516. if (!(0, _isByteLength.default)(username.replace(/\./g, ''), {
  2517. min: 6,
  2518. max: 30
  2519. })) {
  2520. return false;
  2521. }
  2522. var _user_parts = username.split('.');
  2523. for (var i = 0; i < _user_parts.length; i++) {
  2524. if (!gmailUserPart.test(_user_parts[i])) {
  2525. return false;
  2526. }
  2527. }
  2528. }
  2529. if (options.ignore_max_length === false && (!(0, _isByteLength.default)(user, {
  2530. max: 64
  2531. }) || !(0, _isByteLength.default)(domain, {
  2532. max: 254
  2533. }))) {
  2534. return false;
  2535. }
  2536. if (!(0, _isFQDN.default)(domain, {
  2537. require_tld: options.require_tld
  2538. })) {
  2539. if (!options.allow_ip_domain) {
  2540. return false;
  2541. }
  2542. if (!(0, _isIP.default)(domain)) {
  2543. if (!domain.startsWith('[') || !domain.endsWith(']')) {
  2544. return false;
  2545. }
  2546. var noBracketdomain = domain.substr(1, domain.length - 2);
  2547. if (noBracketdomain.length === 0 || !(0, _isIP.default)(noBracketdomain)) {
  2548. return false;
  2549. }
  2550. }
  2551. }
  2552. if (user[0] === '"') {
  2553. user = user.slice(1, user.length - 1);
  2554. return options.allow_utf8_local_part ? quotedEmailUserUtf8.test(user) : quotedEmailUser.test(user);
  2555. }
  2556. var pattern = options.allow_utf8_local_part ? emailUserUtf8Part : emailUserPart;
  2557. var user_parts = user.split('.');
  2558. for (var _i = 0; _i < user_parts.length; _i++) {
  2559. if (!pattern.test(user_parts[_i])) {
  2560. return false;
  2561. }
  2562. }
  2563. if (options.blacklisted_chars) {
  2564. if (user.search(new RegExp("[".concat(options.blacklisted_chars, "]+"), 'g')) !== -1) return false;
  2565. }
  2566. return true;
  2567. }
  2568. module.exports = exports.default;
  2569. module.exports.default = exports.default;
  2570. } (isEmail$1, isEmail$1.exports));
  2571. var isEmailValidator = /*@__PURE__*/getDefaultExportFromCjs(isEmail$1.exports);
  2572. var IS_EMAIL = 'isEmail';
  2573. /**
  2574. * Checks if the string is an email.
  2575. * If given value is not a string, then it returns false.
  2576. */
  2577. function isEmail(value, options) {
  2578. return typeof value === 'string' && isEmailValidator(value, options);
  2579. }
  2580. /**
  2581. * Checks if the string is an email.
  2582. * If given value is not a string, then it returns false.
  2583. */
  2584. function IsEmail(options, validationOptions) {
  2585. return ValidateBy({
  2586. name: IS_EMAIL,
  2587. constraints: [options],
  2588. validator: {
  2589. validate: function (value, args) { return isEmail(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  2590. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be an email'; }, validationOptions),
  2591. },
  2592. }, validationOptions);
  2593. }
  2594. var IS_FQDN = 'isFqdn';
  2595. /**
  2596. * Checks if the string is a fully qualified domain name (e.g. domain.com).
  2597. * If given value is not a string, then it returns false.
  2598. */
  2599. function isFQDN(value, options) {
  2600. return typeof value === 'string' && isFqdnValidator(value, options);
  2601. }
  2602. /**
  2603. * Checks if the string is a fully qualified domain name (e.g. domain.com).
  2604. * If given value is not a string, then it returns false.
  2605. */
  2606. function IsFQDN(options, validationOptions) {
  2607. return ValidateBy({
  2608. name: IS_FQDN,
  2609. constraints: [options],
  2610. validator: {
  2611. validate: function (value, args) { return isFQDN(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  2612. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a valid domain name'; }, validationOptions),
  2613. },
  2614. }, validationOptions);
  2615. }
  2616. var isFullWidth$2 = {};
  2617. Object.defineProperty(isFullWidth$2, "__esModule", {
  2618. value: true
  2619. });
  2620. var _default$6 = isFullWidth$2.default = isFullWidth$1;
  2621. isFullWidth$2.fullWidth = void 0;
  2622. var _assertString$7 = _interopRequireDefault$7(assertString.exports);
  2623. function _interopRequireDefault$7(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2624. var fullWidth = /[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;
  2625. isFullWidth$2.fullWidth = fullWidth;
  2626. function isFullWidth$1(str) {
  2627. (0, _assertString$7.default)(str);
  2628. return fullWidth.test(str);
  2629. }
  2630. var IS_FULL_WIDTH = 'isFullWidth';
  2631. /**
  2632. * Checks if the string contains any full-width chars.
  2633. * If given value is not a string, then it returns false.
  2634. */
  2635. function isFullWidth(value) {
  2636. return typeof value === 'string' && _default$6(value);
  2637. }
  2638. /**
  2639. * Checks if the string contains any full-width chars.
  2640. * If given value is not a string, then it returns false.
  2641. */
  2642. function IsFullWidth(validationOptions) {
  2643. return ValidateBy({
  2644. name: IS_FULL_WIDTH,
  2645. validator: {
  2646. validate: function (value, args) { return isFullWidth(value); },
  2647. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must contain a full-width characters'; }, validationOptions),
  2648. },
  2649. }, validationOptions);
  2650. }
  2651. var isHalfWidth$2 = {};
  2652. Object.defineProperty(isHalfWidth$2, "__esModule", {
  2653. value: true
  2654. });
  2655. var _default$5 = isHalfWidth$2.default = isHalfWidth$1;
  2656. isHalfWidth$2.halfWidth = void 0;
  2657. var _assertString$6 = _interopRequireDefault$6(assertString.exports);
  2658. function _interopRequireDefault$6(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2659. var halfWidth = /[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;
  2660. isHalfWidth$2.halfWidth = halfWidth;
  2661. function isHalfWidth$1(str) {
  2662. (0, _assertString$6.default)(str);
  2663. return halfWidth.test(str);
  2664. }
  2665. var IS_HALF_WIDTH = 'isHalfWidth';
  2666. /**
  2667. * Checks if the string contains any half-width chars.
  2668. * If given value is not a string, then it returns false.
  2669. */
  2670. function isHalfWidth(value) {
  2671. return typeof value === 'string' && _default$5(value);
  2672. }
  2673. /**
  2674. * Checks if the string contains any half-width chars.
  2675. * If given value is not a string, then it returns false.
  2676. */
  2677. function IsHalfWidth(validationOptions) {
  2678. return ValidateBy({
  2679. name: IS_HALF_WIDTH,
  2680. validator: {
  2681. validate: function (value, args) { return isHalfWidth(value); },
  2682. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must contain a half-width characters'; }, validationOptions),
  2683. },
  2684. }, validationOptions);
  2685. }
  2686. var isVariableWidth$1 = {exports: {}};
  2687. (function (module, exports) {
  2688. Object.defineProperty(exports, "__esModule", {
  2689. value: true
  2690. });
  2691. exports.default = isVariableWidth;
  2692. var _assertString = _interopRequireDefault(assertString.exports);
  2693. var _isFullWidth = isFullWidth$2;
  2694. var _isHalfWidth = isHalfWidth$2;
  2695. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2696. function isVariableWidth(str) {
  2697. (0, _assertString.default)(str);
  2698. return _isFullWidth.fullWidth.test(str) && _isHalfWidth.halfWidth.test(str);
  2699. }
  2700. module.exports = exports.default;
  2701. module.exports.default = exports.default;
  2702. } (isVariableWidth$1, isVariableWidth$1.exports));
  2703. var isVariableWidthValidator = /*@__PURE__*/getDefaultExportFromCjs(isVariableWidth$1.exports);
  2704. var IS_VARIABLE_WIDTH = 'isVariableWidth';
  2705. /**
  2706. * Checks if the string contains variable-width chars.
  2707. * If given value is not a string, then it returns false.
  2708. */
  2709. function isVariableWidth(value) {
  2710. return typeof value === 'string' && isVariableWidthValidator(value);
  2711. }
  2712. /**
  2713. * Checks if the string contains variable-width chars.
  2714. * If given value is not a string, then it returns false.
  2715. */
  2716. function IsVariableWidth(validationOptions) {
  2717. return ValidateBy({
  2718. name: IS_VARIABLE_WIDTH,
  2719. validator: {
  2720. validate: function (value, args) { return isVariableWidth(value); },
  2721. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must contain a full-width and half-width characters'; }, validationOptions),
  2722. },
  2723. }, validationOptions);
  2724. }
  2725. var isHexColor$1 = {exports: {}};
  2726. (function (module, exports) {
  2727. Object.defineProperty(exports, "__esModule", {
  2728. value: true
  2729. });
  2730. exports.default = isHexColor;
  2731. var _assertString = _interopRequireDefault(assertString.exports);
  2732. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2733. var hexcolor = /^#?([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$/i;
  2734. function isHexColor(str) {
  2735. (0, _assertString.default)(str);
  2736. return hexcolor.test(str);
  2737. }
  2738. module.exports = exports.default;
  2739. module.exports.default = exports.default;
  2740. } (isHexColor$1, isHexColor$1.exports));
  2741. var isHexColorValidator = /*@__PURE__*/getDefaultExportFromCjs(isHexColor$1.exports);
  2742. var IS_HEX_COLOR = 'isHexColor';
  2743. /**
  2744. * Checks if the string is a hexadecimal color.
  2745. * If given value is not a string, then it returns false.
  2746. */
  2747. function isHexColor(value) {
  2748. return typeof value === 'string' && isHexColorValidator(value);
  2749. }
  2750. /**
  2751. * Checks if the string is a hexadecimal color.
  2752. * If given value is not a string, then it returns false.
  2753. */
  2754. function IsHexColor(validationOptions) {
  2755. return ValidateBy({
  2756. name: IS_HEX_COLOR,
  2757. validator: {
  2758. validate: function (value, args) { return isHexColor(value); },
  2759. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a hexadecimal color'; }, validationOptions),
  2760. },
  2761. }, validationOptions);
  2762. }
  2763. var isHexadecimal$1 = {exports: {}};
  2764. (function (module, exports) {
  2765. Object.defineProperty(exports, "__esModule", {
  2766. value: true
  2767. });
  2768. exports.default = isHexadecimal;
  2769. var _assertString = _interopRequireDefault(assertString.exports);
  2770. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2771. var hexadecimal = /^(0x|0h)?[0-9A-F]+$/i;
  2772. function isHexadecimal(str) {
  2773. (0, _assertString.default)(str);
  2774. return hexadecimal.test(str);
  2775. }
  2776. module.exports = exports.default;
  2777. module.exports.default = exports.default;
  2778. } (isHexadecimal$1, isHexadecimal$1.exports));
  2779. var isHexadecimalValidator = /*@__PURE__*/getDefaultExportFromCjs(isHexadecimal$1.exports);
  2780. var IS_HEXADECIMAL = 'isHexadecimal';
  2781. /**
  2782. * Checks if the string is a hexadecimal number.
  2783. * If given value is not a string, then it returns false.
  2784. */
  2785. function isHexadecimal(value) {
  2786. return typeof value === 'string' && isHexadecimalValidator(value);
  2787. }
  2788. /**
  2789. * Checks if the string is a hexadecimal number.
  2790. * If given value is not a string, then it returns false.
  2791. */
  2792. function IsHexadecimal(validationOptions) {
  2793. return ValidateBy({
  2794. name: IS_HEXADECIMAL,
  2795. validator: {
  2796. validate: function (value, args) { return isHexadecimal(value); },
  2797. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a hexadecimal number'; }, validationOptions),
  2798. },
  2799. }, validationOptions);
  2800. }
  2801. function isValidationOptions(val) {
  2802. if (!val) {
  2803. return false;
  2804. }
  2805. return 'each' in val || 'message' in val || 'groups' in val || 'always' in val || 'context' in val;
  2806. }
  2807. var isMACAddress$1 = {exports: {}};
  2808. (function (module, exports) {
  2809. Object.defineProperty(exports, "__esModule", {
  2810. value: true
  2811. });
  2812. exports.default = isMACAddress;
  2813. var _assertString = _interopRequireDefault(assertString.exports);
  2814. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2815. var macAddress = /^(?:[0-9a-fA-F]{2}([-:\s]))([0-9a-fA-F]{2}\1){4}([0-9a-fA-F]{2})$/;
  2816. var macAddressNoSeparators = /^([0-9a-fA-F]){12}$/;
  2817. var macAddressWithDots = /^([0-9a-fA-F]{4}\.){2}([0-9a-fA-F]{4})$/;
  2818. function isMACAddress(str, options) {
  2819. (0, _assertString.default)(str);
  2820. /**
  2821. * @deprecated `no_colons` TODO: remove it in the next major
  2822. */
  2823. if (options && (options.no_colons || options.no_separators)) {
  2824. return macAddressNoSeparators.test(str);
  2825. }
  2826. return macAddress.test(str) || macAddressWithDots.test(str);
  2827. }
  2828. module.exports = exports.default;
  2829. module.exports.default = exports.default;
  2830. } (isMACAddress$1, isMACAddress$1.exports));
  2831. var isMacAddressValidator = /*@__PURE__*/getDefaultExportFromCjs(isMACAddress$1.exports);
  2832. var IS_MAC_ADDRESS = 'isMacAddress';
  2833. /**
  2834. * Check if the string is a MAC address.
  2835. * If given value is not a string, then it returns false.
  2836. */
  2837. function isMACAddress(value, options) {
  2838. return typeof value === 'string' && isMacAddressValidator(value, options);
  2839. }
  2840. function IsMACAddress(optionsOrValidationOptionsArg, validationOptionsArg) {
  2841. var options = !isValidationOptions(optionsOrValidationOptionsArg) ? optionsOrValidationOptionsArg : undefined;
  2842. var validationOptions = isValidationOptions(optionsOrValidationOptionsArg)
  2843. ? optionsOrValidationOptionsArg
  2844. : validationOptionsArg;
  2845. return ValidateBy({
  2846. name: IS_MAC_ADDRESS,
  2847. constraints: [options],
  2848. validator: {
  2849. validate: function (value, args) { return isMACAddress(value, options); },
  2850. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a MAC Address'; }, validationOptions),
  2851. },
  2852. }, validationOptions);
  2853. }
  2854. var IS_IP = 'isIp';
  2855. /**
  2856. * Checks if the string is an IP (version 4 or 6).
  2857. * If given value is not a string, then it returns false.
  2858. */
  2859. function isIP(value, version) {
  2860. /* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion */
  2861. var versionStr = version ? "".concat(version) : undefined;
  2862. return typeof value === 'string' && isIPValidator(value, versionStr);
  2863. }
  2864. /**
  2865. * Checks if the string is an IP (version 4 or 6).
  2866. * If given value is not a string, then it returns false.
  2867. */
  2868. function IsIP(version, validationOptions) {
  2869. return ValidateBy({
  2870. name: IS_IP,
  2871. constraints: [version],
  2872. validator: {
  2873. validate: function (value, args) { return isIP(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  2874. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be an ip address'; }, validationOptions),
  2875. },
  2876. }, validationOptions);
  2877. }
  2878. var isPort$1 = {exports: {}};
  2879. var isInt$1 = {exports: {}};
  2880. (function (module, exports) {
  2881. Object.defineProperty(exports, "__esModule", {
  2882. value: true
  2883. });
  2884. exports.default = isInt;
  2885. var _assertString = _interopRequireDefault(assertString.exports);
  2886. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2887. var int = /^(?:[-+]?(?:0|[1-9][0-9]*))$/;
  2888. var intLeadingZeroes = /^[-+]?[0-9]+$/;
  2889. function isInt(str, options) {
  2890. (0, _assertString.default)(str);
  2891. options = options || {}; // Get the regex to use for testing, based on whether
  2892. // leading zeroes are allowed or not.
  2893. var regex = options.hasOwnProperty('allow_leading_zeroes') && !options.allow_leading_zeroes ? int : intLeadingZeroes; // Check min/max/lt/gt
  2894. var minCheckPassed = !options.hasOwnProperty('min') || str >= options.min;
  2895. var maxCheckPassed = !options.hasOwnProperty('max') || str <= options.max;
  2896. var ltCheckPassed = !options.hasOwnProperty('lt') || str < options.lt;
  2897. var gtCheckPassed = !options.hasOwnProperty('gt') || str > options.gt;
  2898. return regex.test(str) && minCheckPassed && maxCheckPassed && ltCheckPassed && gtCheckPassed;
  2899. }
  2900. module.exports = exports.default;
  2901. module.exports.default = exports.default;
  2902. } (isInt$1, isInt$1.exports));
  2903. (function (module, exports) {
  2904. Object.defineProperty(exports, "__esModule", {
  2905. value: true
  2906. });
  2907. exports.default = isPort;
  2908. var _isInt = _interopRequireDefault(isInt$1.exports);
  2909. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2910. function isPort(str) {
  2911. return (0, _isInt.default)(str, {
  2912. min: 0,
  2913. max: 65535
  2914. });
  2915. }
  2916. module.exports = exports.default;
  2917. module.exports.default = exports.default;
  2918. } (isPort$1, isPort$1.exports));
  2919. var isPortValidator = /*@__PURE__*/getDefaultExportFromCjs(isPort$1.exports);
  2920. var IS_PORT = 'isPort';
  2921. /**
  2922. * Check if the string is a valid port number.
  2923. */
  2924. function isPort(value) {
  2925. return typeof value === 'string' && isPortValidator(value);
  2926. }
  2927. /**
  2928. * Check if the string is a valid port number.
  2929. */
  2930. function IsPort(validationOptions) {
  2931. return ValidateBy({
  2932. name: IS_PORT,
  2933. validator: {
  2934. validate: function (value, args) { return isPort(value); },
  2935. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a port'; }, validationOptions),
  2936. },
  2937. }, validationOptions);
  2938. }
  2939. var isISBN$1 = {exports: {}};
  2940. (function (module, exports) {
  2941. Object.defineProperty(exports, "__esModule", {
  2942. value: true
  2943. });
  2944. exports.default = isISBN;
  2945. var _assertString = _interopRequireDefault(assertString.exports);
  2946. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2947. var isbn10Maybe = /^(?:[0-9]{9}X|[0-9]{10})$/;
  2948. var isbn13Maybe = /^(?:[0-9]{13})$/;
  2949. var factor = [1, 3];
  2950. function isISBN(str) {
  2951. var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  2952. (0, _assertString.default)(str);
  2953. version = String(version);
  2954. if (!version) {
  2955. return isISBN(str, 10) || isISBN(str, 13);
  2956. }
  2957. var sanitized = str.replace(/[\s-]+/g, '');
  2958. var checksum = 0;
  2959. var i;
  2960. if (version === '10') {
  2961. if (!isbn10Maybe.test(sanitized)) {
  2962. return false;
  2963. }
  2964. for (i = 0; i < 9; i++) {
  2965. checksum += (i + 1) * sanitized.charAt(i);
  2966. }
  2967. if (sanitized.charAt(9) === 'X') {
  2968. checksum += 10 * 10;
  2969. } else {
  2970. checksum += 10 * sanitized.charAt(9);
  2971. }
  2972. if (checksum % 11 === 0) {
  2973. return !!sanitized;
  2974. }
  2975. } else if (version === '13') {
  2976. if (!isbn13Maybe.test(sanitized)) {
  2977. return false;
  2978. }
  2979. for (i = 0; i < 12; i++) {
  2980. checksum += factor[i % 2] * sanitized.charAt(i);
  2981. }
  2982. if (sanitized.charAt(12) - (10 - checksum % 10) % 10 === 0) {
  2983. return !!sanitized;
  2984. }
  2985. }
  2986. return false;
  2987. }
  2988. module.exports = exports.default;
  2989. module.exports.default = exports.default;
  2990. } (isISBN$1, isISBN$1.exports));
  2991. var isIsbnValidator = /*@__PURE__*/getDefaultExportFromCjs(isISBN$1.exports);
  2992. var IS_ISBN = 'isIsbn';
  2993. /**
  2994. * Checks if the string is an ISBN (version 10 or 13).
  2995. * If given value is not a string, then it returns false.
  2996. */
  2997. function isISBN(value, version) {
  2998. /* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion */
  2999. var versionStr = version ? "".concat(version) : undefined;
  3000. return typeof value === 'string' && isIsbnValidator(value, versionStr);
  3001. }
  3002. /**
  3003. * Checks if the string is an ISBN (version 10 or 13).
  3004. * If given value is not a string, then it returns false.
  3005. */
  3006. function IsISBN(version, validationOptions) {
  3007. return ValidateBy({
  3008. name: IS_ISBN,
  3009. constraints: [version],
  3010. validator: {
  3011. validate: function (value, args) { return isISBN(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  3012. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be an ISBN'; }, validationOptions),
  3013. },
  3014. }, validationOptions);
  3015. }
  3016. var isISIN$1 = {exports: {}};
  3017. (function (module, exports) {
  3018. Object.defineProperty(exports, "__esModule", {
  3019. value: true
  3020. });
  3021. exports.default = isISIN;
  3022. var _assertString = _interopRequireDefault(assertString.exports);
  3023. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3024. var isin = /^[A-Z]{2}[0-9A-Z]{9}[0-9]$/; // this link details how the check digit is calculated:
  3025. // https://www.isin.org/isin-format/. it is a little bit
  3026. // odd in that it works with digits, not numbers. in order
  3027. // to make only one pass through the ISIN characters, the
  3028. // each alpha character is handled as 2 characters within
  3029. // the loop.
  3030. function isISIN(str) {
  3031. (0, _assertString.default)(str);
  3032. if (!isin.test(str)) {
  3033. return false;
  3034. }
  3035. var double = true;
  3036. var sum = 0; // convert values
  3037. for (var i = str.length - 2; i >= 0; i--) {
  3038. if (str[i] >= 'A' && str[i] <= 'Z') {
  3039. var value = str[i].charCodeAt(0) - 55;
  3040. var lo = value % 10;
  3041. var hi = Math.trunc(value / 10); // letters have two digits, so handle the low order
  3042. // and high order digits separately.
  3043. for (var _i = 0, _arr = [lo, hi]; _i < _arr.length; _i++) {
  3044. var digit = _arr[_i];
  3045. if (double) {
  3046. if (digit >= 5) {
  3047. sum += 1 + (digit - 5) * 2;
  3048. } else {
  3049. sum += digit * 2;
  3050. }
  3051. } else {
  3052. sum += digit;
  3053. }
  3054. double = !double;
  3055. }
  3056. } else {
  3057. var _digit = str[i].charCodeAt(0) - '0'.charCodeAt(0);
  3058. if (double) {
  3059. if (_digit >= 5) {
  3060. sum += 1 + (_digit - 5) * 2;
  3061. } else {
  3062. sum += _digit * 2;
  3063. }
  3064. } else {
  3065. sum += _digit;
  3066. }
  3067. double = !double;
  3068. }
  3069. }
  3070. var check = Math.trunc((sum + 9) / 10) * 10 - sum;
  3071. return +str[str.length - 1] === check;
  3072. }
  3073. module.exports = exports.default;
  3074. module.exports.default = exports.default;
  3075. } (isISIN$1, isISIN$1.exports));
  3076. var isIsinValidator = /*@__PURE__*/getDefaultExportFromCjs(isISIN$1.exports);
  3077. var IS_ISIN = 'isIsin';
  3078. /**
  3079. * Checks if the string is an ISIN (stock/security identifier).
  3080. * If given value is not a string, then it returns false.
  3081. */
  3082. function isISIN(value) {
  3083. return typeof value === 'string' && isIsinValidator(value);
  3084. }
  3085. /**
  3086. * Checks if the string is an ISIN (stock/security identifier).
  3087. * If given value is not a string, then it returns false.
  3088. */
  3089. function IsISIN(validationOptions) {
  3090. return ValidateBy({
  3091. name: IS_ISIN,
  3092. validator: {
  3093. validate: function (value, args) { return isISIN(value); },
  3094. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be an ISIN (stock/security identifier)'; }, validationOptions),
  3095. },
  3096. }, validationOptions);
  3097. }
  3098. var isISO8601$1 = {exports: {}};
  3099. (function (module, exports) {
  3100. Object.defineProperty(exports, "__esModule", {
  3101. value: true
  3102. });
  3103. exports.default = isISO8601;
  3104. var _assertString = _interopRequireDefault(assertString.exports);
  3105. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3106. /* eslint-disable max-len */
  3107. // from http://goo.gl/0ejHHW
  3108. var iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; // same as above, except with a strict 'T' separator between date and time
  3109. var iso8601StrictSeparator = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
  3110. /* eslint-enable max-len */
  3111. var isValidDate = function isValidDate(str) {
  3112. // str must have passed the ISO8601 check
  3113. // this check is meant to catch invalid dates
  3114. // like 2009-02-31
  3115. // first check for ordinal dates
  3116. var ordinalMatch = str.match(/^(\d{4})-?(\d{3})([ T]{1}\.*|$)/);
  3117. if (ordinalMatch) {
  3118. var oYear = Number(ordinalMatch[1]);
  3119. var oDay = Number(ordinalMatch[2]); // if is leap year
  3120. if (oYear % 4 === 0 && oYear % 100 !== 0 || oYear % 400 === 0) return oDay <= 366;
  3121. return oDay <= 365;
  3122. }
  3123. var match = str.match(/(\d{4})-?(\d{0,2})-?(\d*)/).map(Number);
  3124. var year = match[1];
  3125. var month = match[2];
  3126. var day = match[3];
  3127. var monthString = month ? "0".concat(month).slice(-2) : month;
  3128. var dayString = day ? "0".concat(day).slice(-2) : day; // create a date object and compare
  3129. var d = new Date("".concat(year, "-").concat(monthString || '01', "-").concat(dayString || '01'));
  3130. if (month && day) {
  3131. return d.getUTCFullYear() === year && d.getUTCMonth() + 1 === month && d.getUTCDate() === day;
  3132. }
  3133. return true;
  3134. };
  3135. function isISO8601(str) {
  3136. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  3137. (0, _assertString.default)(str);
  3138. var check = options.strictSeparator ? iso8601StrictSeparator.test(str) : iso8601.test(str);
  3139. if (check && options.strict) return isValidDate(str);
  3140. return check;
  3141. }
  3142. module.exports = exports.default;
  3143. module.exports.default = exports.default;
  3144. } (isISO8601$1, isISO8601$1.exports));
  3145. var isIso8601Validator = /*@__PURE__*/getDefaultExportFromCjs(isISO8601$1.exports);
  3146. var IS_ISO8601 = 'isIso8601';
  3147. /**
  3148. * Checks if the string is a valid ISO 8601 date.
  3149. * If given value is not a string, then it returns false.
  3150. * Use the option strict = true for additional checks for a valid date, e.g. invalidates dates like 2019-02-29.
  3151. */
  3152. function isISO8601(value, options) {
  3153. return typeof value === 'string' && isIso8601Validator(value, options);
  3154. }
  3155. /**
  3156. * Checks if the string is a valid ISO 8601 date.
  3157. * If given value is not a string, then it returns false.
  3158. * Use the option strict = true for additional checks for a valid date, e.g. invalidates dates like 2019-02-29.
  3159. */
  3160. function IsISO8601(options, validationOptions) {
  3161. return ValidateBy({
  3162. name: IS_ISO8601,
  3163. constraints: [options],
  3164. validator: {
  3165. validate: function (value, args) { return isISO8601(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  3166. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a valid ISO 8601 date string'; }, validationOptions),
  3167. },
  3168. }, validationOptions);
  3169. }
  3170. var isJSON$1 = {exports: {}};
  3171. (function (module, exports) {
  3172. Object.defineProperty(exports, "__esModule", {
  3173. value: true
  3174. });
  3175. exports.default = isJSON;
  3176. var _assertString = _interopRequireDefault(assertString.exports);
  3177. var _merge = _interopRequireDefault(merge.exports);
  3178. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3179. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3180. var default_json_options = {
  3181. allow_primitives: false
  3182. };
  3183. function isJSON(str, options) {
  3184. (0, _assertString.default)(str);
  3185. try {
  3186. options = (0, _merge.default)(options, default_json_options);
  3187. var primitives = [];
  3188. if (options.allow_primitives) {
  3189. primitives = [null, false, true];
  3190. }
  3191. var obj = JSON.parse(str);
  3192. return primitives.includes(obj) || !!obj && _typeof(obj) === 'object';
  3193. } catch (e) {
  3194. /* ignore */
  3195. }
  3196. return false;
  3197. }
  3198. module.exports = exports.default;
  3199. module.exports.default = exports.default;
  3200. } (isJSON$1, isJSON$1.exports));
  3201. var isJSONValidator = /*@__PURE__*/getDefaultExportFromCjs(isJSON$1.exports);
  3202. var IS_JSON = 'isJson';
  3203. /**
  3204. * Checks if the string is valid JSON (note: uses JSON.parse).
  3205. * If given value is not a string, then it returns false.
  3206. */
  3207. function isJSON(value) {
  3208. return typeof value === 'string' && isJSONValidator(value);
  3209. }
  3210. /**
  3211. * Checks if the string is valid JSON (note: uses JSON.parse).
  3212. * If given value is not a string, then it returns false.
  3213. */
  3214. function IsJSON(validationOptions) {
  3215. return ValidateBy({
  3216. name: IS_JSON,
  3217. validator: {
  3218. validate: function (value, args) { return isJSON(value); },
  3219. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a json string'; }, validationOptions),
  3220. },
  3221. }, validationOptions);
  3222. }
  3223. var isJWT$1 = {exports: {}};
  3224. (function (module, exports) {
  3225. Object.defineProperty(exports, "__esModule", {
  3226. value: true
  3227. });
  3228. exports.default = isJWT;
  3229. var _assertString = _interopRequireDefault(assertString.exports);
  3230. var _isBase = _interopRequireDefault(isBase64$1.exports);
  3231. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3232. function isJWT(str) {
  3233. (0, _assertString.default)(str);
  3234. var dotSplit = str.split('.');
  3235. var len = dotSplit.length;
  3236. if (len > 3 || len < 2) {
  3237. return false;
  3238. }
  3239. return dotSplit.reduce(function (acc, currElem) {
  3240. return acc && (0, _isBase.default)(currElem, {
  3241. urlSafe: true
  3242. });
  3243. }, true);
  3244. }
  3245. module.exports = exports.default;
  3246. module.exports.default = exports.default;
  3247. } (isJWT$1, isJWT$1.exports));
  3248. var isJwtValidator = /*@__PURE__*/getDefaultExportFromCjs(isJWT$1.exports);
  3249. var IS_JWT = 'isJwt';
  3250. /**
  3251. * Checks if the string is valid JWT token.
  3252. * If given value is not a string, then it returns false.
  3253. */
  3254. function isJWT(value) {
  3255. return typeof value === 'string' && isJwtValidator(value);
  3256. }
  3257. /**
  3258. * Checks if the string is valid JWT token.
  3259. * If given value is not a string, then it returns false.
  3260. */
  3261. function IsJWT(validationOptions) {
  3262. return ValidateBy({
  3263. name: IS_JWT,
  3264. validator: {
  3265. validate: function (value, args) { return isJWT(value); },
  3266. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a jwt string'; }, validationOptions),
  3267. },
  3268. }, validationOptions);
  3269. }
  3270. var isLowercase$1 = {exports: {}};
  3271. (function (module, exports) {
  3272. Object.defineProperty(exports, "__esModule", {
  3273. value: true
  3274. });
  3275. exports.default = isLowercase;
  3276. var _assertString = _interopRequireDefault(assertString.exports);
  3277. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3278. function isLowercase(str) {
  3279. (0, _assertString.default)(str);
  3280. return str === str.toLowerCase();
  3281. }
  3282. module.exports = exports.default;
  3283. module.exports.default = exports.default;
  3284. } (isLowercase$1, isLowercase$1.exports));
  3285. var isLowercaseValidator = /*@__PURE__*/getDefaultExportFromCjs(isLowercase$1.exports);
  3286. var IS_LOWERCASE = 'isLowercase';
  3287. /**
  3288. * Checks if the string is lowercase.
  3289. * If given value is not a string, then it returns false.
  3290. */
  3291. function isLowercase(value) {
  3292. return typeof value === 'string' && isLowercaseValidator(value);
  3293. }
  3294. /**
  3295. * Checks if the string is lowercase.
  3296. * If given value is not a string, then it returns false.
  3297. */
  3298. function IsLowercase(validationOptions) {
  3299. return ValidateBy({
  3300. name: IS_LOWERCASE,
  3301. validator: {
  3302. validate: function (value, args) { return isLowercase(value); },
  3303. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a lowercase string'; }, validationOptions),
  3304. },
  3305. }, validationOptions);
  3306. }
  3307. var isMobilePhone$2 = {};
  3308. Object.defineProperty(isMobilePhone$2, "__esModule", {
  3309. value: true
  3310. });
  3311. var _default$4 = isMobilePhone$2.default = isMobilePhone$1;
  3312. isMobilePhone$2.locales = void 0;
  3313. var _assertString$5 = _interopRequireDefault$5(assertString.exports);
  3314. function _interopRequireDefault$5(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3315. /* eslint-disable max-len */
  3316. var phones = {
  3317. 'am-AM': /^(\+?374|0)((10|[9|7][0-9])\d{6}$|[2-4]\d{7}$)/,
  3318. 'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/,
  3319. 'ar-BH': /^(\+?973)?(3|6)\d{7}$/,
  3320. 'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/,
  3321. 'ar-LB': /^(\+?961)?((3|81)\d{6}|7\d{7})$/,
  3322. 'ar-EG': /^((\+?20)|0)?1[0125]\d{8}$/,
  3323. 'ar-IQ': /^(\+?964|0)?7[0-9]\d{8}$/,
  3324. 'ar-JO': /^(\+?962|0)?7[789]\d{7}$/,
  3325. 'ar-KW': /^(\+?965)[569]\d{7}$/,
  3326. 'ar-LY': /^((\+?218)|0)?(9[1-6]\d{7}|[1-8]\d{7,9})$/,
  3327. 'ar-MA': /^(?:(?:\+|00)212|0)[5-7]\d{8}$/,
  3328. 'ar-OM': /^((\+|00)968)?(9[1-9])\d{6}$/,
  3329. 'ar-PS': /^(\+?970|0)5[6|9](\d{7})$/,
  3330. 'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/,
  3331. 'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/,
  3332. 'ar-TN': /^(\+?216)?[2459]\d{7}$/,
  3333. 'az-AZ': /^(\+994|0)(5[015]|7[07]|99)\d{7}$/,
  3334. 'bs-BA': /^((((\+|00)3876)|06))((([0-3]|[5-6])\d{6})|(4\d{7}))$/,
  3335. 'be-BY': /^(\+?375)?(24|25|29|33|44)\d{7}$/,
  3336. 'bg-BG': /^(\+?359|0)?8[789]\d{7}$/,
  3337. 'bn-BD': /^(\+?880|0)1[13456789][0-9]{8}$/,
  3338. 'ca-AD': /^(\+376)?[346]\d{5}$/,
  3339. 'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
  3340. 'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,
  3341. 'de-DE': /^((\+49|0)[1|3])([0|5][0-45-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7,9}$/,
  3342. 'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/,
  3343. 'de-CH': /^(\+41|0)([1-9])\d{1,9}$/,
  3344. 'de-LU': /^(\+352)?((6\d1)\d{6})$/,
  3345. 'dv-MV': /^(\+?960)?(7[2-9]|91|9[3-9])\d{7}$/,
  3346. 'el-GR': /^(\+?30|0)?(69\d{8})$/,
  3347. 'en-AU': /^(\+?61|0)4\d{8}$/,
  3348. 'en-BM': /^(\+?1)?441(((3|7)\d{6}$)|(5[0-3][0-9]\d{4}$)|(59\d{5}))/,
  3349. 'en-GB': /^(\+?44|0)7\d{9}$/,
  3350. 'en-GG': /^(\+?44|0)1481\d{6}$/,
  3351. 'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28|55|59)\d{7}$/,
  3352. 'en-GY': /^(\+592|0)6\d{6}$/,
  3353. 'en-HK': /^(\+?852[-\s]?)?[456789]\d{3}[-\s]?\d{4}$/,
  3354. 'en-MO': /^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/,
  3355. 'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
  3356. 'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
  3357. 'en-KE': /^(\+?254|0)(7|1)\d{8}$/,
  3358. 'en-KI': /^((\+686|686)?)?( )?((6|7)(2|3|8)[0-9]{6})$/,
  3359. 'en-MT': /^(\+?356|0)?(99|79|77|21|27|22|25)[0-9]{6}$/,
  3360. 'en-MU': /^(\+?230|0)?\d{8}$/,
  3361. 'en-NA': /^(\+?264|0)(6|8)\d{7}$/,
  3362. 'en-NG': /^(\+?234|0)?[789]\d{9}$/,
  3363. 'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
  3364. 'en-PK': /^((00|\+)?92|0)3[0-6]\d{8}$/,
  3365. 'en-PH': /^(09|\+639)\d{9}$/,
  3366. 'en-RW': /^(\+?250|0)?[7]\d{8}$/,
  3367. 'en-SG': /^(\+65)?[3689]\d{7}$/,
  3368. 'en-SL': /^(\+?232|0)\d{8}$/,
  3369. 'en-TZ': /^(\+?255|0)?[67]\d{8}$/,
  3370. 'en-UG': /^(\+?256|0)?[7]\d{8}$/,
  3371. 'en-US': /^((\+1|1)?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/,
  3372. 'en-ZA': /^(\+?27|0)\d{9}$/,
  3373. 'en-ZM': /^(\+?26)?09[567]\d{7}$/,
  3374. 'en-ZW': /^(\+263)[0-9]{9}$/,
  3375. 'en-BW': /^(\+?267)?(7[1-8]{1})\d{6}$/,
  3376. 'es-AR': /^\+?549(11|[2368]\d)\d{8}$/,
  3377. 'es-BO': /^(\+?591)?(6|7)\d{7}$/,
  3378. 'es-CO': /^(\+?57)?3(0(0|1|2|4|5)|1\d|2[0-4]|5(0|1))\d{7}$/,
  3379. 'es-CL': /^(\+?56|0)[2-9]\d{1}\d{7}$/,
  3380. 'es-CR': /^(\+506)?[2-8]\d{7}$/,
  3381. 'es-CU': /^(\+53|0053)?5\d{7}/,
  3382. 'es-DO': /^(\+?1)?8[024]9\d{7}$/,
  3383. 'es-HN': /^(\+?504)?[9|8]\d{7}$/,
  3384. 'es-EC': /^(\+?593|0)([2-7]|9[2-9])\d{7}$/,
  3385. 'es-ES': /^(\+?34)?[6|7]\d{8}$/,
  3386. 'es-PE': /^(\+?51)?9\d{8}$/,
  3387. 'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
  3388. 'es-PA': /^(\+?507)\d{7,8}$/,
  3389. 'es-PY': /^(\+?595|0)9[9876]\d{7}$/,
  3390. 'es-SV': /^(\+?503)?[67]\d{7}$/,
  3391. 'es-UY': /^(\+598|0)9[1-9][\d]{6}$/,
  3392. 'es-VE': /^(\+?58)?(2|4)\d{9}$/,
  3393. 'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/,
  3394. 'fa-IR': /^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/,
  3395. 'fi-FI': /^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/,
  3396. 'fj-FJ': /^(\+?679)?\s?\d{3}\s?\d{4}$/,
  3397. 'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
  3398. 'fr-BF': /^(\+226|0)[67]\d{7}$/,
  3399. 'fr-CM': /^(\+?237)6[0-9]{8}$/,
  3400. 'fr-FR': /^(\+?33|0)[67]\d{8}$/,
  3401. 'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/,
  3402. 'fr-GP': /^(\+?590|0|00590)[67]\d{8}$/,
  3403. 'fr-MQ': /^(\+?596|0|00596)[67]\d{8}$/,
  3404. 'fr-PF': /^(\+?689)?8[789]\d{6}$/,
  3405. 'fr-RE': /^(\+?262|0|00262)[67]\d{8}$/,
  3406. 'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/,
  3407. 'hu-HU': /^(\+?36|06)(20|30|31|50|70)\d{7}$/,
  3408. 'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/,
  3409. 'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/,
  3410. 'it-SM': /^((\+378)|(0549)|(\+390549)|(\+3780549))?6\d{5,9}$/,
  3411. 'ja-JP': /^(\+81[ \-]?(\(0\))?|0)[6789]0[ \-]?\d{4}[ \-]?\d{4}$/,
  3412. 'ka-GE': /^(\+?995)?(5|79)\d{7}$/,
  3413. 'kk-KZ': /^(\+?7|8)?7\d{9}$/,
  3414. 'kl-GL': /^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
  3415. 'ko-KR': /^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,
  3416. 'lt-LT': /^(\+370|8)\d{8}$/,
  3417. 'lv-LV': /^(\+?371)2\d{7}$/,
  3418. 'ms-MY': /^(\+?6?01){1}(([0145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/,
  3419. 'mz-MZ': /^(\+?258)?8[234567]\d{7}$/,
  3420. 'nb-NO': /^(\+?47)?[49]\d{7}$/,
  3421. 'ne-NP': /^(\+?977)?9[78]\d{8}$/,
  3422. 'nl-BE': /^(\+?32|0)4\d{8}$/,
  3423. 'nl-NL': /^(((\+|00)?31\(0\))|((\+|00)?31)|0)6{1}\d{8}$/,
  3424. 'nn-NO': /^(\+?47)?[49]\d{7}$/,
  3425. 'pl-PL': /^(\+?48)? ?[5-8]\d ?\d{3} ?\d{2} ?\d{2}$/,
  3426. 'pt-BR': /^((\+?55\ ?[1-9]{2}\ ?)|(\+?55\ ?\([1-9]{2}\)\ ?)|(0[1-9]{2}\ ?)|(\([1-9]{2}\)\ ?)|([1-9]{2}\ ?))((\d{4}\-?\d{4})|(9[2-9]{1}\d{3}\-?\d{4}))$/,
  3427. 'pt-PT': /^(\+?351)?9[1236]\d{7}$/,
  3428. 'pt-AO': /^(\+244)\d{9}$/,
  3429. 'ro-RO': /^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/,
  3430. 'ru-RU': /^(\+?7|8)?9\d{9}$/,
  3431. 'si-LK': /^(?:0|94|\+94)?(7(0|1|2|4|5|6|7|8)( |-)?)\d{7}$/,
  3432. 'sl-SI': /^(\+386\s?|0)(\d{1}\s?\d{3}\s?\d{2}\s?\d{2}|\d{2}\s?\d{3}\s?\d{3})$/,
  3433. 'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
  3434. 'sq-AL': /^(\+355|0)6[789]\d{6}$/,
  3435. 'sr-RS': /^(\+3816|06)[- \d]{5,9}$/,
  3436. 'sv-SE': /^(\+?46|0)[\s\-]?7[\s\-]?[02369]([\s\-]?\d){7}$/,
  3437. 'tg-TJ': /^(\+?992)?[5][5]\d{7}$/,
  3438. 'th-TH': /^(\+66|66|0)\d{9}$/,
  3439. 'tr-TR': /^(\+?90|0)?5\d{9}$/,
  3440. 'tk-TM': /^(\+993|993|8)\d{8}$/,
  3441. 'uk-UA': /^(\+?38|8)?0\d{9}$/,
  3442. 'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/,
  3443. 'vi-VN': /^((\+?84)|0)((3([2-9]))|(5([25689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/,
  3444. 'zh-CN': /^((\+|00)86)?(1[3-9]|9[28])\d{9}$/,
  3445. 'zh-TW': /^(\+?886\-?|0)?9\d{8}$/,
  3446. 'dz-BT': /^(\+?975|0)?(17|16|77|02)\d{6}$/
  3447. };
  3448. /* eslint-enable max-len */
  3449. // aliases
  3450. phones['en-CA'] = phones['en-US'];
  3451. phones['fr-CA'] = phones['en-CA'];
  3452. phones['fr-BE'] = phones['nl-BE'];
  3453. phones['zh-HK'] = phones['en-HK'];
  3454. phones['zh-MO'] = phones['en-MO'];
  3455. phones['ga-IE'] = phones['en-IE'];
  3456. phones['fr-CH'] = phones['de-CH'];
  3457. phones['it-CH'] = phones['fr-CH'];
  3458. function isMobilePhone$1(str, locale, options) {
  3459. (0, _assertString$5.default)(str);
  3460. if (options && options.strictMode && !str.startsWith('+')) {
  3461. return false;
  3462. }
  3463. if (Array.isArray(locale)) {
  3464. return locale.some(function (key) {
  3465. // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
  3466. // istanbul ignore else
  3467. if (phones.hasOwnProperty(key)) {
  3468. var phone = phones[key];
  3469. if (phone.test(str)) {
  3470. return true;
  3471. }
  3472. }
  3473. return false;
  3474. });
  3475. } else if (locale in phones) {
  3476. return phones[locale].test(str); // alias falsey locale as 'any'
  3477. } else if (!locale || locale === 'any') {
  3478. for (var key in phones) {
  3479. // istanbul ignore else
  3480. if (phones.hasOwnProperty(key)) {
  3481. var phone = phones[key];
  3482. if (phone.test(str)) {
  3483. return true;
  3484. }
  3485. }
  3486. }
  3487. return false;
  3488. }
  3489. throw new Error("Invalid locale '".concat(locale, "'"));
  3490. }
  3491. var locales$2 = Object.keys(phones);
  3492. isMobilePhone$2.locales = locales$2;
  3493. var IS_MOBILE_PHONE = 'isMobilePhone';
  3494. /**
  3495. * Checks if the string is a mobile phone number (locale is either an array of locales (e.g ['sk-SK', 'sr-RS'])
  3496. * OR one of ['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-SA', 'ar-SY', 'ar-TN', 'be-BY',
  3497. * 'bg-BG', 'bn-BD', 'cs-CZ', 'da-DK', 'de-DE', 'de-AT', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-HK',
  3498. * 'en-MO', 'en-IE', 'en-IN', 'en-KE', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PK', 'en-RW', 'en-SG', 'en-SL', 'en-UG',
  3499. * 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'es-CL', 'es-CR', 'es-EC', 'es-ES', 'es-MX', 'es-PA', 'es-PY', 'es-UY', 'et-EE',
  3500. * 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-RE', 'he-IL', 'hu-HU', 'id-ID',
  3501. * 'it-IT', 'ja-JP', 'kk-KZ', 'kl-GL', 'ko-KR', 'lt-LT', 'ms-MY', 'nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL',
  3502. * 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'vi-VN', 'zh-CN',
  3503. * 'zh-HK', 'zh-MO', 'zh-TW']
  3504. * If given value is not a string, then it returns false.
  3505. */
  3506. function isMobilePhone(value, locale, options) {
  3507. return typeof value === 'string' && _default$4(value, locale, options);
  3508. }
  3509. /**
  3510. * Checks if the string is a mobile phone number (locale is either an array of locales (e.g ['sk-SK', 'sr-RS'])
  3511. * OR one of ['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-SA', 'ar-SY', 'ar-TN', 'be-BY',
  3512. * 'bg-BG', 'bn-BD', 'cs-CZ', 'da-DK', 'de-DE', 'de-AT', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-HK',
  3513. * 'en-MO', 'en-IE', 'en-IN', 'en-KE', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PK', 'en-RW', 'en-SG', 'en-SL', 'en-UG',
  3514. * 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'es-CL', 'es-CR', 'es-EC', 'es-ES', 'es-MX', 'es-PA', 'es-PY', 'es-UY', 'et-EE',
  3515. * 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-RE', 'he-IL', 'hu-HU', 'id-ID',
  3516. * 'it-IT', 'ja-JP', 'kk-KZ', 'kl-GL', 'ko-KR', 'lt-LT', 'ms-MY', 'nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL',
  3517. * 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'vi-VN', 'zh-CN',
  3518. * 'zh-HK', 'zh-MO', 'zh-TW']
  3519. * If given value is not a string, then it returns false.
  3520. */
  3521. function IsMobilePhone(locale, options, validationOptions) {
  3522. return ValidateBy({
  3523. name: IS_MOBILE_PHONE,
  3524. constraints: [locale, options],
  3525. validator: {
  3526. validate: function (value, args) { return isMobilePhone(value, args === null || args === void 0 ? void 0 : args.constraints[0], args === null || args === void 0 ? void 0 : args.constraints[1]); },
  3527. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a phone number'; }, validationOptions),
  3528. },
  3529. }, validationOptions);
  3530. }
  3531. var isISO31661Alpha2$2 = {};
  3532. Object.defineProperty(isISO31661Alpha2$2, "__esModule", {
  3533. value: true
  3534. });
  3535. var _default$3 = isISO31661Alpha2$2.default = isISO31661Alpha2$1;
  3536. isISO31661Alpha2$2.CountryCodes = void 0;
  3537. var _assertString$4 = _interopRequireDefault$4(assertString.exports);
  3538. function _interopRequireDefault$4(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3539. // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
  3540. var validISO31661Alpha2CountriesCodes = new Set(['AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SX', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'ZA', 'ZM', 'ZW']);
  3541. function isISO31661Alpha2$1(str) {
  3542. (0, _assertString$4.default)(str);
  3543. return validISO31661Alpha2CountriesCodes.has(str.toUpperCase());
  3544. }
  3545. var CountryCodes = validISO31661Alpha2CountriesCodes;
  3546. isISO31661Alpha2$2.CountryCodes = CountryCodes;
  3547. var IS_ISO31661_ALPHA_2 = 'isISO31661Alpha2';
  3548. /**
  3549. * Check if the string is a valid [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) officially assigned country code.
  3550. */
  3551. function isISO31661Alpha2(value) {
  3552. return typeof value === 'string' && _default$3(value);
  3553. }
  3554. /**
  3555. * Check if the string is a valid [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) officially assigned country code.
  3556. */
  3557. function IsISO31661Alpha2(validationOptions) {
  3558. return ValidateBy({
  3559. name: IS_ISO31661_ALPHA_2,
  3560. validator: {
  3561. validate: function (value, args) { return isISO31661Alpha2(value); },
  3562. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a valid ISO31661 Alpha2 code'; }, validationOptions),
  3563. },
  3564. }, validationOptions);
  3565. }
  3566. var isISO31661Alpha3$1 = {exports: {}};
  3567. (function (module, exports) {
  3568. Object.defineProperty(exports, "__esModule", {
  3569. value: true
  3570. });
  3571. exports.default = isISO31661Alpha3;
  3572. var _assertString = _interopRequireDefault(assertString.exports);
  3573. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3574. // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
  3575. var validISO31661Alpha3CountriesCodes = new Set(['AFG', 'ALA', 'ALB', 'DZA', 'ASM', 'AND', 'AGO', 'AIA', 'ATA', 'ATG', 'ARG', 'ARM', 'ABW', 'AUS', 'AUT', 'AZE', 'BHS', 'BHR', 'BGD', 'BRB', 'BLR', 'BEL', 'BLZ', 'BEN', 'BMU', 'BTN', 'BOL', 'BES', 'BIH', 'BWA', 'BVT', 'BRA', 'IOT', 'BRN', 'BGR', 'BFA', 'BDI', 'KHM', 'CMR', 'CAN', 'CPV', 'CYM', 'CAF', 'TCD', 'CHL', 'CHN', 'CXR', 'CCK', 'COL', 'COM', 'COG', 'COD', 'COK', 'CRI', 'CIV', 'HRV', 'CUB', 'CUW', 'CYP', 'CZE', 'DNK', 'DJI', 'DMA', 'DOM', 'ECU', 'EGY', 'SLV', 'GNQ', 'ERI', 'EST', 'ETH', 'FLK', 'FRO', 'FJI', 'FIN', 'FRA', 'GUF', 'PYF', 'ATF', 'GAB', 'GMB', 'GEO', 'DEU', 'GHA', 'GIB', 'GRC', 'GRL', 'GRD', 'GLP', 'GUM', 'GTM', 'GGY', 'GIN', 'GNB', 'GUY', 'HTI', 'HMD', 'VAT', 'HND', 'HKG', 'HUN', 'ISL', 'IND', 'IDN', 'IRN', 'IRQ', 'IRL', 'IMN', 'ISR', 'ITA', 'JAM', 'JPN', 'JEY', 'JOR', 'KAZ', 'KEN', 'KIR', 'PRK', 'KOR', 'KWT', 'KGZ', 'LAO', 'LVA', 'LBN', 'LSO', 'LBR', 'LBY', 'LIE', 'LTU', 'LUX', 'MAC', 'MKD', 'MDG', 'MWI', 'MYS', 'MDV', 'MLI', 'MLT', 'MHL', 'MTQ', 'MRT', 'MUS', 'MYT', 'MEX', 'FSM', 'MDA', 'MCO', 'MNG', 'MNE', 'MSR', 'MAR', 'MOZ', 'MMR', 'NAM', 'NRU', 'NPL', 'NLD', 'NCL', 'NZL', 'NIC', 'NER', 'NGA', 'NIU', 'NFK', 'MNP', 'NOR', 'OMN', 'PAK', 'PLW', 'PSE', 'PAN', 'PNG', 'PRY', 'PER', 'PHL', 'PCN', 'POL', 'PRT', 'PRI', 'QAT', 'REU', 'ROU', 'RUS', 'RWA', 'BLM', 'SHN', 'KNA', 'LCA', 'MAF', 'SPM', 'VCT', 'WSM', 'SMR', 'STP', 'SAU', 'SEN', 'SRB', 'SYC', 'SLE', 'SGP', 'SXM', 'SVK', 'SVN', 'SLB', 'SOM', 'ZAF', 'SGS', 'SSD', 'ESP', 'LKA', 'SDN', 'SUR', 'SJM', 'SWZ', 'SWE', 'CHE', 'SYR', 'TWN', 'TJK', 'TZA', 'THA', 'TLS', 'TGO', 'TKL', 'TON', 'TTO', 'TUN', 'TUR', 'TKM', 'TCA', 'TUV', 'UGA', 'UKR', 'ARE', 'GBR', 'USA', 'UMI', 'URY', 'UZB', 'VUT', 'VEN', 'VNM', 'VGB', 'VIR', 'WLF', 'ESH', 'YEM', 'ZMB', 'ZWE']);
  3576. function isISO31661Alpha3(str) {
  3577. (0, _assertString.default)(str);
  3578. return validISO31661Alpha3CountriesCodes.has(str.toUpperCase());
  3579. }
  3580. module.exports = exports.default;
  3581. module.exports.default = exports.default;
  3582. } (isISO31661Alpha3$1, isISO31661Alpha3$1.exports));
  3583. var isISO31661Alpha3Validator = /*@__PURE__*/getDefaultExportFromCjs(isISO31661Alpha3$1.exports);
  3584. var IS_ISO31661_ALPHA_3 = 'isISO31661Alpha3';
  3585. /**
  3586. * Check if the string is a valid [ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) officially assigned country code.
  3587. */
  3588. function isISO31661Alpha3(value) {
  3589. return typeof value === 'string' && isISO31661Alpha3Validator(value);
  3590. }
  3591. /**
  3592. * Check if the string is a valid [ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) officially assigned country code.
  3593. */
  3594. function IsISO31661Alpha3(validationOptions) {
  3595. return ValidateBy({
  3596. name: IS_ISO31661_ALPHA_3,
  3597. validator: {
  3598. validate: function (value, args) { return isISO31661Alpha3(value); },
  3599. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a valid ISO31661 Alpha3 code'; }, validationOptions),
  3600. },
  3601. }, validationOptions);
  3602. }
  3603. var isMongoId$1 = {exports: {}};
  3604. (function (module, exports) {
  3605. Object.defineProperty(exports, "__esModule", {
  3606. value: true
  3607. });
  3608. exports.default = isMongoId;
  3609. var _assertString = _interopRequireDefault(assertString.exports);
  3610. var _isHexadecimal = _interopRequireDefault(isHexadecimal$1.exports);
  3611. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3612. function isMongoId(str) {
  3613. (0, _assertString.default)(str);
  3614. return (0, _isHexadecimal.default)(str) && str.length === 24;
  3615. }
  3616. module.exports = exports.default;
  3617. module.exports.default = exports.default;
  3618. } (isMongoId$1, isMongoId$1.exports));
  3619. var isMongoIdValidator = /*@__PURE__*/getDefaultExportFromCjs(isMongoId$1.exports);
  3620. var IS_MONGO_ID = 'isMongoId';
  3621. /**
  3622. * Checks if the string is a valid hex-encoded representation of a MongoDB ObjectId.
  3623. * If given value is not a string, then it returns false.
  3624. */
  3625. function isMongoId(value) {
  3626. return typeof value === 'string' && isMongoIdValidator(value);
  3627. }
  3628. /**
  3629. * Checks if the string is a valid hex-encoded representation of a MongoDB ObjectId.
  3630. * If given value is not a string, then it returns false.
  3631. */
  3632. function IsMongoId(validationOptions) {
  3633. return ValidateBy({
  3634. name: IS_MONGO_ID,
  3635. validator: {
  3636. validate: function (value, args) { return isMongoId(value); },
  3637. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a mongodb id'; }, validationOptions),
  3638. },
  3639. }, validationOptions);
  3640. }
  3641. var isMultibyte$1 = {exports: {}};
  3642. (function (module, exports) {
  3643. Object.defineProperty(exports, "__esModule", {
  3644. value: true
  3645. });
  3646. exports.default = isMultibyte;
  3647. var _assertString = _interopRequireDefault(assertString.exports);
  3648. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3649. /* eslint-disable no-control-regex */
  3650. var multibyte = /[^\x00-\x7F]/;
  3651. /* eslint-enable no-control-regex */
  3652. function isMultibyte(str) {
  3653. (0, _assertString.default)(str);
  3654. return multibyte.test(str);
  3655. }
  3656. module.exports = exports.default;
  3657. module.exports.default = exports.default;
  3658. } (isMultibyte$1, isMultibyte$1.exports));
  3659. var isMultibyteValidator = /*@__PURE__*/getDefaultExportFromCjs(isMultibyte$1.exports);
  3660. var IS_MULTIBYTE = 'isMultibyte';
  3661. /**
  3662. * Checks if the string contains one or more multibyte chars.
  3663. * If given value is not a string, then it returns false.
  3664. */
  3665. function isMultibyte(value) {
  3666. return typeof value === 'string' && isMultibyteValidator(value);
  3667. }
  3668. /**
  3669. * Checks if the string contains one or more multibyte chars.
  3670. * If given value is not a string, then it returns false.
  3671. */
  3672. function IsMultibyte(validationOptions) {
  3673. return ValidateBy({
  3674. name: IS_MULTIBYTE,
  3675. validator: {
  3676. validate: function (value, args) { return isMultibyte(value); },
  3677. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must contain one or more multibyte chars'; }, validationOptions),
  3678. },
  3679. }, validationOptions);
  3680. }
  3681. var isSurrogatePair$1 = {exports: {}};
  3682. (function (module, exports) {
  3683. Object.defineProperty(exports, "__esModule", {
  3684. value: true
  3685. });
  3686. exports.default = isSurrogatePair;
  3687. var _assertString = _interopRequireDefault(assertString.exports);
  3688. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3689. var surrogatePair = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
  3690. function isSurrogatePair(str) {
  3691. (0, _assertString.default)(str);
  3692. return surrogatePair.test(str);
  3693. }
  3694. module.exports = exports.default;
  3695. module.exports.default = exports.default;
  3696. } (isSurrogatePair$1, isSurrogatePair$1.exports));
  3697. var isSurrogatePairValidator = /*@__PURE__*/getDefaultExportFromCjs(isSurrogatePair$1.exports);
  3698. var IS_SURROGATE_PAIR = 'isSurrogatePair';
  3699. /**
  3700. * Checks if the string contains any surrogate pairs chars.
  3701. * If given value is not a string, then it returns false.
  3702. */
  3703. function isSurrogatePair(value) {
  3704. return typeof value === 'string' && isSurrogatePairValidator(value);
  3705. }
  3706. /**
  3707. * Checks if the string contains any surrogate pairs chars.
  3708. * If given value is not a string, then it returns false.
  3709. */
  3710. function IsSurrogatePair(validationOptions) {
  3711. return ValidateBy({
  3712. name: IS_SURROGATE_PAIR,
  3713. validator: {
  3714. validate: function (value, args) { return isSurrogatePair(value); },
  3715. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must contain any surrogate pairs chars'; }, validationOptions),
  3716. },
  3717. }, validationOptions);
  3718. }
  3719. var isURL$1 = {exports: {}};
  3720. (function (module, exports) {
  3721. Object.defineProperty(exports, "__esModule", {
  3722. value: true
  3723. });
  3724. exports.default = isURL;
  3725. var _assertString = _interopRequireDefault(assertString.exports);
  3726. var _isFQDN = _interopRequireDefault(isFQDN$1.exports);
  3727. var _isIP = _interopRequireDefault(isIP$1.exports);
  3728. var _merge = _interopRequireDefault(merge.exports);
  3729. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3730. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  3731. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  3732. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  3733. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  3734. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  3735. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  3736. /*
  3737. options for isURL method
  3738. require_protocol - if set as true isURL will return false if protocol is not present in the URL
  3739. require_valid_protocol - isURL will check if the URL's protocol is present in the protocols option
  3740. protocols - valid protocols can be modified with this option
  3741. require_host - if set as false isURL will not check if host is present in the URL
  3742. require_port - if set as true isURL will check if port is present in the URL
  3743. allow_protocol_relative_urls - if set as true protocol relative URLs will be allowed
  3744. validate_length - if set as false isURL will skip string length validation (IE maximum is 2083)
  3745. */
  3746. var default_url_options = {
  3747. protocols: ['http', 'https', 'ftp'],
  3748. require_tld: true,
  3749. require_protocol: false,
  3750. require_host: true,
  3751. require_port: false,
  3752. require_valid_protocol: true,
  3753. allow_underscores: false,
  3754. allow_trailing_dot: false,
  3755. allow_protocol_relative_urls: false,
  3756. allow_fragments: true,
  3757. allow_query_components: true,
  3758. validate_length: true
  3759. };
  3760. var wrapped_ipv6 = /^\[([^\]]+)\](?::([0-9]+))?$/;
  3761. function isRegExp(obj) {
  3762. return Object.prototype.toString.call(obj) === '[object RegExp]';
  3763. }
  3764. function checkHost(host, matches) {
  3765. for (var i = 0; i < matches.length; i++) {
  3766. var match = matches[i];
  3767. if (host === match || isRegExp(match) && match.test(host)) {
  3768. return true;
  3769. }
  3770. }
  3771. return false;
  3772. }
  3773. function isURL(url, options) {
  3774. (0, _assertString.default)(url);
  3775. if (!url || /[\s<>]/.test(url)) {
  3776. return false;
  3777. }
  3778. if (url.indexOf('mailto:') === 0) {
  3779. return false;
  3780. }
  3781. options = (0, _merge.default)(options, default_url_options);
  3782. if (options.validate_length && url.length >= 2083) {
  3783. return false;
  3784. }
  3785. if (!options.allow_fragments && url.includes('#')) {
  3786. return false;
  3787. }
  3788. if (!options.allow_query_components && (url.includes('?') || url.includes('&'))) {
  3789. return false;
  3790. }
  3791. var protocol, auth, host, hostname, port, port_str, split, ipv6;
  3792. split = url.split('#');
  3793. url = split.shift();
  3794. split = url.split('?');
  3795. url = split.shift();
  3796. split = url.split('://');
  3797. if (split.length > 1) {
  3798. protocol = split.shift().toLowerCase();
  3799. if (options.require_valid_protocol && options.protocols.indexOf(protocol) === -1) {
  3800. return false;
  3801. }
  3802. } else if (options.require_protocol) {
  3803. return false;
  3804. } else if (url.substr(0, 2) === '//') {
  3805. if (!options.allow_protocol_relative_urls) {
  3806. return false;
  3807. }
  3808. split[0] = url.substr(2);
  3809. }
  3810. url = split.join('://');
  3811. if (url === '') {
  3812. return false;
  3813. }
  3814. split = url.split('/');
  3815. url = split.shift();
  3816. if (url === '' && !options.require_host) {
  3817. return true;
  3818. }
  3819. split = url.split('@');
  3820. if (split.length > 1) {
  3821. if (options.disallow_auth) {
  3822. return false;
  3823. }
  3824. if (split[0] === '') {
  3825. return false;
  3826. }
  3827. auth = split.shift();
  3828. if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) {
  3829. return false;
  3830. }
  3831. var _auth$split = auth.split(':'),
  3832. _auth$split2 = _slicedToArray(_auth$split, 2),
  3833. user = _auth$split2[0],
  3834. password = _auth$split2[1];
  3835. if (user === '' && password === '') {
  3836. return false;
  3837. }
  3838. }
  3839. hostname = split.join('@');
  3840. port_str = null;
  3841. ipv6 = null;
  3842. var ipv6_match = hostname.match(wrapped_ipv6);
  3843. if (ipv6_match) {
  3844. host = '';
  3845. ipv6 = ipv6_match[1];
  3846. port_str = ipv6_match[2] || null;
  3847. } else {
  3848. split = hostname.split(':');
  3849. host = split.shift();
  3850. if (split.length) {
  3851. port_str = split.join(':');
  3852. }
  3853. }
  3854. if (port_str !== null && port_str.length > 0) {
  3855. port = parseInt(port_str, 10);
  3856. if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) {
  3857. return false;
  3858. }
  3859. } else if (options.require_port) {
  3860. return false;
  3861. }
  3862. if (options.host_whitelist) {
  3863. return checkHost(host, options.host_whitelist);
  3864. }
  3865. if (!(0, _isIP.default)(host) && !(0, _isFQDN.default)(host, options) && (!ipv6 || !(0, _isIP.default)(ipv6, 6))) {
  3866. return false;
  3867. }
  3868. host = host || ipv6;
  3869. if (options.host_blacklist && checkHost(host, options.host_blacklist)) {
  3870. return false;
  3871. }
  3872. return true;
  3873. }
  3874. module.exports = exports.default;
  3875. module.exports.default = exports.default;
  3876. } (isURL$1, isURL$1.exports));
  3877. var isUrlValidator = /*@__PURE__*/getDefaultExportFromCjs(isURL$1.exports);
  3878. var IS_URL = 'isUrl';
  3879. /**
  3880. * Checks if the string is a url.
  3881. * If given value is not a string, then it returns false.
  3882. */
  3883. function isURL(value, options) {
  3884. return typeof value === 'string' && isUrlValidator(value, options);
  3885. }
  3886. /**
  3887. * Checks if the string is a url.
  3888. * If given value is not a string, then it returns false.
  3889. */
  3890. function IsUrl(options, validationOptions) {
  3891. return ValidateBy({
  3892. name: IS_URL,
  3893. constraints: [options],
  3894. validator: {
  3895. validate: function (value, args) { return isURL(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  3896. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a URL address'; }, validationOptions),
  3897. },
  3898. }, validationOptions);
  3899. }
  3900. var isUUID$1 = {exports: {}};
  3901. (function (module, exports) {
  3902. Object.defineProperty(exports, "__esModule", {
  3903. value: true
  3904. });
  3905. exports.default = isUUID;
  3906. var _assertString = _interopRequireDefault(assertString.exports);
  3907. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3908. var uuid = {
  3909. 1: /^[0-9A-F]{8}-[0-9A-F]{4}-1[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
  3910. 2: /^[0-9A-F]{8}-[0-9A-F]{4}-2[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
  3911. 3: /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
  3912. 4: /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
  3913. 5: /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
  3914. all: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i
  3915. };
  3916. function isUUID(str, version) {
  3917. (0, _assertString.default)(str);
  3918. var pattern = uuid[![undefined, null].includes(version) ? version : 'all'];
  3919. return !!pattern && pattern.test(str);
  3920. }
  3921. module.exports = exports.default;
  3922. module.exports.default = exports.default;
  3923. } (isUUID$1, isUUID$1.exports));
  3924. var isUuidValidator = /*@__PURE__*/getDefaultExportFromCjs(isUUID$1.exports);
  3925. var IS_UUID = 'isUuid';
  3926. /**
  3927. * Checks if the string is a UUID (version 3, 4 or 5).
  3928. * If given value is not a string, then it returns false.
  3929. */
  3930. function isUUID(value, version) {
  3931. return typeof value === 'string' && isUuidValidator(value, version);
  3932. }
  3933. /**
  3934. * Checks if the string is a UUID (version 3, 4 or 5).
  3935. * If given value is not a string, then it returns false.
  3936. */
  3937. function IsUUID(version, validationOptions) {
  3938. return ValidateBy({
  3939. name: IS_UUID,
  3940. constraints: [version],
  3941. validator: {
  3942. validate: function (value, args) { return isUUID(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  3943. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a UUID'; }, validationOptions),
  3944. },
  3945. }, validationOptions);
  3946. }
  3947. var IS_FIREBASE_PUSH_ID = 'IsFirebasePushId';
  3948. /**
  3949. * Checks if the string is a Firebase Push Id
  3950. * If given value is not a Firebase Push Id, it returns false
  3951. */
  3952. function isFirebasePushId(value) {
  3953. var webSafeRegex = /^[a-zA-Z0-9_-]*$/;
  3954. return typeof value === 'string' && value.length === 20 && webSafeRegex.test(value);
  3955. }
  3956. /**
  3957. * Checks if the string is a Firebase Push Id
  3958. * If given value is not a Firebase Push Id, it returns false
  3959. */
  3960. function IsFirebasePushId(validationOptions) {
  3961. return ValidateBy({
  3962. name: IS_FIREBASE_PUSH_ID,
  3963. validator: {
  3964. validate: function (value, args) { return isFirebasePushId(value); },
  3965. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a Firebase Push Id'; }, validationOptions),
  3966. },
  3967. }, validationOptions);
  3968. }
  3969. var isUppercase$1 = {exports: {}};
  3970. (function (module, exports) {
  3971. Object.defineProperty(exports, "__esModule", {
  3972. value: true
  3973. });
  3974. exports.default = isUppercase;
  3975. var _assertString = _interopRequireDefault(assertString.exports);
  3976. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3977. function isUppercase(str) {
  3978. (0, _assertString.default)(str);
  3979. return str === str.toUpperCase();
  3980. }
  3981. module.exports = exports.default;
  3982. module.exports.default = exports.default;
  3983. } (isUppercase$1, isUppercase$1.exports));
  3984. var isUppercaseValidator = /*@__PURE__*/getDefaultExportFromCjs(isUppercase$1.exports);
  3985. var IS_UPPERCASE = 'isUppercase';
  3986. /**
  3987. * Checks if the string is uppercase.
  3988. * If given value is not a string, then it returns false.
  3989. */
  3990. function isUppercase(value) {
  3991. return typeof value === 'string' && isUppercaseValidator(value);
  3992. }
  3993. /**
  3994. * Checks if the string is uppercase.
  3995. * If given value is not a string, then it returns false.
  3996. */
  3997. function IsUppercase(validationOptions) {
  3998. return ValidateBy({
  3999. name: IS_UPPERCASE,
  4000. validator: {
  4001. validate: function (value, args) { return isUppercase(value); },
  4002. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be uppercase'; }, validationOptions),
  4003. },
  4004. }, validationOptions);
  4005. }
  4006. var isLength = {exports: {}};
  4007. (function (module, exports) {
  4008. Object.defineProperty(exports, "__esModule", {
  4009. value: true
  4010. });
  4011. exports.default = isLength;
  4012. var _assertString = _interopRequireDefault(assertString.exports);
  4013. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4014. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  4015. /* eslint-disable prefer-rest-params */
  4016. function isLength(str, options) {
  4017. (0, _assertString.default)(str);
  4018. var min;
  4019. var max;
  4020. if (_typeof(options) === 'object') {
  4021. min = options.min || 0;
  4022. max = options.max;
  4023. } else {
  4024. // backwards compatibility: isLength(str, min [, max])
  4025. min = arguments[1] || 0;
  4026. max = arguments[2];
  4027. }
  4028. var surrogatePairs = str.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g) || [];
  4029. var len = str.length - surrogatePairs.length;
  4030. return len >= min && (typeof max === 'undefined' || len <= max);
  4031. }
  4032. module.exports = exports.default;
  4033. module.exports.default = exports.default;
  4034. } (isLength, isLength.exports));
  4035. var isLengthValidator = /*@__PURE__*/getDefaultExportFromCjs(isLength.exports);
  4036. var IS_LENGTH = 'isLength';
  4037. /**
  4038. * Checks if the string's length falls in a range. Note: this function takes into account surrogate pairs.
  4039. * If given value is not a string, then it returns false.
  4040. */
  4041. function length(value, min, max) {
  4042. return typeof value === 'string' && isLengthValidator(value, { min: min, max: max });
  4043. }
  4044. /**
  4045. * Checks if the string's length falls in a range. Note: this function takes into account surrogate pairs.
  4046. * If given value is not a string, then it returns false.
  4047. */
  4048. function Length(min, max, validationOptions) {
  4049. return ValidateBy({
  4050. name: IS_LENGTH,
  4051. constraints: [min, max],
  4052. validator: {
  4053. validate: function (value, args) { return length(value, args === null || args === void 0 ? void 0 : args.constraints[0], args === null || args === void 0 ? void 0 : args.constraints[1]); },
  4054. defaultMessage: buildMessage(function (eachPrefix, args) {
  4055. var isMinLength = (args === null || args === void 0 ? void 0 : args.constraints[0]) !== null && (args === null || args === void 0 ? void 0 : args.constraints[0]) !== undefined;
  4056. var isMaxLength = (args === null || args === void 0 ? void 0 : args.constraints[1]) !== null && (args === null || args === void 0 ? void 0 : args.constraints[1]) !== undefined;
  4057. if (isMinLength && (!args.value || args.value.length < (args === null || args === void 0 ? void 0 : args.constraints[0]))) {
  4058. return eachPrefix + '$property must be longer than or equal to $constraint1 characters';
  4059. }
  4060. else if (isMaxLength && args.value.length > (args === null || args === void 0 ? void 0 : args.constraints[1])) {
  4061. return eachPrefix + '$property must be shorter than or equal to $constraint2 characters';
  4062. }
  4063. return (eachPrefix +
  4064. '$property must be longer than or equal to $constraint1 and shorter than or equal to $constraint2 characters');
  4065. }, validationOptions),
  4066. },
  4067. }, validationOptions);
  4068. }
  4069. var MAX_LENGTH = 'maxLength';
  4070. /**
  4071. * Checks if the string's length is not more than given number. Note: this function takes into account surrogate pairs.
  4072. * If given value is not a string, then it returns false.
  4073. */
  4074. function maxLength(value, max) {
  4075. return typeof value === 'string' && isLengthValidator(value, { min: 0, max: max });
  4076. }
  4077. /**
  4078. * Checks if the string's length is not more than given number. Note: this function takes into account surrogate pairs.
  4079. * If given value is not a string, then it returns false.
  4080. */
  4081. function MaxLength(max, validationOptions) {
  4082. return ValidateBy({
  4083. name: MAX_LENGTH,
  4084. constraints: [max],
  4085. validator: {
  4086. validate: function (value, args) { return maxLength(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  4087. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be shorter than or equal to $constraint1 characters'; }, validationOptions),
  4088. },
  4089. }, validationOptions);
  4090. }
  4091. var MIN_LENGTH = 'minLength';
  4092. /**
  4093. * Checks if the string's length is not less than given number. Note: this function takes into account surrogate pairs.
  4094. * If given value is not a string, then it returns false.
  4095. */
  4096. function minLength(value, min) {
  4097. return typeof value === 'string' && isLengthValidator(value, { min: min });
  4098. }
  4099. /**
  4100. * Checks if the string's length is not less than given number. Note: this function takes into account surrogate pairs.
  4101. * If given value is not a string, then it returns false.
  4102. */
  4103. function MinLength(min, validationOptions) {
  4104. return ValidateBy({
  4105. name: MIN_LENGTH,
  4106. constraints: [min],
  4107. validator: {
  4108. validate: function (value, args) { return minLength(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  4109. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be longer than or equal to $constraint1 characters'; }, validationOptions),
  4110. },
  4111. }, validationOptions);
  4112. }
  4113. var matches$1 = {exports: {}};
  4114. (function (module, exports) {
  4115. Object.defineProperty(exports, "__esModule", {
  4116. value: true
  4117. });
  4118. exports.default = matches;
  4119. var _assertString = _interopRequireDefault(assertString.exports);
  4120. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4121. function matches(str, pattern, modifiers) {
  4122. (0, _assertString.default)(str);
  4123. if (Object.prototype.toString.call(pattern) !== '[object RegExp]') {
  4124. pattern = new RegExp(pattern, modifiers);
  4125. }
  4126. return pattern.test(str);
  4127. }
  4128. module.exports = exports.default;
  4129. module.exports.default = exports.default;
  4130. } (matches$1, matches$1.exports));
  4131. var matchesValidator = /*@__PURE__*/getDefaultExportFromCjs(matches$1.exports);
  4132. var MATCHES = 'matches';
  4133. function matches(value, pattern, modifiers) {
  4134. return typeof value === 'string' && matchesValidator(value, pattern, modifiers);
  4135. }
  4136. function Matches(pattern, modifiersOrAnnotationOptions, validationOptions) {
  4137. var modifiers;
  4138. if (modifiersOrAnnotationOptions && modifiersOrAnnotationOptions instanceof Object && !validationOptions) {
  4139. validationOptions = modifiersOrAnnotationOptions;
  4140. }
  4141. else {
  4142. modifiers = modifiersOrAnnotationOptions;
  4143. }
  4144. return ValidateBy({
  4145. name: MATCHES,
  4146. constraints: [pattern, modifiers],
  4147. validator: {
  4148. validate: function (value, args) { return matches(value, args === null || args === void 0 ? void 0 : args.constraints[0], args === null || args === void 0 ? void 0 : args.constraints[1]); },
  4149. defaultMessage: buildMessage(function (eachPrefix, args) { return eachPrefix + '$property must match $constraint1 regular expression'; }, validationOptions),
  4150. },
  4151. }, validationOptions);
  4152. }
  4153. // This file is a workaround for a bug in web browsers' "native"
  4154. // ES6 importing system which is uncapable of importing "*.json" files.
  4155. // https://github.com/catamphetamine/libphonenumber-js/issues/239
  4156. var metadata = {"version":4,"country_calling_codes":{"1":["US","AG","AI","AS","BB","BM","BS","CA","DM","DO","GD","GU","JM","KN","KY","LC","MP","MS","PR","SX","TC","TT","VC","VG","VI"],"7":["RU","KZ"],"20":["EG"],"27":["ZA"],"30":["GR"],"31":["NL"],"32":["BE"],"33":["FR"],"34":["ES"],"36":["HU"],"39":["IT","VA"],"40":["RO"],"41":["CH"],"43":["AT"],"44":["GB","GG","IM","JE"],"45":["DK"],"46":["SE"],"47":["NO","SJ"],"48":["PL"],"49":["DE"],"51":["PE"],"52":["MX"],"53":["CU"],"54":["AR"],"55":["BR"],"56":["CL"],"57":["CO"],"58":["VE"],"60":["MY"],"61":["AU","CC","CX"],"62":["ID"],"63":["PH"],"64":["NZ"],"65":["SG"],"66":["TH"],"81":["JP"],"82":["KR"],"84":["VN"],"86":["CN"],"90":["TR"],"91":["IN"],"92":["PK"],"93":["AF"],"94":["LK"],"95":["MM"],"98":["IR"],"211":["SS"],"212":["MA","EH"],"213":["DZ"],"216":["TN"],"218":["LY"],"220":["GM"],"221":["SN"],"222":["MR"],"223":["ML"],"224":["GN"],"225":["CI"],"226":["BF"],"227":["NE"],"228":["TG"],"229":["BJ"],"230":["MU"],"231":["LR"],"232":["SL"],"233":["GH"],"234":["NG"],"235":["TD"],"236":["CF"],"237":["CM"],"238":["CV"],"239":["ST"],"240":["GQ"],"241":["GA"],"242":["CG"],"243":["CD"],"244":["AO"],"245":["GW"],"246":["IO"],"247":["AC"],"248":["SC"],"249":["SD"],"250":["RW"],"251":["ET"],"252":["SO"],"253":["DJ"],"254":["KE"],"255":["TZ"],"256":["UG"],"257":["BI"],"258":["MZ"],"260":["ZM"],"261":["MG"],"262":["RE","YT"],"263":["ZW"],"264":["NA"],"265":["MW"],"266":["LS"],"267":["BW"],"268":["SZ"],"269":["KM"],"290":["SH","TA"],"291":["ER"],"297":["AW"],"298":["FO"],"299":["GL"],"350":["GI"],"351":["PT"],"352":["LU"],"353":["IE"],"354":["IS"],"355":["AL"],"356":["MT"],"357":["CY"],"358":["FI","AX"],"359":["BG"],"370":["LT"],"371":["LV"],"372":["EE"],"373":["MD"],"374":["AM"],"375":["BY"],"376":["AD"],"377":["MC"],"378":["SM"],"380":["UA"],"381":["RS"],"382":["ME"],"383":["XK"],"385":["HR"],"386":["SI"],"387":["BA"],"389":["MK"],"420":["CZ"],"421":["SK"],"423":["LI"],"500":["FK"],"501":["BZ"],"502":["GT"],"503":["SV"],"504":["HN"],"505":["NI"],"506":["CR"],"507":["PA"],"508":["PM"],"509":["HT"],"590":["GP","BL","MF"],"591":["BO"],"592":["GY"],"593":["EC"],"594":["GF"],"595":["PY"],"596":["MQ"],"597":["SR"],"598":["UY"],"599":["CW","BQ"],"670":["TL"],"672":["NF"],"673":["BN"],"674":["NR"],"675":["PG"],"676":["TO"],"677":["SB"],"678":["VU"],"679":["FJ"],"680":["PW"],"681":["WF"],"682":["CK"],"683":["NU"],"685":["WS"],"686":["KI"],"687":["NC"],"688":["TV"],"689":["PF"],"690":["TK"],"691":["FM"],"692":["MH"],"850":["KP"],"852":["HK"],"853":["MO"],"855":["KH"],"856":["LA"],"880":["BD"],"886":["TW"],"960":["MV"],"961":["LB"],"962":["JO"],"963":["SY"],"964":["IQ"],"965":["KW"],"966":["SA"],"967":["YE"],"968":["OM"],"970":["PS"],"971":["AE"],"972":["IL"],"973":["BH"],"974":["QA"],"975":["BT"],"976":["MN"],"977":["NP"],"992":["TJ"],"993":["TM"],"994":["AZ"],"995":["GE"],"996":["KG"],"998":["UZ"]},"countries":{"AC":["247","00","(?:[01589]\\d|[46])\\d{4}",[5,6]],"AD":["376","00","(?:1|6\\d)\\d{7}|[135-9]\\d{5}",[6,8,9],[["(\\d{3})(\\d{3})","$1 $2",["[135-9]"]],["(\\d{4})(\\d{4})","$1 $2",["1"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]]],"AE":["971","00","(?:[4-7]\\d|9[0-689])\\d{7}|800\\d{2,9}|[2-4679]\\d{7}",[5,6,7,8,9,10,11,12],[["(\\d{3})(\\d{2,9})","$1 $2",["60|8"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[236]|[479][2-8]"],"0$1"],["(\\d{3})(\\d)(\\d{5})","$1 $2 $3",["[479]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"]],"0"],"AF":["93","00","[2-7]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"]],"0"],"AG":["1","011","(?:268|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([457]\\d{6})$","268$1",0,"268"],"AI":["1","011","(?:264|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([2457]\\d{6})$","264$1",0,"264"],"AL":["355","00","(?:700\\d\\d|900)\\d{3}|8\\d{5,7}|(?:[2-5]|6\\d)\\d{7}",[6,7,8,9],[["(\\d{3})(\\d{3,4})","$1 $2",["80|9"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["4[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2358][2-5]|4"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["[23578]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["6"],"0$1"]],"0"],"AM":["374","00","(?:[1-489]\\d|55|60|77)\\d{6}",[8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[89]0"],"0 $1"],["(\\d{3})(\\d{5})","$1 $2",["2|3[12]"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["1|47"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[3-9]"],"0$1"]],"0"],"AO":["244","00","[29]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[29]"]]]],"AR":["54","00","(?:11|[89]\\d\\d)\\d{8}|[2368]\\d{9}",[10,11],[["(\\d{4})(\\d{2})(\\d{4})","$1 $2-$3",["2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9])","2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8]))|2(?:2[24-9]|3[1-59]|47)","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5[56][46]|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|58|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|54(?:4|5[13-7]|6[89])|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:454|85[56])[46]|3(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["1"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[68]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2-$3",["[23]"],"0$1",1],["(\\d)(\\d{4})(\\d{2})(\\d{4})","$2 15-$3-$4",["9(?:2[2-469]|3[3-578])","9(?:2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9]))","9(?:2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8])))|92(?:2[24-9]|3[1-59]|47)","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5(?:[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|5(?:4(?:4|5[13-7]|6[89])|[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",0,"$1 $2 $3-$4"],["(\\d)(\\d{2})(\\d{4})(\\d{4})","$2 15-$3-$4",["91"],"0$1",0,"$1 $2 $3-$4"],["(\\d{3})(\\d{3})(\\d{5})","$1-$2-$3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{4})","$2 15-$3-$4",["9"],"0$1",0,"$1 $2 $3-$4"]],"0",0,"0?(?:(11|2(?:2(?:02?|[13]|2[13-79]|4[1-6]|5[2457]|6[124-8]|7[1-4]|8[13-6]|9[1267])|3(?:02?|1[467]|2[03-6]|3[13-8]|[49][2-6]|5[2-8]|[67])|4(?:7[3-578]|9)|6(?:[0136]|2[24-6]|4[6-8]?|5[15-8])|80|9(?:0[1-3]|[19]|2\\d|3[1-6]|4[02568]?|5[2-4]|6[2-46]|72?|8[23]?))|3(?:3(?:2[79]|6|8[2578])|4(?:0[0-24-9]|[12]|3[5-8]?|4[24-7]|5[4-68]?|6[02-9]|7[126]|8[2379]?|9[1-36-8])|5(?:1|2[1245]|3[237]?|4[1-46-9]|6[2-4]|7[1-6]|8[2-5]?)|6[24]|7(?:[069]|1[1568]|2[15]|3[145]|4[13]|5[14-8]|7[2-57]|8[126])|8(?:[01]|2[15-7]|3[2578]?|4[13-6]|5[4-8]?|6[1-357-9]|7[36-8]?|8[5-8]?|9[124])))15)?","9$1"],"AS":["1","011","(?:[58]\\d\\d|684|900)\\d{7}",[10],0,"1",0,"1|([267]\\d{6})$","684$1",0,"684"],"AT":["43","00","1\\d{3,12}|2\\d{6,12}|43(?:(?:0\\d|5[02-9])\\d{3,9}|2\\d{4,5}|[3467]\\d{4}|8\\d{4,6}|9\\d{4,7})|5\\d{4,12}|8\\d{7,12}|9\\d{8,12}|(?:[367]\\d|4[0-24-9])\\d{4,11}",[4,5,6,7,8,9,10,11,12,13],[["(\\d)(\\d{3,12})","$1 $2",["1(?:11|[2-9])"],"0$1"],["(\\d{3})(\\d{2})","$1 $2",["517"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["5[079]"],"0$1"],["(\\d{3})(\\d{3,10})","$1 $2",["(?:31|4)6|51|6(?:5[0-3579]|[6-9])|7(?:20|32|8)|[89]"],"0$1"],["(\\d{4})(\\d{3,9})","$1 $2",["[2-467]|5[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["5"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,7})","$1 $2 $3",["5"],"0$1"]],"0"],"AU":["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{7}(?:\\d(?:\\d{2})?)?|8[0-24-9]\\d{7})|[2-478]\\d{8}|1\\d{4,7}",[5,6,7,8,9,10,12],[["(\\d{2})(\\d{3,4})","$1 $2",["16"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,4})","$1 $2 $3",["16"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["14|4"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[2378]"],"(0$1)"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:30|[89])"]]],"0",0,"0|(183[12])",0,0,0,[["(?:(?:2(?:[0-26-9]\\d|3[0-8]|4[02-9]|5[0135-9])|3(?:[0-3589]\\d|4[0-578]|6[1-9]|7[0-35-9])|7(?:[013-57-9]\\d|2[0-8]))\\d{3}|8(?:51(?:0(?:0[03-9]|[12479]\\d|3[2-9]|5[0-8]|6[1-9]|8[0-7])|1(?:[0235689]\\d|1[0-69]|4[0-589]|7[0-47-9])|2(?:0[0-79]|[18][13579]|2[14-9]|3[0-46-9]|[4-6]\\d|7[89]|9[0-4]))|(?:6[0-8]|[78]\\d)\\d{3}|9(?:[02-9]\\d{3}|1(?:(?:[0-58]\\d|6[0135-9])\\d|7(?:0[0-24-9]|[1-9]\\d)|9(?:[0-46-9]\\d|5[0-79])))))\\d{3}",[9]],["4(?:83[0-38]|93[0-6])\\d{5}|4(?:[0-3]\\d|4[047-9]|5[0-25-9]|6[016-9]|7[02-9]|8[0-24-9]|9[0-27-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,["163\\d{2,6}",[5,6,7,8,9]],["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],"AW":["297","00","(?:[25-79]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[25-9]"]]]],"AX":["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","2\\d{4,9}|35\\d{4,5}|(?:60\\d\\d|800)\\d{4,6}|7\\d{5,11}|(?:[14]\\d|3[0-46-9]|50)\\d{4,8}",[5,6,7,8,9,10,11,12],0,"0",0,0,0,0,"18",0,"00"],"AZ":["994","00","365\\d{6}|(?:[124579]\\d|60|88)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[28]|2|365|46","1[28]|2|365[45]|46","1[28]|2|365(?:4|5[02])|46"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[13-9]"],"0$1"]],"0"],"BA":["387","00","6\\d{8}|(?:[35689]\\d|49|70)\\d{6}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["6[1-3]|[7-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2-$3",["[3-5]|6[56]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["6"],"0$1"]],"0"],"BB":["1","011","(?:246|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([2-9]\\d{6})$","246$1",0,"246"],"BD":["880","00","[1-469]\\d{9}|8[0-79]\\d{7,8}|[2-79]\\d{8}|[2-9]\\d{7}|[3-9]\\d{6}|[57-9]\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{4,6})","$1-$2",["31[5-8]|[459]1"],"0$1"],["(\\d{3})(\\d{3,7})","$1-$2",["3(?:[67]|8[013-9])|4(?:6[168]|7|[89][18])|5(?:6[128]|9)|6(?:28|4[14]|5)|7[2-589]|8(?:0[014-9]|[12])|9[358]|(?:3[2-5]|4[235]|5[2-578]|6[0389]|76|8[3-7]|9[24])1|(?:44|66)[01346-9]"],"0$1"],["(\\d{4})(\\d{3,6})","$1-$2",["[13-9]|22"],"0$1"],["(\\d)(\\d{7,8})","$1-$2",["2"],"0$1"]],"0"],"BE":["32","00","4\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:80|9)0"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[239]|4[23]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[15-8]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4"],"0$1"]],"0"],"BF":["226","00","[025-7]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[025-7]"]]]],"BG":["359","00","[2-7]\\d{6,7}|[89]\\d{6,8}|2\\d{5}",[6,7,8,9],[["(\\d)(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["43[1-6]|70[1-9]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["[356]|4[124-7]|7[1-9]|8[1-6]|9[1-7]"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:70|8)0"],"0$1"],["(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3",["43[1-7]|7"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[48]|9[08]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"]],"0"],"BH":["973","00","[136-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[13679]|8[047]"]]]],"BI":["257","00","(?:[267]\\d|31)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2367]"]]]],"BJ":["229","00","(?:[25689]\\d|40)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-689]"]]]],"BL":["590","00","(?:590|(?:69|80)\\d|976)\\d{6}",[9],0,"0",0,0,0,0,0,[["590(?:2[7-9]|5[12]|87)\\d{4}"],["69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["976[01]\\d{5}"]]],"BM":["1","011","(?:441|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([2-8]\\d{6})$","441$1",0,"441"],"BN":["673","00","[2-578]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-578]"]]]],"BO":["591","00(?:1\\d)?","(?:[2-467]\\d\\d|8001)\\d{5}",[8,9],[["(\\d)(\\d{7})","$1 $2",["[23]|4[46]"]],["(\\d{8})","$1",["[67]"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["8"]]],"0",0,"0(1\\d)?"],"BQ":["599","00","(?:[34]1|7\\d)\\d{5}",[7],0,0,0,0,0,0,"[347]"],"BR":["55","00(?:1[245]|2[1-35]|31|4[13]|[56]5|99)","(?:[1-46-9]\\d\\d|5(?:[0-46-9]\\d|5[0-46-9]))\\d{8}|[1-9]\\d{9}|[3589]\\d{8}|[34]\\d{7}",[8,9,10,11],[["(\\d{4})(\\d{4})","$1-$2",["300|4(?:0[02]|37)","4(?:02|37)0|[34]00"]],["(\\d{3})(\\d{2,3})(\\d{4})","$1 $2 $3",["(?:[358]|90)0"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["(?:[14689][1-9]|2[12478]|3[1-578]|5[13-5]|7[13-579])[2-57]"],"($1)"],["(\\d{2})(\\d{5})(\\d{4})","$1 $2-$3",["[16][1-9]|[2-57-9]"],"($1)"]],"0",0,"(?:0|90)(?:(1[245]|2[1-35]|31|4[13]|[56]5|99)(\\d{10,11}))?","$2"],"BS":["1","011","(?:242|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([3-8]\\d{6})$","242$1",0,"242"],"BT":["975","00","[17]\\d{7}|[2-8]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[2-68]|7[246]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[67]|7"]]]],"BW":["267","00","(?:0800|(?:[37]|800)\\d)\\d{6}|(?:[2-6]\\d|90)\\d{5}",[7,8,10],[["(\\d{2})(\\d{5})","$1 $2",["90"]],["(\\d{3})(\\d{4})","$1 $2",["[24-6]|3[15-79]"]],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37]"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["8"]]]],"BY":["375","810","(?:[12]\\d|33|44|902)\\d{7}|8(?:0[0-79]\\d{5,7}|[1-7]\\d{9})|8(?:1[0-489]|[5-79]\\d)\\d{7}|8[1-79]\\d{6,7}|8[0-79]\\d{5}|8\\d{5}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3})","$1 $2",["800"],"8 $1"],["(\\d{3})(\\d{2})(\\d{2,4})","$1 $2 $3",["800"],"8 $1"],["(\\d{4})(\\d{2})(\\d{3})","$1 $2-$3",["1(?:5[169]|6[3-5]|7[179])|2(?:1[35]|2[34]|3[3-5])","1(?:5[169]|6(?:3[1-3]|4|5[125])|7(?:1[3-9]|7[0-24-6]|9[2-7]))|2(?:1[35]|2[34]|3[3-5])"],"8 0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["1(?:[56]|7[467])|2[1-3]"],"8 0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-4]"],"8 0$1"],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["[89]"],"8 $1"]],"8",0,"0|80?",0,0,0,0,"8~10"],"BZ":["501","00","(?:0800\\d|[2-8])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1-$2",["[2-8]"]],["(\\d)(\\d{3})(\\d{4})(\\d{3})","$1-$2-$3-$4",["0"]]]],"CA":["1","011","(?:[2-8]\\d|90)\\d{8}|3\\d{6}",[7,10],0,"1",0,0,0,0,0,[["(?:2(?:04|[23]6|[48]9|50|63)|3(?:06|43|6[578])|4(?:03|1[68]|3[178]|50|68|74)|5(?:06|1[49]|48|79|8[147])|6(?:04|13|39|47|72)|7(?:0[59]|42|53|78|8[02])|8(?:[06]7|19|25|73)|90[25])[2-9]\\d{6}",[10]],["",[10]],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",[10]],["900[2-9]\\d{6}",[10]],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|(?:5(?:00|2[125-7]|33|44|66|77|88)|622)[2-9]\\d{6}",[10]],0,["310\\d{4}",[7]],0,["600[2-9]\\d{6}",[10]]]],"CC":["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"0|([59]\\d{7})$","8$1",0,0,[["8(?:51(?:0(?:02|31|60|89)|1(?:18|76)|223)|91(?:0(?:1[0-2]|29)|1(?:[28]2|50|79)|2(?:10|64)|3(?:[06]8|22)|4[29]8|62\\d|70[23]|959))\\d{3}",[9]],["4(?:83[0-38]|93[0-6])\\d{5}|4(?:[0-3]\\d|4[047-9]|5[0-25-9]|6[016-9]|7[02-9]|8[0-24-9]|9[0-27-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],"CD":["243","00","[189]\\d{8}|[1-68]\\d{6}",[7,9],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[1-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]"],"0$1"]],"0"],"CF":["236","00","(?:[27]\\d{3}|8776)\\d{4}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[278]"]]]],"CG":["242","00","222\\d{6}|(?:0\\d|80)\\d{7}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[02]"]]]],"CH":["41","00","8\\d{11}|[2-9]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8[047]|90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]|81"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["8"],"0$1"]],"0"],"CI":["225","00","[02]\\d{9}",[10],[["(\\d{2})(\\d{2})(\\d)(\\d{5})","$1 $2 $3 $4",["2"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3 $4",["0"]]]],"CK":["682","00","[2-578]\\d{4}",[5],[["(\\d{2})(\\d{3})","$1 $2",["[2-578]"]]]],"CL":["56","(?:0|1(?:1[0-69]|2[02-5]|5[13-58]|69|7[0167]|8[018]))0","12300\\d{6}|6\\d{9,10}|[2-9]\\d{8}",[9,10,11],[["(\\d{5})(\\d{4})","$1 $2",["219","2196"],"($1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["44"]],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2[1-36]"],"($1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["9[2-9]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["3[2-5]|[47]|5[1-3578]|6[13-57]|8(?:0[1-9]|[1-9])"],"($1)"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["60|8"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{3})(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3 $4",["60"]]]],"CM":["237","00","[26]\\d{8}|88\\d{6,7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["88"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[26]|88"]]]],"CN":["86","00|1(?:[12]\\d|79)\\d\\d00","1[127]\\d{8,9}|2\\d{9}(?:\\d{2})?|[12]\\d{6,7}|86\\d{6}|(?:1[03-689]\\d|6)\\d{7,9}|(?:[3-579]\\d|8[0-57-9])\\d{6,9}",[7,8,9,10,11,12],[["(\\d{2})(\\d{5,6})","$1 $2",["(?:10|2[0-57-9])[19]","(?:10|2[0-57-9])(?:10|9[56])","(?:10|2[0-57-9])(?:100|9[56])"],"0$1"],["(\\d{3})(\\d{5,6})","$1 $2",["3(?:[157]|35|49|9[1-68])|4(?:[17]|2[179]|6[47-9]|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])|(?:4[35]|59|85)[1-9]","(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))[19]","85[23](?:10|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:10|9[56])","85[23](?:100|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:100|9[56])"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["(?:4|80)0"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|2(?:[02-57-9]|1[1-9])","10|2(?:[02-57-9]|1[1-9])","10[0-79]|2(?:[02-57-9]|1[1-79])|(?:10|21)8(?:0[1-9]|[1-9])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["3(?:[3-59]|7[02-68])|4(?:[26-8]|3[3-9]|5[2-9])|5(?:3[03-9]|[468]|7[028]|9[2-46-9])|6|7(?:[0-247]|3[04-9]|5[0-4689]|6[2368])|8(?:[1-358]|9[1-7])|9(?:[013479]|5[1-5])|(?:[34]1|55|79|87)[02-9]"],"0$1",1],["(\\d{3})(\\d{7,8})","$1 $2",["9"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["80"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[3-578]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["1[3-9]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3 $4",["[12]"],"0$1",1]],"0",0,"0|(1(?:[12]\\d|79)\\d\\d)",0,0,0,0,"00"],"CO":["57","00(?:4(?:[14]4|56)|[579])","(?:60\\d\\d|9101)\\d{6}|(?:1\\d|3)\\d{9}",[10,11],[["(\\d{3})(\\d{7})","$1 $2",["6"],"($1)"],["(\\d{3})(\\d{7})","$1 $2",["3[0-357]|91"]],["(\\d)(\\d{3})(\\d{7})","$1-$2-$3",["1"],"0$1",0,"$1 $2 $3"]],"0",0,"0(4(?:[14]4|56)|[579])?"],"CR":["506","00","(?:8\\d|90)\\d{8}|(?:[24-8]\\d{3}|3005)\\d{4}",[8,10],[["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[3-9]"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[89]"]]],0,0,"(19(?:0[0-2468]|1[09]|20|66|77|99))"],"CU":["53","119","[27]\\d{6,7}|[34]\\d{5,7}|(?:5|8\\d\\d)\\d{7}",[6,7,8,10],[["(\\d{2})(\\d{4,6})","$1 $2",["2[1-4]|[34]"],"(0$1)"],["(\\d)(\\d{6,7})","$1 $2",["7"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["5"],"0$1"],["(\\d{3})(\\d{7})","$1 $2",["8"],"0$1"]],"0"],"CV":["238","0","(?:[2-59]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2-589]"]]]],"CW":["599","00","(?:[34]1|60|(?:7|9\\d)\\d)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[3467]"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["9[4-8]"]]],0,0,0,0,0,"[69]"],"CX":["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"0|([59]\\d{7})$","8$1",0,0,[["8(?:51(?:0(?:01|30|59|88)|1(?:17|46|75)|2(?:22|35))|91(?:00[6-9]|1(?:[28]1|49|78)|2(?:09|63)|3(?:12|26|75)|4(?:56|97)|64\\d|7(?:0[01]|1[0-2])|958))\\d{3}",[9]],["4(?:83[0-38]|93[0-6])\\d{5}|4(?:[0-3]\\d|4[047-9]|5[0-25-9]|6[016-9]|7[02-9]|8[0-24-9]|9[0-27-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],"CY":["357","00","(?:[279]\\d|[58]0)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[257-9]"]]]],"CZ":["420","00","(?:[2-578]\\d|60)\\d{7}|9\\d{8,11}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]|9[015-7]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3 $4",["96"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]]],"DE":["49","00","[2579]\\d{5,14}|49(?:[34]0|69|8\\d)\\d\\d?|49(?:37|49|60|7[089]|9\\d)\\d{1,3}|49(?:2[024-9]|3[2-689]|7[1-7])\\d{1,8}|(?:1|[368]\\d|4[0-8])\\d{3,13}|49(?:[015]\\d|2[13]|31|[46][1-8])\\d{1,9}",[4,5,6,7,8,9,10,11,12,13,14,15],[["(\\d{2})(\\d{3,13})","$1 $2",["3[02]|40|[68]9"],"0$1"],["(\\d{3})(\\d{3,12})","$1 $2",["2(?:0[1-389]|1[124]|2[18]|3[14])|3(?:[35-9][15]|4[015])|906|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1","2(?:0[1-389]|12[0-8])|3(?:[35-9][15]|4[015])|906|2(?:[13][14]|2[18])|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1"],"0$1"],["(\\d{4})(\\d{2,11})","$1 $2",["[24-6]|3(?:[3569][02-46-9]|4[2-4679]|7[2-467]|8[2-46-8])|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]","[24-6]|3(?:3(?:0[1-467]|2[127-9]|3[124578]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|4[13578]|9[1346])|5(?:0[14]|2[1-3589]|6[1-4]|7[13468]|8[13568])|6(?:2[1-489]|3[124-6]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|6|7[1467]|8[136])|9(?:0[12479]|2[1358]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]|3[68]4[1347]|3(?:47|60)[1356]|3(?:3[46]|46|5[49])[1246]|3[4579]3[1357]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["138"],"0$1"],["(\\d{5})(\\d{2,10})","$1 $2",["3"],"0$1"],["(\\d{3})(\\d{5,11})","$1 $2",["181"],"0$1"],["(\\d{3})(\\d)(\\d{4,10})","$1 $2 $3",["1(?:3|80)|9"],"0$1"],["(\\d{3})(\\d{7,8})","$1 $2",["1[67]"],"0$1"],["(\\d{3})(\\d{7,12})","$1 $2",["8"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["185","1850","18500"],"0$1"],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["18[68]"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["15[0568]"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["15[1279]"],"0$1"],["(\\d{3})(\\d{8})","$1 $2",["18"],"0$1"],["(\\d{3})(\\d{2})(\\d{7,8})","$1 $2 $3",["1(?:6[023]|7)"],"0$1"],["(\\d{4})(\\d{2})(\\d{7})","$1 $2 $3",["15[279]"],"0$1"],["(\\d{3})(\\d{2})(\\d{8})","$1 $2 $3",["15"],"0$1"]],"0"],"DJ":["253","00","(?:2\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[27]"]]]],"DK":["45","00","[2-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-9]"]]]],"DM":["1","011","(?:[58]\\d\\d|767|900)\\d{7}",[10],0,"1",0,"1|([2-7]\\d{6})$","767$1",0,"767"],"DO":["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,0,0,0,"8001|8[024]9"],"DZ":["213","00","(?:[1-4]|[5-79]\\d|80)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["9"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-8]"],"0$1"]],"0"],"EC":["593","00","1\\d{9,10}|(?:[2-7]|9\\d)\\d{7}",[8,9,10,11],[["(\\d)(\\d{3})(\\d{4})","$1 $2-$3",["[2-7]"],"(0$1)",0,"$1-$2-$3"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{3})(\\d{3,4})","$1 $2 $3",["1"]]],"0"],"EE":["372","00","8\\d{9}|[4578]\\d{7}|(?:[3-8]\\d|90)\\d{5}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[369]|4[3-8]|5(?:[0-2]|5[0-478]|6[45])|7[1-9]|88","[369]|4[3-8]|5(?:[02]|1(?:[0-8]|95)|5[0-478]|6(?:4[0-4]|5[1-589]))|7[1-9]|88"]],["(\\d{4})(\\d{3,4})","$1 $2",["[45]|8(?:00|[1-49])","[45]|8(?:00[1-9]|[1-49])"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],"EG":["20","00","[189]\\d{8,9}|[24-6]\\d{8}|[135]\\d{7}",[8,9,10],[["(\\d)(\\d{7,8})","$1 $2",["[23]"],"0$1"],["(\\d{2})(\\d{6,7})","$1 $2",["1[35]|[4-6]|8[2468]|9[235-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[189]"],"0$1"]],"0"],"EH":["212","00","[5-8]\\d{8}",[9],0,"0",0,0,0,0,"528[89]"],"ER":["291","00","[178]\\d{6}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[178]"],"0$1"]],"0"],"ES":["34","00","[5-9]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]00"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-9]"]]]],"ET":["251","00","(?:11|[2-579]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-579]"],"0$1"]],"0"],"FI":["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","[1-35689]\\d{4}|7\\d{10,11}|(?:[124-7]\\d|3[0-46-9])\\d{8}|[1-9]\\d{5,8}",[5,6,7,8,9,10,11,12],[["(\\d)(\\d{4,9})","$1 $2",["[2568][1-8]|3(?:0[1-9]|[1-9])|9"],"0$1"],["(\\d{3})(\\d{3,7})","$1 $2",["[12]00|[368]|70[07-9]"],"0$1"],["(\\d{2})(\\d{4,8})","$1 $2",["[1245]|7[135]"],"0$1"],["(\\d{2})(\\d{6,10})","$1 $2",["7"],"0$1"]],"0",0,0,0,0,"1[03-79]|[2-9]",0,"00"],"FJ":["679","0(?:0|52)","45\\d{5}|(?:0800\\d|[235-9])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1 $2",["[235-9]|45"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]]],0,0,0,0,0,0,0,"00"],"FK":["500","00","[2-7]\\d{4}",[5]],"FM":["691","00","(?:[39]\\d\\d|820)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[389]"]]]],"FO":["298","00","[2-9]\\d{5}",[6],[["(\\d{6})","$1",["[2-9]"]]],0,0,"(10(?:01|[12]0|88))"],"FR":["33","00","[1-9]\\d{8}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0 $1"],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[1-79]"],"0$1"]],"0"],"GA":["241","00","(?:[067]\\d|11)\\d{6}|[2-7]\\d{6}",[7,8],[["(\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-7]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["11|[67]"],"0$1"]],0,0,"0(11\\d{6}|60\\d{6}|61\\d{6}|6[256]\\d{6}|7[467]\\d{6})","$1"],"GB":["44","00","[1-357-9]\\d{9}|[18]\\d{8}|8\\d{6}",[7,9,10],[["(\\d{3})(\\d{4})","$1 $2",["800","8001","80011","800111","8001111"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["845","8454","84546","845464"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["800"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["1(?:38|5[23]|69|76|94)","1(?:(?:38|69)7|5(?:24|39)|768|946)","1(?:3873|5(?:242|39[4-6])|(?:697|768)[347]|9467)"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["1(?:[2-69][02-9]|[78])"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[25]|7(?:0|6[02-9])","[25]|7(?:0|6(?:[03-9]|2[356]))"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[1389]"],"0$1"]],"0",0,0,0,0,0,[["(?:1(?:1(?:3(?:[0-58]\\d\\d|73[0235])|4(?:[0-5]\\d\\d|69[7-9]|70[013579])|(?:(?:5[0-26-9]|[78][0-49])\\d|6(?:[0-4]\\d|50))\\d)|2(?:(?:0[024-9]|2[3-9]|3[3-79]|4[1-689]|[58][02-9]|6[0-47-9]|7[013-9]|9\\d)\\d\\d|1(?:[0-7]\\d\\d|8(?:[02]\\d|1[0-246-9])))|(?:3(?:0\\d|1[0-8]|[25][02-9]|3[02-579]|[468][0-46-9]|7[1-35-79]|9[2-578])|4(?:0[03-9]|[137]\\d|[28][02-57-9]|4[02-69]|5[0-8]|[69][0-79])|5(?:0[1-35-9]|[16]\\d|2[024-9]|3[015689]|4[02-9]|5[03-9]|7[0-35-9]|8[0-468]|9[0-57-9])|6(?:0[034689]|1\\d|2[0-35689]|[38][013-9]|4[1-467]|5[0-69]|6[13-9]|7[0-8]|9[0-24578])|7(?:0[0246-9]|2\\d|3[0236-8]|4[03-9]|5[0-46-9]|6[013-9]|7[0-35-9]|8[024-9]|9[02-9])|8(?:0[35-9]|2[1-57-9]|3[02-578]|4[0-578]|5[124-9]|6[2-69]|7\\d|8[02-9]|9[02569])|9(?:0[02-589]|[18]\\d|2[02-689]|3[1-57-9]|4[2-9]|5[0-579]|6[2-47-9]|7[0-24578]|9[2-57]))\\d\\d)|2(?:0[013478]|3[0189]|4[017]|8[0-46-9]|9[0-2])\\d{3})\\d{4}|1(?:2(?:0(?:46[1-4]|87[2-9])|545[1-79]|76(?:2\\d|3[1-8]|6[1-6])|9(?:7(?:2[0-4]|3[2-5])|8(?:2[2-8]|7[0-47-9]|8[3-5])))|3(?:6(?:38[2-5]|47[23])|8(?:47[04-9]|64[0157-9]))|4(?:044[1-7]|20(?:2[23]|8\\d)|6(?:0(?:30|5[2-57]|6[1-8]|7[2-8])|140)|8(?:052|87[1-3]))|5(?:2(?:4(?:3[2-79]|6\\d)|76\\d)|6(?:26[06-9]|686))|6(?:06(?:4\\d|7[4-79])|295[5-7]|35[34]\\d|47(?:24|61)|59(?:5[08]|6[67]|74)|9(?:55[0-4]|77[23]))|7(?:26(?:6[13-9]|7[0-7])|(?:442|688)\\d|50(?:2[0-3]|[3-68]2|76))|8(?:27[56]\\d|37(?:5[2-5]|8[239])|843[2-58])|9(?:0(?:0(?:6[1-8]|85)|52\\d)|3583|4(?:66[1-8]|9(?:2[01]|81))|63(?:23|3[1-4])|9561))\\d{3}",[9,10]],["7(?:457[0-57-9]|700[01]|911[028])\\d{5}|7(?:[1-3]\\d\\d|4(?:[0-46-9]\\d|5[0-689])|5(?:0[0-8]|[13-9]\\d|2[0-35-9])|7(?:0[1-9]|[1-7]\\d|8[02-9]|9[0-689])|8(?:[014-9]\\d|[23][0-8])|9(?:[024-9]\\d|1[02-9]|3[0-689]))\\d{6}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[2-49]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]],0," x"],"GD":["1","011","(?:473|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([2-9]\\d{6})$","473$1",0,"473"],"GE":["995","00","(?:[3-57]\\d\\d|800)\\d{6}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["32"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[57]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[348]"],"0$1"]],"0"],"GF":["594","00","(?:[56]94|80\\d|976)\\d{6}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[569]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],"GG":["44","00","(?:1481|[357-9]\\d{3})\\d{6}|8\\d{6}(?:\\d{2})?",[7,9,10],0,"0",0,"0|([25-9]\\d{5})$","1481$1",0,0,[["1481[25-9]\\d{5}",[10]],["7(?:(?:781|839)\\d|911[17])\\d{5}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[0-3]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]]],"GH":["233","00","(?:[235]\\d{3}|800)\\d{5}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[235]"],"0$1"]],"0"],"GI":["350","00","(?:[25]\\d\\d|606)\\d{5}",[8],[["(\\d{3})(\\d{5})","$1 $2",["2"]]]],"GL":["299","00","(?:19|[2-689]\\d|70)\\d{4}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["19|[2-9]"]]]],"GM":["220","00","[2-9]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],"GN":["224","00","722\\d{6}|(?:3|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["3"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[67]"]]]],"GP":["590","00","(?:590|(?:69|80)\\d|976)\\d{6}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[569]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0",0,0,0,0,0,[["590(?:0[1-68]|[14][0-24-9]|2[0-68]|3[1289]|5[3-579]|6[0-289]|7[08]|8[0-689]|9\\d)\\d{4}"],["69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["976[01]\\d{5}"]]],"GQ":["240","00","222\\d{6}|(?:3\\d|55|[89]0)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235]"]],["(\\d{3})(\\d{6})","$1 $2",["[89]"]]]],"GR":["30","00","5005000\\d{3}|8\\d{9,11}|(?:[269]\\d|70)\\d{8}",[10,11,12],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["21|7"]],["(\\d{4})(\\d{6})","$1 $2",["2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2689]"]],["(\\d{3})(\\d{3,4})(\\d{5})","$1 $2 $3",["8"]]]],"GT":["502","00","(?:1\\d{3}|[2-7])\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1 $2",["[2-7]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],"GU":["1","011","(?:[58]\\d\\d|671|900)\\d{7}",[10],0,"1",0,"1|([3-9]\\d{6})$","671$1",0,"671"],"GW":["245","00","[49]\\d{8}|4\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["40"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"]]]],"GY":["592","001","9008\\d{3}|(?:[2-467]\\d\\d|862)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-46-9]"]]]],"HK":["852","00(?:30|5[09]|[126-9]?)","8[0-46-9]\\d{6,7}|9\\d{4,7}|(?:[2-7]|9\\d{3})\\d{7}",[5,6,7,8,9,11],[["(\\d{3})(\\d{2,5})","$1 $2",["900","9003"]],["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[1-4]|9(?:0[1-9]|[1-8])"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{3})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]],0,0,0,0,0,0,0,"00"],"HN":["504","00","8\\d{10}|[237-9]\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1-$2",["[237-9]"]]]],"HR":["385","00","(?:[24-69]\\d|3[0-79])\\d{7}|80\\d{5,7}|[1-79]\\d{7}|6\\d{5,6}",[6,7,8,9],[["(\\d{2})(\\d{2})(\\d{2,3})","$1 $2 $3",["6[01]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{4})(\\d{3})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[67]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-5]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"]],"0"],"HT":["509","00","[2-489]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[2-489]"]]]],"HU":["36","00","[235-7]\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27][2-9]|3[2-7]|4[24-9]|5[2-79]|6|8[2-57-9]|9[2-69]"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"06 $1"]],"06"],"ID":["62","00[89]","(?:(?:00[1-9]|8\\d)\\d{4}|[1-36])\\d{6}|00\\d{10}|[1-9]\\d{8,10}|[2-9]\\d{7}",[7,8,9,10,11,12,13],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["15"]],["(\\d{2})(\\d{5,9})","$1 $2",["2[124]|[36]1"],"(0$1)"],["(\\d{3})(\\d{5,7})","$1 $2",["800"],"0$1"],["(\\d{3})(\\d{5,8})","$1 $2",["[2-79]"],"(0$1)"],["(\\d{3})(\\d{3,4})(\\d{3})","$1-$2-$3",["8[1-35-9]"],"0$1"],["(\\d{3})(\\d{6,8})","$1 $2",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["804"],"0$1"],["(\\d{3})(\\d)(\\d{3})(\\d{3})","$1 $2 $3 $4",["80"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1-$2-$3",["8"],"0$1"]],"0"],"IE":["353","00","(?:1\\d|[2569])\\d{6,8}|4\\d{6,9}|7\\d{8}|8\\d{8,9}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["2[24-9]|47|58|6[237-9]|9[35-9]"],"(0$1)"],["(\\d{3})(\\d{5})","$1 $2",["[45]0"],"(0$1)"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["1"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2569]|4[1-69]|7[14]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["81"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[78]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["4"],"(0$1)"],["(\\d{2})(\\d)(\\d{3})(\\d{4})","$1 $2 $3 $4",["8"],"0$1"]],"0"],"IL":["972","0(?:0|1[2-9])","1\\d{6}(?:\\d{3,5})?|[57]\\d{8}|[1-489]\\d{7}",[7,8,9,10,11,12],[["(\\d{4})(\\d{3})","$1-$2",["125"]],["(\\d{4})(\\d{2})(\\d{2})","$1-$2-$3",["121"]],["(\\d)(\\d{3})(\\d{4})","$1-$2-$3",["[2-489]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1-$2-$3",["12"]],["(\\d{4})(\\d{6})","$1-$2",["159"]],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3-$4",["1[7-9]"]],["(\\d{3})(\\d{1,2})(\\d{3})(\\d{4})","$1-$2 $3-$4",["15"]]],"0"],"IM":["44","00","1624\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"0|([25-8]\\d{5})$","1624$1",0,"74576|(?:16|7[56])24"],"IN":["91","00","(?:000800|[2-9]\\d\\d)\\d{7}|1\\d{7,12}",[8,9,10,11,12,13],[["(\\d{8})","$1",["5(?:0|2[23]|3[03]|[67]1|88)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|888)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|8888)"],0,1],["(\\d{4})(\\d{4,5})","$1 $2",["180","1800"],0,1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["140"],0,1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["11|2[02]|33|4[04]|79[1-7]|80[2-46]","11|2[02]|33|4[04]|79(?:[1-6]|7[19])|80(?:[2-4]|6[0-589])","11|2[02]|33|4[04]|79(?:[124-6]|3(?:[02-9]|1[0-24-9])|7(?:1|9[1-6]))|80(?:[2-4]|6[0-589])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1(?:2[0-249]|3[0-25]|4[145]|[68]|7[1257])|2(?:1[257]|3[013]|4[01]|5[0137]|6[0158]|78|8[1568])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|5[12]|[78]1)|6(?:12|[2-4]1|5[17]|6[13]|80)|7(?:12|3[134]|4[47]|61|88)|8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91)|(?:43|59|75)[15]|(?:1[59]|29|67|72)[14]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|674|7(?:(?:2[14]|3[34]|5[15])[2-6]|61[346]|88[0-8])|8(?:70[2-6]|84[235-7]|91[3-7])|(?:1(?:29|60|8[06])|261|552|6(?:12|[2-47]1|5[17]|6[13]|80)|7(?:12|31|4[47])|8(?:16|2[014]|3[126]|6[136]|7[78]|83))[2-7]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|6(?:12(?:[2-6]|7[0-8])|74[2-7])|7(?:(?:2[14]|5[15])[2-6]|3171|61[346]|88(?:[2-7]|82))|8(?:70[2-6]|84(?:[2356]|7[19])|91(?:[3-6]|7[19]))|73[134][2-6]|(?:74[47]|8(?:16|2[014]|3[126]|6[136]|7[78]|83))(?:[2-6]|7[19])|(?:1(?:29|60|8[06])|261|552|6(?:[2-4]1|5[17]|6[13]|7(?:1|4[0189])|80)|7(?:12|88[01]))[2-7]"],"0$1",1],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2[2457-9]|3[2-5]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1[013-9]|28|3[129]|4[1-35689]|5[29]|6[02-5]|70)|807","1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2(?:[2457]|84|95)|3(?:[2-4]|55)|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1(?:[013-8]|9[6-9])|28[6-8]|3(?:17|2[0-49]|9[2-57])|4(?:1[2-4]|[29][0-7]|3[0-8]|[56]|8[0-24-7])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4|5[0-367])|70[13-7])|807[19]","1(?:[2-479]|5(?:[0236-9]|5[013-9]))|[2-5]|6(?:2(?:84|95)|355|83)|73179|807(?:1|9[1-3])|(?:1552|6(?:1[1358]|2[2457]|3[2-4]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[124-6])\\d|7(?:1(?:[013-8]\\d|9[6-9])|28[6-8]|3(?:2[0-49]|9[2-57])|4(?:1[2-4]|[29][0-7]|3[0-8]|[56]\\d|8[0-24-7])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4\\d|5[0-367])|70[13-7]))[2-7]"],"0$1",1],["(\\d{5})(\\d{5})","$1 $2",["[6-9]"],"0$1",1],["(\\d{4})(\\d{2,4})(\\d{4})","$1 $2 $3",["1(?:6|8[06])","1(?:6|8[06]0)"],0,1],["(\\d{4})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["18"],0,1]],"0"],"IO":["246","00","3\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["3"]]]],"IQ":["964","00","(?:1|7\\d\\d)\\d{7}|[2-6]\\d{7,8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-6]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0"],"IR":["98","00","[1-9]\\d{9}|(?:[1-8]\\d\\d|9)\\d{3,4}",[4,5,6,7,10],[["(\\d{4,5})","$1",["96"],"0$1"],["(\\d{2})(\\d{4,5})","$1 $2",["(?:1[137]|2[13-68]|3[1458]|4[145]|5[1468]|6[16]|7[1467]|8[13467])[12689]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[1-8]"],"0$1"]],"0"],"IS":["354","00|1(?:0(?:01|[12]0)|100)","(?:38\\d|[4-9])\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["[4-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["3"]]],0,0,0,0,0,0,0,"00"],"IT":["39","00","0\\d{5,10}|1\\d{8,10}|3(?:[0-8]\\d{7,10}|9\\d{7,8})|(?:55|70)\\d{8}|8\\d{5}(?:\\d{2,4})?",[6,7,8,9,10,11],[["(\\d{2})(\\d{4,6})","$1 $2",["0[26]"]],["(\\d{3})(\\d{3,6})","$1 $2",["0[13-57-9][0159]|8(?:03|4[17]|9[2-5])","0[13-57-9][0159]|8(?:03|4[17]|9(?:2|3[04]|[45][0-4]))"]],["(\\d{4})(\\d{2,6})","$1 $2",["0(?:[13-579][2-46-8]|8[236-8])"]],["(\\d{4})(\\d{4})","$1 $2",["894"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[26]|5"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["1(?:44|[679])|[378]"]],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[13-57-9][0159]|14"]],["(\\d{2})(\\d{4})(\\d{5})","$1 $2 $3",["0[26]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["3"]]],0,0,0,0,0,0,[["0669[0-79]\\d{1,6}|0(?:1(?:[0159]\\d|[27][1-5]|31|4[1-4]|6[1356]|8[2-57])|2\\d\\d|3(?:[0159]\\d|2[1-4]|3[12]|[48][1-6]|6[2-59]|7[1-7])|4(?:[0159]\\d|[23][1-9]|4[245]|6[1-5]|7[1-4]|81)|5(?:[0159]\\d|2[1-5]|3[2-6]|4[1-79]|6[4-6]|7[1-578]|8[3-8])|6(?:[0-57-9]\\d|6[0-8])|7(?:[0159]\\d|2[12]|3[1-7]|4[2-46]|6[13569]|7[13-6]|8[1-59])|8(?:[0159]\\d|2[3-578]|3[1-356]|[6-8][1-5])|9(?:[0159]\\d|[238][1-5]|4[12]|6[1-8]|7[1-6]))\\d{2,7}"],["3[1-9]\\d{8}|3[2-9]\\d{7}",[9,10]],["80(?:0\\d{3}|3)\\d{3}",[6,9]],["(?:0878\\d{3}|89(?:2\\d|3[04]|4(?:[0-4]|[5-9]\\d\\d)|5[0-4]))\\d\\d|(?:1(?:44|6[346])|89(?:38|5[5-9]|9))\\d{6}",[6,8,9,10]],["1(?:78\\d|99)\\d{6}",[9,10]],0,0,0,["55\\d{8}",[10]],["84(?:[08]\\d{3}|[17])\\d{3}",[6,9]]]],"JE":["44","00","1534\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"0|([0-24-8]\\d{5})$","1534$1",0,0,[["1534[0-24-8]\\d{5}"],["7(?:(?:(?:50|82)9|937)\\d|7(?:00[378]|97[7-9]))\\d{5}"],["80(?:07(?:35|81)|8901)\\d{4}"],["(?:8(?:4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|90(?:066[59]|1810|71(?:07|55)))\\d{4}"],["701511\\d{4}"],0,["(?:3(?:0(?:07(?:35|81)|8901)|3\\d{4}|4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|55\\d{4})\\d{4}"],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}"],["56\\d{8}"]]],"JM":["1","011","(?:[58]\\d\\d|658|900)\\d{7}",[10],0,"1",0,0,0,0,"658|876"],"JO":["962","00","(?:(?:[2689]|7\\d)\\d|32|53)\\d{6}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2356]|87"],"(0$1)"],["(\\d{3})(\\d{5,6})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["70"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0"],"JP":["81","010","00[1-9]\\d{6,14}|[257-9]\\d{9}|(?:00|[1-9]\\d\\d)\\d{6}",[8,9,10,11,12,13,14,15,16,17],[["(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3",["(?:12|57|99)0"],"0$1"],["(\\d{4})(\\d)(\\d{4})","$1-$2-$3",["1(?:26|3[79]|4[56]|5[4-68]|6[3-5])|499|5(?:76|97)|746|8(?:3[89]|47|51|63)|9(?:80|9[16])","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:76|97)9|7468|8(?:3(?:8[7-9]|96)|477|51[2-9]|636)|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:769|979[2-69])|7468|8(?:3(?:8[7-9]|96[2457-9])|477|51[2-9]|636[457-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["60"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2-$3",["[36]|4(?:2[09]|7[01])","[36]|4(?:2(?:0|9[02-69])|7(?:0[019]|1))"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["1(?:1|5[45]|77|88|9[69])|2(?:2[1-37]|3[0-269]|4[59]|5|6[24]|7[1-358]|8[1369]|9[0-38])|4(?:[28][1-9]|3[0-57]|[45]|6[248]|7[2-579]|9[29])|5(?:2|3[045]|4[0-369]|5[29]|8[02389]|9[0-389])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9[2-6])|8(?:2[124589]|3[27-9]|49|51|6|7[0-468]|8[68]|9[019])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9[1-489])","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2(?:[127]|3[014-9])|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9[19])|62|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|8[1-9])|5(?:2|3[045]|4[0-369]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0-2469])|49|51|6(?:[0-24]|36|5[0-3589]|72|9[01459])|7[0-468]|8[68])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9(?:[1289]|3[34]|4[0178]))|(?:49|55|83)[29]|(?:264|837)[016-9]|2(?:57|93)[015-9]|(?:25[0468]|422|838)[01]|(?:47[59]|59[89]|8(?:6[68]|9))[019]","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2[127]|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9(?:17|99))|6(?:2|4[016-9])|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|9[29])|5(?:2|3[045]|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0169])|3(?:[29]|7(?:[017-9]|6[6-8]))|49|51|6(?:[0-24]|36[23]|5(?:[0-389]|5[23])|6(?:[01]|9[178])|72|9[0145])|7[0-468]|8[68])|9(?:4[15]|5[138]|7[156]|8[189]|9(?:[1289]|3(?:31|4[357])|4[0178]))|(?:8294|96)[1-3]|2(?:57|93)[015-9]|(?:223|8699)[014-9]|(?:25[0468]|422|838)[01]|(?:48|8292|9[23])[1-9]|(?:47[59]|59[89]|8(?:68|9))[019]","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2[127]|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|7[015-9]|9(?:17|99))|6(?:2|4[016-9])|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17|3[015-9]))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|9[29])|5(?:2|3[045]|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9(?:[019]|4[1-3]|6(?:[0-47-9]|5[01346-9])))|3(?:[29]|7(?:[017-9]|6[6-8]))|49|51|6(?:[0-24]|36[23]|5(?:[0-389]|5[23])|6(?:[01]|9[178])|72|9[0145])|7[0-468]|8[68])|9(?:4[15]|5[138]|6[1-3]|7[156]|8[189]|9(?:[1289]|3(?:31|4[357])|4[0178]))|(?:223|8699)[014-9]|(?:25[0468]|422|838)[01]|(?:48|829(?:2|66)|9[23])[1-9]|(?:47[59]|59[89]|8(?:68|9))[019]"],"0$1"],["(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["[14]|[289][2-9]|5[3-9]|7[2-4679]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["800"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[257-9]"],"0$1"]],"0"],"KE":["254","000","(?:[17]\\d\\d|900)\\d{6}|(?:2|80)0\\d{6,7}|[4-6]\\d{6,8}",[7,8,9,10],[["(\\d{2})(\\d{5,7})","$1 $2",["[24-6]"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[17]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0"],"KG":["996","00","8\\d{9}|(?:[235-8]\\d|99)\\d{7}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["3(?:1[346]|[24-79])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-79]|88"],"0$1"],["(\\d{3})(\\d{3})(\\d)(\\d{2,3})","$1 $2 $3 $4",["8"],"0$1"]],"0"],"KH":["855","00[14-9]","1\\d{9}|[1-9]\\d{7,8}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],"KI":["686","00","(?:[37]\\d|6[0-79])\\d{6}|(?:[2-48]\\d|50)\\d{3}",[5,8],0,"0"],"KM":["269","00","[3478]\\d{6}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[3478]"]]]],"KN":["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([2-7]\\d{6})$","869$1",0,"869"],"KP":["850","00|99","85\\d{6}|(?:19\\d|[2-7])\\d{7}",[8,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"]],"0"],"KR":["82","00(?:[125689]|3(?:[46]5|91)|7(?:00|27|3|55|6[126]))","00[1-9]\\d{8,11}|(?:[12]|5\\d{3})\\d{7}|[13-6]\\d{9}|(?:[1-6]\\d|80)\\d{7}|[3-6]\\d{4,5}|(?:00|7)0\\d{8}",[5,6,8,9,10,11,12,13,14],[["(\\d{2})(\\d{3,4})","$1-$2",["(?:3[1-3]|[46][1-4]|5[1-5])1"],"0$1"],["(\\d{4})(\\d{4})","$1-$2",["1"]],["(\\d)(\\d{3,4})(\\d{4})","$1-$2-$3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["60|8"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1-$2-$3",["[1346]|5[1-5]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{2})(\\d{5})(\\d{4})","$1-$2-$3",["5"],"0$1"]],"0",0,"0(8(?:[1-46-8]|5\\d\\d))?"],"KW":["965","00","18\\d{5}|(?:[2569]\\d|41)\\d{6}",[7,8],[["(\\d{4})(\\d{3,4})","$1 $2",["[169]|2(?:[235]|4[1-35-9])|52"]],["(\\d{3})(\\d{5})","$1 $2",["[245]"]]]],"KY":["1","011","(?:345|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([2-9]\\d{6})$","345$1",0,"345"],"KZ":["7","810","(?:33622|8\\d{8})\\d{5}|[78]\\d{9}",[10,14],0,"8",0,0,0,0,"33|7",0,"8~10"],"LA":["856","00","[23]\\d{9}|3\\d{8}|(?:[235-8]\\d|41)\\d{6}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2[13]|3[14]|[4-8]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["30[013-9]"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[23]"],"0$1"]],"0"],"LB":["961","00","[27-9]\\d{7}|[13-9]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[13-69]|7(?:[2-57]|62|8[0-7]|9[04-9])|8[02-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27-9]"]]],"0"],"LC":["1","011","(?:[58]\\d\\d|758|900)\\d{7}",[10],0,"1",0,"1|([2-8]\\d{6})$","758$1",0,"758"],"LI":["423","00","[68]\\d{8}|(?:[2378]\\d|90)\\d{5}",[7,9],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2379]|8(?:0[09]|7)","[2379]|8(?:0(?:02|9)|7)"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["69"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]],"0",0,"0|(1001)"],"LK":["94","00","[1-9]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[1-689]"],"0$1"]],"0"],"LR":["231","00","(?:2|33|5\\d|77|88)\\d{7}|[4-6]\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[4-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3578]"],"0$1"]],"0"],"LS":["266","00","(?:[256]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2568]"]]]],"LT":["370","00","(?:[3469]\\d|52|[78]0)\\d{6}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["52[0-7]"],"(8-$1)",1],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[7-9]"],"8 $1",1],["(\\d{2})(\\d{6})","$1 $2",["37|4(?:[15]|6[1-8])"],"(8-$1)",1],["(\\d{3})(\\d{5})","$1 $2",["[3-6]"],"(8-$1)",1]],"8",0,"[08]"],"LU":["352","00","35[013-9]\\d{4,8}|6\\d{8}|35\\d{2,4}|(?:[2457-9]\\d|3[0-46-9])\\d{2,9}",[4,5,6,7,8,9,10,11],[["(\\d{2})(\\d{3})","$1 $2",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["20[2-689]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4",["2(?:[0367]|4[3-8])"]],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["80[01]|90[015]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["20"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4 $5",["2(?:[0367]|4[3-8])"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,5})","$1 $2 $3 $4",["[3-57]|8[13-9]|9(?:0[89]|[2-579])|(?:2|80)[2-9]"]]],0,0,"(15(?:0[06]|1[12]|[35]5|4[04]|6[26]|77|88|99)\\d)"],"LV":["371","00","(?:[268]\\d|90)\\d{6}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[269]|8[01]"]]]],"LY":["218","00","[2-9]\\d{8}",[9],[["(\\d{2})(\\d{7})","$1-$2",["[2-9]"],"0$1"]],"0"],"MA":["212","00","[5-8]\\d{8}",[9],[["(\\d{5})(\\d{4})","$1-$2",["5(?:29|38)","5(?:29[89]|389)","5(?:29[89]|389)0"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5[45]"],"0$1"],["(\\d{4})(\\d{5})","$1-$2",["5(?:2[2-489]|3[5-9]|9)|892","5(?:2(?:[2-49]|8[235-9])|3[5-9]|9)|892"],"0$1"],["(\\d{2})(\\d{7})","$1-$2",["8"],"0$1"],["(\\d{3})(\\d{6})","$1-$2",["[5-7]"],"0$1"]],"0",0,0,0,0,0,[["5(?:29(?:[189][05]|2[29]|3[01])|389[05])\\d{4}|5(?:2(?:[0-25-7]\\d|3[1-578]|4[02-46-8]|8[0235-7]|90)|3(?:[0-47]\\d|5[02-9]|6[02-8]|8[08]|9[3-9])|(?:4[067]|5[03])\\d)\\d{5}"],["(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[017]\\d|2[0-2]|6[0-8]|8[0-3]))\\d{6}"],["80\\d{7}"],["89\\d{7}"],0,0,0,0,["592(?:4[0-2]|93)\\d{4}"]]],"MC":["377","00","(?:[3489]|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["4"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[389]"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["6"],"0$1"]],"0"],"MD":["373","00","(?:[235-7]\\d|[89]0)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["22|3"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[25-7]"],"0$1"]],"0"],"ME":["382","00","(?:20|[3-79]\\d)\\d{6}|80\\d{6,7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"0$1"]],"0"],"MF":["590","00","(?:590|(?:69|80)\\d|976)\\d{6}",[9],0,"0",0,0,0,0,0,[["590(?:0[079]|[14]3|[27][79]|30|5[0-268]|87)\\d{4}"],["69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["976[01]\\d{5}"]]],"MG":["261","00","[23]\\d{8}",[9],[["(\\d{2})(\\d{2})(\\d{3})(\\d{2})","$1 $2 $3 $4",["[23]"],"0$1"]],"0",0,"0|([24-9]\\d{6})$","20$1"],"MH":["692","011","329\\d{4}|(?:[256]\\d|45)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1-$2",["[2-6]"]]],"1"],"MK":["389","00","[2-578]\\d{7}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2|34[47]|4(?:[37]7|5[47]|64)"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[347]"],"0$1"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["[58]"],"0$1"]],"0"],"ML":["223","00","[24-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-9]"]]]],"MM":["95","00","1\\d{5,7}|95\\d{6}|(?:[4-7]|9[0-46-9])\\d{6,8}|(?:2|8\\d)\\d{5,8}",[6,7,8,9,10],[["(\\d)(\\d{2})(\\d{3})","$1 $2 $3",["16|2"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["[45]|6(?:0[23]|[1-689]|7[235-7])|7(?:[0-4]|5[2-7])|8[1-6]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[12]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[4-7]|8[1-35]"],"0$1"],["(\\d)(\\d{3})(\\d{4,6})","$1 $2 $3",["9(?:2[0-4]|[35-9]|4[137-9])"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["92"],"0$1"],["(\\d)(\\d{5})(\\d{4})","$1 $2 $3",["9"],"0$1"]],"0"],"MN":["976","001","[12]\\d{7,9}|[5-9]\\d{7}",[8,9,10],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[12]1"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[5-9]"]],["(\\d{3})(\\d{5,6})","$1 $2",["[12]2[1-3]"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["[12](?:27|3[2-8]|4[2-68]|5[1-4689])","[12](?:27|3[2-8]|4[2-68]|5[1-4689])[0-3]"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["[12]"],"0$1"]],"0"],"MO":["853","00","0800\\d{3}|(?:28|[68]\\d)\\d{6}",[7,8],[["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{4})(\\d{4})","$1 $2",["[268]"]]]],"MP":["1","011","[58]\\d{9}|(?:67|90)0\\d{7}",[10],0,"1",0,"1|([2-9]\\d{6})$","670$1",0,"670"],"MQ":["596","00","(?:69|80)\\d{7}|(?:59|97)6\\d{6}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[569]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],"MR":["222","00","(?:[2-4]\\d\\d|800)\\d{5}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-48]"]]]],"MS":["1","011","(?:[58]\\d\\d|664|900)\\d{7}",[10],0,"1",0,"1|([34]\\d{6})$","664$1",0,"664"],"MT":["356","00","3550\\d{4}|(?:[2579]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2357-9]"]]]],"MU":["230","0(?:0|[24-7]0|3[03])","(?:5|8\\d\\d)\\d{7}|[2-468]\\d{6}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[2-46]|8[013]"]],["(\\d{4})(\\d{4})","$1 $2",["5"]],["(\\d{5})(\\d{5})","$1 $2",["8"]]],0,0,0,0,0,0,0,"020"],"MV":["960","0(?:0|19)","(?:800|9[0-57-9]\\d)\\d{7}|[34679]\\d{6}",[7,10],[["(\\d{3})(\\d{4})","$1-$2",["[3467]|9[13-9]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"]]],0,0,0,0,0,0,0,"00"],"MW":["265","00","(?:[1289]\\d|31|77)\\d{7}|1\\d{6}",[7,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["1[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[137-9]"],"0$1"]],"0"],"MX":["52","0[09]","1(?:(?:44|99)[1-9]|65[0-689])\\d{7}|(?:1(?:[017]\\d|[235][1-9]|4[0-35-9]|6[0-46-9]|8[1-79]|9[1-8])|[2-9]\\d)\\d{8}",[10,11],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["33|5[56]|81"],0,1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2-9]"],0,1],["(\\d)(\\d{2})(\\d{4})(\\d{4})","$2 $3 $4",["1(?:33|5[56]|81)"],0,1],["(\\d)(\\d{3})(\\d{3})(\\d{4})","$2 $3 $4",["1"],0,1]],"01",0,"0(?:[12]|4[45])|1",0,0,0,0,"00"],"MY":["60","00","1\\d{8,9}|(?:3\\d|[4-9])\\d{7}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1-$2 $3",["[4-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1-$2 $3",["1(?:[02469]|[378][1-9]|53)|8","1(?:[02469]|[37][1-9]|53|8(?:[1-46-9]|5[7-9]))|8"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2 $3",["3"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3-$4",["1(?:[367]|80)"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2 $3",["15"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2 $3",["1"],"0$1"]],"0"],"MZ":["258","00","(?:2|8\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2|8[2-79]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],"NA":["264","00","[68]\\d{7,8}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["87"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],"NC":["687","00","(?:050|[2-57-9]\\d\\d)\\d{3}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1.$2.$3",["[02-57-9]"]]]],"NE":["227","00","[027-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["08"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[089]|2[013]|7[04]"]]]],"NF":["672","00","[13]\\d{5}",[6],[["(\\d{2})(\\d{4})","$1 $2",["1[0-3]"]],["(\\d)(\\d{5})","$1 $2",["[13]"]]],0,0,"([0-258]\\d{4})$","3$1"],"NG":["234","009","(?:[124-7]|9\\d{3})\\d{6}|[1-9]\\d{7}|[78]\\d{9,13}",[7,8,10,11,12,13,14],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["78"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[12]|9(?:0[3-9]|[1-9])"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["[3-7]|8[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[7-9]"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["[78]"],"0$1"],["(\\d{3})(\\d{5})(\\d{5,6})","$1 $2 $3",["[78]"],"0$1"]],"0"],"NI":["505","00","(?:1800|[25-8]\\d{3})\\d{4}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[125-8]"]]]],"NL":["31","00","(?:[124-7]\\d\\d|3(?:[02-9]\\d|1[0-8]))\\d{6}|8\\d{6,9}|9\\d{6,10}|1\\d{4,5}",[5,6,7,8,9,10,11],[["(\\d{3})(\\d{4,7})","$1 $2",["[89]0"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["66"],"0$1"],["(\\d)(\\d{8})","$1 $2",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["1[16-8]|2[259]|3[124]|4[17-9]|5[124679]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-578]|91"],"0$1"],["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3",["9"],"0$1"]],"0"],"NO":["47","00","(?:0|[2-9]\\d{3})\\d{4}",[5,8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[489]|59"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[235-7]"]]],0,0,0,0,0,"[02-689]|7[0-8]"],"NP":["977","00","(?:1\\d|9)\\d{9}|[1-9]\\d{7}",[8,10,11],[["(\\d)(\\d{7})","$1-$2",["1[2-6]"],"0$1"],["(\\d{2})(\\d{6})","$1-$2",["1[01]|[2-8]|9(?:[1-59]|[67][2-6])"],"0$1"],["(\\d{3})(\\d{7})","$1-$2",["9"]]],"0"],"NR":["674","00","(?:444|(?:55|8\\d)\\d|666)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[4-68]"]]]],"NU":["683","00","(?:[47]|888\\d)\\d{3}",[4,7],[["(\\d{3})(\\d{4})","$1 $2",["8"]]]],"NZ":["64","0(?:0|161)","[29]\\d{7,9}|50\\d{5}(?:\\d{2,3})?|6[0-35-9]\\d{6}|7\\d{7,8}|8\\d{4,9}|(?:11\\d|[34])\\d{7}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,8})","$1 $2",["8[1-579]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["50[036-8]|[89]0","50(?:[0367]|88)|[89]0"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["24|[346]|7[2-57-9]|9[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:10|74)|[59]|80"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["1|2[028]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,5})","$1 $2 $3",["2(?:[169]|7[0-35-9])|7|86"],"0$1"]],"0",0,0,0,0,0,0,"00"],"OM":["968","00","(?:1505|[279]\\d{3}|500)\\d{4}|800\\d{5,6}",[7,8,9],[["(\\d{3})(\\d{4,6})","$1 $2",["[58]"]],["(\\d{2})(\\d{6})","$1 $2",["2"]],["(\\d{4})(\\d{4})","$1 $2",["[179]"]]]],"PA":["507","00","(?:00800|8\\d{3})\\d{6}|[68]\\d{7}|[1-57-9]\\d{6}",[7,8,10,11],[["(\\d{3})(\\d{4})","$1-$2",["[1-57-9]"]],["(\\d{4})(\\d{4})","$1-$2",["[68]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]]],"PE":["51","00|19(?:1[124]|77|90)00","(?:[14-8]|9\\d)\\d{7}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["80"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["1"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[4-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"]]],"0",0,0,0,0,0,0,"00"," Anexo "],"PF":["689","00","4\\d{5}(?:\\d{2})?|8\\d{7,8}",[6,8,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["44"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4|8[7-9]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],"PG":["675","00|140[1-3]","(?:180|[78]\\d{3})\\d{4}|(?:[2-589]\\d|64)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["18|[2-69]|85"]],["(\\d{4})(\\d{4})","$1 $2",["[78]"]]],0,0,0,0,0,0,0,"00"],"PH":["63","00","(?:[2-7]|9\\d)\\d{8}|2\\d{5}|(?:1800|8)\\d{7,9}",[6,8,9,10,11,12,13],[["(\\d)(\\d{5})","$1 $2",["2"],"(0$1)"],["(\\d{4})(\\d{4,6})","$1 $2",["3(?:23|39|46)|4(?:2[3-6]|[35]9|4[26]|76)|544|88[245]|(?:52|64|86)2","3(?:230|397|461)|4(?:2(?:35|[46]4|51)|396|4(?:22|63)|59[347]|76[15])|5(?:221|446)|642[23]|8(?:622|8(?:[24]2|5[13]))"],"(0$1)"],["(\\d{5})(\\d{4})","$1 $2",["346|4(?:27|9[35])|883","3469|4(?:279|9(?:30|56))|8834"],"(0$1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|8[2-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{4})(\\d{1,2})(\\d{3})(\\d{4})","$1 $2 $3 $4",["1"]]],"0"],"PK":["92","00","122\\d{6}|[24-8]\\d{10,11}|9(?:[013-9]\\d{8,10}|2(?:[01]\\d\\d|2(?:[06-8]\\d|1[01]))\\d{7})|(?:[2-8]\\d{3}|92(?:[0-7]\\d|8[1-9]))\\d{6}|[24-9]\\d{8}|[89]\\d{7}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,7})","$1 $2 $3",["[89]0"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["1"]],["(\\d{3})(\\d{6,7})","$1 $2",["2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:2[2-8]|3[27-9]|4[2-6]|6[3569]|9[25-8])","9(?:2[3-8]|98)|(?:2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:22|3[27-9]|4[2-6]|6[3569]|9[25-7]))[2-9]"],"(0$1)"],["(\\d{2})(\\d{7,8})","$1 $2",["(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)[2-9]"],"(0$1)"],["(\\d{5})(\\d{5})","$1 $2",["58"],"(0$1)"],["(\\d{3})(\\d{7})","$1 $2",["3"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[24-9]"],"(0$1)"]],"0"],"PL":["48","00","(?:6|8\\d\\d)\\d{7}|[1-9]\\d{6}(?:\\d{2})?|[26]\\d{5}",[6,7,8,9,10],[["(\\d{5})","$1",["19"]],["(\\d{3})(\\d{3})","$1 $2",["11|20|64"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])1","(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])19"]],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["64"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["21|39|45|5[0137]|6[0469]|7[02389]|8(?:0[14]|8)"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[2-8]|[2-7]|8[1-79]|9[145]"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["8"]]]],"PM":["508","00","(?:[45]|80\\d\\d)\\d{5}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[45]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],"PR":["1","011","(?:[589]\\d\\d|787)\\d{7}",[10],0,"1",0,0,0,0,"787|939"],"PS":["970","00","[2489]2\\d{6}|(?:1\\d|5)\\d{8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2489]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["5"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],"PT":["351","00","1693\\d{5}|(?:[26-9]\\d|30)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["2[12]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["16|[236-9]"]]]],"PW":["680","01[12]","(?:[24-8]\\d\\d|345|900)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],"PY":["595","00","59\\d{4,6}|9\\d{5,10}|(?:[2-46-8]\\d|5[0-8])\\d{4,7}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3,6})","$1 $2",["[2-9]0"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[26]1|3[289]|4[1246-8]|7[1-3]|8[1-36]"],"(0$1)"],["(\\d{3})(\\d{4,5})","$1 $2",["2[279]|3[13-5]|4[359]|5|6(?:[34]|7[1-46-8])|7[46-8]|85"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2[14-68]|3[26-9]|4[1246-8]|6(?:1|75)|7[1-35]|8[1-36]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["87"]],["(\\d{3})(\\d{6})","$1 $2",["9(?:[5-79]|8[1-6])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["9"]]],"0"],"QA":["974","00","[2-7]\\d{7}|800\\d{4}(?:\\d{2})?|2\\d{6}",[7,8,9],[["(\\d{3})(\\d{4})","$1 $2",["2[126]|8"]],["(\\d{4})(\\d{4})","$1 $2",["[2-7]"]]]],"RE":["262","00","976\\d{6}|(?:26|[68]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2689]"],"0$1"]],"0",0,0,0,0,"26[23]|69|[89]"],"RO":["40","00","(?:[2378]\\d|90)\\d{7}|[23]\\d{5}",[6,9],[["(\\d{3})(\\d{3})","$1 $2",["2[3-6]","2[3-6]\\d9"],"0$1"],["(\\d{2})(\\d{4})","$1 $2",["219|31"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[23]1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[237-9]"],"0$1"]],"0",0,0,0,0,0,0,0," int "],"RS":["381","00","38[02-9]\\d{6,9}|6\\d{7,9}|90\\d{4,8}|38\\d{5,6}|(?:7\\d\\d|800)\\d{3,9}|(?:[12]\\d|3[0-79])\\d{5,10}",[6,7,8,9,10,11,12],[["(\\d{3})(\\d{3,9})","$1 $2",["(?:2[389]|39)0|[7-9]"],"0$1"],["(\\d{2})(\\d{5,10})","$1 $2",["[1-36]"],"0$1"]],"0"],"RU":["7","810","8\\d{13}|[347-9]\\d{9}",[10,14],[["(\\d{4})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-8]|2[1-9])","7(?:1(?:[0-6]2|7|8[27])|2(?:1[23]|[2-9]2))","7(?:1(?:[0-6]2|7|8[27])|2(?:13[03-69]|62[013-9]))|72[1-57-9]2"],"8 ($1)",1],["(\\d{5})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-68]|2[1-9])","7(?:1(?:[06][3-6]|[18]|2[35]|[3-5][3-5])|2(?:[13][3-5]|[24-689]|7[457]))","7(?:1(?:0(?:[356]|4[023])|[18]|2(?:3[013-9]|5)|3[45]|43[013-79]|5(?:3[1-8]|4[1-7]|5)|6(?:3[0-35-9]|[4-6]))|2(?:1(?:3[178]|[45])|[24-689]|3[35]|7[457]))|7(?:14|23)4[0-8]|71(?:33|45)[1-79]"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[349]|8(?:[02-7]|1[1-8])"],"8 ($1)",1],["(\\d{4})(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3 $4",["8"],"8 ($1)"]],"8",0,0,0,0,"3[04-689]|[489]",0,"8~10"],"RW":["250","00","(?:06|[27]\\d\\d|[89]00)\\d{6}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[7-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"]]],"0"],"SA":["966","00","92\\d{7}|(?:[15]|8\\d)\\d{8}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["9"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["81"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]],"0"],"SB":["677","0[01]","(?:[1-6]|[7-9]\\d\\d)\\d{4}",[5,7],[["(\\d{2})(\\d{5})","$1 $2",["7|8[4-9]|9(?:[1-8]|9[0-8])"]]]],"SC":["248","010|0[0-2]","800\\d{4}|(?:[249]\\d|64)\\d{5}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[246]|9[57]"]]],0,0,0,0,0,0,0,"00"],"SD":["249","00","[19]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[19]"],"0$1"]],"0"],"SE":["46","00","(?:[26]\\d\\d|9)\\d{9}|[1-9]\\d{8}|[1-689]\\d{7}|[1-4689]\\d{6}|2\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{2,3})(\\d{2})","$1-$2 $3",["20"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{4})","$1-$2",["9(?:00|39|44|9)"],"0$1",0,"$1 $2"],["(\\d{2})(\\d{3})(\\d{2})","$1-$2 $3",["[12][136]|3[356]|4[0246]|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3"],["(\\d)(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2,3})(\\d{2})","$1-$2 $3",["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[125689]|4[02-57]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{2,3})(\\d{3})","$1-$2 $3",["9(?:00|39|44)"],"0$1",0,"$1 $2 $3"],["(\\d{2})(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["1[13689]|2[0136]|3[1356]|4[0246]|54|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3 $4"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["10|7"],"0$1",0,"$1 $2 $3 $4"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1-$2 $3 $4",["[13-5]|2(?:[247-9]|5[0138])|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{3})","$1-$2 $3 $4",["9"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4 $5",["[26]"],"0$1",0,"$1 $2 $3 $4 $5"]],"0"],"SG":["65","0[0-3]\\d","(?:(?:1\\d|8)\\d\\d|7000)\\d{7}|[3689]\\d{7}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["[369]|8(?:0[1-5]|[1-9])"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]],["(\\d{4})(\\d{4})(\\d{3})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],"SH":["290","00","(?:[256]\\d|8)\\d{3}",[4,5],0,0,0,0,0,0,"[256]"],"SI":["386","00|10(?:22|66|88|99)","[1-7]\\d{7}|8\\d{4,7}|90\\d{4,6}",[5,6,7,8],[["(\\d{2})(\\d{3,6})","$1 $2",["8[09]|9"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["59|8"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37][01]|4[0139]|51|6"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-57]"],"(0$1)"]],"0",0,0,0,0,0,0,"00"],"SJ":["47","00","0\\d{4}|(?:[489]\\d|[57]9)\\d{6}",[5,8],0,0,0,0,0,0,"79"],"SK":["421","00","[2-689]\\d{8}|[2-59]\\d{6}|[2-5]\\d{5}",[6,7,9],[["(\\d)(\\d{2})(\\d{3,4})","$1 $2 $3",["21"],"0$1"],["(\\d{2})(\\d{2})(\\d{2,3})","$1 $2 $3",["[3-5][1-8]1","[3-5][1-8]1[67]"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1/$2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[689]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1/$2 $3 $4",["[3-5]"],"0$1"]],"0"],"SL":["232","00","(?:[237-9]\\d|66)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[236-9]"],"(0$1)"]],"0"],"SM":["378","00","(?:0549|[5-7]\\d)\\d{6}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]"]],["(\\d{4})(\\d{6})","$1 $2",["0"]]],0,0,"([89]\\d{5})$","0549$1"],"SN":["221","00","(?:[378]\\d|93)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[379]"]]]],"SO":["252","00","[346-9]\\d{8}|[12679]\\d{7}|[1-5]\\d{6}|[1348]\\d{5}",[6,7,8,9],[["(\\d{2})(\\d{4})","$1 $2",["8[125]"]],["(\\d{6})","$1",["[134]"]],["(\\d)(\\d{6})","$1 $2",["[15]|2[0-79]|3[0-46-8]|4[0-7]"]],["(\\d)(\\d{7})","$1 $2",["24|[67]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[3478]|64|90"]],["(\\d{2})(\\d{5,7})","$1 $2",["1|28|6(?:0[5-7]|[1-35-9])|9[2-9]"]]],"0"],"SR":["597","00","(?:[2-5]|68|[78]\\d)\\d{5}",[6,7],[["(\\d{2})(\\d{2})(\\d{2})","$1-$2-$3",["56"]],["(\\d{3})(\\d{3})","$1-$2",["[2-5]"]],["(\\d{3})(\\d{4})","$1-$2",["[6-8]"]]]],"SS":["211","00","[19]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[19]"],"0$1"]],"0"],"ST":["239","00","(?:22|9\\d)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[29]"]]]],"SV":["503","00","[267]\\d{7}|[89]00\\d{4}(?:\\d{4})?",[7,8,11],[["(\\d{3})(\\d{4})","$1 $2",["[89]"]],["(\\d{4})(\\d{4})","$1 $2",["[267]"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[89]"]]]],"SX":["1","011","7215\\d{6}|(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|(5\\d{6})$","721$1",0,"721"],"SY":["963","00","[1-39]\\d{8}|[1-5]\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-5]"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1",1]],"0"],"SZ":["268","00","0800\\d{4}|(?:[237]\\d|900)\\d{6}",[8,9],[["(\\d{4})(\\d{4})","$1 $2",["[0237]"]],["(\\d{5})(\\d{4})","$1 $2",["9"]]]],"TA":["290","00","8\\d{3}",[4],0,0,0,0,0,0,"8"],"TC":["1","011","(?:[58]\\d\\d|649|900)\\d{7}",[10],0,"1",0,"1|([2-479]\\d{6})$","649$1",0,"649"],"TD":["235","00|16","(?:22|[69]\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2679]"]]],0,0,0,0,0,0,0,"00"],"TG":["228","00","[279]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[279]"]]]],"TH":["66","00[1-9]","(?:001800|[2-57]|[689]\\d)\\d{7}|1\\d{7,9}",[8,9,10,13],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],"TJ":["992","810","(?:00|[1-57-9]\\d)\\d{7}",[9],[["(\\d{6})(\\d)(\\d{2})","$1 $2 $3",["331","3317"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["[34]7|91[78]"]],["(\\d{4})(\\d)(\\d{4})","$1 $2 $3",["3[1-5]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[0-57-9]"]]],0,0,0,0,0,0,0,"8~10"],"TK":["690","00","[2-47]\\d{3,6}",[4,5,6,7]],"TL":["670","00","7\\d{7}|(?:[2-47]\\d|[89]0)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[2-489]|70"]],["(\\d{4})(\\d{4})","$1 $2",["7"]]]],"TM":["993","810","[1-6]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["12"],"(8 $1)"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-5]"],"(8 $1)"],["(\\d{2})(\\d{6})","$1 $2",["6"],"8 $1"]],"8",0,0,0,0,0,0,"8~10"],"TN":["216","00","[2-57-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-57-9]"]]]],"TO":["676","00","(?:0800|(?:[5-8]\\d\\d|999)\\d)\\d{3}|[2-8]\\d{4}",[5,7],[["(\\d{2})(\\d{3})","$1-$2",["[2-4]|50|6[09]|7[0-24-69]|8[05]"]],["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[5-9]"]]]],"TR":["90","00","4\\d{6}|8\\d{11,12}|(?:[2-58]\\d\\d|900)\\d{7}",[7,10,12,13],[["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["512|8[01589]|90"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5(?:[0-59]|61)","5(?:[0-59]|616)","5(?:[0-59]|6161)"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24][1-8]|3[1-9]"],"(0$1)",1],["(\\d{3})(\\d{3})(\\d{6,7})","$1 $2 $3",["80"],"0$1",1]],"0"],"TT":["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([2-46-8]\\d{6})$","868$1",0,"868"],"TV":["688","00","(?:2|7\\d\\d|90)\\d{4}",[5,6,7],[["(\\d{2})(\\d{3})","$1 $2",["2"]],["(\\d{2})(\\d{4})","$1 $2",["90"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],"TW":["886","0(?:0[25-79]|19)","[2-689]\\d{8}|7\\d{9,10}|[2-8]\\d{7}|2\\d{6}",[7,8,9,10,11],[["(\\d{2})(\\d)(\\d{4})","$1 $2 $3",["202"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[258]0"],"0$1"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["[23568]|4(?:0[02-48]|[1-47-9])|7[1-9]","[23568]|4(?:0[2-48]|[1-47-9])|(?:400|7)[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,5})","$1 $2 $3",["7"],"0$1"]],"0",0,0,0,0,0,0,0,"#"],"TZ":["255","00[056]","(?:[25-8]\\d|41|90)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[24]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["5"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[67]"],"0$1"]],"0"],"UA":["380","00","[89]\\d{9}|[3-9]\\d{8}",[9,10],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6[12][29]|(?:3[1-8]|4[136-8]|5[12457]|6[49])2|(?:56|65)[24]","6[12][29]|(?:35|4[1378]|5[12457]|6[49])2|(?:56|65)[24]|(?:3[1-46-8]|46)2[013-9]"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6[0135689]|7[4-6])|6(?:[12][3-7]|[459])","3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6(?:[015689]|3[02389])|7[4-6])|6(?:[12][3-7]|[459])"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|89|9[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0",0,0,0,0,0,0,"0~0"],"UG":["256","00[057]","800\\d{6}|(?:[29]0|[347]\\d)\\d{7}",[9],[["(\\d{4})(\\d{5})","$1 $2",["202","2024"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[27-9]|4(?:6[45]|[7-9])"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[34]"],"0$1"]],"0"],"US":["1","011","[2-9]\\d{9}|3\\d{6}",[10],[["(\\d{3})(\\d{4})","$1-$2",["310"],0,1],["(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",["[2-9]"],0,1,"$1-$2-$3"]],"1",0,0,0,0,0,[["505(?:[2-57-9]\\d\\d|6(?:[0-35-9]\\d|44))\\d{4}|(?:2(?:0[1-35-9]|1[02-9]|2[03-589]|3[149]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[01356]|3[0-24679]|4[167]|5[12]|6[014]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[19]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|[34][016]|5[01679]|6[0-279]|78|8[0-29])|7(?:0[1-46-8]|1[2-9]|2[04-7]|3[1247]|4[037]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[068]|3[0-289]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-389]|8[04-69]))[2-9]\\d{6}"],[""],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}"],["900[2-9]\\d{6}"],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|5(?:00|2[125-7]|33|44|66|77|88)[2-9]\\d{6}"]]],"UY":["598","0(?:0|1[3-9]\\d)","4\\d{9}|[1249]\\d{7}|(?:[49]\\d|80)\\d{5}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["405|8|90"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[124]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["4"],"0$1"]],"0",0,0,0,0,0,0,"00"," int. "],"UZ":["998","810","(?:33|55|[679]\\d|88)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[35-9]"],"8 $1"]],"8",0,0,0,0,0,0,"8~10"],"VA":["39","00","0\\d{5,10}|3[0-8]\\d{7,10}|55\\d{8}|8\\d{5}(?:\\d{2,4})?|(?:1\\d|39)\\d{7,8}",[6,7,8,9,10,11],0,0,0,0,0,0,"06698"],"VC":["1","011","(?:[58]\\d\\d|784|900)\\d{7}",[10],0,"1",0,"1|([2-7]\\d{6})$","784$1",0,"784"],"VE":["58","00","[68]00\\d{7}|(?:[24]\\d|[59]0)\\d{8}",[10],[["(\\d{3})(\\d{7})","$1-$2",["[24-689]"],"0$1"]],"0"],"VG":["1","011","(?:284|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([2-578]\\d{6})$","284$1",0,"284"],"VI":["1","011","[58]\\d{9}|(?:34|90)0\\d{7}",[10],0,"1",0,"1|([2-9]\\d{6})$","340$1",0,"340"],"VN":["84","00","[12]\\d{9}|[135-9]\\d{8}|[16]\\d{7}|[16-8]\\d{6}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["80"],"0$1",1],["(\\d{4})(\\d{4,6})","$1 $2",["1"],0,1],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[69]"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[3578]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["2[48]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["2"],"0$1",1]],"0"],"VU":["678","00","[57-9]\\d{6}|(?:[238]\\d|48)\\d{3}",[5,7],[["(\\d{3})(\\d{4})","$1 $2",["[57-9]"]]]],"WF":["681","00","(?:40|72)\\d{4}|8\\d{5}(?:\\d{3})?",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[478]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],"WS":["685","0","(?:[2-6]|8\\d{5})\\d{4}|[78]\\d{6}|[68]\\d{5}",[5,6,7,10],[["(\\d{5})","$1",["[2-5]|6[1-9]"]],["(\\d{3})(\\d{3,7})","$1 $2",["[68]"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],"XK":["383","00","[23]\\d{7,8}|(?:4\\d\\d|[89]00)\\d{5}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[23]"],"0$1"]],"0"],"YE":["967","00","(?:1|7\\d)\\d{7}|[1-7]\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-6]|7[24-68]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"],"0$1"]],"0"],"YT":["262","00","80\\d{7}|(?:26|63)9\\d{6}",[9],0,"0",0,0,0,0,"269|63"],"ZA":["27","00","[1-79]\\d{8}|8\\d{4,9}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,4})","$1 $2",["8[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["8[1-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["860"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],"ZM":["260","00","800\\d{6}|(?:21|63|[79]\\d)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[28]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[79]"],"0$1"]],"0"],"ZW":["263","00","2(?:[0-57-9]\\d{6,8}|6[0-24-9]\\d{6,7})|[38]\\d{9}|[35-8]\\d{8}|[3-6]\\d{7}|[1-689]\\d{6}|[1-3569]\\d{5}|[1356]\\d{4}",[5,6,7,8,9,10],[["(\\d{3})(\\d{3,5})","$1 $2",["2(?:0[45]|2[278]|[49]8)|3(?:[09]8|17)|6(?:[29]8|37|75)|[23][78]|(?:33|5[15]|6[68])[78]"],"0$1"],["(\\d)(\\d{3})(\\d{2,4})","$1 $2 $3",["[49]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["80"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["24|8[13-59]|(?:2[05-79]|39|5[45]|6[15-8])2","2(?:02[014]|4|[56]20|[79]2)|392|5(?:42|525)|6(?:[16-8]21|52[013])|8[13-59]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:1[39]|2[0157]|[378]|[56][14])|3(?:12|29)","2(?:1[39]|2[0157]|[378]|[56][14])|3(?:123|29)"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["1|2(?:0[0-36-9]|12|29|[56])|3(?:1[0-689]|[24-6])|5(?:[0236-9]|1[2-4])|6(?:[013-59]|7[0-46-9])|(?:33|55|6[68])[0-69]|(?:29|3[09]|62)[0-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["29[013-9]|39|54"],"0$1"],["(\\d{4})(\\d{3,5})","$1 $2",["(?:25|54)8","258|5483"],"0$1"]],"0"]},"nonGeographic":{"800":["800",0,"(?:00|[1-9]\\d)\\d{6}",[8],[["(\\d{4})(\\d{4})","$1 $2",["\\d"]]],0,0,0,0,0,0,[0,0,["(?:00|[1-9]\\d)\\d{6}"]]],"808":["808",0,"[1-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[1-9]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,0,["[1-9]\\d{7}"]]],"870":["870",0,"7\\d{11}|[35-7]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[35-7]"]]],0,0,0,0,0,0,[0,["(?:[356]|774[45])\\d{8}|7[6-8]\\d{7}"]]],"878":["878",0,"10\\d{10}",[12],[["(\\d{2})(\\d{5})(\\d{5})","$1 $2 $3",["1"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["10\\d{10}"]]],"881":["881",0,"[0-36-9]\\d{8}",[9],[["(\\d)(\\d{3})(\\d{5})","$1 $2 $3",["[0-36-9]"]]],0,0,0,0,0,0,[0,["[0-36-9]\\d{8}"]]],"882":["882",0,"[13]\\d{6}(?:\\d{2,5})?|285\\d{9}|(?:[19]\\d|49)\\d{6}",[7,8,9,10,11,12],[["(\\d{2})(\\d{5})","$1 $2",["16|342"]],["(\\d{2})(\\d{6})","$1 $2",["4"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[19]"]],["(\\d{2})(\\d{4})(\\d{3})","$1 $2 $3",["3[23]"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["1"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["34[57]"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["34"]],["(\\d{2})(\\d{4,5})(\\d{5})","$1 $2 $3",["[1-3]"]]],0,0,0,0,0,0,[0,["342\\d{4}|(?:337|49)\\d{6}|3(?:2|47|7\\d{3})\\d{7}",[7,8,9,10,12]],0,0,0,0,0,0,["1(?:3(?:0[0347]|[13][0139]|2[035]|4[013568]|6[0459]|7[06]|8[15-8]|9[0689])\\d{4}|6\\d{5,10})|(?:(?:285\\d\\d|3(?:45|[69]\\d{3}))\\d|9[89])\\d{6}"]]],"883":["883",0,"(?:210|370\\d\\d)\\d{7}|51\\d{7}(?:\\d{3})?",[9,10,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["510"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["2"]],["(\\d{4})(\\d{4})(\\d{4})","$1 $2 $3",["51[13]"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[35]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["(?:210|(?:370[1-9]|51[013]0)\\d)\\d{7}|5100\\d{5}"]]],"888":["888",0,"\\d{11}",[11],[["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3"]],0,0,0,0,0,0,[0,0,0,0,0,0,["\\d{11}"]]],"979":["979",0,"[1359]\\d{8}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[1359]"]]],0,0,0,0,0,0,[0,0,0,["[1359]\\d{8}"]]]}};
  4157. // Importing from a ".js" file is a workaround for Node.js "ES Modules"
  4158. function withMetadataArgument(func, _arguments) {
  4159. var args = Array.prototype.slice.call(_arguments);
  4160. args.push(metadata);
  4161. return func.apply(this, args)
  4162. }
  4163. function _typeof$2(obj) { "@babel/helpers - typeof"; return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof$2(obj); }
  4164. function _defineProperties$2(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4165. function _createClass$2(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$2(Constructor.prototype, protoProps); if (staticProps) _defineProperties$2(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  4166. function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4167. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
  4168. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  4169. function _possibleConstructorReturn(self, call) { if (call && (_typeof$2(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
  4170. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  4171. function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
  4172. function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
  4173. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  4174. function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
  4175. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  4176. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  4177. // https://stackoverflow.com/a/46971044/970769
  4178. // "Breaking changes in Typescript 2.1"
  4179. // "Extending built-ins like Error, Array, and Map may no longer work."
  4180. // "As a recommendation, you can manually adjust the prototype immediately after any super(...) calls."
  4181. // https://github.com/Microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
  4182. var ParseError = /*#__PURE__*/function (_Error) {
  4183. _inherits(ParseError, _Error);
  4184. var _super = _createSuper(ParseError);
  4185. function ParseError(code) {
  4186. var _this;
  4187. _classCallCheck$2(this, ParseError);
  4188. _this = _super.call(this, code); // Set the prototype explicitly.
  4189. // Any subclass of FooError will have to manually set the prototype as well.
  4190. Object.setPrototypeOf(_assertThisInitialized(_this), ParseError.prototype);
  4191. _this.name = _this.constructor.name;
  4192. return _this;
  4193. }
  4194. return _createClass$2(ParseError);
  4195. }( /*#__PURE__*/_wrapNativeSuper(Error));
  4196. // The minimum length of the national significant number.
  4197. var MIN_LENGTH_FOR_NSN = 2; // The ITU says the maximum length should be 15,
  4198. // but one can find longer numbers in Germany.
  4199. var MAX_LENGTH_FOR_NSN = 17; // The maximum length of the country calling code.
  4200. var MAX_LENGTH_COUNTRY_CODE = 3; // Digits accepted in phone numbers
  4201. // (ascii, fullwidth, arabic-indic, and eastern arabic digits).
  4202. var VALID_DIGITS = "0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9"; // `DASHES` will be right after the opening square bracket of the "character class"
  4203. var DASHES = "-\u2010-\u2015\u2212\u30FC\uFF0D";
  4204. var SLASHES = "\uFF0F/";
  4205. var DOTS = "\uFF0E.";
  4206. var WHITESPACE = " \xA0\xAD\u200B\u2060\u3000";
  4207. var BRACKETS = "()\uFF08\uFF09\uFF3B\uFF3D\\[\\]"; // export const OPENING_BRACKETS = '(\uFF08\uFF3B\\\['
  4208. var TILDES = "~\u2053\u223C\uFF5E"; // Regular expression of acceptable punctuation found in phone numbers. This
  4209. // excludes punctuation found as a leading character only. This consists of dash
  4210. // characters, white space characters, full stops, slashes, square brackets,
  4211. // parentheses and tildes. Full-width variants are also present.
  4212. var VALID_PUNCTUATION = "".concat(DASHES).concat(SLASHES).concat(DOTS).concat(WHITESPACE).concat(BRACKETS).concat(TILDES);
  4213. var PLUS_CHARS = "+\uFF0B"; // const LEADING_PLUS_CHARS_PATTERN = new RegExp('^[' + PLUS_CHARS + ']+')
  4214. // Copy-pasted from:
  4215. // https://github.com/substack/semver-compare/blob/master/index.js
  4216. //
  4217. // Inlining this function because some users reported issues with
  4218. // importing from `semver-compare` in a browser with ES6 "native" modules.
  4219. //
  4220. // Fixes `semver-compare` not being able to compare versions with alpha/beta/etc "tags".
  4221. // https://github.com/catamphetamine/libphonenumber-js/issues/381
  4222. function compare (a, b) {
  4223. a = a.split('-');
  4224. b = b.split('-');
  4225. var pa = a[0].split('.');
  4226. var pb = b[0].split('.');
  4227. for (var i = 0; i < 3; i++) {
  4228. var na = Number(pa[i]);
  4229. var nb = Number(pb[i]);
  4230. if (na > nb) return 1;
  4231. if (nb > na) return -1;
  4232. if (!isNaN(na) && isNaN(nb)) return 1;
  4233. if (isNaN(na) && !isNaN(nb)) return -1;
  4234. }
  4235. if (a[1] && b[1]) {
  4236. return a[1] > b[1] ? 1 : a[1] < b[1] ? -1 : 0;
  4237. }
  4238. return !a[1] && b[1] ? 1 : a[1] && !b[1] ? -1 : 0;
  4239. }
  4240. function _typeof$1(obj) { "@babel/helpers - typeof"; return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof$1(obj); }
  4241. function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4242. function _defineProperties$1(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4243. function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  4244. var V3 = '1.2.0'; // Moved `001` country code to "nonGeographic" section of metadata.
  4245. var V4 = '1.7.35';
  4246. var DEFAULT_EXT_PREFIX = ' ext. ';
  4247. var CALLING_CODE_REG_EXP = /^\d+$/;
  4248. /**
  4249. * See: https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/METADATA.md
  4250. */
  4251. var Metadata = /*#__PURE__*/function () {
  4252. function Metadata(metadata) {
  4253. _classCallCheck$1(this, Metadata);
  4254. validateMetadata(metadata);
  4255. this.metadata = metadata;
  4256. setVersion.call(this, metadata);
  4257. }
  4258. _createClass$1(Metadata, [{
  4259. key: "getCountries",
  4260. value: function getCountries() {
  4261. return Object.keys(this.metadata.countries).filter(function (_) {
  4262. return _ !== '001';
  4263. });
  4264. }
  4265. }, {
  4266. key: "getCountryMetadata",
  4267. value: function getCountryMetadata(countryCode) {
  4268. return this.metadata.countries[countryCode];
  4269. }
  4270. }, {
  4271. key: "nonGeographic",
  4272. value: function nonGeographic() {
  4273. if (this.v1 || this.v2 || this.v3) return; // `nonGeographical` was a typo.
  4274. // It's present in metadata generated from `1.7.35` to `1.7.37`.
  4275. // The test case could be found by searching for "nonGeographical".
  4276. return this.metadata.nonGeographic || this.metadata.nonGeographical;
  4277. }
  4278. }, {
  4279. key: "hasCountry",
  4280. value: function hasCountry(country) {
  4281. return this.getCountryMetadata(country) !== undefined;
  4282. }
  4283. }, {
  4284. key: "hasCallingCode",
  4285. value: function hasCallingCode(callingCode) {
  4286. if (this.getCountryCodesForCallingCode(callingCode)) {
  4287. return true;
  4288. }
  4289. if (this.nonGeographic()) {
  4290. if (this.nonGeographic()[callingCode]) {
  4291. return true;
  4292. }
  4293. } else {
  4294. // A hacky workaround for old custom metadata (generated before V4).
  4295. var countryCodes = this.countryCallingCodes()[callingCode];
  4296. if (countryCodes && countryCodes.length === 1 && countryCodes[0] === '001') {
  4297. return true;
  4298. }
  4299. }
  4300. }
  4301. }, {
  4302. key: "isNonGeographicCallingCode",
  4303. value: function isNonGeographicCallingCode(callingCode) {
  4304. if (this.nonGeographic()) {
  4305. return this.nonGeographic()[callingCode] ? true : false;
  4306. } else {
  4307. return this.getCountryCodesForCallingCode(callingCode) ? false : true;
  4308. }
  4309. } // Deprecated.
  4310. }, {
  4311. key: "country",
  4312. value: function country(countryCode) {
  4313. return this.selectNumberingPlan(countryCode);
  4314. }
  4315. }, {
  4316. key: "selectNumberingPlan",
  4317. value: function selectNumberingPlan(countryCode, callingCode) {
  4318. // Supports just passing `callingCode` as the first argument.
  4319. if (countryCode && CALLING_CODE_REG_EXP.test(countryCode)) {
  4320. callingCode = countryCode;
  4321. countryCode = null;
  4322. }
  4323. if (countryCode && countryCode !== '001') {
  4324. if (!this.hasCountry(countryCode)) {
  4325. throw new Error("Unknown country: ".concat(countryCode));
  4326. }
  4327. this.numberingPlan = new NumberingPlan(this.getCountryMetadata(countryCode), this);
  4328. } else if (callingCode) {
  4329. if (!this.hasCallingCode(callingCode)) {
  4330. throw new Error("Unknown calling code: ".concat(callingCode));
  4331. }
  4332. this.numberingPlan = new NumberingPlan(this.getNumberingPlanMetadata(callingCode), this);
  4333. } else {
  4334. this.numberingPlan = undefined;
  4335. }
  4336. return this;
  4337. }
  4338. }, {
  4339. key: "getCountryCodesForCallingCode",
  4340. value: function getCountryCodesForCallingCode(callingCode) {
  4341. var countryCodes = this.countryCallingCodes()[callingCode];
  4342. if (countryCodes) {
  4343. // Metadata before V4 included "non-geographic entity" calling codes
  4344. // inside `country_calling_codes` (for example, `"881":["001"]`).
  4345. // Now the semantics of `country_calling_codes` has changed:
  4346. // it's specifically for "countries" now.
  4347. // Older versions of custom metadata will simply skip parsing
  4348. // "non-geographic entity" phone numbers with new versions
  4349. // of this library: it's not considered a bug,
  4350. // because such numbers are extremely rare,
  4351. // and developers extremely rarely use custom metadata.
  4352. if (countryCodes.length === 1 && countryCodes[0].length === 3) {
  4353. return;
  4354. }
  4355. return countryCodes;
  4356. }
  4357. }
  4358. }, {
  4359. key: "getCountryCodeForCallingCode",
  4360. value: function getCountryCodeForCallingCode(callingCode) {
  4361. var countryCodes = this.getCountryCodesForCallingCode(callingCode);
  4362. if (countryCodes) {
  4363. return countryCodes[0];
  4364. }
  4365. }
  4366. }, {
  4367. key: "getNumberingPlanMetadata",
  4368. value: function getNumberingPlanMetadata(callingCode) {
  4369. var countryCode = this.getCountryCodeForCallingCode(callingCode);
  4370. if (countryCode) {
  4371. return this.getCountryMetadata(countryCode);
  4372. }
  4373. if (this.nonGeographic()) {
  4374. var metadata = this.nonGeographic()[callingCode];
  4375. if (metadata) {
  4376. return metadata;
  4377. }
  4378. } else {
  4379. // A hacky workaround for old custom metadata (generated before V4).
  4380. // In that metadata, there was no concept of "non-geographic" metadata
  4381. // so metadata for `001` country code was stored along with other countries.
  4382. // The test case can be found by searching for:
  4383. // "should work around `nonGeographic` metadata not existing".
  4384. var countryCodes = this.countryCallingCodes()[callingCode];
  4385. if (countryCodes && countryCodes.length === 1 && countryCodes[0] === '001') {
  4386. return this.metadata.countries['001'];
  4387. }
  4388. }
  4389. } // Deprecated.
  4390. }, {
  4391. key: "countryCallingCode",
  4392. value: function countryCallingCode() {
  4393. return this.numberingPlan.callingCode();
  4394. } // Deprecated.
  4395. }, {
  4396. key: "IDDPrefix",
  4397. value: function IDDPrefix() {
  4398. return this.numberingPlan.IDDPrefix();
  4399. } // Deprecated.
  4400. }, {
  4401. key: "defaultIDDPrefix",
  4402. value: function defaultIDDPrefix() {
  4403. return this.numberingPlan.defaultIDDPrefix();
  4404. } // Deprecated.
  4405. }, {
  4406. key: "nationalNumberPattern",
  4407. value: function nationalNumberPattern() {
  4408. return this.numberingPlan.nationalNumberPattern();
  4409. } // Deprecated.
  4410. }, {
  4411. key: "possibleLengths",
  4412. value: function possibleLengths() {
  4413. return this.numberingPlan.possibleLengths();
  4414. } // Deprecated.
  4415. }, {
  4416. key: "formats",
  4417. value: function formats() {
  4418. return this.numberingPlan.formats();
  4419. } // Deprecated.
  4420. }, {
  4421. key: "nationalPrefixForParsing",
  4422. value: function nationalPrefixForParsing() {
  4423. return this.numberingPlan.nationalPrefixForParsing();
  4424. } // Deprecated.
  4425. }, {
  4426. key: "nationalPrefixTransformRule",
  4427. value: function nationalPrefixTransformRule() {
  4428. return this.numberingPlan.nationalPrefixTransformRule();
  4429. } // Deprecated.
  4430. }, {
  4431. key: "leadingDigits",
  4432. value: function leadingDigits() {
  4433. return this.numberingPlan.leadingDigits();
  4434. } // Deprecated.
  4435. }, {
  4436. key: "hasTypes",
  4437. value: function hasTypes() {
  4438. return this.numberingPlan.hasTypes();
  4439. } // Deprecated.
  4440. }, {
  4441. key: "type",
  4442. value: function type(_type) {
  4443. return this.numberingPlan.type(_type);
  4444. } // Deprecated.
  4445. }, {
  4446. key: "ext",
  4447. value: function ext() {
  4448. return this.numberingPlan.ext();
  4449. }
  4450. }, {
  4451. key: "countryCallingCodes",
  4452. value: function countryCallingCodes() {
  4453. if (this.v1) return this.metadata.country_phone_code_to_countries;
  4454. return this.metadata.country_calling_codes;
  4455. } // Deprecated.
  4456. }, {
  4457. key: "chooseCountryByCountryCallingCode",
  4458. value: function chooseCountryByCountryCallingCode(callingCode) {
  4459. return this.selectNumberingPlan(callingCode);
  4460. }
  4461. }, {
  4462. key: "hasSelectedNumberingPlan",
  4463. value: function hasSelectedNumberingPlan() {
  4464. return this.numberingPlan !== undefined;
  4465. }
  4466. }]);
  4467. return Metadata;
  4468. }();
  4469. var NumberingPlan = /*#__PURE__*/function () {
  4470. function NumberingPlan(metadata, globalMetadataObject) {
  4471. _classCallCheck$1(this, NumberingPlan);
  4472. this.globalMetadataObject = globalMetadataObject;
  4473. this.metadata = metadata;
  4474. setVersion.call(this, globalMetadataObject.metadata);
  4475. }
  4476. _createClass$1(NumberingPlan, [{
  4477. key: "callingCode",
  4478. value: function callingCode() {
  4479. return this.metadata[0];
  4480. } // Formatting information for regions which share
  4481. // a country calling code is contained by only one region
  4482. // for performance reasons. For example, for NANPA region
  4483. // ("North American Numbering Plan Administration",
  4484. // which includes USA, Canada, Cayman Islands, Bahamas, etc)
  4485. // it will be contained in the metadata for `US`.
  4486. }, {
  4487. key: "getDefaultCountryMetadataForRegion",
  4488. value: function getDefaultCountryMetadataForRegion() {
  4489. return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode());
  4490. } // Is always present.
  4491. }, {
  4492. key: "IDDPrefix",
  4493. value: function IDDPrefix() {
  4494. if (this.v1 || this.v2) return;
  4495. return this.metadata[1];
  4496. } // Is only present when a country supports multiple IDD prefixes.
  4497. }, {
  4498. key: "defaultIDDPrefix",
  4499. value: function defaultIDDPrefix() {
  4500. if (this.v1 || this.v2) return;
  4501. return this.metadata[12];
  4502. }
  4503. }, {
  4504. key: "nationalNumberPattern",
  4505. value: function nationalNumberPattern() {
  4506. if (this.v1 || this.v2) return this.metadata[1];
  4507. return this.metadata[2];
  4508. } // "possible length" data is always present in Google's metadata.
  4509. }, {
  4510. key: "possibleLengths",
  4511. value: function possibleLengths() {
  4512. if (this.v1) return;
  4513. return this.metadata[this.v2 ? 2 : 3];
  4514. }
  4515. }, {
  4516. key: "_getFormats",
  4517. value: function _getFormats(metadata) {
  4518. return metadata[this.v1 ? 2 : this.v2 ? 3 : 4];
  4519. } // For countries of the same region (e.g. NANPA)
  4520. // formats are all stored in the "main" country for that region.
  4521. // E.g. "RU" and "KZ", "US" and "CA".
  4522. }, {
  4523. key: "formats",
  4524. value: function formats() {
  4525. var _this = this;
  4526. var formats = this._getFormats(this.metadata) || this._getFormats(this.getDefaultCountryMetadataForRegion()) || [];
  4527. return formats.map(function (_) {
  4528. return new Format(_, _this);
  4529. });
  4530. }
  4531. }, {
  4532. key: "nationalPrefix",
  4533. value: function nationalPrefix() {
  4534. return this.metadata[this.v1 ? 3 : this.v2 ? 4 : 5];
  4535. }
  4536. }, {
  4537. key: "_getNationalPrefixFormattingRule",
  4538. value: function _getNationalPrefixFormattingRule(metadata) {
  4539. return metadata[this.v1 ? 4 : this.v2 ? 5 : 6];
  4540. } // For countries of the same region (e.g. NANPA)
  4541. // national prefix formatting rule is stored in the "main" country for that region.
  4542. // E.g. "RU" and "KZ", "US" and "CA".
  4543. }, {
  4544. key: "nationalPrefixFormattingRule",
  4545. value: function nationalPrefixFormattingRule() {
  4546. return this._getNationalPrefixFormattingRule(this.metadata) || this._getNationalPrefixFormattingRule(this.getDefaultCountryMetadataForRegion());
  4547. }
  4548. }, {
  4549. key: "_nationalPrefixForParsing",
  4550. value: function _nationalPrefixForParsing() {
  4551. return this.metadata[this.v1 ? 5 : this.v2 ? 6 : 7];
  4552. }
  4553. }, {
  4554. key: "nationalPrefixForParsing",
  4555. value: function nationalPrefixForParsing() {
  4556. // If `national_prefix_for_parsing` is not set explicitly,
  4557. // then infer it from `national_prefix` (if any)
  4558. return this._nationalPrefixForParsing() || this.nationalPrefix();
  4559. }
  4560. }, {
  4561. key: "nationalPrefixTransformRule",
  4562. value: function nationalPrefixTransformRule() {
  4563. return this.metadata[this.v1 ? 6 : this.v2 ? 7 : 8];
  4564. }
  4565. }, {
  4566. key: "_getNationalPrefixIsOptionalWhenFormatting",
  4567. value: function _getNationalPrefixIsOptionalWhenFormatting() {
  4568. return !!this.metadata[this.v1 ? 7 : this.v2 ? 8 : 9];
  4569. } // For countries of the same region (e.g. NANPA)
  4570. // "national prefix is optional when formatting" flag is
  4571. // stored in the "main" country for that region.
  4572. // E.g. "RU" and "KZ", "US" and "CA".
  4573. }, {
  4574. key: "nationalPrefixIsOptionalWhenFormattingInNationalFormat",
  4575. value: function nationalPrefixIsOptionalWhenFormattingInNationalFormat() {
  4576. return this._getNationalPrefixIsOptionalWhenFormatting(this.metadata) || this._getNationalPrefixIsOptionalWhenFormatting(this.getDefaultCountryMetadataForRegion());
  4577. }
  4578. }, {
  4579. key: "leadingDigits",
  4580. value: function leadingDigits() {
  4581. return this.metadata[this.v1 ? 8 : this.v2 ? 9 : 10];
  4582. }
  4583. }, {
  4584. key: "types",
  4585. value: function types() {
  4586. return this.metadata[this.v1 ? 9 : this.v2 ? 10 : 11];
  4587. }
  4588. }, {
  4589. key: "hasTypes",
  4590. value: function hasTypes() {
  4591. // Versions 1.2.0 - 1.2.4: can be `[]`.
  4592. /* istanbul ignore next */
  4593. if (this.types() && this.types().length === 0) {
  4594. return false;
  4595. } // Versions <= 1.2.4: can be `undefined`.
  4596. // Version >= 1.2.5: can be `0`.
  4597. return !!this.types();
  4598. }
  4599. }, {
  4600. key: "type",
  4601. value: function type(_type2) {
  4602. if (this.hasTypes() && getType(this.types(), _type2)) {
  4603. return new Type(getType(this.types(), _type2), this);
  4604. }
  4605. }
  4606. }, {
  4607. key: "ext",
  4608. value: function ext() {
  4609. if (this.v1 || this.v2) return DEFAULT_EXT_PREFIX;
  4610. return this.metadata[13] || DEFAULT_EXT_PREFIX;
  4611. }
  4612. }]);
  4613. return NumberingPlan;
  4614. }();
  4615. var Format = /*#__PURE__*/function () {
  4616. function Format(format, metadata) {
  4617. _classCallCheck$1(this, Format);
  4618. this._format = format;
  4619. this.metadata = metadata;
  4620. }
  4621. _createClass$1(Format, [{
  4622. key: "pattern",
  4623. value: function pattern() {
  4624. return this._format[0];
  4625. }
  4626. }, {
  4627. key: "format",
  4628. value: function format() {
  4629. return this._format[1];
  4630. }
  4631. }, {
  4632. key: "leadingDigitsPatterns",
  4633. value: function leadingDigitsPatterns() {
  4634. return this._format[2] || [];
  4635. }
  4636. }, {
  4637. key: "nationalPrefixFormattingRule",
  4638. value: function nationalPrefixFormattingRule() {
  4639. return this._format[3] || this.metadata.nationalPrefixFormattingRule();
  4640. }
  4641. }, {
  4642. key: "nationalPrefixIsOptionalWhenFormattingInNationalFormat",
  4643. value: function nationalPrefixIsOptionalWhenFormattingInNationalFormat() {
  4644. return !!this._format[4] || this.metadata.nationalPrefixIsOptionalWhenFormattingInNationalFormat();
  4645. }
  4646. }, {
  4647. key: "nationalPrefixIsMandatoryWhenFormattingInNationalFormat",
  4648. value: function nationalPrefixIsMandatoryWhenFormattingInNationalFormat() {
  4649. // National prefix is omitted if there's no national prefix formatting rule
  4650. // set for this country, or when the national prefix formatting rule
  4651. // contains no national prefix itself, or when this rule is set but
  4652. // national prefix is optional for this phone number format
  4653. // (and it is not enforced explicitly)
  4654. return this.usesNationalPrefix() && !this.nationalPrefixIsOptionalWhenFormattingInNationalFormat();
  4655. } // Checks whether national prefix formatting rule contains national prefix.
  4656. }, {
  4657. key: "usesNationalPrefix",
  4658. value: function usesNationalPrefix() {
  4659. return this.nationalPrefixFormattingRule() && // Check that national prefix formatting rule is not a "dummy" one.
  4660. !FIRST_GROUP_ONLY_PREFIX_PATTERN.test(this.nationalPrefixFormattingRule()) // In compressed metadata, `this.nationalPrefixFormattingRule()` is `0`
  4661. // when `national_prefix_formatting_rule` is not present.
  4662. // So, `true` or `false` are returned explicitly here, so that
  4663. // `0` number isn't returned.
  4664. ? true : false;
  4665. }
  4666. }, {
  4667. key: "internationalFormat",
  4668. value: function internationalFormat() {
  4669. return this._format[5] || this.format();
  4670. }
  4671. }]);
  4672. return Format;
  4673. }();
  4674. /**
  4675. * A pattern that is used to determine if the national prefix formatting rule
  4676. * has the first group only, i.e., does not start with the national prefix.
  4677. * Note that the pattern explicitly allows for unbalanced parentheses.
  4678. */
  4679. var FIRST_GROUP_ONLY_PREFIX_PATTERN = /^\(?\$1\)?$/;
  4680. var Type = /*#__PURE__*/function () {
  4681. function Type(type, metadata) {
  4682. _classCallCheck$1(this, Type);
  4683. this.type = type;
  4684. this.metadata = metadata;
  4685. }
  4686. _createClass$1(Type, [{
  4687. key: "pattern",
  4688. value: function pattern() {
  4689. if (this.metadata.v1) return this.type;
  4690. return this.type[0];
  4691. }
  4692. }, {
  4693. key: "possibleLengths",
  4694. value: function possibleLengths() {
  4695. if (this.metadata.v1) return;
  4696. return this.type[1] || this.metadata.possibleLengths();
  4697. }
  4698. }]);
  4699. return Type;
  4700. }();
  4701. function getType(types, type) {
  4702. switch (type) {
  4703. case 'FIXED_LINE':
  4704. return types[0];
  4705. case 'MOBILE':
  4706. return types[1];
  4707. case 'TOLL_FREE':
  4708. return types[2];
  4709. case 'PREMIUM_RATE':
  4710. return types[3];
  4711. case 'PERSONAL_NUMBER':
  4712. return types[4];
  4713. case 'VOICEMAIL':
  4714. return types[5];
  4715. case 'UAN':
  4716. return types[6];
  4717. case 'PAGER':
  4718. return types[7];
  4719. case 'VOIP':
  4720. return types[8];
  4721. case 'SHARED_COST':
  4722. return types[9];
  4723. }
  4724. }
  4725. function validateMetadata(metadata) {
  4726. if (!metadata) {
  4727. throw new Error('[libphonenumber-js] `metadata` argument not passed. Check your arguments.');
  4728. } // `country_phone_code_to_countries` was renamed to
  4729. // `country_calling_codes` in `1.0.18`.
  4730. if (!is_object(metadata) || !is_object(metadata.countries)) {
  4731. throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat(is_object(metadata) ? 'an object of shape: { ' + Object.keys(metadata).join(', ') + ' }' : 'a ' + type_of(metadata) + ': ' + metadata, "."));
  4732. }
  4733. } // Babel transforms `typeof` into some "branches"
  4734. // so istanbul will show this as "branch not covered".
  4735. /* istanbul ignore next */
  4736. var is_object = function is_object(_) {
  4737. return _typeof$1(_) === 'object';
  4738. }; // Babel transforms `typeof` into some "branches"
  4739. // so istanbul will show this as "branch not covered".
  4740. /* istanbul ignore next */
  4741. var type_of = function type_of(_) {
  4742. return _typeof$1(_);
  4743. };
  4744. /**
  4745. * Returns "country calling code" for a country.
  4746. * Throws an error if the country doesn't exist or isn't supported by this library.
  4747. * @param {string} country
  4748. * @param {object} metadata
  4749. * @return {string}
  4750. * @example
  4751. * // Returns "44"
  4752. * getCountryCallingCode("GB")
  4753. */
  4754. function getCountryCallingCode(country, metadata) {
  4755. metadata = new Metadata(metadata);
  4756. if (metadata.hasCountry(country)) {
  4757. return metadata.country(country).countryCallingCode();
  4758. }
  4759. throw new Error("Unknown country: ".concat(country));
  4760. }
  4761. function isSupportedCountry(country, metadata) {
  4762. // metadata = new Metadata(metadata)
  4763. // return metadata.hasCountry(country)
  4764. return metadata.countries[country] !== undefined;
  4765. }
  4766. function setVersion(metadata) {
  4767. var version = metadata.version;
  4768. if (typeof version === 'number') {
  4769. this.v1 = version === 1;
  4770. this.v2 = version === 2;
  4771. this.v3 = version === 3;
  4772. this.v4 = version === 4;
  4773. } else {
  4774. if (!version) {
  4775. this.v1 = true;
  4776. } else if (compare(version, V3) === -1) {
  4777. this.v2 = true;
  4778. } else if (compare(version, V4) === -1) {
  4779. this.v3 = true;
  4780. } else {
  4781. this.v4 = true;
  4782. }
  4783. }
  4784. } // const ISO_COUNTRY_CODE = /^[A-Z]{2}$/
  4785. // function isCountryCode(countryCode) {
  4786. // return ISO_COUNTRY_CODE.test(countryCodeOrCountryCallingCode)
  4787. // }
  4788. var RFC3966_EXTN_PREFIX = ';ext=';
  4789. /**
  4790. * Helper method for constructing regular expressions for parsing. Creates
  4791. * an expression that captures up to max_length digits.
  4792. * @return {string} RegEx pattern to capture extension digits.
  4793. */
  4794. var getExtensionDigitsPattern = function getExtensionDigitsPattern(maxLength) {
  4795. return "([".concat(VALID_DIGITS, "]{1,").concat(maxLength, "})");
  4796. };
  4797. /**
  4798. * Helper initialiser method to create the regular-expression pattern to match
  4799. * extensions.
  4800. * Copy-pasted from Google's `libphonenumber`:
  4801. * https://github.com/google/libphonenumber/blob/55b2646ec9393f4d3d6661b9c82ef9e258e8b829/javascript/i18n/phonenumbers/phonenumberutil.js#L759-L766
  4802. * @return {string} RegEx pattern to capture extensions.
  4803. */
  4804. function createExtensionPattern(purpose) {
  4805. // We cap the maximum length of an extension based on the ambiguity of the way
  4806. // the extension is prefixed. As per ITU, the officially allowed length for
  4807. // extensions is actually 40, but we don't support this since we haven't seen real
  4808. // examples and this introduces many false interpretations as the extension labels
  4809. // are not standardized.
  4810. /** @type {string} */
  4811. var extLimitAfterExplicitLabel = '20';
  4812. /** @type {string} */
  4813. var extLimitAfterLikelyLabel = '15';
  4814. /** @type {string} */
  4815. var extLimitAfterAmbiguousChar = '9';
  4816. /** @type {string} */
  4817. var extLimitWhenNotSure = '6';
  4818. /** @type {string} */
  4819. var possibleSeparatorsBetweenNumberAndExtLabel = "[ \xA0\\t,]*"; // Optional full stop (.) or colon, followed by zero or more spaces/tabs/commas.
  4820. /** @type {string} */
  4821. var possibleCharsAfterExtLabel = "[:\\.\uFF0E]?[ \xA0\\t,-]*";
  4822. /** @type {string} */
  4823. var optionalExtnSuffix = "#?"; // Here the extension is called out in more explicit way, i.e mentioning it obvious
  4824. // patterns like "ext.".
  4825. /** @type {string} */
  4826. var explicitExtLabels = "(?:e?xt(?:ensi(?:o\u0301?|\xF3))?n?|\uFF45?\uFF58\uFF54\uFF4E?|\u0434\u043E\u0431|anexo)"; // One-character symbols that can be used to indicate an extension, and less
  4827. // commonly used or more ambiguous extension labels.
  4828. /** @type {string} */
  4829. var ambiguousExtLabels = "(?:[x\uFF58#\uFF03~\uFF5E]|int|\uFF49\uFF4E\uFF54)"; // When extension is not separated clearly.
  4830. /** @type {string} */
  4831. var ambiguousSeparator = "[- ]+"; // This is the same as possibleSeparatorsBetweenNumberAndExtLabel, but not matching
  4832. // comma as extension label may have it.
  4833. /** @type {string} */
  4834. var possibleSeparatorsNumberExtLabelNoComma = "[ \xA0\\t]*"; // ",," is commonly used for auto dialling the extension when connected. First
  4835. // comma is matched through possibleSeparatorsBetweenNumberAndExtLabel, so we do
  4836. // not repeat it here. Semi-colon works in Iphone and Android also to pop up a
  4837. // button with the extension number following.
  4838. /** @type {string} */
  4839. var autoDiallingAndExtLabelsFound = "(?:,{2}|;)";
  4840. /** @type {string} */
  4841. var rfcExtn = RFC3966_EXTN_PREFIX + getExtensionDigitsPattern(extLimitAfterExplicitLabel);
  4842. /** @type {string} */
  4843. var explicitExtn = possibleSeparatorsBetweenNumberAndExtLabel + explicitExtLabels + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterExplicitLabel) + optionalExtnSuffix;
  4844. /** @type {string} */
  4845. var ambiguousExtn = possibleSeparatorsBetweenNumberAndExtLabel + ambiguousExtLabels + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterAmbiguousChar) + optionalExtnSuffix;
  4846. /** @type {string} */
  4847. var americanStyleExtnWithSuffix = ambiguousSeparator + getExtensionDigitsPattern(extLimitWhenNotSure) + "#";
  4848. /** @type {string} */
  4849. var autoDiallingExtn = possibleSeparatorsNumberExtLabelNoComma + autoDiallingAndExtLabelsFound + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterLikelyLabel) + optionalExtnSuffix;
  4850. /** @type {string} */
  4851. var onlyCommasExtn = possibleSeparatorsNumberExtLabelNoComma + "(?:,)+" + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterAmbiguousChar) + optionalExtnSuffix; // The first regular expression covers RFC 3966 format, where the extension is added
  4852. // using ";ext=". The second more generic where extension is mentioned with explicit
  4853. // labels like "ext:". In both the above cases we allow more numbers in extension than
  4854. // any other extension labels. The third one captures when single character extension
  4855. // labels or less commonly used labels are used. In such cases we capture fewer
  4856. // extension digits in order to reduce the chance of falsely interpreting two
  4857. // numbers beside each other as a number + extension. The fourth one covers the
  4858. // special case of American numbers where the extension is written with a hash
  4859. // at the end, such as "- 503#". The fifth one is exclusively for extension
  4860. // autodialling formats which are used when dialling and in this case we accept longer
  4861. // extensions. The last one is more liberal on the number of commas that acts as
  4862. // extension labels, so we have a strict cap on the number of digits in such extensions.
  4863. return rfcExtn + "|" + explicitExtn + "|" + ambiguousExtn + "|" + americanStyleExtnWithSuffix + "|" + autoDiallingExtn + "|" + onlyCommasExtn;
  4864. }
  4865. // Checks we have at least three leading digits, and only valid punctuation,
  4866. // alpha characters and digits in the phone number. Does not include extension
  4867. // data. The symbol 'x' is allowed here as valid punctuation since it is often
  4868. // used as a placeholder for carrier codes, for example in Brazilian phone
  4869. // numbers. We also allow multiple '+' characters at the start.
  4870. //
  4871. // Corresponds to the following:
  4872. // [digits]{minLengthNsn}|
  4873. // plus_sign*
  4874. // (([punctuation]|[star])*[digits]){3,}([punctuation]|[star]|[digits]|[alpha])*
  4875. //
  4876. // The first reg-ex is to allow short numbers (two digits long) to be parsed if
  4877. // they are entered as "15" etc, but only if there is no punctuation in them.
  4878. // The second expression restricts the number of digits to three or more, but
  4879. // then allows them to be in international form, and to have alpha-characters
  4880. // and punctuation. We split up the two reg-exes here and combine them when
  4881. // creating the reg-ex VALID_PHONE_NUMBER_PATTERN itself so we can prefix it
  4882. // with ^ and append $ to each branch.
  4883. //
  4884. // "Note VALID_PUNCTUATION starts with a -,
  4885. // so must be the first in the range" (c) Google devs.
  4886. // (wtf did they mean by saying that; probably nothing)
  4887. //
  4888. var MIN_LENGTH_PHONE_NUMBER_PATTERN = '[' + VALID_DIGITS + ']{' + MIN_LENGTH_FOR_NSN + '}'; //
  4889. // And this is the second reg-exp:
  4890. // (see MIN_LENGTH_PHONE_NUMBER_PATTERN for a full description of this reg-exp)
  4891. //
  4892. var VALID_PHONE_NUMBER = '[' + PLUS_CHARS + ']{0,1}' + '(?:' + '[' + VALID_PUNCTUATION + ']*' + '[' + VALID_DIGITS + ']' + '){3,}' + '[' + VALID_PUNCTUATION + VALID_DIGITS + ']*'; // This regular expression isn't present in Google's `libphonenumber`
  4893. // and is only used to determine whether the phone number being input
  4894. // is too short for it to even consider it a "valid" number.
  4895. // This is just a way to differentiate between a really invalid phone
  4896. // number like "abcde" and a valid phone number that a user has just
  4897. // started inputting, like "+1" or "1": both these cases would be
  4898. // considered `NOT_A_NUMBER` by Google's `libphonenumber`, but this
  4899. // library can provide a more detailed error message — whether it's
  4900. // really "not a number", or is it just a start of a valid phone number.
  4901. var VALID_PHONE_NUMBER_START_REG_EXP = new RegExp('^' + '[' + PLUS_CHARS + ']{0,1}' + '(?:' + '[' + VALID_PUNCTUATION + ']*' + '[' + VALID_DIGITS + ']' + '){1,2}' + '$', 'i');
  4902. var VALID_PHONE_NUMBER_WITH_EXTENSION = VALID_PHONE_NUMBER + // Phone number extensions
  4903. '(?:' + createExtensionPattern() + ')?'; // The combined regular expression for valid phone numbers:
  4904. //
  4905. var VALID_PHONE_NUMBER_PATTERN = new RegExp( // Either a short two-digit-only phone number
  4906. '^' + MIN_LENGTH_PHONE_NUMBER_PATTERN + '$' + '|' + // Or a longer fully parsed phone number (min 3 characters)
  4907. '^' + VALID_PHONE_NUMBER_WITH_EXTENSION + '$', 'i'); // Checks to see if the string of characters could possibly be a phone number at
  4908. // all. At the moment, checks to see that the string begins with at least 2
  4909. // digits, ignoring any punctuation commonly found in phone numbers. This method
  4910. // does not require the number to be normalized in advance - but does assume
  4911. // that leading non-number symbols have been removed, such as by the method
  4912. // `extract_possible_number`.
  4913. //
  4914. function isViablePhoneNumber(number) {
  4915. return number.length >= MIN_LENGTH_FOR_NSN && VALID_PHONE_NUMBER_PATTERN.test(number);
  4916. } // This is just a way to differentiate between a really invalid phone
  4917. // number like "abcde" and a valid phone number that a user has just
  4918. // started inputting, like "+1" or "1": both these cases would be
  4919. // considered `NOT_A_NUMBER` by Google's `libphonenumber`, but this
  4920. // library can provide a more detailed error message — whether it's
  4921. // really "not a number", or is it just a start of a valid phone number.
  4922. function isViablePhoneNumberStart(number) {
  4923. return VALID_PHONE_NUMBER_START_REG_EXP.test(number);
  4924. }
  4925. // 1 or more valid digits, for use when parsing.
  4926. var EXTN_PATTERN = new RegExp('(?:' + createExtensionPattern() + ')$', 'i'); // Strips any extension (as in, the part of the number dialled after the call is
  4927. // connected, usually indicated with extn, ext, x or similar) from the end of
  4928. // the number, and returns it.
  4929. function extractExtension(number) {
  4930. var start = number.search(EXTN_PATTERN);
  4931. if (start < 0) {
  4932. return {};
  4933. } // If we find a potential extension, and the number preceding this is a viable
  4934. // number, we assume it is an extension.
  4935. var numberWithoutExtension = number.slice(0, start);
  4936. var matches = number.match(EXTN_PATTERN);
  4937. var i = 1;
  4938. while (i < matches.length) {
  4939. if (matches[i]) {
  4940. return {
  4941. number: numberWithoutExtension,
  4942. ext: matches[i]
  4943. };
  4944. }
  4945. i++;
  4946. }
  4947. }
  4948. // These mappings map a character (key) to a specific digit that should
  4949. // replace it for normalization purposes. Non-European digits that
  4950. // may be used in phone numbers are mapped to a European equivalent.
  4951. //
  4952. // E.g. in Iraq they don't write `+442323234` but rather `+٤٤٢٣٢٣٢٣٤`.
  4953. //
  4954. var DIGITS = {
  4955. '0': '0',
  4956. '1': '1',
  4957. '2': '2',
  4958. '3': '3',
  4959. '4': '4',
  4960. '5': '5',
  4961. '6': '6',
  4962. '7': '7',
  4963. '8': '8',
  4964. '9': '9',
  4965. "\uFF10": '0',
  4966. // Fullwidth digit 0
  4967. "\uFF11": '1',
  4968. // Fullwidth digit 1
  4969. "\uFF12": '2',
  4970. // Fullwidth digit 2
  4971. "\uFF13": '3',
  4972. // Fullwidth digit 3
  4973. "\uFF14": '4',
  4974. // Fullwidth digit 4
  4975. "\uFF15": '5',
  4976. // Fullwidth digit 5
  4977. "\uFF16": '6',
  4978. // Fullwidth digit 6
  4979. "\uFF17": '7',
  4980. // Fullwidth digit 7
  4981. "\uFF18": '8',
  4982. // Fullwidth digit 8
  4983. "\uFF19": '9',
  4984. // Fullwidth digit 9
  4985. "\u0660": '0',
  4986. // Arabic-indic digit 0
  4987. "\u0661": '1',
  4988. // Arabic-indic digit 1
  4989. "\u0662": '2',
  4990. // Arabic-indic digit 2
  4991. "\u0663": '3',
  4992. // Arabic-indic digit 3
  4993. "\u0664": '4',
  4994. // Arabic-indic digit 4
  4995. "\u0665": '5',
  4996. // Arabic-indic digit 5
  4997. "\u0666": '6',
  4998. // Arabic-indic digit 6
  4999. "\u0667": '7',
  5000. // Arabic-indic digit 7
  5001. "\u0668": '8',
  5002. // Arabic-indic digit 8
  5003. "\u0669": '9',
  5004. // Arabic-indic digit 9
  5005. "\u06F0": '0',
  5006. // Eastern-Arabic digit 0
  5007. "\u06F1": '1',
  5008. // Eastern-Arabic digit 1
  5009. "\u06F2": '2',
  5010. // Eastern-Arabic digit 2
  5011. "\u06F3": '3',
  5012. // Eastern-Arabic digit 3
  5013. "\u06F4": '4',
  5014. // Eastern-Arabic digit 4
  5015. "\u06F5": '5',
  5016. // Eastern-Arabic digit 5
  5017. "\u06F6": '6',
  5018. // Eastern-Arabic digit 6
  5019. "\u06F7": '7',
  5020. // Eastern-Arabic digit 7
  5021. "\u06F8": '8',
  5022. // Eastern-Arabic digit 8
  5023. "\u06F9": '9' // Eastern-Arabic digit 9
  5024. };
  5025. function parseDigit(character) {
  5026. return DIGITS[character];
  5027. }
  5028. function _createForOfIteratorHelperLoose$5(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$6(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  5029. function _unsupportedIterableToArray$6(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$6(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$6(o, minLen); }
  5030. function _arrayLikeToArray$6(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5031. /**
  5032. * Parses phone number characters from a string.
  5033. * Drops all punctuation leaving only digits and the leading `+` sign (if any).
  5034. * Also converts wide-ascii and arabic-indic numerals to conventional numerals.
  5035. * E.g. in Iraq they don't write `+442323234` but rather `+٤٤٢٣٢٣٢٣٤`.
  5036. * @param {string} string
  5037. * @return {string}
  5038. * @example
  5039. * ```js
  5040. * // Outputs '8800555'.
  5041. * parseIncompletePhoneNumber('8 (800) 555')
  5042. * // Outputs '+7800555'.
  5043. * parseIncompletePhoneNumber('+7 800 555')
  5044. * ```
  5045. */
  5046. function parseIncompletePhoneNumber(string) {
  5047. var result = ''; // Using `.split('')` here instead of normal `for ... of`
  5048. // because the importing application doesn't neccessarily include an ES6 polyfill.
  5049. // The `.split('')` approach discards "exotic" UTF-8 characters
  5050. // (the ones consisting of four bytes) but digits
  5051. // (including non-European ones) don't fall into that range
  5052. // so such "exotic" characters would be discarded anyway.
  5053. for (var _iterator = _createForOfIteratorHelperLoose$5(string.split('')), _step; !(_step = _iterator()).done;) {
  5054. var character = _step.value;
  5055. result += parsePhoneNumberCharacter(character, result) || '';
  5056. }
  5057. return result;
  5058. }
  5059. /**
  5060. * Parses next character while parsing phone number digits (including a `+`)
  5061. * from text: discards everything except `+` and digits, and `+` is only allowed
  5062. * at the start of a phone number.
  5063. * For example, is used in `react-phone-number-input` where it uses
  5064. * [`input-format`](https://gitlab.com/catamphetamine/input-format).
  5065. * @param {string} character - Yet another character from raw input string.
  5066. * @param {string?} prevParsedCharacters - Previous parsed characters.
  5067. * @param {object} meta - Optional custom use-case-specific metadata.
  5068. * @return {string?} The parsed character.
  5069. */
  5070. function parsePhoneNumberCharacter(character, prevParsedCharacters) {
  5071. // Only allow a leading `+`.
  5072. if (character === '+') {
  5073. // If this `+` is not the first parsed character
  5074. // then discard it.
  5075. if (prevParsedCharacters) {
  5076. return;
  5077. }
  5078. return '+';
  5079. } // Allow digits.
  5080. return parseDigit(character);
  5081. }
  5082. function _createForOfIteratorHelperLoose$4(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$5(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  5083. function _unsupportedIterableToArray$5(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$5(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$5(o, minLen); }
  5084. function _arrayLikeToArray$5(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5085. /**
  5086. * Merges two arrays.
  5087. * @param {*} a
  5088. * @param {*} b
  5089. * @return {*}
  5090. */
  5091. function mergeArrays(a, b) {
  5092. var merged = a.slice();
  5093. for (var _iterator = _createForOfIteratorHelperLoose$4(b), _step; !(_step = _iterator()).done;) {
  5094. var element = _step.value;
  5095. if (a.indexOf(element) < 0) {
  5096. merged.push(element);
  5097. }
  5098. }
  5099. return merged.sort(function (a, b) {
  5100. return a - b;
  5101. }); // ES6 version, requires Set polyfill.
  5102. // let merged = new Set(a)
  5103. // for (const element of b) {
  5104. // merged.add(i)
  5105. // }
  5106. // return Array.from(merged).sort((a, b) => a - b)
  5107. }
  5108. function checkNumberLength(nationalNumber, metadata) {
  5109. return checkNumberLengthForType(nationalNumber, undefined, metadata);
  5110. } // Checks whether a number is possible for the country based on its length.
  5111. // Should only be called for the "new" metadata which has "possible lengths".
  5112. function checkNumberLengthForType(nationalNumber, type, metadata) {
  5113. var type_info = metadata.type(type); // There should always be "<possiblePengths/>" set for every type element.
  5114. // This is declared in the XML schema.
  5115. // For size efficiency, where a sub-description (e.g. fixed-line)
  5116. // has the same "<possiblePengths/>" as the "general description", this is missing,
  5117. // so we fall back to the "general description". Where no numbers of the type
  5118. // exist at all, there is one possible length (-1) which is guaranteed
  5119. // not to match the length of any real phone number.
  5120. var possible_lengths = type_info && type_info.possibleLengths() || metadata.possibleLengths(); // let local_lengths = type_info && type.possibleLengthsLocal() || metadata.possibleLengthsLocal()
  5121. // Metadata before version `1.0.18` didn't contain `possible_lengths`.
  5122. if (!possible_lengths) {
  5123. return 'IS_POSSIBLE';
  5124. }
  5125. if (type === 'FIXED_LINE_OR_MOBILE') {
  5126. // No such country in metadata.
  5127. /* istanbul ignore next */
  5128. if (!metadata.type('FIXED_LINE')) {
  5129. // The rare case has been encountered where no fixedLine data is available
  5130. // (true for some non-geographic entities), so we just check mobile.
  5131. return checkNumberLengthForType(nationalNumber, 'MOBILE', metadata);
  5132. }
  5133. var mobile_type = metadata.type('MOBILE');
  5134. if (mobile_type) {
  5135. // Merge the mobile data in if there was any. "Concat" creates a new
  5136. // array, it doesn't edit possible_lengths in place, so we don't need a copy.
  5137. // Note that when adding the possible lengths from mobile, we have
  5138. // to again check they aren't empty since if they are this indicates
  5139. // they are the same as the general desc and should be obtained from there.
  5140. possible_lengths = mergeArrays(possible_lengths, mobile_type.possibleLengths()); // The current list is sorted; we need to merge in the new list and
  5141. // re-sort (duplicates are okay). Sorting isn't so expensive because
  5142. // the lists are very small.
  5143. // if (local_lengths) {
  5144. // local_lengths = mergeArrays(local_lengths, mobile_type.possibleLengthsLocal())
  5145. // } else {
  5146. // local_lengths = mobile_type.possibleLengthsLocal()
  5147. // }
  5148. }
  5149. } // If the type doesn't exist then return 'INVALID_LENGTH'.
  5150. else if (type && !type_info) {
  5151. return 'INVALID_LENGTH';
  5152. }
  5153. var actual_length = nationalNumber.length; // In `libphonenumber-js` all "local-only" formats are dropped for simplicity.
  5154. // // This is safe because there is never an overlap beween the possible lengths
  5155. // // and the local-only lengths; this is checked at build time.
  5156. // if (local_lengths && local_lengths.indexOf(nationalNumber.length) >= 0)
  5157. // {
  5158. // return 'IS_POSSIBLE_LOCAL_ONLY'
  5159. // }
  5160. var minimum_length = possible_lengths[0];
  5161. if (minimum_length === actual_length) {
  5162. return 'IS_POSSIBLE';
  5163. }
  5164. if (minimum_length > actual_length) {
  5165. return 'TOO_SHORT';
  5166. }
  5167. if (possible_lengths[possible_lengths.length - 1] < actual_length) {
  5168. return 'TOO_LONG';
  5169. } // We skip the first element since we've already checked it.
  5170. return possible_lengths.indexOf(actual_length, 1) >= 0 ? 'IS_POSSIBLE' : 'INVALID_LENGTH';
  5171. }
  5172. function isPossiblePhoneNumber(input, options, metadata) {
  5173. /* istanbul ignore if */
  5174. if (options === undefined) {
  5175. options = {};
  5176. }
  5177. metadata = new Metadata(metadata);
  5178. if (options.v2) {
  5179. if (!input.countryCallingCode) {
  5180. throw new Error('Invalid phone number object passed');
  5181. }
  5182. metadata.selectNumberingPlan(input.countryCallingCode);
  5183. } else {
  5184. if (!input.phone) {
  5185. return false;
  5186. }
  5187. if (input.country) {
  5188. if (!metadata.hasCountry(input.country)) {
  5189. throw new Error("Unknown country: ".concat(input.country));
  5190. }
  5191. metadata.country(input.country);
  5192. } else {
  5193. if (!input.countryCallingCode) {
  5194. throw new Error('Invalid phone number object passed');
  5195. }
  5196. metadata.selectNumberingPlan(input.countryCallingCode);
  5197. }
  5198. } // Old metadata (< 1.0.18) had no "possible length" data.
  5199. if (metadata.possibleLengths()) {
  5200. return isPossibleNumber(input.phone || input.nationalNumber, metadata);
  5201. } else {
  5202. // There was a bug between `1.7.35` and `1.7.37` where "possible_lengths"
  5203. // were missing for "non-geographical" numbering plans.
  5204. // Just assume the number is possible in such cases:
  5205. // it's unlikely that anyone generated their custom metadata
  5206. // in that short period of time (one day).
  5207. // This code can be removed in some future major version update.
  5208. if (input.countryCallingCode && metadata.isNonGeographicCallingCode(input.countryCallingCode)) {
  5209. // "Non-geographic entities" did't have `possibleLengths`
  5210. // due to a bug in metadata generation process.
  5211. return true;
  5212. } else {
  5213. throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.');
  5214. }
  5215. }
  5216. }
  5217. function isPossibleNumber(nationalNumber, metadata) {
  5218. //, isInternational) {
  5219. switch (checkNumberLength(nationalNumber, metadata)) {
  5220. case 'IS_POSSIBLE':
  5221. return true;
  5222. // This library ignores "local-only" phone numbers (for simplicity).
  5223. // See the readme for more info on what are "local-only" phone numbers.
  5224. // case 'IS_POSSIBLE_LOCAL_ONLY':
  5225. // return !isInternational
  5226. default:
  5227. return false;
  5228. }
  5229. }
  5230. function _slicedToArray$1(arr, i) { return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$4(arr, i) || _nonIterableRest$1(); }
  5231. function _nonIterableRest$1() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  5232. function _iterableToArrayLimit$1(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  5233. function _arrayWithHoles$1(arr) { if (Array.isArray(arr)) return arr; }
  5234. function _createForOfIteratorHelperLoose$3(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$4(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  5235. function _unsupportedIterableToArray$4(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$4(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$4(o, minLen); }
  5236. function _arrayLikeToArray$4(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5237. /**
  5238. * @param {string} text - Phone URI (RFC 3966).
  5239. * @return {object} `{ ?number, ?ext }`.
  5240. */
  5241. function parseRFC3966(text) {
  5242. var number;
  5243. var ext; // Replace "tel:" with "tel=" for parsing convenience.
  5244. text = text.replace(/^tel:/, 'tel=');
  5245. for (var _iterator = _createForOfIteratorHelperLoose$3(text.split(';')), _step; !(_step = _iterator()).done;) {
  5246. var part = _step.value;
  5247. var _part$split = part.split('='),
  5248. _part$split2 = _slicedToArray$1(_part$split, 2),
  5249. name = _part$split2[0],
  5250. value = _part$split2[1];
  5251. switch (name) {
  5252. case 'tel':
  5253. number = value;
  5254. break;
  5255. case 'ext':
  5256. ext = value;
  5257. break;
  5258. case 'phone-context':
  5259. // Only "country contexts" are supported.
  5260. // "Domain contexts" are ignored.
  5261. if (value[0] === '+') {
  5262. number = value + number;
  5263. }
  5264. break;
  5265. }
  5266. } // If the phone number is not viable, then abort.
  5267. if (!isViablePhoneNumber(number)) {
  5268. return {};
  5269. }
  5270. var result = {
  5271. number: number
  5272. };
  5273. if (ext) {
  5274. result.ext = ext;
  5275. }
  5276. return result;
  5277. }
  5278. /**
  5279. * @param {object} - `{ ?number, ?extension }`.
  5280. * @return {string} Phone URI (RFC 3966).
  5281. */
  5282. function formatRFC3966(_ref) {
  5283. var number = _ref.number,
  5284. ext = _ref.ext;
  5285. if (!number) {
  5286. return '';
  5287. }
  5288. if (number[0] !== '+') {
  5289. throw new Error("\"formatRFC3966()\" expects \"number\" to be in E.164 format.");
  5290. }
  5291. return "tel:".concat(number).concat(ext ? ';ext=' + ext : '');
  5292. }
  5293. /**
  5294. * Checks whether the entire input sequence can be matched
  5295. * against the regular expression.
  5296. * @return {boolean}
  5297. */
  5298. function matchesEntirely(text, regular_expression) {
  5299. // If assigning the `''` default value is moved to the arguments above,
  5300. // code coverage would decrease for some weird reason.
  5301. text = text || '';
  5302. return new RegExp('^(?:' + regular_expression + ')$').test(text);
  5303. }
  5304. function _createForOfIteratorHelperLoose$2(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$3(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  5305. function _unsupportedIterableToArray$3(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); }
  5306. function _arrayLikeToArray$3(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5307. var NON_FIXED_LINE_PHONE_TYPES = ['MOBILE', 'PREMIUM_RATE', 'TOLL_FREE', 'SHARED_COST', 'VOIP', 'PERSONAL_NUMBER', 'PAGER', 'UAN', 'VOICEMAIL']; // Finds out national phone number type (fixed line, mobile, etc)
  5308. function getNumberType(input, options, metadata) {
  5309. // If assigning the `{}` default value is moved to the arguments above,
  5310. // code coverage would decrease for some weird reason.
  5311. options = options || {}; // When `parse()` returned `{}`
  5312. // meaning that the phone number is not a valid one.
  5313. if (!input.country) {
  5314. return;
  5315. }
  5316. metadata = new Metadata(metadata);
  5317. metadata.selectNumberingPlan(input.country, input.countryCallingCode);
  5318. var nationalNumber = options.v2 ? input.nationalNumber : input.phone; // The following is copy-pasted from the original function:
  5319. // https://github.com/googlei18n/libphonenumber/blob/3ea547d4fbaa2d0b67588904dfa5d3f2557c27ff/javascript/i18n/phonenumbers/phonenumberutil.js#L2835
  5320. // Is this national number even valid for this country
  5321. if (!matchesEntirely(nationalNumber, metadata.nationalNumberPattern())) {
  5322. return;
  5323. } // Is it fixed line number
  5324. if (isNumberTypeEqualTo(nationalNumber, 'FIXED_LINE', metadata)) {
  5325. // Because duplicate regular expressions are removed
  5326. // to reduce metadata size, if "mobile" pattern is ""
  5327. // then it means it was removed due to being a duplicate of the fixed-line pattern.
  5328. //
  5329. if (metadata.type('MOBILE') && metadata.type('MOBILE').pattern() === '') {
  5330. return 'FIXED_LINE_OR_MOBILE';
  5331. } // `MOBILE` type pattern isn't included if it matched `FIXED_LINE` one.
  5332. // For example, for "US" country.
  5333. // Old metadata (< `1.0.18`) had a specific "types" data structure
  5334. // that happened to be `undefined` for `MOBILE` in that case.
  5335. // Newer metadata (>= `1.0.18`) has another data structure that is
  5336. // not `undefined` for `MOBILE` in that case (it's just an empty array).
  5337. // So this `if` is just for backwards compatibility with old metadata.
  5338. if (!metadata.type('MOBILE')) {
  5339. return 'FIXED_LINE_OR_MOBILE';
  5340. } // Check if the number happens to qualify as both fixed line and mobile.
  5341. // (no such country in the minimal metadata set)
  5342. /* istanbul ignore if */
  5343. if (isNumberTypeEqualTo(nationalNumber, 'MOBILE', metadata)) {
  5344. return 'FIXED_LINE_OR_MOBILE';
  5345. }
  5346. return 'FIXED_LINE';
  5347. }
  5348. for (var _iterator = _createForOfIteratorHelperLoose$2(NON_FIXED_LINE_PHONE_TYPES), _step; !(_step = _iterator()).done;) {
  5349. var type = _step.value;
  5350. if (isNumberTypeEqualTo(nationalNumber, type, metadata)) {
  5351. return type;
  5352. }
  5353. }
  5354. }
  5355. function isNumberTypeEqualTo(nationalNumber, type, metadata) {
  5356. type = metadata.type(type);
  5357. if (!type || !type.pattern()) {
  5358. return false;
  5359. } // Check if any possible number lengths are present;
  5360. // if so, we use them to avoid checking
  5361. // the validation pattern if they don't match.
  5362. // If they are absent, this means they match
  5363. // the general description, which we have
  5364. // already checked before a specific number type.
  5365. if (type.possibleLengths() && type.possibleLengths().indexOf(nationalNumber.length) < 0) {
  5366. return false;
  5367. }
  5368. return matchesEntirely(nationalNumber, type.pattern());
  5369. }
  5370. /**
  5371. * Checks if a given phone number is valid.
  5372. *
  5373. * If the `number` is a string, it will be parsed to an object,
  5374. * but only if it contains only valid phone number characters (including punctuation).
  5375. * If the `number` is an object, it is used as is.
  5376. *
  5377. * The optional `defaultCountry` argument is the default country.
  5378. * I.e. it does not restrict to just that country,
  5379. * e.g. in those cases where several countries share
  5380. * the same phone numbering rules (NANPA, Britain, etc).
  5381. * For example, even though the number `07624 369230`
  5382. * belongs to the Isle of Man ("IM" country code)
  5383. * calling `isValidNumber('07624369230', 'GB', metadata)`
  5384. * still returns `true` because the country is not restricted to `GB`,
  5385. * it's just that `GB` is the default one for the phone numbering rules.
  5386. * For restricting the country see `isValidNumberForRegion()`
  5387. * though restricting a country might not be a good idea.
  5388. * https://github.com/googlei18n/libphonenumber/blob/master/FAQ.md#when-should-i-use-isvalidnumberforregion
  5389. *
  5390. * Examples:
  5391. *
  5392. * ```js
  5393. * isValidNumber('+78005553535', metadata)
  5394. * isValidNumber('8005553535', 'RU', metadata)
  5395. * isValidNumber('88005553535', 'RU', metadata)
  5396. * isValidNumber({ phone: '8005553535', country: 'RU' }, metadata)
  5397. * ```
  5398. */
  5399. function isValidNumber(input, options, metadata) {
  5400. // If assigning the `{}` default value is moved to the arguments above,
  5401. // code coverage would decrease for some weird reason.
  5402. options = options || {};
  5403. metadata = new Metadata(metadata); // This is just to support `isValidNumber({})`
  5404. // for cases when `parseNumber()` returns `{}`.
  5405. if (!input.country) {
  5406. return false;
  5407. }
  5408. metadata.selectNumberingPlan(input.country, input.countryCallingCode); // By default, countries only have type regexps when it's required for
  5409. // distinguishing different countries having the same `countryCallingCode`.
  5410. if (metadata.hasTypes()) {
  5411. return getNumberType(input, options, metadata.metadata) !== undefined;
  5412. } // If there are no type regexps for this country in metadata then use
  5413. // `nationalNumberPattern` as a "better than nothing" replacement.
  5414. var national_number = options.v2 ? input.nationalNumber : input.phone;
  5415. return matchesEntirely(national_number, metadata.nationalNumberPattern());
  5416. }
  5417. //
  5418. // E.g. "(999) 111-22-33" -> "999 111 22 33"
  5419. //
  5420. // For some reason Google's metadata contains `<intlFormat/>`s with brackets and dashes.
  5421. // Meanwhile, there's no single opinion about using punctuation in international phone numbers.
  5422. //
  5423. // For example, Google's `<intlFormat/>` for USA is `+1 213-373-4253`.
  5424. // And here's a quote from WikiPedia's "North American Numbering Plan" page:
  5425. // https://en.wikipedia.org/wiki/North_American_Numbering_Plan
  5426. //
  5427. // "The country calling code for all countries participating in the NANP is 1.
  5428. // In international format, an NANP number should be listed as +1 301 555 01 00,
  5429. // where 301 is an area code (Maryland)."
  5430. //
  5431. // I personally prefer the international format without any punctuation.
  5432. // For example, brackets are remnants of the old age, meaning that the
  5433. // phone number part in brackets (so called "area code") can be omitted
  5434. // if dialing within the same "area".
  5435. // And hyphens were clearly introduced for splitting local numbers into memorizable groups.
  5436. // For example, remembering "5553535" is difficult but "555-35-35" is much simpler.
  5437. // Imagine a man taking a bus from home to work and seeing an ad with a phone number.
  5438. // He has a couple of seconds to memorize that number until it passes by.
  5439. // If it were spaces instead of hyphens the man wouldn't necessarily get it,
  5440. // but with hyphens instead of spaces the grouping is more explicit.
  5441. // I personally think that hyphens introduce visual clutter,
  5442. // so I prefer replacing them with spaces in international numbers.
  5443. // In the modern age all output is done on displays where spaces are clearly distinguishable
  5444. // so hyphens can be safely replaced with spaces without losing any legibility.
  5445. //
  5446. function applyInternationalSeparatorStyle(formattedNumber) {
  5447. return formattedNumber.replace(new RegExp("[".concat(VALID_PUNCTUATION, "]+"), 'g'), ' ').trim();
  5448. }
  5449. // first group is not used in the national pattern (e.g. Argentina) so the $1
  5450. // group does not match correctly. Therefore, we use `\d`, so that the first
  5451. // group actually used in the pattern will be matched.
  5452. var FIRST_GROUP_PATTERN = /(\$\d)/;
  5453. function formatNationalNumberUsingFormat(number, format, _ref) {
  5454. var useInternationalFormat = _ref.useInternationalFormat,
  5455. withNationalPrefix = _ref.withNationalPrefix;
  5456. _ref.carrierCode;
  5457. _ref.metadata;
  5458. var formattedNumber = number.replace(new RegExp(format.pattern()), useInternationalFormat ? format.internationalFormat() : // This library doesn't use `domestic_carrier_code_formatting_rule`,
  5459. // because that one is only used when formatting phone numbers
  5460. // for dialing from a mobile phone, and this is not a dialing library.
  5461. // carrierCode && format.domesticCarrierCodeFormattingRule()
  5462. // // First, replace the $CC in the formatting rule with the desired carrier code.
  5463. // // Then, replace the $FG in the formatting rule with the first group
  5464. // // and the carrier code combined in the appropriate way.
  5465. // ? format.format().replace(FIRST_GROUP_PATTERN, format.domesticCarrierCodeFormattingRule().replace('$CC', carrierCode))
  5466. // : (
  5467. // withNationalPrefix && format.nationalPrefixFormattingRule()
  5468. // ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule())
  5469. // : format.format()
  5470. // )
  5471. withNationalPrefix && format.nationalPrefixFormattingRule() ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule()) : format.format());
  5472. if (useInternationalFormat) {
  5473. return applyInternationalSeparatorStyle(formattedNumber);
  5474. }
  5475. return formattedNumber;
  5476. }
  5477. /**
  5478. * Pattern that makes it easy to distinguish whether a region has a single
  5479. * international dialing prefix or not. If a region has a single international
  5480. * prefix (e.g. 011 in USA), it will be represented as a string that contains
  5481. * a sequence of ASCII digits, and possibly a tilde, which signals waiting for
  5482. * the tone. If there are multiple available international prefixes in a
  5483. * region, they will be represented as a regex string that always contains one
  5484. * or more characters that are not ASCII digits or a tilde.
  5485. */
  5486. var SINGLE_IDD_PREFIX_REG_EXP = /^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/; // For regions that have multiple IDD prefixes
  5487. // a preferred IDD prefix is returned.
  5488. function getIddPrefix(country, callingCode, metadata) {
  5489. var countryMetadata = new Metadata(metadata);
  5490. countryMetadata.selectNumberingPlan(country, callingCode);
  5491. if (countryMetadata.defaultIDDPrefix()) {
  5492. return countryMetadata.defaultIDDPrefix();
  5493. }
  5494. if (SINGLE_IDD_PREFIX_REG_EXP.test(countryMetadata.IDDPrefix())) {
  5495. return countryMetadata.IDDPrefix();
  5496. }
  5497. }
  5498. function _createForOfIteratorHelperLoose$1(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$2(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  5499. function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$2(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen); }
  5500. function _arrayLikeToArray$2(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5501. function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  5502. function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty$4(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  5503. function _defineProperty$4(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  5504. var DEFAULT_OPTIONS = {
  5505. formatExtension: function formatExtension(formattedNumber, extension, metadata) {
  5506. return "".concat(formattedNumber).concat(metadata.ext()).concat(extension);
  5507. }
  5508. }; // Formats a phone number
  5509. //
  5510. // Example use cases:
  5511. //
  5512. // ```js
  5513. // formatNumber('8005553535', 'RU', 'INTERNATIONAL')
  5514. // formatNumber('8005553535', 'RU', 'INTERNATIONAL', metadata)
  5515. // formatNumber({ phone: '8005553535', country: 'RU' }, 'INTERNATIONAL')
  5516. // formatNumber({ phone: '8005553535', country: 'RU' }, 'INTERNATIONAL', metadata)
  5517. // formatNumber('+78005553535', 'NATIONAL')
  5518. // formatNumber('+78005553535', 'NATIONAL', metadata)
  5519. // ```
  5520. //
  5521. function formatNumber(input, format, options, metadata) {
  5522. // Apply default options.
  5523. if (options) {
  5524. options = _objectSpread$4(_objectSpread$4({}, DEFAULT_OPTIONS), options);
  5525. } else {
  5526. options = DEFAULT_OPTIONS;
  5527. }
  5528. metadata = new Metadata(metadata);
  5529. if (input.country && input.country !== '001') {
  5530. // Validate `input.country`.
  5531. if (!metadata.hasCountry(input.country)) {
  5532. throw new Error("Unknown country: ".concat(input.country));
  5533. }
  5534. metadata.country(input.country);
  5535. } else if (input.countryCallingCode) {
  5536. metadata.selectNumberingPlan(input.countryCallingCode);
  5537. } else return input.phone || '';
  5538. var countryCallingCode = metadata.countryCallingCode();
  5539. var nationalNumber = options.v2 ? input.nationalNumber : input.phone; // This variable should have been declared inside `case`s
  5540. // but Babel has a bug and it says "duplicate variable declaration".
  5541. var number;
  5542. switch (format) {
  5543. case 'NATIONAL':
  5544. // Legacy argument support.
  5545. // (`{ country: ..., phone: '' }`)
  5546. if (!nationalNumber) {
  5547. return '';
  5548. }
  5549. number = formatNationalNumber(nationalNumber, input.carrierCode, 'NATIONAL', metadata, options);
  5550. return addExtension(number, input.ext, metadata, options.formatExtension);
  5551. case 'INTERNATIONAL':
  5552. // Legacy argument support.
  5553. // (`{ country: ..., phone: '' }`)
  5554. if (!nationalNumber) {
  5555. return "+".concat(countryCallingCode);
  5556. }
  5557. number = formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata, options);
  5558. number = "+".concat(countryCallingCode, " ").concat(number);
  5559. return addExtension(number, input.ext, metadata, options.formatExtension);
  5560. case 'E.164':
  5561. // `E.164` doesn't define "phone number extensions".
  5562. return "+".concat(countryCallingCode).concat(nationalNumber);
  5563. case 'RFC3966':
  5564. return formatRFC3966({
  5565. number: "+".concat(countryCallingCode).concat(nationalNumber),
  5566. ext: input.ext
  5567. });
  5568. // For reference, here's Google's IDD formatter:
  5569. // https://github.com/google/libphonenumber/blob/32719cf74e68796788d1ca45abc85dcdc63ba5b9/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L1546
  5570. // Not saying that this IDD formatter replicates it 1:1, but it seems to work.
  5571. // Who would even need to format phone numbers in IDD format anyway?
  5572. case 'IDD':
  5573. if (!options.fromCountry) {
  5574. return; // throw new Error('`fromCountry` option not passed for IDD-prefixed formatting.')
  5575. }
  5576. var formattedNumber = formatIDD(nationalNumber, input.carrierCode, countryCallingCode, options.fromCountry, metadata);
  5577. return addExtension(formattedNumber, input.ext, metadata, options.formatExtension);
  5578. default:
  5579. throw new Error("Unknown \"format\" argument passed to \"formatNumber()\": \"".concat(format, "\""));
  5580. }
  5581. }
  5582. function formatNationalNumber(number, carrierCode, formatAs, metadata, options) {
  5583. var format = chooseFormatForNumber(metadata.formats(), number);
  5584. if (!format) {
  5585. return number;
  5586. }
  5587. return formatNationalNumberUsingFormat(number, format, {
  5588. useInternationalFormat: formatAs === 'INTERNATIONAL',
  5589. withNationalPrefix: format.nationalPrefixIsOptionalWhenFormattingInNationalFormat() && options && options.nationalPrefix === false ? false : true,
  5590. carrierCode: carrierCode,
  5591. metadata: metadata
  5592. });
  5593. }
  5594. function chooseFormatForNumber(availableFormats, nationalNnumber) {
  5595. for (var _iterator = _createForOfIteratorHelperLoose$1(availableFormats), _step; !(_step = _iterator()).done;) {
  5596. var format = _step.value;
  5597. // Validate leading digits.
  5598. // The test case for "else path" could be found by searching for
  5599. // "format.leadingDigitsPatterns().length === 0".
  5600. if (format.leadingDigitsPatterns().length > 0) {
  5601. // The last leading_digits_pattern is used here, as it is the most detailed
  5602. var lastLeadingDigitsPattern = format.leadingDigitsPatterns()[format.leadingDigitsPatterns().length - 1]; // If leading digits don't match then move on to the next phone number format
  5603. if (nationalNnumber.search(lastLeadingDigitsPattern) !== 0) {
  5604. continue;
  5605. }
  5606. } // Check that the national number matches the phone number format regular expression
  5607. if (matchesEntirely(nationalNnumber, format.pattern())) {
  5608. return format;
  5609. }
  5610. }
  5611. }
  5612. function addExtension(formattedNumber, ext, metadata, formatExtension) {
  5613. return ext ? formatExtension(formattedNumber, ext, metadata) : formattedNumber;
  5614. }
  5615. function formatIDD(nationalNumber, carrierCode, countryCallingCode, fromCountry, metadata) {
  5616. var fromCountryCallingCode = getCountryCallingCode(fromCountry, metadata.metadata); // When calling within the same country calling code.
  5617. if (fromCountryCallingCode === countryCallingCode) {
  5618. var formattedNumber = formatNationalNumber(nationalNumber, carrierCode, 'NATIONAL', metadata); // For NANPA regions, return the national format for these regions
  5619. // but prefix it with the country calling code.
  5620. if (countryCallingCode === '1') {
  5621. return countryCallingCode + ' ' + formattedNumber;
  5622. } // If regions share a country calling code, the country calling code need
  5623. // not be dialled. This also applies when dialling within a region, so this
  5624. // if clause covers both these cases. Technically this is the case for
  5625. // dialling from La Reunion to other overseas departments of France (French
  5626. // Guiana, Martinique, Guadeloupe), but not vice versa - so we don't cover
  5627. // this edge case for now and for those cases return the version including
  5628. // country calling code. Details here:
  5629. // http://www.petitfute.com/voyage/225-info-pratiques-reunion
  5630. //
  5631. return formattedNumber;
  5632. }
  5633. var iddPrefix = getIddPrefix(fromCountry, undefined, metadata.metadata);
  5634. if (iddPrefix) {
  5635. return "".concat(iddPrefix, " ").concat(countryCallingCode, " ").concat(formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata));
  5636. }
  5637. }
  5638. function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  5639. function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty$3(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  5640. function _defineProperty$3(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  5641. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5642. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5643. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  5644. var PhoneNumber = /*#__PURE__*/function () {
  5645. function PhoneNumber(countryCallingCode, nationalNumber, metadata) {
  5646. _classCallCheck(this, PhoneNumber);
  5647. if (!countryCallingCode) {
  5648. throw new TypeError('`country` or `countryCallingCode` not passed');
  5649. }
  5650. if (!nationalNumber) {
  5651. throw new TypeError('`nationalNumber` not passed');
  5652. }
  5653. if (!metadata) {
  5654. throw new TypeError('`metadata` not passed');
  5655. }
  5656. var _metadata = new Metadata(metadata); // If country code is passed then derive `countryCallingCode` from it.
  5657. // Also store the country code as `.country`.
  5658. if (isCountryCode(countryCallingCode)) {
  5659. this.country = countryCallingCode;
  5660. _metadata.country(countryCallingCode);
  5661. countryCallingCode = _metadata.countryCallingCode();
  5662. }
  5663. this.countryCallingCode = countryCallingCode;
  5664. this.nationalNumber = nationalNumber;
  5665. this.number = '+' + this.countryCallingCode + this.nationalNumber;
  5666. this.metadata = metadata;
  5667. }
  5668. _createClass(PhoneNumber, [{
  5669. key: "setExt",
  5670. value: function setExt(ext) {
  5671. this.ext = ext;
  5672. }
  5673. }, {
  5674. key: "isPossible",
  5675. value: function isPossible() {
  5676. return isPossiblePhoneNumber(this, {
  5677. v2: true
  5678. }, this.metadata);
  5679. }
  5680. }, {
  5681. key: "isValid",
  5682. value: function isValid() {
  5683. return isValidNumber(this, {
  5684. v2: true
  5685. }, this.metadata);
  5686. }
  5687. }, {
  5688. key: "isNonGeographic",
  5689. value: function isNonGeographic() {
  5690. var metadata = new Metadata(this.metadata);
  5691. return metadata.isNonGeographicCallingCode(this.countryCallingCode);
  5692. }
  5693. }, {
  5694. key: "isEqual",
  5695. value: function isEqual(phoneNumber) {
  5696. return this.number === phoneNumber.number && this.ext === phoneNumber.ext;
  5697. } // // Is just an alias for `this.isValid() && this.country === country`.
  5698. // // https://github.com/googlei18n/libphonenumber/blob/master/FAQ.md#when-should-i-use-isvalidnumberforregion
  5699. // isValidForRegion(country) {
  5700. // return isValidNumberForRegion(this, country, { v2: true }, this.metadata)
  5701. // }
  5702. }, {
  5703. key: "getType",
  5704. value: function getType() {
  5705. return getNumberType(this, {
  5706. v2: true
  5707. }, this.metadata);
  5708. }
  5709. }, {
  5710. key: "format",
  5711. value: function format(_format, options) {
  5712. return formatNumber(this, _format, options ? _objectSpread$3(_objectSpread$3({}, options), {}, {
  5713. v2: true
  5714. }) : {
  5715. v2: true
  5716. }, this.metadata);
  5717. }
  5718. }, {
  5719. key: "formatNational",
  5720. value: function formatNational(options) {
  5721. return this.format('NATIONAL', options);
  5722. }
  5723. }, {
  5724. key: "formatInternational",
  5725. value: function formatInternational(options) {
  5726. return this.format('INTERNATIONAL', options);
  5727. }
  5728. }, {
  5729. key: "getURI",
  5730. value: function getURI(options) {
  5731. return this.format('RFC3966', options);
  5732. }
  5733. }]);
  5734. return PhoneNumber;
  5735. }();
  5736. var isCountryCode = function isCountryCode(value) {
  5737. return /^[A-Z]{2}$/.test(value);
  5738. };
  5739. var CAPTURING_DIGIT_PATTERN = new RegExp('([' + VALID_DIGITS + '])');
  5740. function stripIddPrefix(number, country, callingCode, metadata) {
  5741. if (!country) {
  5742. return;
  5743. } // Check if the number is IDD-prefixed.
  5744. var countryMetadata = new Metadata(metadata);
  5745. countryMetadata.selectNumberingPlan(country, callingCode);
  5746. var IDDPrefixPattern = new RegExp(countryMetadata.IDDPrefix());
  5747. if (number.search(IDDPrefixPattern) !== 0) {
  5748. return;
  5749. } // Strip IDD prefix.
  5750. number = number.slice(number.match(IDDPrefixPattern)[0].length); // If there're any digits after an IDD prefix,
  5751. // then those digits are a country calling code.
  5752. // Since no country code starts with a `0`,
  5753. // the code below validates that the next digit (if present) is not `0`.
  5754. var matchedGroups = number.match(CAPTURING_DIGIT_PATTERN);
  5755. if (matchedGroups && matchedGroups[1] != null && matchedGroups[1].length > 0) {
  5756. if (matchedGroups[1] === '0') {
  5757. return;
  5758. }
  5759. }
  5760. return number;
  5761. }
  5762. /**
  5763. * Strips any national prefix (such as 0, 1) present in a
  5764. * (possibly incomplete) number provided.
  5765. * "Carrier codes" are only used in Colombia and Brazil,
  5766. * and only when dialing within those countries from a mobile phone to a fixed line number.
  5767. * Sometimes it won't actually strip national prefix
  5768. * and will instead prepend some digits to the `number`:
  5769. * for example, when number `2345678` is passed with `VI` country selected,
  5770. * it will return `{ number: "3402345678" }`, because `340` area code is prepended.
  5771. * @param {string} number — National number digits.
  5772. * @param {object} metadata — Metadata with country selected.
  5773. * @return {object} `{ nationalNumber: string, nationalPrefix: string? carrierCode: string? }`. Even if a national prefix was extracted, it's not necessarily present in the returned object, so don't rely on its presence in the returned object in order to find out whether a national prefix has been extracted or not.
  5774. */
  5775. function extractNationalNumberFromPossiblyIncompleteNumber(number, metadata) {
  5776. if (number && metadata.numberingPlan.nationalPrefixForParsing()) {
  5777. // See METADATA.md for the description of
  5778. // `national_prefix_for_parsing` and `national_prefix_transform_rule`.
  5779. // Attempt to parse the first digits as a national prefix.
  5780. var prefixPattern = new RegExp('^(?:' + metadata.numberingPlan.nationalPrefixForParsing() + ')');
  5781. var prefixMatch = prefixPattern.exec(number);
  5782. if (prefixMatch) {
  5783. var nationalNumber;
  5784. var carrierCode; // https://gitlab.com/catamphetamine/libphonenumber-js/-/blob/master/METADATA.md#national_prefix_for_parsing--national_prefix_transform_rule
  5785. // If a `national_prefix_for_parsing` has any "capturing groups"
  5786. // then it means that the national (significant) number is equal to
  5787. // those "capturing groups" transformed via `national_prefix_transform_rule`,
  5788. // and nothing could be said about the actual national prefix:
  5789. // what is it and was it even there.
  5790. // If a `national_prefix_for_parsing` doesn't have any "capturing groups",
  5791. // then everything it matches is a national prefix.
  5792. // To determine whether `national_prefix_for_parsing` matched any
  5793. // "capturing groups", the value of the result of calling `.exec()`
  5794. // is looked at, and if it has non-undefined values where there're
  5795. // "capturing groups" in the regular expression, then it means
  5796. // that "capturing groups" have been matched.
  5797. // It's not possible to tell whether there'll be any "capturing gropus"
  5798. // before the matching process, because a `national_prefix_for_parsing`
  5799. // could exhibit both behaviors.
  5800. var capturedGroupsCount = prefixMatch.length - 1;
  5801. var hasCapturedGroups = capturedGroupsCount > 0 && prefixMatch[capturedGroupsCount];
  5802. if (metadata.nationalPrefixTransformRule() && hasCapturedGroups) {
  5803. nationalNumber = number.replace(prefixPattern, metadata.nationalPrefixTransformRule()); // If there's more than one captured group,
  5804. // then carrier code is the second one.
  5805. if (capturedGroupsCount > 1) {
  5806. carrierCode = prefixMatch[1];
  5807. }
  5808. } // If there're no "capturing groups",
  5809. // or if there're "capturing groups" but no
  5810. // `national_prefix_transform_rule`,
  5811. // then just strip the national prefix from the number,
  5812. // and possibly a carrier code.
  5813. // Seems like there could be more.
  5814. else {
  5815. // `prefixBeforeNationalNumber` is the whole substring matched by
  5816. // the `national_prefix_for_parsing` regular expression.
  5817. // There seem to be no guarantees that it's just a national prefix.
  5818. // For example, if there's a carrier code, it's gonna be a
  5819. // part of `prefixBeforeNationalNumber` too.
  5820. var prefixBeforeNationalNumber = prefixMatch[0];
  5821. nationalNumber = number.slice(prefixBeforeNationalNumber.length); // If there's at least one captured group,
  5822. // then carrier code is the first one.
  5823. if (hasCapturedGroups) {
  5824. carrierCode = prefixMatch[1];
  5825. }
  5826. } // Tries to guess whether a national prefix was present in the input.
  5827. // This is not something copy-pasted from Google's library:
  5828. // they don't seem to have an equivalent for that.
  5829. // So this isn't an "officially approved" way of doing something like that.
  5830. // But since there seems no other existing method, this library uses it.
  5831. var nationalPrefix;
  5832. if (hasCapturedGroups) {
  5833. var possiblePositionOfTheFirstCapturedGroup = number.indexOf(prefixMatch[1]);
  5834. var possibleNationalPrefix = number.slice(0, possiblePositionOfTheFirstCapturedGroup); // Example: an Argentinian (AR) phone number `0111523456789`.
  5835. // `prefixMatch[0]` is `01115`, and `$1` is `11`,
  5836. // and the rest of the phone number is `23456789`.
  5837. // The national number is transformed via `9$1` to `91123456789`.
  5838. // National prefix `0` is detected being present at the start.
  5839. // if (possibleNationalPrefix.indexOf(metadata.numberingPlan.nationalPrefix()) === 0) {
  5840. if (possibleNationalPrefix === metadata.numberingPlan.nationalPrefix()) {
  5841. nationalPrefix = metadata.numberingPlan.nationalPrefix();
  5842. }
  5843. } else {
  5844. nationalPrefix = prefixMatch[0];
  5845. }
  5846. return {
  5847. nationalNumber: nationalNumber,
  5848. nationalPrefix: nationalPrefix,
  5849. carrierCode: carrierCode
  5850. };
  5851. }
  5852. }
  5853. return {
  5854. nationalNumber: number
  5855. };
  5856. }
  5857. /**
  5858. * Strips national prefix and carrier code from a complete phone number.
  5859. * The difference from the non-"FromCompleteNumber" function is that
  5860. * it won't extract national prefix if the resultant number is too short
  5861. * to be a complete number for the selected phone numbering plan.
  5862. * @param {string} number — Complete phone number digits.
  5863. * @param {Metadata} metadata — Metadata with a phone numbering plan selected.
  5864. * @return {object} `{ nationalNumber: string, carrierCode: string? }`.
  5865. */
  5866. function extractNationalNumber(number, metadata) {
  5867. // Parsing national prefixes and carrier codes
  5868. // is only required for local phone numbers
  5869. // but some people don't understand that
  5870. // and sometimes write international phone numbers
  5871. // with national prefixes (or maybe even carrier codes).
  5872. // http://ucken.blogspot.ru/2016/03/trunk-prefixes-in-skype4b.html
  5873. // Google's original library forgives such mistakes
  5874. // and so does this library, because it has been requested:
  5875. // https://github.com/catamphetamine/libphonenumber-js/issues/127
  5876. var _extractNationalNumbe = extractNationalNumberFromPossiblyIncompleteNumber(number, metadata),
  5877. carrierCode = _extractNationalNumbe.carrierCode,
  5878. nationalNumber = _extractNationalNumbe.nationalNumber;
  5879. if (nationalNumber !== number) {
  5880. if (!shouldHaveExtractedNationalPrefix(number, nationalNumber, metadata)) {
  5881. // Don't strip the national prefix.
  5882. return {
  5883. nationalNumber: number
  5884. };
  5885. } // Check the national (significant) number length after extracting national prefix and carrier code.
  5886. // Legacy generated metadata (before `1.0.18`) didn't support the "possible lengths" feature.
  5887. if (metadata.possibleLengths()) {
  5888. // The number remaining after stripping the national prefix and carrier code
  5889. // should be long enough to have a possible length for the country.
  5890. // Otherwise, don't strip the national prefix and carrier code,
  5891. // since the original number could be a valid number.
  5892. // This check has been copy-pasted "as is" from Google's original library:
  5893. // https://github.com/google/libphonenumber/blob/876268eb1ad6cdc1b7b5bef17fc5e43052702d57/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L3236-L3250
  5894. // It doesn't check for the "possibility" of the original `number`.
  5895. // I guess it's fine not checking that one. It works as is anyway.
  5896. if (!isPossibleIncompleteNationalNumber(nationalNumber, metadata)) {
  5897. // Don't strip the national prefix.
  5898. return {
  5899. nationalNumber: number
  5900. };
  5901. }
  5902. }
  5903. }
  5904. return {
  5905. nationalNumber: nationalNumber,
  5906. carrierCode: carrierCode
  5907. };
  5908. } // In some countries, the same digit could be a national prefix
  5909. // or a leading digit of a valid phone number.
  5910. // For example, in Russia, national prefix is `8`,
  5911. // and also `800 555 35 35` is a valid number
  5912. // in which `8` is not a national prefix, but the first digit
  5913. // of a national (significant) number.
  5914. // Same's with Belarus:
  5915. // `82004910060` is a valid national (significant) number,
  5916. // but `2004910060` is not.
  5917. // To support such cases (to prevent the code from always stripping
  5918. // national prefix), a condition is imposed: a national prefix
  5919. // is not extracted when the original number is "viable" and the
  5920. // resultant number is not, a "viable" national number being the one
  5921. // that matches `national_number_pattern`.
  5922. function shouldHaveExtractedNationalPrefix(nationalNumberBefore, nationalNumberAfter, metadata) {
  5923. // The equivalent in Google's code is:
  5924. // https://github.com/google/libphonenumber/blob/e326fa1fc4283bb05eb35cb3c15c18f98a31af33/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L2969-L3004
  5925. if (matchesEntirely(nationalNumberBefore, metadata.nationalNumberPattern()) && !matchesEntirely(nationalNumberAfter, metadata.nationalNumberPattern())) {
  5926. return false;
  5927. } // This "is possible" national number (length) check has been commented out
  5928. // because it's superceded by the (effectively) same check done in the
  5929. // `extractNationalNumber()` function after it calls `shouldHaveExtractedNationalPrefix()`.
  5930. // In other words, why run the same check twice if it could only be run once.
  5931. // // Check the national (significant) number length after extracting national prefix and carrier code.
  5932. // // Fixes a minor "weird behavior" bug: https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/57
  5933. // // (Legacy generated metadata (before `1.0.18`) didn't support the "possible lengths" feature).
  5934. // if (metadata.possibleLengths()) {
  5935. // if (isPossibleIncompleteNationalNumber(nationalNumberBefore, metadata) &&
  5936. // !isPossibleIncompleteNationalNumber(nationalNumberAfter, metadata)) {
  5937. // return false
  5938. // }
  5939. // }
  5940. return true;
  5941. }
  5942. function isPossibleIncompleteNationalNumber(nationalNumber, metadata) {
  5943. switch (checkNumberLength(nationalNumber, metadata)) {
  5944. case 'TOO_SHORT':
  5945. case 'INVALID_LENGTH':
  5946. // This library ignores "local-only" phone numbers (for simplicity).
  5947. // See the readme for more info on what are "local-only" phone numbers.
  5948. // case 'IS_POSSIBLE_LOCAL_ONLY':
  5949. return false;
  5950. default:
  5951. return true;
  5952. }
  5953. }
  5954. /**
  5955. * Sometimes some people incorrectly input international phone numbers
  5956. * without the leading `+`. This function corrects such input.
  5957. * @param {string} number — Phone number digits.
  5958. * @param {string?} country
  5959. * @param {string?} callingCode
  5960. * @param {object} metadata
  5961. * @return {object} `{ countryCallingCode: string?, number: string }`.
  5962. */
  5963. function extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(number, country, callingCode, metadata) {
  5964. var countryCallingCode = country ? getCountryCallingCode(country, metadata) : callingCode;
  5965. if (number.indexOf(countryCallingCode) === 0) {
  5966. metadata = new Metadata(metadata);
  5967. metadata.selectNumberingPlan(country, callingCode);
  5968. var possibleShorterNumber = number.slice(countryCallingCode.length);
  5969. var _extractNationalNumbe = extractNationalNumber(possibleShorterNumber, metadata),
  5970. possibleShorterNationalNumber = _extractNationalNumbe.nationalNumber;
  5971. var _extractNationalNumbe2 = extractNationalNumber(number, metadata),
  5972. nationalNumber = _extractNationalNumbe2.nationalNumber; // If the number was not valid before but is valid now,
  5973. // or if it was too long before, we consider the number
  5974. // with the country calling code stripped to be a better result
  5975. // and keep that instead.
  5976. // For example, in Germany (+49), `49` is a valid area code,
  5977. // so if a number starts with `49`, it could be both a valid
  5978. // national German number or an international number without
  5979. // a leading `+`.
  5980. if (!matchesEntirely(nationalNumber, metadata.nationalNumberPattern()) && matchesEntirely(possibleShorterNationalNumber, metadata.nationalNumberPattern()) || checkNumberLength(nationalNumber, metadata) === 'TOO_LONG') {
  5981. return {
  5982. countryCallingCode: countryCallingCode,
  5983. number: possibleShorterNumber
  5984. };
  5985. }
  5986. }
  5987. return {
  5988. number: number
  5989. };
  5990. }
  5991. /**
  5992. * Converts a phone number digits (possibly with a `+`)
  5993. * into a calling code and the rest phone number digits.
  5994. * The "rest phone number digits" could include
  5995. * a national prefix, carrier code, and national
  5996. * (significant) number.
  5997. * @param {string} number — Phone number digits (possibly with a `+`).
  5998. * @param {string} [country] — Default country.
  5999. * @param {string} [callingCode] — Default calling code (some phone numbering plans are non-geographic).
  6000. * @param {object} metadata
  6001. * @return {object} `{ countryCallingCode: string?, number: string }`
  6002. * @example
  6003. * // Returns `{ countryCallingCode: "1", number: "2133734253" }`.
  6004. * extractCountryCallingCode('2133734253', 'US', null, metadata)
  6005. * extractCountryCallingCode('2133734253', null, '1', metadata)
  6006. * extractCountryCallingCode('+12133734253', null, null, metadata)
  6007. * extractCountryCallingCode('+12133734253', 'RU', null, metadata)
  6008. */
  6009. function extractCountryCallingCode(number, country, callingCode, metadata) {
  6010. if (!number) {
  6011. return {};
  6012. } // If this is not an international phone number,
  6013. // then either extract an "IDD" prefix, or extract a
  6014. // country calling code from a number by autocorrecting it
  6015. // by prepending a leading `+` in cases when it starts
  6016. // with the country calling code.
  6017. // https://wikitravel.org/en/International_dialling_prefix
  6018. // https://github.com/catamphetamine/libphonenumber-js/issues/376
  6019. if (number[0] !== '+') {
  6020. // Convert an "out-of-country" dialing phone number
  6021. // to a proper international phone number.
  6022. var numberWithoutIDD = stripIddPrefix(number, country, callingCode, metadata); // If an IDD prefix was stripped then
  6023. // convert the number to international one
  6024. // for subsequent parsing.
  6025. if (numberWithoutIDD && numberWithoutIDD !== number) {
  6026. number = '+' + numberWithoutIDD;
  6027. } else {
  6028. // Check to see if the number starts with the country calling code
  6029. // for the default country. If so, we remove the country calling code,
  6030. // and do some checks on the validity of the number before and after.
  6031. // https://github.com/catamphetamine/libphonenumber-js/issues/376
  6032. if (country || callingCode) {
  6033. var _extractCountryCallin = extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(number, country, callingCode, metadata),
  6034. countryCallingCode = _extractCountryCallin.countryCallingCode,
  6035. shorterNumber = _extractCountryCallin.number;
  6036. if (countryCallingCode) {
  6037. return {
  6038. countryCallingCode: countryCallingCode,
  6039. number: shorterNumber
  6040. };
  6041. }
  6042. }
  6043. return {
  6044. number: number
  6045. };
  6046. }
  6047. } // Fast abortion: country codes do not begin with a '0'
  6048. if (number[1] === '0') {
  6049. return {};
  6050. }
  6051. metadata = new Metadata(metadata); // The thing with country phone codes
  6052. // is that they are orthogonal to each other
  6053. // i.e. there's no such country phone code A
  6054. // for which country phone code B exists
  6055. // where B starts with A.
  6056. // Therefore, while scanning digits,
  6057. // if a valid country code is found,
  6058. // that means that it is the country code.
  6059. //
  6060. var i = 2;
  6061. while (i - 1 <= MAX_LENGTH_COUNTRY_CODE && i <= number.length) {
  6062. var _countryCallingCode = number.slice(1, i);
  6063. if (metadata.hasCallingCode(_countryCallingCode)) {
  6064. metadata.selectNumberingPlan(_countryCallingCode);
  6065. return {
  6066. countryCallingCode: _countryCallingCode,
  6067. number: number.slice(i)
  6068. };
  6069. }
  6070. i++;
  6071. }
  6072. return {};
  6073. }
  6074. function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  6075. function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
  6076. function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  6077. var USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;
  6078. function getCountryByCallingCode(callingCode, nationalPhoneNumber, metadata) {
  6079. /* istanbul ignore if */
  6080. if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
  6081. if (metadata.isNonGeographicCallingCode(callingCode)) {
  6082. return '001';
  6083. }
  6084. } // Is always non-empty, because `callingCode` is always valid
  6085. var possibleCountries = metadata.getCountryCodesForCallingCode(callingCode);
  6086. if (!possibleCountries) {
  6087. return;
  6088. } // If there's just one country corresponding to the country code,
  6089. // then just return it, without further phone number digits validation.
  6090. if (possibleCountries.length === 1) {
  6091. return possibleCountries[0];
  6092. }
  6093. return selectCountryFromList(possibleCountries, nationalPhoneNumber, metadata.metadata);
  6094. }
  6095. function selectCountryFromList(possibleCountries, nationalPhoneNumber, metadata) {
  6096. // Re-create `metadata` because it will be selecting a `country`.
  6097. metadata = new Metadata(metadata);
  6098. for (var _iterator = _createForOfIteratorHelperLoose(possibleCountries), _step; !(_step = _iterator()).done;) {
  6099. var country = _step.value;
  6100. metadata.country(country); // Leading digits check would be the simplest and fastest one.
  6101. // Leading digits patterns are only defined for about 20% of all countries.
  6102. // https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/METADATA.md#leading_digits
  6103. // Matching "leading digits" is a sufficient but not necessary condition.
  6104. if (metadata.leadingDigits()) {
  6105. if (nationalPhoneNumber && nationalPhoneNumber.search(metadata.leadingDigits()) === 0) {
  6106. return country;
  6107. }
  6108. } // Else perform full validation with all of those
  6109. // fixed-line/mobile/etc regular expressions.
  6110. else if (getNumberType({
  6111. phone: nationalPhoneNumber,
  6112. country: country
  6113. }, undefined, metadata.metadata)) {
  6114. return country;
  6115. }
  6116. }
  6117. }
  6118. // This is a port of Google Android `libphonenumber`'s
  6119. // This prevents malicious input from consuming CPU.
  6120. var MAX_INPUT_STRING_LENGTH = 250; // This consists of the plus symbol, digits, and arabic-indic digits.
  6121. var PHONE_NUMBER_START_PATTERN = new RegExp('[' + PLUS_CHARS + VALID_DIGITS + ']'); // Regular expression of trailing characters that we want to remove.
  6122. // A trailing `#` is sometimes used when writing phone numbers with extensions in US.
  6123. // Example: "+1 (645) 123 1234-910#" number has extension "910".
  6124. var AFTER_PHONE_NUMBER_END_PATTERN = new RegExp('[^' + VALID_DIGITS + '#' + ']+$');
  6125. //
  6126. // ```js
  6127. // parse('8 (800) 555-35-35', 'RU')
  6128. // parse('8 (800) 555-35-35', 'RU', metadata)
  6129. // parse('8 (800) 555-35-35', { country: { default: 'RU' } })
  6130. // parse('8 (800) 555-35-35', { country: { default: 'RU' } }, metadata)
  6131. // parse('+7 800 555 35 35')
  6132. // parse('+7 800 555 35 35', metadata)
  6133. // ```
  6134. //
  6135. function parse(text, options, metadata) {
  6136. // If assigning the `{}` default value is moved to the arguments above,
  6137. // code coverage would decrease for some weird reason.
  6138. options = options || {};
  6139. metadata = new Metadata(metadata); // Validate `defaultCountry`.
  6140. if (options.defaultCountry && !metadata.hasCountry(options.defaultCountry)) {
  6141. if (options.v2) {
  6142. throw new ParseError('INVALID_COUNTRY');
  6143. }
  6144. throw new Error("Unknown country: ".concat(options.defaultCountry));
  6145. } // Parse the phone number.
  6146. var _parseInput = parseInput(text, options.v2, options.extract),
  6147. formattedPhoneNumber = _parseInput.number,
  6148. ext = _parseInput.ext,
  6149. error = _parseInput.error; // If the phone number is not viable then return nothing.
  6150. if (!formattedPhoneNumber) {
  6151. if (options.v2) {
  6152. if (error === 'TOO_SHORT') {
  6153. throw new ParseError('TOO_SHORT');
  6154. }
  6155. throw new ParseError('NOT_A_NUMBER');
  6156. }
  6157. return {};
  6158. }
  6159. var _parsePhoneNumber = parsePhoneNumber$1(formattedPhoneNumber, options.defaultCountry, options.defaultCallingCode, metadata),
  6160. country = _parsePhoneNumber.country,
  6161. nationalNumber = _parsePhoneNumber.nationalNumber,
  6162. countryCallingCode = _parsePhoneNumber.countryCallingCode,
  6163. carrierCode = _parsePhoneNumber.carrierCode;
  6164. if (!metadata.hasSelectedNumberingPlan()) {
  6165. if (options.v2) {
  6166. throw new ParseError('INVALID_COUNTRY');
  6167. }
  6168. return {};
  6169. } // Validate national (significant) number length.
  6170. if (!nationalNumber || nationalNumber.length < MIN_LENGTH_FOR_NSN) {
  6171. // Won't throw here because the regexp already demands length > 1.
  6172. /* istanbul ignore if */
  6173. if (options.v2) {
  6174. throw new ParseError('TOO_SHORT');
  6175. } // Google's demo just throws an error in this case.
  6176. return {};
  6177. } // Validate national (significant) number length.
  6178. //
  6179. // A sidenote:
  6180. //
  6181. // They say that sometimes national (significant) numbers
  6182. // can be longer than `MAX_LENGTH_FOR_NSN` (e.g. in Germany).
  6183. // https://github.com/googlei18n/libphonenumber/blob/7e1748645552da39c4e1ba731e47969d97bdb539/resources/phonenumber.proto#L36
  6184. // Such numbers will just be discarded.
  6185. //
  6186. if (nationalNumber.length > MAX_LENGTH_FOR_NSN) {
  6187. if (options.v2) {
  6188. throw new ParseError('TOO_LONG');
  6189. } // Google's demo just throws an error in this case.
  6190. return {};
  6191. }
  6192. if (options.v2) {
  6193. var phoneNumber = new PhoneNumber(countryCallingCode, nationalNumber, metadata.metadata);
  6194. if (country) {
  6195. phoneNumber.country = country;
  6196. }
  6197. if (carrierCode) {
  6198. phoneNumber.carrierCode = carrierCode;
  6199. }
  6200. if (ext) {
  6201. phoneNumber.ext = ext;
  6202. }
  6203. return phoneNumber;
  6204. } // Check if national phone number pattern matches the number.
  6205. // National number pattern is different for each country,
  6206. // even for those ones which are part of the "NANPA" group.
  6207. var valid = (options.extended ? metadata.hasSelectedNumberingPlan() : country) ? matchesEntirely(nationalNumber, metadata.nationalNumberPattern()) : false;
  6208. if (!options.extended) {
  6209. return valid ? result(country, nationalNumber, ext) : {};
  6210. } // isInternational: countryCallingCode !== undefined
  6211. return {
  6212. country: country,
  6213. countryCallingCode: countryCallingCode,
  6214. carrierCode: carrierCode,
  6215. valid: valid,
  6216. possible: valid ? true : options.extended === true && metadata.possibleLengths() && isPossibleNumber(nationalNumber, metadata) ? true : false,
  6217. phone: nationalNumber,
  6218. ext: ext
  6219. };
  6220. }
  6221. /**
  6222. * Extracts a formatted phone number from text.
  6223. * Doesn't guarantee that the extracted phone number
  6224. * is a valid phone number (for example, doesn't validate its length).
  6225. * @param {string} text
  6226. * @param {boolean} [extract] — If `false`, then will parse the entire `text` as a phone number.
  6227. * @param {boolean} [throwOnError] — By default, it won't throw if the text is too long.
  6228. * @return {string}
  6229. * @example
  6230. * // Returns "(213) 373-4253".
  6231. * extractFormattedPhoneNumber("Call (213) 373-4253 for assistance.")
  6232. */
  6233. function extractFormattedPhoneNumber(text, extract, throwOnError) {
  6234. if (!text) {
  6235. return;
  6236. }
  6237. if (text.length > MAX_INPUT_STRING_LENGTH) {
  6238. if (throwOnError) {
  6239. throw new ParseError('TOO_LONG');
  6240. }
  6241. return;
  6242. }
  6243. if (extract === false) {
  6244. return text;
  6245. } // Attempt to extract a possible number from the string passed in
  6246. var startsAt = text.search(PHONE_NUMBER_START_PATTERN);
  6247. if (startsAt < 0) {
  6248. return;
  6249. }
  6250. return text // Trim everything to the left of the phone number
  6251. .slice(startsAt) // Remove trailing non-numerical characters
  6252. .replace(AFTER_PHONE_NUMBER_END_PATTERN, '');
  6253. }
  6254. /**
  6255. * @param {string} text - Input.
  6256. * @param {boolean} v2 - Legacy API functions don't pass `v2: true` flag.
  6257. * @param {boolean} [extract] - Whether to extract a phone number from `text`, or attempt to parse the entire text as a phone number.
  6258. * @return {object} `{ ?number, ?ext }`.
  6259. */
  6260. function parseInput(text, v2, extract) {
  6261. // Parse RFC 3966 phone number URI.
  6262. if (text && text.indexOf('tel:') === 0) {
  6263. return parseRFC3966(text);
  6264. }
  6265. var number = extractFormattedPhoneNumber(text, extract, v2); // If the phone number is not viable, then abort.
  6266. if (!number) {
  6267. return {};
  6268. }
  6269. if (!isViablePhoneNumber(number)) {
  6270. if (isViablePhoneNumberStart(number)) {
  6271. return {
  6272. error: 'TOO_SHORT'
  6273. };
  6274. }
  6275. return {};
  6276. } // Attempt to parse extension first, since it doesn't require region-specific
  6277. // data and we want to have the non-normalised number here.
  6278. var withExtensionStripped = extractExtension(number);
  6279. if (withExtensionStripped.ext) {
  6280. return withExtensionStripped;
  6281. }
  6282. return {
  6283. number: number
  6284. };
  6285. }
  6286. /**
  6287. * Creates `parse()` result object.
  6288. */
  6289. function result(country, nationalNumber, ext) {
  6290. var result = {
  6291. country: country,
  6292. phone: nationalNumber
  6293. };
  6294. if (ext) {
  6295. result.ext = ext;
  6296. }
  6297. return result;
  6298. }
  6299. /**
  6300. * Parses a viable phone number.
  6301. * @param {string} formattedPhoneNumber — Example: "(213) 373-4253".
  6302. * @param {string} [defaultCountry]
  6303. * @param {string} [defaultCallingCode]
  6304. * @param {Metadata} metadata
  6305. * @return {object} Returns `{ country: string?, countryCallingCode: string?, nationalNumber: string? }`.
  6306. */
  6307. function parsePhoneNumber$1(formattedPhoneNumber, defaultCountry, defaultCallingCode, metadata) {
  6308. // Extract calling code from phone number.
  6309. var _extractCountryCallin = extractCountryCallingCode(parseIncompletePhoneNumber(formattedPhoneNumber), defaultCountry, defaultCallingCode, metadata.metadata),
  6310. countryCallingCode = _extractCountryCallin.countryCallingCode,
  6311. number = _extractCountryCallin.number; // Choose a country by `countryCallingCode`.
  6312. var country;
  6313. if (countryCallingCode) {
  6314. metadata.selectNumberingPlan(countryCallingCode);
  6315. } // If `formattedPhoneNumber` is in "national" format
  6316. // then `number` is defined and `countryCallingCode` isn't.
  6317. else if (number && (defaultCountry || defaultCallingCode)) {
  6318. metadata.selectNumberingPlan(defaultCountry, defaultCallingCode);
  6319. if (defaultCountry) {
  6320. country = defaultCountry;
  6321. }
  6322. countryCallingCode = defaultCallingCode || getCountryCallingCode(defaultCountry, metadata.metadata);
  6323. } else return {};
  6324. if (!number) {
  6325. return {
  6326. countryCallingCode: countryCallingCode
  6327. };
  6328. }
  6329. var _extractNationalNumbe = extractNationalNumber(parseIncompletePhoneNumber(number), metadata),
  6330. nationalNumber = _extractNationalNumbe.nationalNumber,
  6331. carrierCode = _extractNationalNumbe.carrierCode; // Sometimes there are several countries
  6332. // corresponding to the same country phone code
  6333. // (e.g. NANPA countries all having `1` country phone code).
  6334. // Therefore, to reliably determine the exact country,
  6335. // national (significant) number should have been parsed first.
  6336. //
  6337. // When `metadata.json` is generated, all "ambiguous" country phone codes
  6338. // get their countries populated with the full set of
  6339. // "phone number type" regular expressions.
  6340. //
  6341. var exactCountry = getCountryByCallingCode(countryCallingCode, nationalNumber, metadata);
  6342. if (exactCountry) {
  6343. country = exactCountry;
  6344. /* istanbul ignore if */
  6345. if (exactCountry === '001') ; else {
  6346. metadata.country(country);
  6347. }
  6348. }
  6349. return {
  6350. country: country,
  6351. countryCallingCode: countryCallingCode,
  6352. nationalNumber: nationalNumber,
  6353. carrierCode: carrierCode
  6354. };
  6355. }
  6356. function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  6357. function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty$2(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  6358. function _defineProperty$2(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  6359. function parsePhoneNumber(text, options, metadata) {
  6360. return parse(text, _objectSpread$2(_objectSpread$2({}, options), {}, {
  6361. v2: true
  6362. }), metadata);
  6363. }
  6364. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  6365. function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  6366. function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  6367. function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  6368. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  6369. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  6370. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  6371. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  6372. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  6373. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  6374. function normalizeArguments(args) {
  6375. var _Array$prototype$slic = Array.prototype.slice.call(args),
  6376. _Array$prototype$slic2 = _slicedToArray(_Array$prototype$slic, 4),
  6377. arg_1 = _Array$prototype$slic2[0],
  6378. arg_2 = _Array$prototype$slic2[1],
  6379. arg_3 = _Array$prototype$slic2[2],
  6380. arg_4 = _Array$prototype$slic2[3];
  6381. var text;
  6382. var options;
  6383. var metadata; // If the phone number is passed as a string.
  6384. // `parsePhoneNumber('88005553535', ...)`.
  6385. if (typeof arg_1 === 'string') {
  6386. text = arg_1;
  6387. } else throw new TypeError('A text for parsing must be a string.'); // If "default country" argument is being passed then move it to `options`.
  6388. // `parsePhoneNumber('88005553535', 'RU', [options], metadata)`.
  6389. if (!arg_2 || typeof arg_2 === 'string') {
  6390. if (arg_4) {
  6391. options = arg_3;
  6392. metadata = arg_4;
  6393. } else {
  6394. options = undefined;
  6395. metadata = arg_3;
  6396. }
  6397. if (arg_2) {
  6398. options = _objectSpread$1({
  6399. defaultCountry: arg_2
  6400. }, options);
  6401. }
  6402. } // `defaultCountry` is not passed.
  6403. // Example: `parsePhoneNumber('+78005553535', [options], metadata)`.
  6404. else if (isObject$1(arg_2)) {
  6405. if (arg_3) {
  6406. options = arg_2;
  6407. metadata = arg_3;
  6408. } else {
  6409. metadata = arg_2;
  6410. }
  6411. } else throw new Error("Invalid second argument: ".concat(arg_2));
  6412. return {
  6413. text: text,
  6414. options: options,
  6415. metadata: metadata
  6416. };
  6417. } // Otherwise istanbul would show this as "branch not covered".
  6418. /* istanbul ignore next */
  6419. var isObject$1 = function isObject(_) {
  6420. return _typeof(_) === 'object';
  6421. };
  6422. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  6423. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  6424. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  6425. function parsePhoneNumberFromString$2(text, options, metadata) {
  6426. // Validate `defaultCountry`.
  6427. if (options && options.defaultCountry && !isSupportedCountry(options.defaultCountry, metadata)) {
  6428. options = _objectSpread(_objectSpread({}, options), {}, {
  6429. defaultCountry: undefined
  6430. });
  6431. } // Parse phone number.
  6432. try {
  6433. return parsePhoneNumber(text, options, metadata);
  6434. } catch (error) {
  6435. /* istanbul ignore else */
  6436. if (error instanceof ParseError) ; else {
  6437. throw error;
  6438. }
  6439. }
  6440. }
  6441. function parsePhoneNumberFromString$1() {
  6442. var _normalizeArguments = normalizeArguments(arguments),
  6443. text = _normalizeArguments.text,
  6444. options = _normalizeArguments.options,
  6445. metadata = _normalizeArguments.metadata;
  6446. return parsePhoneNumberFromString$2(text, options, metadata);
  6447. }
  6448. function parsePhoneNumberFromString() {
  6449. return withMetadataArgument(parsePhoneNumberFromString$1, arguments)
  6450. }
  6451. var IS_PHONE_NUMBER = 'isPhoneNumber';
  6452. /**
  6453. * Checks if the string is a valid phone number. To successfully validate any phone number the text must include
  6454. * the intl. calling code, if the calling code wont be provided then the region must be set.
  6455. *
  6456. * @param value the potential phone number string to test
  6457. * @param region 2 characters uppercase country code (e.g. DE, US, CH) for country specific validation.
  6458. * If text doesn't start with the international calling code (e.g. +41), then you must set this parameter.
  6459. */
  6460. function isPhoneNumber(value, region) {
  6461. try {
  6462. var phoneNum = parsePhoneNumberFromString(value, region);
  6463. var result = phoneNum === null || phoneNum === void 0 ? void 0 : phoneNum.isValid();
  6464. return !!result;
  6465. }
  6466. catch (error) {
  6467. // logging?
  6468. return false;
  6469. }
  6470. }
  6471. /**
  6472. * Checks if the string is a valid phone number. To successfully validate any phone number the text must include
  6473. * the intl. calling code, if the calling code wont be provided then the region must be set.
  6474. *
  6475. * @param region 2 characters uppercase country code (e.g. DE, US, CH) for country specific validation.
  6476. * If text doesn't start with the international calling code (e.g. +41), then you must set this parameter.
  6477. */
  6478. function IsPhoneNumber(region, validationOptions) {
  6479. return ValidateBy({
  6480. name: IS_PHONE_NUMBER,
  6481. constraints: [region],
  6482. validator: {
  6483. validate: function (value, args) { return isPhoneNumber(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  6484. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a valid phone number'; }, validationOptions),
  6485. },
  6486. }, validationOptions);
  6487. }
  6488. var IS_MILITARY_TIME = 'isMilitaryTime';
  6489. /**
  6490. * Checks if the string represents a time without a given timezone in the format HH:MM (military)
  6491. * If the given value does not match the pattern HH:MM, then it returns false.
  6492. */
  6493. function isMilitaryTime(value) {
  6494. var militaryTimeRegex = /^([01]\d|2[0-3]):?([0-5]\d)$/;
  6495. return typeof value === 'string' && matchesValidator(value, militaryTimeRegex);
  6496. }
  6497. /**
  6498. * Checks if the string represents a time without a given timezone in the format HH:MM (military)
  6499. * If the given value does not match the pattern HH:MM, then it returns false.
  6500. */
  6501. function IsMilitaryTime(validationOptions) {
  6502. return ValidateBy({
  6503. name: IS_MILITARY_TIME,
  6504. validator: {
  6505. validate: function (value, args) { return isMilitaryTime(value); },
  6506. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a valid representation of military time in the format HH:MM'; }, validationOptions),
  6507. },
  6508. }, validationOptions);
  6509. }
  6510. var isHash$1 = {exports: {}};
  6511. (function (module, exports) {
  6512. Object.defineProperty(exports, "__esModule", {
  6513. value: true
  6514. });
  6515. exports.default = isHash;
  6516. var _assertString = _interopRequireDefault(assertString.exports);
  6517. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6518. var lengths = {
  6519. md5: 32,
  6520. md4: 32,
  6521. sha1: 40,
  6522. sha256: 64,
  6523. sha384: 96,
  6524. sha512: 128,
  6525. ripemd128: 32,
  6526. ripemd160: 40,
  6527. tiger128: 32,
  6528. tiger160: 40,
  6529. tiger192: 48,
  6530. crc32: 8,
  6531. crc32b: 8
  6532. };
  6533. function isHash(str, algorithm) {
  6534. (0, _assertString.default)(str);
  6535. var hash = new RegExp("^[a-fA-F0-9]{".concat(lengths[algorithm], "}$"));
  6536. return hash.test(str);
  6537. }
  6538. module.exports = exports.default;
  6539. module.exports.default = exports.default;
  6540. } (isHash$1, isHash$1.exports));
  6541. var isHashValidator = /*@__PURE__*/getDefaultExportFromCjs(isHash$1.exports);
  6542. var IS_HASH = 'isHash';
  6543. /**
  6544. * Check if the string is a hash of type algorithm.
  6545. * Algorithm is one of ['md4', 'md5', 'sha1', 'sha256', 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128',
  6546. * 'tiger160', 'tiger192', 'crc32', 'crc32b']
  6547. */
  6548. function isHash(value, algorithm) {
  6549. return typeof value === 'string' && isHashValidator(value, algorithm);
  6550. }
  6551. /**
  6552. * Check if the string is a hash of type algorithm.
  6553. * Algorithm is one of ['md4', 'md5', 'sha1', 'sha256', 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128',
  6554. * 'tiger160', 'tiger192', 'crc32', 'crc32b']
  6555. */
  6556. function IsHash(algorithm, validationOptions) {
  6557. return ValidateBy({
  6558. name: IS_HASH,
  6559. constraints: [algorithm],
  6560. validator: {
  6561. validate: function (value, args) { return isHash(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  6562. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a hash of type $constraint1'; }, validationOptions),
  6563. },
  6564. }, validationOptions);
  6565. }
  6566. var isISSN$1 = {exports: {}};
  6567. (function (module, exports) {
  6568. Object.defineProperty(exports, "__esModule", {
  6569. value: true
  6570. });
  6571. exports.default = isISSN;
  6572. var _assertString = _interopRequireDefault(assertString.exports);
  6573. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6574. var issn = '^\\d{4}-?\\d{3}[\\dX]$';
  6575. function isISSN(str) {
  6576. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  6577. (0, _assertString.default)(str);
  6578. var testIssn = issn;
  6579. testIssn = options.require_hyphen ? testIssn.replace('?', '') : testIssn;
  6580. testIssn = options.case_sensitive ? new RegExp(testIssn) : new RegExp(testIssn, 'i');
  6581. if (!testIssn.test(str)) {
  6582. return false;
  6583. }
  6584. var digits = str.replace('-', '').toUpperCase();
  6585. var checksum = 0;
  6586. for (var i = 0; i < digits.length; i++) {
  6587. var digit = digits[i];
  6588. checksum += (digit === 'X' ? 10 : +digit) * (8 - i);
  6589. }
  6590. return checksum % 11 === 0;
  6591. }
  6592. module.exports = exports.default;
  6593. module.exports.default = exports.default;
  6594. } (isISSN$1, isISSN$1.exports));
  6595. var isISSNValidator = /*@__PURE__*/getDefaultExportFromCjs(isISSN$1.exports);
  6596. var IS_ISSN = 'isISSN';
  6597. /**
  6598. * Checks if the string is a ISSN.
  6599. * If given value is not a string, then it returns false.
  6600. */
  6601. function isISSN(value, options) {
  6602. return typeof value === 'string' && isISSNValidator(value, options);
  6603. }
  6604. /**
  6605. * Checks if the string is a ISSN.
  6606. * If given value is not a string, then it returns false.
  6607. */
  6608. function IsISSN(options, validationOptions) {
  6609. return ValidateBy({
  6610. name: IS_ISSN,
  6611. constraints: [options],
  6612. validator: {
  6613. validate: function (value, args) { return isISSN(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  6614. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a ISSN'; }, validationOptions),
  6615. },
  6616. }, validationOptions);
  6617. }
  6618. var IS_DATE_STRING = 'isDateString';
  6619. /**
  6620. * Alias for IsISO8601 validator
  6621. */
  6622. function isDateString(value, options) {
  6623. return isISO8601(value, options);
  6624. }
  6625. /**
  6626. * Alias for IsISO8601 validator
  6627. */
  6628. function IsDateString(options, validationOptions) {
  6629. return ValidateBy({
  6630. name: IS_DATE_STRING,
  6631. constraints: [options],
  6632. validator: {
  6633. validate: function (value) { return isDateString(value, options); },
  6634. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a valid ISO 8601 date string'; }, validationOptions),
  6635. },
  6636. }, validationOptions);
  6637. }
  6638. var isBoolean$1 = {exports: {}};
  6639. (function (module, exports) {
  6640. Object.defineProperty(exports, "__esModule", {
  6641. value: true
  6642. });
  6643. exports.default = isBoolean;
  6644. var _assertString = _interopRequireDefault(assertString.exports);
  6645. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6646. var defaultOptions = {
  6647. loose: false
  6648. };
  6649. var strictBooleans = ['true', 'false', '1', '0'];
  6650. var looseBooleans = [].concat(strictBooleans, ['yes', 'no']);
  6651. function isBoolean(str) {
  6652. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
  6653. (0, _assertString.default)(str);
  6654. if (options.loose) {
  6655. return looseBooleans.includes(str.toLowerCase());
  6656. }
  6657. return strictBooleans.includes(str);
  6658. }
  6659. module.exports = exports.default;
  6660. module.exports.default = exports.default;
  6661. } (isBoolean$1, isBoolean$1.exports));
  6662. var isBooleanValidator = /*@__PURE__*/getDefaultExportFromCjs(isBoolean$1.exports);
  6663. var IS_BOOLEAN_STRING = 'isBooleanString';
  6664. /**
  6665. * Checks if a string is a boolean.
  6666. * If given value is not a string, then it returns false.
  6667. */
  6668. function isBooleanString(value) {
  6669. return typeof value === 'string' && isBooleanValidator(value);
  6670. }
  6671. /**
  6672. * Checks if a string is a boolean.
  6673. * If given value is not a string, then it returns false.
  6674. */
  6675. function IsBooleanString(validationOptions) {
  6676. return ValidateBy({
  6677. name: IS_BOOLEAN_STRING,
  6678. validator: {
  6679. validate: function (value, args) { return isBooleanString(value); },
  6680. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a boolean string'; }, validationOptions),
  6681. },
  6682. }, validationOptions);
  6683. }
  6684. var isNumeric = {exports: {}};
  6685. (function (module, exports) {
  6686. Object.defineProperty(exports, "__esModule", {
  6687. value: true
  6688. });
  6689. exports.default = isNumeric;
  6690. var _assertString = _interopRequireDefault(assertString.exports);
  6691. var _alpha = alpha$1;
  6692. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6693. var numericNoSymbols = /^[0-9]+$/;
  6694. function isNumeric(str, options) {
  6695. (0, _assertString.default)(str);
  6696. if (options && options.no_symbols) {
  6697. return numericNoSymbols.test(str);
  6698. }
  6699. return new RegExp("^[+-]?([0-9]*[".concat((options || {}).locale ? _alpha.decimal[options.locale] : '.', "])?[0-9]+$")).test(str);
  6700. }
  6701. module.exports = exports.default;
  6702. module.exports.default = exports.default;
  6703. } (isNumeric, isNumeric.exports));
  6704. var isNumericValidator = /*@__PURE__*/getDefaultExportFromCjs(isNumeric.exports);
  6705. var IS_NUMBER_STRING = 'isNumberString';
  6706. /**
  6707. * Checks if the string is numeric.
  6708. * If given value is not a string, then it returns false.
  6709. */
  6710. function isNumberString(value, options) {
  6711. return typeof value === 'string' && isNumericValidator(value, options);
  6712. }
  6713. /**
  6714. * Checks if the string is numeric.
  6715. * If given value is not a string, then it returns false.
  6716. */
  6717. function IsNumberString(options, validationOptions) {
  6718. return ValidateBy({
  6719. name: IS_NUMBER_STRING,
  6720. constraints: [options],
  6721. validator: {
  6722. validate: function (value, args) { return isNumberString(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  6723. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a number string'; }, validationOptions),
  6724. },
  6725. }, validationOptions);
  6726. }
  6727. var isBase32$1 = {exports: {}};
  6728. (function (module, exports) {
  6729. Object.defineProperty(exports, "__esModule", {
  6730. value: true
  6731. });
  6732. exports.default = isBase32;
  6733. var _assertString = _interopRequireDefault(assertString.exports);
  6734. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6735. var base32 = /^[A-Z2-7]+=*$/;
  6736. function isBase32(str) {
  6737. (0, _assertString.default)(str);
  6738. var len = str.length;
  6739. if (len % 8 === 0 && base32.test(str)) {
  6740. return true;
  6741. }
  6742. return false;
  6743. }
  6744. module.exports = exports.default;
  6745. module.exports.default = exports.default;
  6746. } (isBase32$1, isBase32$1.exports));
  6747. var isBase32Validator = /*@__PURE__*/getDefaultExportFromCjs(isBase32$1.exports);
  6748. var IS_BASE32 = 'isBase32';
  6749. /**
  6750. * Checks if a string is base32 encoded.
  6751. * If given value is not a string, then it returns false.
  6752. */
  6753. function isBase32(value) {
  6754. return typeof value === 'string' && isBase32Validator(value);
  6755. }
  6756. /**
  6757. * Check if a string is base32 encoded.
  6758. * If given value is not a string, then it returns false.
  6759. */
  6760. function IsBase32(validationOptions) {
  6761. return ValidateBy({
  6762. name: IS_BASE32,
  6763. validator: {
  6764. validate: function (value, args) { return isBase32(value); },
  6765. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be base32 encoded'; }, validationOptions),
  6766. },
  6767. }, validationOptions);
  6768. }
  6769. var isBIC$1 = {exports: {}};
  6770. (function (module, exports) {
  6771. Object.defineProperty(exports, "__esModule", {
  6772. value: true
  6773. });
  6774. exports.default = isBIC;
  6775. var _assertString = _interopRequireDefault(assertString.exports);
  6776. var _isISO31661Alpha = isISO31661Alpha2$2;
  6777. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6778. // https://en.wikipedia.org/wiki/ISO_9362
  6779. var isBICReg = /^[A-Za-z]{6}[A-Za-z0-9]{2}([A-Za-z0-9]{3})?$/;
  6780. function isBIC(str) {
  6781. (0, _assertString.default)(str); // toUpperCase() should be removed when a new major version goes out that changes
  6782. // the regex to [A-Z] (per the spec).
  6783. if (!_isISO31661Alpha.CountryCodes.has(str.slice(4, 6).toUpperCase())) {
  6784. return false;
  6785. }
  6786. return isBICReg.test(str);
  6787. }
  6788. module.exports = exports.default;
  6789. module.exports.default = exports.default;
  6790. } (isBIC$1, isBIC$1.exports));
  6791. var isBICValidator = /*@__PURE__*/getDefaultExportFromCjs(isBIC$1.exports);
  6792. var IS_BIC = 'isBIC';
  6793. /**
  6794. * Check if a string is a BIC (Bank Identification Code) or SWIFT code.
  6795. * If given value is not a string, then it returns false.
  6796. */
  6797. function isBIC(value) {
  6798. return typeof value === 'string' && isBICValidator(value);
  6799. }
  6800. /**
  6801. * Check if a string is a BIC (Bank Identification Code) or SWIFT code.
  6802. * If given value is not a string, then it returns false.
  6803. */
  6804. function IsBIC(validationOptions) {
  6805. return ValidateBy({
  6806. name: IS_BIC,
  6807. validator: {
  6808. validate: function (value, args) { return isBIC(value); },
  6809. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a BIC or SWIFT code'; }, validationOptions),
  6810. },
  6811. }, validationOptions);
  6812. }
  6813. var isBtcAddress$1 = {exports: {}};
  6814. (function (module, exports) {
  6815. Object.defineProperty(exports, "__esModule", {
  6816. value: true
  6817. });
  6818. exports.default = isBtcAddress;
  6819. var _assertString = _interopRequireDefault(assertString.exports);
  6820. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6821. // supports Bech32 addresses
  6822. var bech32 = /^(bc1)[a-z0-9]{25,39}$/;
  6823. var base58 = /^(1|3)[A-HJ-NP-Za-km-z1-9]{25,39}$/;
  6824. function isBtcAddress(str) {
  6825. (0, _assertString.default)(str); // check for bech32
  6826. if (str.startsWith('bc1')) {
  6827. return bech32.test(str);
  6828. }
  6829. return base58.test(str);
  6830. }
  6831. module.exports = exports.default;
  6832. module.exports.default = exports.default;
  6833. } (isBtcAddress$1, isBtcAddress$1.exports));
  6834. var isBtcAddressValidator = /*@__PURE__*/getDefaultExportFromCjs(isBtcAddress$1.exports);
  6835. var IS_BTC_ADDRESS = 'isBtcAddress';
  6836. /**
  6837. * Check if the string is a valid BTC address.
  6838. * If given value is not a string, then it returns false.
  6839. */
  6840. function isBtcAddress(value) {
  6841. return typeof value === 'string' && isBtcAddressValidator(value);
  6842. }
  6843. /**
  6844. * Check if the string is a valid BTC address.
  6845. * If given value is not a string, then it returns false.
  6846. */
  6847. function IsBtcAddress(validationOptions) {
  6848. return ValidateBy({
  6849. name: IS_BTC_ADDRESS,
  6850. validator: {
  6851. validate: function (value, args) { return isBtcAddress(value); },
  6852. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a BTC address'; }, validationOptions),
  6853. },
  6854. }, validationOptions);
  6855. }
  6856. var isDataURI$1 = {exports: {}};
  6857. (function (module, exports) {
  6858. Object.defineProperty(exports, "__esModule", {
  6859. value: true
  6860. });
  6861. exports.default = isDataURI;
  6862. var _assertString = _interopRequireDefault(assertString.exports);
  6863. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6864. var validMediaType = /^[a-z]+\/[a-z0-9\-\+]+$/i;
  6865. var validAttribute = /^[a-z\-]+=[a-z0-9\-]+$/i;
  6866. var validData = /^[a-z0-9!\$&'\(\)\*\+,;=\-\._~:@\/\?%\s]*$/i;
  6867. function isDataURI(str) {
  6868. (0, _assertString.default)(str);
  6869. var data = str.split(',');
  6870. if (data.length < 2) {
  6871. return false;
  6872. }
  6873. var attributes = data.shift().trim().split(';');
  6874. var schemeAndMediaType = attributes.shift();
  6875. if (schemeAndMediaType.substr(0, 5) !== 'data:') {
  6876. return false;
  6877. }
  6878. var mediaType = schemeAndMediaType.substr(5);
  6879. if (mediaType !== '' && !validMediaType.test(mediaType)) {
  6880. return false;
  6881. }
  6882. for (var i = 0; i < attributes.length; i++) {
  6883. if (!(i === attributes.length - 1 && attributes[i].toLowerCase() === 'base64') && !validAttribute.test(attributes[i])) {
  6884. return false;
  6885. }
  6886. }
  6887. for (var _i = 0; _i < data.length; _i++) {
  6888. if (!validData.test(data[_i])) {
  6889. return false;
  6890. }
  6891. }
  6892. return true;
  6893. }
  6894. module.exports = exports.default;
  6895. module.exports.default = exports.default;
  6896. } (isDataURI$1, isDataURI$1.exports));
  6897. var isDataURIValidator = /*@__PURE__*/getDefaultExportFromCjs(isDataURI$1.exports);
  6898. var IS_DATA_URI = 'isDataURI';
  6899. /**
  6900. * Check if the string is a data uri format.
  6901. * If given value is not a string, then it returns false.
  6902. */
  6903. function isDataURI(value) {
  6904. return typeof value === 'string' && isDataURIValidator(value);
  6905. }
  6906. /**
  6907. * Check if the string is a data uri format.
  6908. * If given value is not a string, then it returns false.
  6909. */
  6910. function IsDataURI(validationOptions) {
  6911. return ValidateBy({
  6912. name: IS_DATA_URI,
  6913. validator: {
  6914. validate: function (value, args) { return isDataURI(value); },
  6915. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a data uri format'; }, validationOptions),
  6916. },
  6917. }, validationOptions);
  6918. }
  6919. var isEAN$1 = {exports: {}};
  6920. (function (module, exports) {
  6921. Object.defineProperty(exports, "__esModule", {
  6922. value: true
  6923. });
  6924. exports.default = isEAN;
  6925. var _assertString = _interopRequireDefault(assertString.exports);
  6926. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6927. /**
  6928. * The most commonly used EAN standard is
  6929. * the thirteen-digit EAN-13, while the
  6930. * less commonly used 8-digit EAN-8 barcode was
  6931. * introduced for use on small packages.
  6932. * Also EAN/UCC-14 is used for Grouping of individual
  6933. * trade items above unit level(Intermediate, Carton or Pallet).
  6934. * For more info about EAN-14 checkout: https://www.gtin.info/itf-14-barcodes/
  6935. * EAN consists of:
  6936. * GS1 prefix, manufacturer code, product code and check digit
  6937. * Reference: https://en.wikipedia.org/wiki/International_Article_Number
  6938. * Reference: https://www.gtin.info/
  6939. */
  6940. /**
  6941. * Define EAN Lenghts; 8 for EAN-8; 13 for EAN-13; 14 for EAN-14
  6942. * and Regular Expression for valid EANs (EAN-8, EAN-13, EAN-14),
  6943. * with exact numberic matching of 8 or 13 or 14 digits [0-9]
  6944. */
  6945. var LENGTH_EAN_8 = 8;
  6946. var LENGTH_EAN_14 = 14;
  6947. var validEanRegex = /^(\d{8}|\d{13}|\d{14})$/;
  6948. /**
  6949. * Get position weight given:
  6950. * EAN length and digit index/position
  6951. *
  6952. * @param {number} length
  6953. * @param {number} index
  6954. * @return {number}
  6955. */
  6956. function getPositionWeightThroughLengthAndIndex(length, index) {
  6957. if (length === LENGTH_EAN_8 || length === LENGTH_EAN_14) {
  6958. return index % 2 === 0 ? 3 : 1;
  6959. }
  6960. return index % 2 === 0 ? 1 : 3;
  6961. }
  6962. /**
  6963. * Calculate EAN Check Digit
  6964. * Reference: https://en.wikipedia.org/wiki/International_Article_Number#Calculation_of_checksum_digit
  6965. *
  6966. * @param {string} ean
  6967. * @return {number}
  6968. */
  6969. function calculateCheckDigit(ean) {
  6970. var checksum = ean.slice(0, -1).split('').map(function (char, index) {
  6971. return Number(char) * getPositionWeightThroughLengthAndIndex(ean.length, index);
  6972. }).reduce(function (acc, partialSum) {
  6973. return acc + partialSum;
  6974. }, 0);
  6975. var remainder = 10 - checksum % 10;
  6976. return remainder < 10 ? remainder : 0;
  6977. }
  6978. /**
  6979. * Check if string is valid EAN:
  6980. * Matches EAN-8/EAN-13/EAN-14 regex
  6981. * Has valid check digit.
  6982. *
  6983. * @param {string} str
  6984. * @return {boolean}
  6985. */
  6986. function isEAN(str) {
  6987. (0, _assertString.default)(str);
  6988. var actualCheckDigit = Number(str.slice(-1));
  6989. return validEanRegex.test(str) && actualCheckDigit === calculateCheckDigit(str);
  6990. }
  6991. module.exports = exports.default;
  6992. module.exports.default = exports.default;
  6993. } (isEAN$1, isEAN$1.exports));
  6994. var isEANValidator = /*@__PURE__*/getDefaultExportFromCjs(isEAN$1.exports);
  6995. var IS_EAN = 'isEAN';
  6996. /**
  6997. * Check if the string is an EAN (European Article Number).
  6998. * If given value is not a string, then it returns false.
  6999. */
  7000. function isEAN(value) {
  7001. return typeof value === 'string' && isEANValidator(value);
  7002. }
  7003. /**
  7004. * Check if the string is an EAN (European Article Number).
  7005. * If given value is not a string, then it returns false.
  7006. */
  7007. function IsEAN(validationOptions) {
  7008. return ValidateBy({
  7009. name: IS_EAN,
  7010. validator: {
  7011. validate: function (value, args) { return isEAN(value); },
  7012. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be an EAN (European Article Number)'; }, validationOptions),
  7013. },
  7014. }, validationOptions);
  7015. }
  7016. var isEthereumAddress$1 = {exports: {}};
  7017. (function (module, exports) {
  7018. Object.defineProperty(exports, "__esModule", {
  7019. value: true
  7020. });
  7021. exports.default = isEthereumAddress;
  7022. var _assertString = _interopRequireDefault(assertString.exports);
  7023. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7024. var eth = /^(0x)[0-9a-f]{40}$/i;
  7025. function isEthereumAddress(str) {
  7026. (0, _assertString.default)(str);
  7027. return eth.test(str);
  7028. }
  7029. module.exports = exports.default;
  7030. module.exports.default = exports.default;
  7031. } (isEthereumAddress$1, isEthereumAddress$1.exports));
  7032. var isEthereumAddressValidator = /*@__PURE__*/getDefaultExportFromCjs(isEthereumAddress$1.exports);
  7033. var IS_ETHEREUM_ADDRESS = 'isEthereumAddress';
  7034. /**
  7035. * Check if the string is an Ethereum address using basic regex. Does not validate address checksums.
  7036. * If given value is not a string, then it returns false.
  7037. */
  7038. function isEthereumAddress(value) {
  7039. return typeof value === 'string' && isEthereumAddressValidator(value);
  7040. }
  7041. /**
  7042. * Check if the string is an Ethereum address using basic regex. Does not validate address checksums.
  7043. * If given value is not a string, then it returns false.
  7044. */
  7045. function IsEthereumAddress(validationOptions) {
  7046. return ValidateBy({
  7047. name: IS_ETHEREUM_ADDRESS,
  7048. validator: {
  7049. validate: function (value, args) { return isEthereumAddress(value); },
  7050. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be an Ethereum address'; }, validationOptions),
  7051. },
  7052. }, validationOptions);
  7053. }
  7054. var isHSL$1 = {exports: {}};
  7055. (function (module, exports) {
  7056. Object.defineProperty(exports, "__esModule", {
  7057. value: true
  7058. });
  7059. exports.default = isHSL;
  7060. var _assertString = _interopRequireDefault(assertString.exports);
  7061. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7062. var hslComma = /^hsla?\(((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn)?(,(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}(,((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?))?\)$/i;
  7063. var hslSpace = /^hsla?\(((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn)?(\s(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}\s?(\/\s((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?)\s?)?\)$/i;
  7064. function isHSL(str) {
  7065. (0, _assertString.default)(str); // Strip duplicate spaces before calling the validation regex (See #1598 for more info)
  7066. var strippedStr = str.replace(/\s+/g, ' ').replace(/\s?(hsla?\(|\)|,)\s?/ig, '$1');
  7067. if (strippedStr.indexOf(',') !== -1) {
  7068. return hslComma.test(strippedStr);
  7069. }
  7070. return hslSpace.test(strippedStr);
  7071. }
  7072. module.exports = exports.default;
  7073. module.exports.default = exports.default;
  7074. } (isHSL$1, isHSL$1.exports));
  7075. var isHSLValidator = /*@__PURE__*/getDefaultExportFromCjs(isHSL$1.exports);
  7076. var IS_HSL = 'isHSL';
  7077. /**
  7078. * Check if the string is an HSL (hue, saturation, lightness, optional alpha) color based on CSS Colors Level 4 specification.
  7079. * Comma-separated format supported. Space-separated format supported with the exception of a few edge cases (ex: hsl(200grad+.1%62%/1)).
  7080. * If given value is not a string, then it returns false.
  7081. */
  7082. function isHSL(value) {
  7083. return typeof value === 'string' && isHSLValidator(value);
  7084. }
  7085. /**
  7086. * Check if the string is an HSL (hue, saturation, lightness, optional alpha) color based on CSS Colors Level 4 specification.
  7087. * Comma-separated format supported. Space-separated format supported with the exception of a few edge cases (ex: hsl(200grad+.1%62%/1)).
  7088. * If given value is not a string, then it returns false.
  7089. */
  7090. function IsHSL(validationOptions) {
  7091. return ValidateBy({
  7092. name: IS_HSL,
  7093. validator: {
  7094. validate: function (value, args) { return isHSL(value); },
  7095. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a HSL color'; }, validationOptions),
  7096. },
  7097. }, validationOptions);
  7098. }
  7099. var isIBAN$2 = {};
  7100. Object.defineProperty(isIBAN$2, "__esModule", {
  7101. value: true
  7102. });
  7103. var _default$2 = isIBAN$2.default = isIBAN$1;
  7104. isIBAN$2.locales = void 0;
  7105. var _assertString$3 = _interopRequireDefault$3(assertString.exports);
  7106. function _interopRequireDefault$3(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7107. /**
  7108. * List of country codes with
  7109. * corresponding IBAN regular expression
  7110. * Reference: https://en.wikipedia.org/wiki/International_Bank_Account_Number
  7111. */
  7112. var ibanRegexThroughCountryCode = {
  7113. AD: /^(AD[0-9]{2})\d{8}[A-Z0-9]{12}$/,
  7114. AE: /^(AE[0-9]{2})\d{3}\d{16}$/,
  7115. AL: /^(AL[0-9]{2})\d{8}[A-Z0-9]{16}$/,
  7116. AT: /^(AT[0-9]{2})\d{16}$/,
  7117. AZ: /^(AZ[0-9]{2})[A-Z0-9]{4}\d{20}$/,
  7118. BA: /^(BA[0-9]{2})\d{16}$/,
  7119. BE: /^(BE[0-9]{2})\d{12}$/,
  7120. BG: /^(BG[0-9]{2})[A-Z]{4}\d{6}[A-Z0-9]{8}$/,
  7121. BH: /^(BH[0-9]{2})[A-Z]{4}[A-Z0-9]{14}$/,
  7122. BR: /^(BR[0-9]{2})\d{23}[A-Z]{1}[A-Z0-9]{1}$/,
  7123. BY: /^(BY[0-9]{2})[A-Z0-9]{4}\d{20}$/,
  7124. CH: /^(CH[0-9]{2})\d{5}[A-Z0-9]{12}$/,
  7125. CR: /^(CR[0-9]{2})\d{18}$/,
  7126. CY: /^(CY[0-9]{2})\d{8}[A-Z0-9]{16}$/,
  7127. CZ: /^(CZ[0-9]{2})\d{20}$/,
  7128. DE: /^(DE[0-9]{2})\d{18}$/,
  7129. DK: /^(DK[0-9]{2})\d{14}$/,
  7130. DO: /^(DO[0-9]{2})[A-Z]{4}\d{20}$/,
  7131. EE: /^(EE[0-9]{2})\d{16}$/,
  7132. EG: /^(EG[0-9]{2})\d{25}$/,
  7133. ES: /^(ES[0-9]{2})\d{20}$/,
  7134. FI: /^(FI[0-9]{2})\d{14}$/,
  7135. FO: /^(FO[0-9]{2})\d{14}$/,
  7136. FR: /^(FR[0-9]{2})\d{10}[A-Z0-9]{11}\d{2}$/,
  7137. GB: /^(GB[0-9]{2})[A-Z]{4}\d{14}$/,
  7138. GE: /^(GE[0-9]{2})[A-Z0-9]{2}\d{16}$/,
  7139. GI: /^(GI[0-9]{2})[A-Z]{4}[A-Z0-9]{15}$/,
  7140. GL: /^(GL[0-9]{2})\d{14}$/,
  7141. GR: /^(GR[0-9]{2})\d{7}[A-Z0-9]{16}$/,
  7142. GT: /^(GT[0-9]{2})[A-Z0-9]{4}[A-Z0-9]{20}$/,
  7143. HR: /^(HR[0-9]{2})\d{17}$/,
  7144. HU: /^(HU[0-9]{2})\d{24}$/,
  7145. IE: /^(IE[0-9]{2})[A-Z0-9]{4}\d{14}$/,
  7146. IL: /^(IL[0-9]{2})\d{19}$/,
  7147. IQ: /^(IQ[0-9]{2})[A-Z]{4}\d{15}$/,
  7148. IR: /^(IR[0-9]{2})0\d{2}0\d{18}$/,
  7149. IS: /^(IS[0-9]{2})\d{22}$/,
  7150. IT: /^(IT[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/,
  7151. JO: /^(JO[0-9]{2})[A-Z]{4}\d{22}$/,
  7152. KW: /^(KW[0-9]{2})[A-Z]{4}[A-Z0-9]{22}$/,
  7153. KZ: /^(KZ[0-9]{2})\d{3}[A-Z0-9]{13}$/,
  7154. LB: /^(LB[0-9]{2})\d{4}[A-Z0-9]{20}$/,
  7155. LC: /^(LC[0-9]{2})[A-Z]{4}[A-Z0-9]{24}$/,
  7156. LI: /^(LI[0-9]{2})\d{5}[A-Z0-9]{12}$/,
  7157. LT: /^(LT[0-9]{2})\d{16}$/,
  7158. LU: /^(LU[0-9]{2})\d{3}[A-Z0-9]{13}$/,
  7159. LV: /^(LV[0-9]{2})[A-Z]{4}[A-Z0-9]{13}$/,
  7160. MC: /^(MC[0-9]{2})\d{10}[A-Z0-9]{11}\d{2}$/,
  7161. MD: /^(MD[0-9]{2})[A-Z0-9]{20}$/,
  7162. ME: /^(ME[0-9]{2})\d{18}$/,
  7163. MK: /^(MK[0-9]{2})\d{3}[A-Z0-9]{10}\d{2}$/,
  7164. MR: /^(MR[0-9]{2})\d{23}$/,
  7165. MT: /^(MT[0-9]{2})[A-Z]{4}\d{5}[A-Z0-9]{18}$/,
  7166. MU: /^(MU[0-9]{2})[A-Z]{4}\d{19}[A-Z]{3}$/,
  7167. MZ: /^(MZ[0-9]{2})\d{21}$/,
  7168. NL: /^(NL[0-9]{2})[A-Z]{4}\d{10}$/,
  7169. NO: /^(NO[0-9]{2})\d{11}$/,
  7170. PK: /^(PK[0-9]{2})[A-Z0-9]{4}\d{16}$/,
  7171. PL: /^(PL[0-9]{2})\d{24}$/,
  7172. PS: /^(PS[0-9]{2})[A-Z0-9]{4}\d{21}$/,
  7173. PT: /^(PT[0-9]{2})\d{21}$/,
  7174. QA: /^(QA[0-9]{2})[A-Z]{4}[A-Z0-9]{21}$/,
  7175. RO: /^(RO[0-9]{2})[A-Z]{4}[A-Z0-9]{16}$/,
  7176. RS: /^(RS[0-9]{2})\d{18}$/,
  7177. SA: /^(SA[0-9]{2})\d{2}[A-Z0-9]{18}$/,
  7178. SC: /^(SC[0-9]{2})[A-Z]{4}\d{20}[A-Z]{3}$/,
  7179. SE: /^(SE[0-9]{2})\d{20}$/,
  7180. SI: /^(SI[0-9]{2})\d{15}$/,
  7181. SK: /^(SK[0-9]{2})\d{20}$/,
  7182. SM: /^(SM[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/,
  7183. SV: /^(SV[0-9]{2})[A-Z0-9]{4}\d{20}$/,
  7184. TL: /^(TL[0-9]{2})\d{19}$/,
  7185. TN: /^(TN[0-9]{2})\d{20}$/,
  7186. TR: /^(TR[0-9]{2})\d{5}[A-Z0-9]{17}$/,
  7187. UA: /^(UA[0-9]{2})\d{6}[A-Z0-9]{19}$/,
  7188. VA: /^(VA[0-9]{2})\d{18}$/,
  7189. VG: /^(VG[0-9]{2})[A-Z0-9]{4}\d{16}$/,
  7190. XK: /^(XK[0-9]{2})\d{16}$/
  7191. };
  7192. /**
  7193. * Check whether string has correct universal IBAN format
  7194. * The IBAN consists of up to 34 alphanumeric characters, as follows:
  7195. * Country Code using ISO 3166-1 alpha-2, two letters
  7196. * check digits, two digits and
  7197. * Basic Bank Account Number (BBAN), up to 30 alphanumeric characters.
  7198. * NOTE: Permitted IBAN characters are: digits [0-9] and the 26 latin alphabetic [A-Z]
  7199. *
  7200. * @param {string} str - string under validation
  7201. * @return {boolean}
  7202. */
  7203. function hasValidIbanFormat(str) {
  7204. // Strip white spaces and hyphens
  7205. var strippedStr = str.replace(/[\s\-]+/gi, '').toUpperCase();
  7206. var isoCountryCode = strippedStr.slice(0, 2).toUpperCase();
  7207. return isoCountryCode in ibanRegexThroughCountryCode && ibanRegexThroughCountryCode[isoCountryCode].test(strippedStr);
  7208. }
  7209. /**
  7210. * Check whether string has valid IBAN Checksum
  7211. * by performing basic mod-97 operation and
  7212. * the remainder should equal 1
  7213. * -- Start by rearranging the IBAN by moving the four initial characters to the end of the string
  7214. * -- Replace each letter in the string with two digits, A -> 10, B = 11, Z = 35
  7215. * -- Interpret the string as a decimal integer and
  7216. * -- compute the remainder on division by 97 (mod 97)
  7217. * Reference: https://en.wikipedia.org/wiki/International_Bank_Account_Number
  7218. *
  7219. * @param {string} str
  7220. * @return {boolean}
  7221. */
  7222. function hasValidIbanChecksum(str) {
  7223. var strippedStr = str.replace(/[^A-Z0-9]+/gi, '').toUpperCase(); // Keep only digits and A-Z latin alphabetic
  7224. var rearranged = strippedStr.slice(4) + strippedStr.slice(0, 4);
  7225. var alphaCapsReplacedWithDigits = rearranged.replace(/[A-Z]/g, function (char) {
  7226. return char.charCodeAt(0) - 55;
  7227. });
  7228. var remainder = alphaCapsReplacedWithDigits.match(/\d{1,7}/g).reduce(function (acc, value) {
  7229. return Number(acc + value) % 97;
  7230. }, '');
  7231. return remainder === 1;
  7232. }
  7233. function isIBAN$1(str) {
  7234. (0, _assertString$3.default)(str);
  7235. return hasValidIbanFormat(str) && hasValidIbanChecksum(str);
  7236. }
  7237. var locales$1 = Object.keys(ibanRegexThroughCountryCode);
  7238. isIBAN$2.locales = locales$1;
  7239. var IS_IBAN = 'isIBAN';
  7240. /**
  7241. * Check if a string is a IBAN (International Bank Account Number).
  7242. * If given value is not a string, then it returns false.
  7243. */
  7244. function isIBAN(value) {
  7245. return typeof value === 'string' && _default$2(value);
  7246. }
  7247. /**
  7248. * Check if a string is a IBAN (International Bank Account Number).
  7249. * If given value is not a string, then it returns false.
  7250. */
  7251. function IsIBAN(validationOptions) {
  7252. return ValidateBy({
  7253. name: IS_IBAN,
  7254. validator: {
  7255. validate: function (value, args) { return isIBAN(value); },
  7256. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be an IBAN'; }, validationOptions),
  7257. },
  7258. }, validationOptions);
  7259. }
  7260. var isIdentityCard$1 = {exports: {}};
  7261. (function (module, exports) {
  7262. Object.defineProperty(exports, "__esModule", {
  7263. value: true
  7264. });
  7265. exports.default = isIdentityCard;
  7266. var _assertString = _interopRequireDefault(assertString.exports);
  7267. var _isInt = _interopRequireDefault(isInt$1.exports);
  7268. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7269. var validators = {
  7270. PL: function PL(str) {
  7271. (0, _assertString.default)(str);
  7272. var weightOfDigits = {
  7273. 1: 1,
  7274. 2: 3,
  7275. 3: 7,
  7276. 4: 9,
  7277. 5: 1,
  7278. 6: 3,
  7279. 7: 7,
  7280. 8: 9,
  7281. 9: 1,
  7282. 10: 3,
  7283. 11: 0
  7284. };
  7285. if (str != null && str.length === 11 && (0, _isInt.default)(str, {
  7286. allow_leading_zeroes: true
  7287. })) {
  7288. var digits = str.split('').slice(0, -1);
  7289. var sum = digits.reduce(function (acc, digit, index) {
  7290. return acc + Number(digit) * weightOfDigits[index + 1];
  7291. }, 0);
  7292. var modulo = sum % 10;
  7293. var lastDigit = Number(str.charAt(str.length - 1));
  7294. if (modulo === 0 && lastDigit === 0 || lastDigit === 10 - modulo) {
  7295. return true;
  7296. }
  7297. }
  7298. return false;
  7299. },
  7300. ES: function ES(str) {
  7301. (0, _assertString.default)(str);
  7302. var DNI = /^[0-9X-Z][0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKE]$/;
  7303. var charsValue = {
  7304. X: 0,
  7305. Y: 1,
  7306. Z: 2
  7307. };
  7308. var controlDigits = ['T', 'R', 'W', 'A', 'G', 'M', 'Y', 'F', 'P', 'D', 'X', 'B', 'N', 'J', 'Z', 'S', 'Q', 'V', 'H', 'L', 'C', 'K', 'E']; // sanitize user input
  7309. var sanitized = str.trim().toUpperCase(); // validate the data structure
  7310. if (!DNI.test(sanitized)) {
  7311. return false;
  7312. } // validate the control digit
  7313. var number = sanitized.slice(0, -1).replace(/[X,Y,Z]/g, function (char) {
  7314. return charsValue[char];
  7315. });
  7316. return sanitized.endsWith(controlDigits[number % 23]);
  7317. },
  7318. FI: function FI(str) {
  7319. // https://dvv.fi/en/personal-identity-code#:~:text=control%20character%20for%20a-,personal,-identity%20code%20calculated
  7320. (0, _assertString.default)(str);
  7321. if (str.length !== 11) {
  7322. return false;
  7323. }
  7324. if (!str.match(/^\d{6}[\-A\+]\d{3}[0-9ABCDEFHJKLMNPRSTUVWXY]{1}$/)) {
  7325. return false;
  7326. }
  7327. var checkDigits = '0123456789ABCDEFHJKLMNPRSTUVWXY';
  7328. var idAsNumber = parseInt(str.slice(0, 6), 10) * 1000 + parseInt(str.slice(7, 10), 10);
  7329. var remainder = idAsNumber % 31;
  7330. var checkDigit = checkDigits[remainder];
  7331. return checkDigit === str.slice(10, 11);
  7332. },
  7333. IN: function IN(str) {
  7334. var DNI = /^[1-9]\d{3}\s?\d{4}\s?\d{4}$/; // multiplication table
  7335. var d = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 0, 6, 7, 8, 9, 5], [2, 3, 4, 0, 1, 7, 8, 9, 5, 6], [3, 4, 0, 1, 2, 8, 9, 5, 6, 7], [4, 0, 1, 2, 3, 9, 5, 6, 7, 8], [5, 9, 8, 7, 6, 0, 4, 3, 2, 1], [6, 5, 9, 8, 7, 1, 0, 4, 3, 2], [7, 6, 5, 9, 8, 2, 1, 0, 4, 3], [8, 7, 6, 5, 9, 3, 2, 1, 0, 4], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]; // permutation table
  7336. var p = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 5, 7, 6, 2, 8, 3, 0, 9, 4], [5, 8, 0, 3, 7, 9, 6, 1, 4, 2], [8, 9, 1, 6, 0, 4, 3, 5, 2, 7], [9, 4, 5, 3, 1, 2, 6, 8, 7, 0], [4, 2, 8, 6, 5, 7, 3, 9, 0, 1], [2, 7, 9, 3, 8, 0, 6, 4, 1, 5], [7, 0, 4, 6, 9, 1, 3, 2, 5, 8]]; // sanitize user input
  7337. var sanitized = str.trim(); // validate the data structure
  7338. if (!DNI.test(sanitized)) {
  7339. return false;
  7340. }
  7341. var c = 0;
  7342. var invertedArray = sanitized.replace(/\s/g, '').split('').map(Number).reverse();
  7343. invertedArray.forEach(function (val, i) {
  7344. c = d[c][p[i % 8][val]];
  7345. });
  7346. return c === 0;
  7347. },
  7348. IR: function IR(str) {
  7349. if (!str.match(/^\d{10}$/)) return false;
  7350. str = "0000".concat(str).substr(str.length - 6);
  7351. if (parseInt(str.substr(3, 6), 10) === 0) return false;
  7352. var lastNumber = parseInt(str.substr(9, 1), 10);
  7353. var sum = 0;
  7354. for (var i = 0; i < 9; i++) {
  7355. sum += parseInt(str.substr(i, 1), 10) * (10 - i);
  7356. }
  7357. sum %= 11;
  7358. return sum < 2 && lastNumber === sum || sum >= 2 && lastNumber === 11 - sum;
  7359. },
  7360. IT: function IT(str) {
  7361. if (str.length !== 9) return false;
  7362. if (str === 'CA00000AA') return false; // https://it.wikipedia.org/wiki/Carta_d%27identit%C3%A0_elettronica_italiana
  7363. return str.search(/C[A-Z][0-9]{5}[A-Z]{2}/i) > -1;
  7364. },
  7365. NO: function NO(str) {
  7366. var sanitized = str.trim();
  7367. if (isNaN(Number(sanitized))) return false;
  7368. if (sanitized.length !== 11) return false;
  7369. if (sanitized === '00000000000') return false; // https://no.wikipedia.org/wiki/F%C3%B8dselsnummer
  7370. var f = sanitized.split('').map(Number);
  7371. var k1 = (11 - (3 * f[0] + 7 * f[1] + 6 * f[2] + 1 * f[3] + 8 * f[4] + 9 * f[5] + 4 * f[6] + 5 * f[7] + 2 * f[8]) % 11) % 11;
  7372. var k2 = (11 - (5 * f[0] + 4 * f[1] + 3 * f[2] + 2 * f[3] + 7 * f[4] + 6 * f[5] + 5 * f[6] + 4 * f[7] + 3 * f[8] + 2 * k1) % 11) % 11;
  7373. if (k1 !== f[9] || k2 !== f[10]) return false;
  7374. return true;
  7375. },
  7376. TH: function TH(str) {
  7377. if (!str.match(/^[1-8]\d{12}$/)) return false; // validate check digit
  7378. var sum = 0;
  7379. for (var i = 0; i < 12; i++) {
  7380. sum += parseInt(str[i], 10) * (13 - i);
  7381. }
  7382. return str[12] === ((11 - sum % 11) % 10).toString();
  7383. },
  7384. LK: function LK(str) {
  7385. var old_nic = /^[1-9]\d{8}[vx]$/i;
  7386. var new_nic = /^[1-9]\d{11}$/i;
  7387. if (str.length === 10 && old_nic.test(str)) return true;else if (str.length === 12 && new_nic.test(str)) return true;
  7388. return false;
  7389. },
  7390. 'he-IL': function heIL(str) {
  7391. var DNI = /^\d{9}$/; // sanitize user input
  7392. var sanitized = str.trim(); // validate the data structure
  7393. if (!DNI.test(sanitized)) {
  7394. return false;
  7395. }
  7396. var id = sanitized;
  7397. var sum = 0,
  7398. incNum;
  7399. for (var i = 0; i < id.length; i++) {
  7400. incNum = Number(id[i]) * (i % 2 + 1); // Multiply number by 1 or 2
  7401. sum += incNum > 9 ? incNum - 9 : incNum; // Sum the digits up and add to total
  7402. }
  7403. return sum % 10 === 0;
  7404. },
  7405. 'ar-LY': function arLY(str) {
  7406. // Libya National Identity Number NIN is 12 digits, the first digit is either 1 or 2
  7407. var NIN = /^(1|2)\d{11}$/; // sanitize user input
  7408. var sanitized = str.trim(); // validate the data structure
  7409. if (!NIN.test(sanitized)) {
  7410. return false;
  7411. }
  7412. return true;
  7413. },
  7414. 'ar-TN': function arTN(str) {
  7415. var DNI = /^\d{8}$/; // sanitize user input
  7416. var sanitized = str.trim(); // validate the data structure
  7417. if (!DNI.test(sanitized)) {
  7418. return false;
  7419. }
  7420. return true;
  7421. },
  7422. 'zh-CN': function zhCN(str) {
  7423. var provincesAndCities = ['11', // 北京
  7424. '12', // 天津
  7425. '13', // 河北
  7426. '14', // 山西
  7427. '15', // 内蒙古
  7428. '21', // 辽宁
  7429. '22', // 吉林
  7430. '23', // 黑龙江
  7431. '31', // 上海
  7432. '32', // 江苏
  7433. '33', // 浙江
  7434. '34', // 安徽
  7435. '35', // 福建
  7436. '36', // 江西
  7437. '37', // 山东
  7438. '41', // 河南
  7439. '42', // 湖北
  7440. '43', // 湖南
  7441. '44', // 广东
  7442. '45', // 广西
  7443. '46', // 海南
  7444. '50', // 重庆
  7445. '51', // 四川
  7446. '52', // 贵州
  7447. '53', // 云南
  7448. '54', // 西藏
  7449. '61', // 陕西
  7450. '62', // 甘肃
  7451. '63', // 青海
  7452. '64', // 宁夏
  7453. '65', // 新疆
  7454. '71', // 台湾
  7455. '81', // 香港
  7456. '82', // 澳门
  7457. '91' // 国外
  7458. ];
  7459. var powers = ['7', '9', '10', '5', '8', '4', '2', '1', '6', '3', '7', '9', '10', '5', '8', '4', '2'];
  7460. var parityBit = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
  7461. var checkAddressCode = function checkAddressCode(addressCode) {
  7462. return provincesAndCities.includes(addressCode);
  7463. };
  7464. var checkBirthDayCode = function checkBirthDayCode(birDayCode) {
  7465. var yyyy = parseInt(birDayCode.substring(0, 4), 10);
  7466. var mm = parseInt(birDayCode.substring(4, 6), 10);
  7467. var dd = parseInt(birDayCode.substring(6), 10);
  7468. var xdata = new Date(yyyy, mm - 1, dd);
  7469. if (xdata > new Date()) {
  7470. return false; // eslint-disable-next-line max-len
  7471. } else if (xdata.getFullYear() === yyyy && xdata.getMonth() === mm - 1 && xdata.getDate() === dd) {
  7472. return true;
  7473. }
  7474. return false;
  7475. };
  7476. var getParityBit = function getParityBit(idCardNo) {
  7477. var id17 = idCardNo.substring(0, 17);
  7478. var power = 0;
  7479. for (var i = 0; i < 17; i++) {
  7480. power += parseInt(id17.charAt(i), 10) * parseInt(powers[i], 10);
  7481. }
  7482. var mod = power % 11;
  7483. return parityBit[mod];
  7484. };
  7485. var checkParityBit = function checkParityBit(idCardNo) {
  7486. return getParityBit(idCardNo) === idCardNo.charAt(17).toUpperCase();
  7487. };
  7488. var check15IdCardNo = function check15IdCardNo(idCardNo) {
  7489. var check = /^[1-9]\d{7}((0[1-9])|(1[0-2]))((0[1-9])|([1-2][0-9])|(3[0-1]))\d{3}$/.test(idCardNo);
  7490. if (!check) return false;
  7491. var addressCode = idCardNo.substring(0, 2);
  7492. check = checkAddressCode(addressCode);
  7493. if (!check) return false;
  7494. var birDayCode = "19".concat(idCardNo.substring(6, 12));
  7495. check = checkBirthDayCode(birDayCode);
  7496. if (!check) return false;
  7497. return true;
  7498. };
  7499. var check18IdCardNo = function check18IdCardNo(idCardNo) {
  7500. var check = /^[1-9]\d{5}[1-9]\d{3}((0[1-9])|(1[0-2]))((0[1-9])|([1-2][0-9])|(3[0-1]))\d{3}(\d|x|X)$/.test(idCardNo);
  7501. if (!check) return false;
  7502. var addressCode = idCardNo.substring(0, 2);
  7503. check = checkAddressCode(addressCode);
  7504. if (!check) return false;
  7505. var birDayCode = idCardNo.substring(6, 14);
  7506. check = checkBirthDayCode(birDayCode);
  7507. if (!check) return false;
  7508. return checkParityBit(idCardNo);
  7509. };
  7510. var checkIdCardNo = function checkIdCardNo(idCardNo) {
  7511. var check = /^\d{15}|(\d{17}(\d|x|X))$/.test(idCardNo);
  7512. if (!check) return false;
  7513. if (idCardNo.length === 15) {
  7514. return check15IdCardNo(idCardNo);
  7515. }
  7516. return check18IdCardNo(idCardNo);
  7517. };
  7518. return checkIdCardNo(str);
  7519. },
  7520. 'zh-TW': function zhTW(str) {
  7521. var ALPHABET_CODES = {
  7522. A: 10,
  7523. B: 11,
  7524. C: 12,
  7525. D: 13,
  7526. E: 14,
  7527. F: 15,
  7528. G: 16,
  7529. H: 17,
  7530. I: 34,
  7531. J: 18,
  7532. K: 19,
  7533. L: 20,
  7534. M: 21,
  7535. N: 22,
  7536. O: 35,
  7537. P: 23,
  7538. Q: 24,
  7539. R: 25,
  7540. S: 26,
  7541. T: 27,
  7542. U: 28,
  7543. V: 29,
  7544. W: 32,
  7545. X: 30,
  7546. Y: 31,
  7547. Z: 33
  7548. };
  7549. var sanitized = str.trim().toUpperCase();
  7550. if (!/^[A-Z][0-9]{9}$/.test(sanitized)) return false;
  7551. return Array.from(sanitized).reduce(function (sum, number, index) {
  7552. if (index === 0) {
  7553. var code = ALPHABET_CODES[number];
  7554. return code % 10 * 9 + Math.floor(code / 10);
  7555. }
  7556. if (index === 9) {
  7557. return (10 - sum % 10 - Number(number)) % 10 === 0;
  7558. }
  7559. return sum + Number(number) * (9 - index);
  7560. }, 0);
  7561. }
  7562. };
  7563. function isIdentityCard(str, locale) {
  7564. (0, _assertString.default)(str);
  7565. if (locale in validators) {
  7566. return validators[locale](str);
  7567. } else if (locale === 'any') {
  7568. for (var key in validators) {
  7569. // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
  7570. // istanbul ignore else
  7571. if (validators.hasOwnProperty(key)) {
  7572. var validator = validators[key];
  7573. if (validator(str)) {
  7574. return true;
  7575. }
  7576. }
  7577. }
  7578. return false;
  7579. }
  7580. throw new Error("Invalid locale '".concat(locale, "'"));
  7581. }
  7582. module.exports = exports.default;
  7583. module.exports.default = exports.default;
  7584. } (isIdentityCard$1, isIdentityCard$1.exports));
  7585. var isIdentityCardValidator = /*@__PURE__*/getDefaultExportFromCjs(isIdentityCard$1.exports);
  7586. var IS_IDENTITY_CARD = 'isIdentityCard';
  7587. /**
  7588. * Check if the string is a valid identity card code.
  7589. * locale is one of ['ES', 'zh-TW', 'he-IL', 'ar-TN'] OR 'any'. If 'any' is used, function will check if any of the locals match.
  7590. * Defaults to 'any'.
  7591. * If given value is not a string, then it returns false.
  7592. */
  7593. function isIdentityCard(value, locale) {
  7594. return typeof value === 'string' && isIdentityCardValidator(value, locale);
  7595. }
  7596. /**
  7597. * Check if the string is a valid identity card code.
  7598. * locale is one of ['ES', 'zh-TW', 'he-IL', 'ar-TN'] OR 'any'. If 'any' is used, function will check if any of the locals match.
  7599. * Defaults to 'any'.
  7600. * If given value is not a string, then it returns false.
  7601. */
  7602. function IsIdentityCard(locale, validationOptions) {
  7603. return ValidateBy({
  7604. name: IS_IDENTITY_CARD,
  7605. constraints: [locale],
  7606. validator: {
  7607. validate: function (value, args) { return isIdentityCard(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  7608. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a identity card number'; }, validationOptions),
  7609. },
  7610. }, validationOptions);
  7611. }
  7612. var isISRC$1 = {exports: {}};
  7613. (function (module, exports) {
  7614. Object.defineProperty(exports, "__esModule", {
  7615. value: true
  7616. });
  7617. exports.default = isISRC;
  7618. var _assertString = _interopRequireDefault(assertString.exports);
  7619. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7620. // see http://isrc.ifpi.org/en/isrc-standard/code-syntax
  7621. var isrc = /^[A-Z]{2}[0-9A-Z]{3}\d{2}\d{5}$/;
  7622. function isISRC(str) {
  7623. (0, _assertString.default)(str);
  7624. return isrc.test(str);
  7625. }
  7626. module.exports = exports.default;
  7627. module.exports.default = exports.default;
  7628. } (isISRC$1, isISRC$1.exports));
  7629. var isISRCValidator = /*@__PURE__*/getDefaultExportFromCjs(isISRC$1.exports);
  7630. var IS_ISRC = 'isISRC';
  7631. /**
  7632. * Check if the string is a ISRC.
  7633. * If given value is not a string, then it returns false.
  7634. */
  7635. function isISRC(value) {
  7636. return typeof value === 'string' && isISRCValidator(value);
  7637. }
  7638. /**
  7639. * Check if the string is a ISRC.
  7640. * If given value is not a string, then it returns false.
  7641. */
  7642. function IsISRC(validationOptions) {
  7643. return ValidateBy({
  7644. name: IS_ISRC,
  7645. validator: {
  7646. validate: function (value, args) { return isISRC(value); },
  7647. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be an ISRC'; }, validationOptions),
  7648. },
  7649. }, validationOptions);
  7650. }
  7651. var isLocale$1 = {exports: {}};
  7652. (function (module, exports) {
  7653. Object.defineProperty(exports, "__esModule", {
  7654. value: true
  7655. });
  7656. exports.default = isLocale;
  7657. var _assertString = _interopRequireDefault(assertString.exports);
  7658. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7659. var localeReg = /^[A-Za-z]{2,4}([_-]([A-Za-z]{4}|[\d]{3}))?([_-]([A-Za-z]{2}|[\d]{3}))?$/;
  7660. function isLocale(str) {
  7661. (0, _assertString.default)(str);
  7662. if (str === 'en_US_POSIX' || str === 'ca_ES_VALENCIA') {
  7663. return true;
  7664. }
  7665. return localeReg.test(str);
  7666. }
  7667. module.exports = exports.default;
  7668. module.exports.default = exports.default;
  7669. } (isLocale$1, isLocale$1.exports));
  7670. var isLocaleValidator = /*@__PURE__*/getDefaultExportFromCjs(isLocale$1.exports);
  7671. var IS_LOCALE = 'isLocale';
  7672. /**
  7673. * Check if the string is a locale.
  7674. * If given value is not a string, then it returns false.
  7675. */
  7676. function isLocale(value) {
  7677. return typeof value === 'string' && isLocaleValidator(value);
  7678. }
  7679. /**
  7680. * Check if the string is a locale.
  7681. * If given value is not a string, then it returns false.
  7682. */
  7683. function IsLocale(validationOptions) {
  7684. return ValidateBy({
  7685. name: IS_LOCALE,
  7686. validator: {
  7687. validate: function (value, args) { return isLocale(value); },
  7688. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be locale'; }, validationOptions),
  7689. },
  7690. }, validationOptions);
  7691. }
  7692. var isMagnetURI$1 = {exports: {}};
  7693. (function (module, exports) {
  7694. Object.defineProperty(exports, "__esModule", {
  7695. value: true
  7696. });
  7697. exports.default = isMagnetURI;
  7698. var _assertString = _interopRequireDefault(assertString.exports);
  7699. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7700. var magnetURI = /^magnet:\?xt(?:\.1)?=urn:(?:aich|bitprint|btih|ed2k|ed2khash|kzhash|md5|sha1|tree:tiger):[a-z0-9]{32}(?:[a-z0-9]{8})?($|&)/i;
  7701. function isMagnetURI(url) {
  7702. (0, _assertString.default)(url);
  7703. return magnetURI.test(url.trim());
  7704. }
  7705. module.exports = exports.default;
  7706. module.exports.default = exports.default;
  7707. } (isMagnetURI$1, isMagnetURI$1.exports));
  7708. var isMagnetURIValidator = /*@__PURE__*/getDefaultExportFromCjs(isMagnetURI$1.exports);
  7709. var IS_MAGNET_URI = 'isMagnetURI';
  7710. /**
  7711. * Check if the string is a magnet uri format.
  7712. * If given value is not a string, then it returns false.
  7713. */
  7714. function isMagnetURI(value) {
  7715. return typeof value === 'string' && isMagnetURIValidator(value);
  7716. }
  7717. /**
  7718. * Check if the string is a magnet uri format.
  7719. * If given value is not a string, then it returns false.
  7720. */
  7721. function IsMagnetURI(validationOptions) {
  7722. return ValidateBy({
  7723. name: IS_MAGNET_URI,
  7724. validator: {
  7725. validate: function (value, args) { return isMagnetURI(value); },
  7726. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be magnet uri format'; }, validationOptions),
  7727. },
  7728. }, validationOptions);
  7729. }
  7730. var isMimeType$1 = {exports: {}};
  7731. (function (module, exports) {
  7732. Object.defineProperty(exports, "__esModule", {
  7733. value: true
  7734. });
  7735. exports.default = isMimeType;
  7736. var _assertString = _interopRequireDefault(assertString.exports);
  7737. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7738. /*
  7739. Checks if the provided string matches to a correct Media type format (MIME type)
  7740. This function only checks is the string format follows the
  7741. etablished rules by the according RFC specifications.
  7742. This function supports 'charset' in textual media types
  7743. (https://tools.ietf.org/html/rfc6657).
  7744. This function does not check against all the media types listed
  7745. by the IANA (https://www.iana.org/assignments/media-types/media-types.xhtml)
  7746. because of lightness purposes : it would require to include
  7747. all these MIME types in this librairy, which would weigh it
  7748. significantly. This kind of effort maybe is not worth for the use that
  7749. this function has in this entire librairy.
  7750. More informations in the RFC specifications :
  7751. - https://tools.ietf.org/html/rfc2045
  7752. - https://tools.ietf.org/html/rfc2046
  7753. - https://tools.ietf.org/html/rfc7231#section-3.1.1.1
  7754. - https://tools.ietf.org/html/rfc7231#section-3.1.1.5
  7755. */
  7756. // Match simple MIME types
  7757. // NB :
  7758. // Subtype length must not exceed 100 characters.
  7759. // This rule does not comply to the RFC specs (what is the max length ?).
  7760. var mimeTypeSimple = /^(application|audio|font|image|message|model|multipart|text|video)\/[a-zA-Z0-9\.\-\+]{1,100}$/i; // eslint-disable-line max-len
  7761. // Handle "charset" in "text/*"
  7762. var mimeTypeText = /^text\/[a-zA-Z0-9\.\-\+]{1,100};\s?charset=("[a-zA-Z0-9\.\-\+\s]{0,70}"|[a-zA-Z0-9\.\-\+]{0,70})(\s?\([a-zA-Z0-9\.\-\+\s]{1,20}\))?$/i; // eslint-disable-line max-len
  7763. // Handle "boundary" in "multipart/*"
  7764. var mimeTypeMultipart = /^multipart\/[a-zA-Z0-9\.\-\+]{1,100}(;\s?(boundary|charset)=("[a-zA-Z0-9\.\-\+\s]{0,70}"|[a-zA-Z0-9\.\-\+]{0,70})(\s?\([a-zA-Z0-9\.\-\+\s]{1,20}\))?){0,2}$/i; // eslint-disable-line max-len
  7765. function isMimeType(str) {
  7766. (0, _assertString.default)(str);
  7767. return mimeTypeSimple.test(str) || mimeTypeText.test(str) || mimeTypeMultipart.test(str);
  7768. }
  7769. module.exports = exports.default;
  7770. module.exports.default = exports.default;
  7771. } (isMimeType$1, isMimeType$1.exports));
  7772. var isMimeTypeValidator = /*@__PURE__*/getDefaultExportFromCjs(isMimeType$1.exports);
  7773. var IS_MIME_TYPE = 'isMimeType';
  7774. /**
  7775. * Check if the string matches to a valid MIME type format
  7776. * If given value is not a string, then it returns false.
  7777. */
  7778. function isMimeType(value) {
  7779. return typeof value === 'string' && isMimeTypeValidator(value);
  7780. }
  7781. /**
  7782. * Check if the string matches to a valid MIME type format
  7783. * If given value is not a string, then it returns false.
  7784. */
  7785. function IsMimeType(validationOptions) {
  7786. return ValidateBy({
  7787. name: IS_MIME_TYPE,
  7788. validator: {
  7789. validate: function (value, args) { return isMimeType(value); },
  7790. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be MIME type format'; }, validationOptions),
  7791. },
  7792. }, validationOptions);
  7793. }
  7794. var isOctal$1 = {exports: {}};
  7795. (function (module, exports) {
  7796. Object.defineProperty(exports, "__esModule", {
  7797. value: true
  7798. });
  7799. exports.default = isOctal;
  7800. var _assertString = _interopRequireDefault(assertString.exports);
  7801. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7802. var octal = /^(0o)?[0-7]+$/i;
  7803. function isOctal(str) {
  7804. (0, _assertString.default)(str);
  7805. return octal.test(str);
  7806. }
  7807. module.exports = exports.default;
  7808. module.exports.default = exports.default;
  7809. } (isOctal$1, isOctal$1.exports));
  7810. var isOctalValidator = /*@__PURE__*/getDefaultExportFromCjs(isOctal$1.exports);
  7811. var IS_OCTAL = 'isOctal';
  7812. /**
  7813. * Check if the string is a valid octal number.
  7814. * If given value is not a string, then it returns false.
  7815. */
  7816. function isOctal(value) {
  7817. return typeof value === 'string' && isOctalValidator(value);
  7818. }
  7819. /**
  7820. * Check if the string is a valid octal number.
  7821. * If given value is not a string, then it returns false.
  7822. */
  7823. function IsOctal(validationOptions) {
  7824. return ValidateBy({
  7825. name: IS_OCTAL,
  7826. validator: {
  7827. validate: function (value, args) { return isOctal(value); },
  7828. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be valid octal number'; }, validationOptions),
  7829. },
  7830. }, validationOptions);
  7831. }
  7832. var isPassportNumber$1 = {exports: {}};
  7833. (function (module, exports) {
  7834. Object.defineProperty(exports, "__esModule", {
  7835. value: true
  7836. });
  7837. exports.default = isPassportNumber;
  7838. var _assertString = _interopRequireDefault(assertString.exports);
  7839. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7840. /**
  7841. * Reference:
  7842. * https://en.wikipedia.org/ -- Wikipedia
  7843. * https://docs.microsoft.com/en-us/microsoft-365/compliance/eu-passport-number -- EU Passport Number
  7844. * https://countrycode.org/ -- Country Codes
  7845. */
  7846. var passportRegexByCountryCode = {
  7847. AM: /^[A-Z]{2}\d{7}$/,
  7848. // ARMENIA
  7849. AR: /^[A-Z]{3}\d{6}$/,
  7850. // ARGENTINA
  7851. AT: /^[A-Z]\d{7}$/,
  7852. // AUSTRIA
  7853. AU: /^[A-Z]\d{7}$/,
  7854. // AUSTRALIA
  7855. BE: /^[A-Z]{2}\d{6}$/,
  7856. // BELGIUM
  7857. BG: /^\d{9}$/,
  7858. // BULGARIA
  7859. BR: /^[A-Z]{2}\d{6}$/,
  7860. // BRAZIL
  7861. BY: /^[A-Z]{2}\d{7}$/,
  7862. // BELARUS
  7863. CA: /^[A-Z]{2}\d{6}$/,
  7864. // CANADA
  7865. CH: /^[A-Z]\d{7}$/,
  7866. // SWITZERLAND
  7867. CN: /^G\d{8}$|^E(?![IO])[A-Z0-9]\d{7}$/,
  7868. // CHINA [G=Ordinary, E=Electronic] followed by 8-digits, or E followed by any UPPERCASE letter (except I and O) followed by 7 digits
  7869. CY: /^[A-Z](\d{6}|\d{8})$/,
  7870. // CYPRUS
  7871. CZ: /^\d{8}$/,
  7872. // CZECH REPUBLIC
  7873. DE: /^[CFGHJKLMNPRTVWXYZ0-9]{9}$/,
  7874. // GERMANY
  7875. DK: /^\d{9}$/,
  7876. // DENMARK
  7877. DZ: /^\d{9}$/,
  7878. // ALGERIA
  7879. EE: /^([A-Z]\d{7}|[A-Z]{2}\d{7})$/,
  7880. // ESTONIA (K followed by 7-digits), e-passports have 2 UPPERCASE followed by 7 digits
  7881. ES: /^[A-Z0-9]{2}([A-Z0-9]?)\d{6}$/,
  7882. // SPAIN
  7883. FI: /^[A-Z]{2}\d{7}$/,
  7884. // FINLAND
  7885. FR: /^\d{2}[A-Z]{2}\d{5}$/,
  7886. // FRANCE
  7887. GB: /^\d{9}$/,
  7888. // UNITED KINGDOM
  7889. GR: /^[A-Z]{2}\d{7}$/,
  7890. // GREECE
  7891. HR: /^\d{9}$/,
  7892. // CROATIA
  7893. HU: /^[A-Z]{2}(\d{6}|\d{7})$/,
  7894. // HUNGARY
  7895. IE: /^[A-Z0-9]{2}\d{7}$/,
  7896. // IRELAND
  7897. IN: /^[A-Z]{1}-?\d{7}$/,
  7898. // INDIA
  7899. ID: /^[A-C]\d{7}$/,
  7900. // INDONESIA
  7901. IR: /^[A-Z]\d{8}$/,
  7902. // IRAN
  7903. IS: /^(A)\d{7}$/,
  7904. // ICELAND
  7905. IT: /^[A-Z0-9]{2}\d{7}$/,
  7906. // ITALY
  7907. JP: /^[A-Z]{2}\d{7}$/,
  7908. // JAPAN
  7909. KR: /^[MS]\d{8}$/,
  7910. // SOUTH KOREA, REPUBLIC OF KOREA, [S=PS Passports, M=PM Passports]
  7911. LT: /^[A-Z0-9]{8}$/,
  7912. // LITHUANIA
  7913. LU: /^[A-Z0-9]{8}$/,
  7914. // LUXEMBURG
  7915. LV: /^[A-Z0-9]{2}\d{7}$/,
  7916. // LATVIA
  7917. LY: /^[A-Z0-9]{8}$/,
  7918. // LIBYA
  7919. MT: /^\d{7}$/,
  7920. // MALTA
  7921. MZ: /^([A-Z]{2}\d{7})|(\d{2}[A-Z]{2}\d{5})$/,
  7922. // MOZAMBIQUE
  7923. MY: /^[AHK]\d{8}$/,
  7924. // MALAYSIA
  7925. NL: /^[A-Z]{2}[A-Z0-9]{6}\d$/,
  7926. // NETHERLANDS
  7927. PL: /^[A-Z]{2}\d{7}$/,
  7928. // POLAND
  7929. PT: /^[A-Z]\d{6}$/,
  7930. // PORTUGAL
  7931. RO: /^\d{8,9}$/,
  7932. // ROMANIA
  7933. RU: /^\d{9}$/,
  7934. // RUSSIAN FEDERATION
  7935. SE: /^\d{8}$/,
  7936. // SWEDEN
  7937. SL: /^(P)[A-Z]\d{7}$/,
  7938. // SLOVANIA
  7939. SK: /^[0-9A-Z]\d{7}$/,
  7940. // SLOVAKIA
  7941. TR: /^[A-Z]\d{8}$/,
  7942. // TURKEY
  7943. UA: /^[A-Z]{2}\d{6}$/,
  7944. // UKRAINE
  7945. US: /^\d{9}$/ // UNITED STATES
  7946. };
  7947. /**
  7948. * Check if str is a valid passport number
  7949. * relative to provided ISO Country Code.
  7950. *
  7951. * @param {string} str
  7952. * @param {string} countryCode
  7953. * @return {boolean}
  7954. */
  7955. function isPassportNumber(str, countryCode) {
  7956. (0, _assertString.default)(str);
  7957. /** Remove All Whitespaces, Convert to UPPERCASE */
  7958. var normalizedStr = str.replace(/\s/g, '').toUpperCase();
  7959. return countryCode.toUpperCase() in passportRegexByCountryCode && passportRegexByCountryCode[countryCode].test(normalizedStr);
  7960. }
  7961. module.exports = exports.default;
  7962. module.exports.default = exports.default;
  7963. } (isPassportNumber$1, isPassportNumber$1.exports));
  7964. var isPassportNumberValidator = /*@__PURE__*/getDefaultExportFromCjs(isPassportNumber$1.exports);
  7965. var IS_PASSPORT_NUMBER = 'isPassportNumber';
  7966. /**
  7967. * Check if the string is a valid passport number relative to a specific country code.
  7968. * If given value is not a string, then it returns false.
  7969. */
  7970. function isPassportNumber(value, countryCode) {
  7971. return typeof value === 'string' && isPassportNumberValidator(value, countryCode);
  7972. }
  7973. /**
  7974. * Check if the string is a valid passport number relative to a specific country code.
  7975. * If given value is not a string, then it returns false.
  7976. */
  7977. function IsPassportNumber(countryCode, validationOptions) {
  7978. return ValidateBy({
  7979. name: IS_PASSPORT_NUMBER,
  7980. constraints: [countryCode],
  7981. validator: {
  7982. validate: function (value, args) { return isPassportNumber(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  7983. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be valid passport number'; }, validationOptions),
  7984. },
  7985. }, validationOptions);
  7986. }
  7987. var isPostalCode$2 = {};
  7988. Object.defineProperty(isPostalCode$2, "__esModule", {
  7989. value: true
  7990. });
  7991. var _default$1 = isPostalCode$2.default = isPostalCode$1;
  7992. isPostalCode$2.locales = void 0;
  7993. var _assertString$2 = _interopRequireDefault$2(assertString.exports);
  7994. function _interopRequireDefault$2(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7995. // common patterns
  7996. var threeDigit = /^\d{3}$/;
  7997. var fourDigit = /^\d{4}$/;
  7998. var fiveDigit = /^\d{5}$/;
  7999. var sixDigit = /^\d{6}$/;
  8000. var patterns = {
  8001. AD: /^AD\d{3}$/,
  8002. AT: fourDigit,
  8003. AU: fourDigit,
  8004. AZ: /^AZ\d{4}$/,
  8005. BE: fourDigit,
  8006. BG: fourDigit,
  8007. BR: /^\d{5}-\d{3}$/,
  8008. BY: /2[1-4]{1}\d{4}$/,
  8009. CA: /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,
  8010. CH: fourDigit,
  8011. CN: /^(0[1-7]|1[012356]|2[0-7]|3[0-6]|4[0-7]|5[1-7]|6[1-7]|7[1-5]|8[1345]|9[09])\d{4}$/,
  8012. CZ: /^\d{3}\s?\d{2}$/,
  8013. DE: fiveDigit,
  8014. DK: fourDigit,
  8015. DO: fiveDigit,
  8016. DZ: fiveDigit,
  8017. EE: fiveDigit,
  8018. ES: /^(5[0-2]{1}|[0-4]{1}\d{1})\d{3}$/,
  8019. FI: fiveDigit,
  8020. FR: /^\d{2}\s?\d{3}$/,
  8021. GB: /^(gir\s?0aa|[a-z]{1,2}\d[\da-z]?\s?(\d[a-z]{2})?)$/i,
  8022. GR: /^\d{3}\s?\d{2}$/,
  8023. HR: /^([1-5]\d{4}$)/,
  8024. HT: /^HT\d{4}$/,
  8025. HU: fourDigit,
  8026. ID: fiveDigit,
  8027. IE: /^(?!.*(?:o))[A-Za-z]\d[\dw]\s\w{4}$/i,
  8028. IL: /^(\d{5}|\d{7})$/,
  8029. IN: /^((?!10|29|35|54|55|65|66|86|87|88|89)[1-9][0-9]{5})$/,
  8030. IR: /\b(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}\b/,
  8031. IS: threeDigit,
  8032. IT: fiveDigit,
  8033. JP: /^\d{3}\-\d{4}$/,
  8034. KE: fiveDigit,
  8035. KR: /^(\d{5}|\d{6})$/,
  8036. LI: /^(948[5-9]|949[0-7])$/,
  8037. LT: /^LT\-\d{5}$/,
  8038. LU: fourDigit,
  8039. LV: /^LV\-\d{4}$/,
  8040. LK: fiveDigit,
  8041. MX: fiveDigit,
  8042. MT: /^[A-Za-z]{3}\s{0,1}\d{4}$/,
  8043. MY: fiveDigit,
  8044. NL: /^\d{4}\s?[a-z]{2}$/i,
  8045. NO: fourDigit,
  8046. NP: /^(10|21|22|32|33|34|44|45|56|57)\d{3}$|^(977)$/i,
  8047. NZ: fourDigit,
  8048. PL: /^\d{2}\-\d{3}$/,
  8049. PR: /^00[679]\d{2}([ -]\d{4})?$/,
  8050. PT: /^\d{4}\-\d{3}?$/,
  8051. RO: sixDigit,
  8052. RU: sixDigit,
  8053. SA: fiveDigit,
  8054. SE: /^[1-9]\d{2}\s?\d{2}$/,
  8055. SG: sixDigit,
  8056. SI: fourDigit,
  8057. SK: /^\d{3}\s?\d{2}$/,
  8058. TH: fiveDigit,
  8059. TN: fourDigit,
  8060. TW: /^\d{3}(\d{2})?$/,
  8061. UA: fiveDigit,
  8062. US: /^\d{5}(-\d{4})?$/,
  8063. ZA: fourDigit,
  8064. ZM: fiveDigit
  8065. };
  8066. var locales = Object.keys(patterns);
  8067. isPostalCode$2.locales = locales;
  8068. function isPostalCode$1(str, locale) {
  8069. (0, _assertString$2.default)(str);
  8070. if (locale in patterns) {
  8071. return patterns[locale].test(str);
  8072. } else if (locale === 'any') {
  8073. for (var key in patterns) {
  8074. // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
  8075. // istanbul ignore else
  8076. if (patterns.hasOwnProperty(key)) {
  8077. var pattern = patterns[key];
  8078. if (pattern.test(str)) {
  8079. return true;
  8080. }
  8081. }
  8082. }
  8083. return false;
  8084. }
  8085. throw new Error("Invalid locale '".concat(locale, "'"));
  8086. }
  8087. var IS_POSTAL_CODE = 'isPostalCode';
  8088. /**
  8089. * Check if the string is a postal code, in the specified locale.
  8090. * If given value is not a string, then it returns false.
  8091. */
  8092. function isPostalCode(value, locale) {
  8093. return typeof value === 'string' && _default$1(value, locale);
  8094. }
  8095. /**
  8096. * Check if the string is a postal code, in the specified locale.
  8097. * If given value is not a string, then it returns false.
  8098. */
  8099. function IsPostalCode(locale, validationOptions) {
  8100. return ValidateBy({
  8101. name: IS_POSTAL_CODE,
  8102. constraints: [locale],
  8103. validator: {
  8104. validate: function (value, args) { return isPostalCode(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  8105. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a postal code'; }, validationOptions),
  8106. },
  8107. }, validationOptions);
  8108. }
  8109. var isRFC3339$1 = {exports: {}};
  8110. (function (module, exports) {
  8111. Object.defineProperty(exports, "__esModule", {
  8112. value: true
  8113. });
  8114. exports.default = isRFC3339;
  8115. var _assertString = _interopRequireDefault(assertString.exports);
  8116. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8117. /* Based on https://tools.ietf.org/html/rfc3339#section-5.6 */
  8118. var dateFullYear = /[0-9]{4}/;
  8119. var dateMonth = /(0[1-9]|1[0-2])/;
  8120. var dateMDay = /([12]\d|0[1-9]|3[01])/;
  8121. var timeHour = /([01][0-9]|2[0-3])/;
  8122. var timeMinute = /[0-5][0-9]/;
  8123. var timeSecond = /([0-5][0-9]|60)/;
  8124. var timeSecFrac = /(\.[0-9]+)?/;
  8125. var timeNumOffset = new RegExp("[-+]".concat(timeHour.source, ":").concat(timeMinute.source));
  8126. var timeOffset = new RegExp("([zZ]|".concat(timeNumOffset.source, ")"));
  8127. var partialTime = new RegExp("".concat(timeHour.source, ":").concat(timeMinute.source, ":").concat(timeSecond.source).concat(timeSecFrac.source));
  8128. var fullDate = new RegExp("".concat(dateFullYear.source, "-").concat(dateMonth.source, "-").concat(dateMDay.source));
  8129. var fullTime = new RegExp("".concat(partialTime.source).concat(timeOffset.source));
  8130. var rfc3339 = new RegExp("^".concat(fullDate.source, "[ tT]").concat(fullTime.source, "$"));
  8131. function isRFC3339(str) {
  8132. (0, _assertString.default)(str);
  8133. return rfc3339.test(str);
  8134. }
  8135. module.exports = exports.default;
  8136. module.exports.default = exports.default;
  8137. } (isRFC3339$1, isRFC3339$1.exports));
  8138. var isRFC3339Validator = /*@__PURE__*/getDefaultExportFromCjs(isRFC3339$1.exports);
  8139. var IS_RFC_3339 = 'isRFC3339';
  8140. /**
  8141. * Check if the string is a valid RFC 3339 date.
  8142. * If given value is not a string, then it returns false.
  8143. */
  8144. function isRFC3339(value) {
  8145. return typeof value === 'string' && isRFC3339Validator(value);
  8146. }
  8147. /**
  8148. * Check if the string is a valid RFC 3339 date.
  8149. * If given value is not a string, then it returns false.
  8150. */
  8151. function IsRFC3339(validationOptions) {
  8152. return ValidateBy({
  8153. name: IS_RFC_3339,
  8154. validator: {
  8155. validate: function (value, args) { return isRFC3339(value); },
  8156. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be RFC 3339 date'; }, validationOptions),
  8157. },
  8158. }, validationOptions);
  8159. }
  8160. var isRgbColor$1 = {exports: {}};
  8161. (function (module, exports) {
  8162. Object.defineProperty(exports, "__esModule", {
  8163. value: true
  8164. });
  8165. exports.default = isRgbColor;
  8166. var _assertString = _interopRequireDefault(assertString.exports);
  8167. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8168. var rgbColor = /^rgb\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){2}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\)$/;
  8169. var rgbaColor = /^rgba\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)$/;
  8170. var rgbColorPercent = /^rgb\((([0-9]%|[1-9][0-9]%|100%),){2}([0-9]%|[1-9][0-9]%|100%)\)/;
  8171. var rgbaColorPercent = /^rgba\((([0-9]%|[1-9][0-9]%|100%),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)/;
  8172. function isRgbColor(str) {
  8173. var includePercentValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  8174. (0, _assertString.default)(str);
  8175. if (!includePercentValues) {
  8176. return rgbColor.test(str) || rgbaColor.test(str);
  8177. }
  8178. return rgbColor.test(str) || rgbaColor.test(str) || rgbColorPercent.test(str) || rgbaColorPercent.test(str);
  8179. }
  8180. module.exports = exports.default;
  8181. module.exports.default = exports.default;
  8182. } (isRgbColor$1, isRgbColor$1.exports));
  8183. var isRgbColorValidator = /*@__PURE__*/getDefaultExportFromCjs(isRgbColor$1.exports);
  8184. var IS_RGB_COLOR = 'isRgbColor';
  8185. /**
  8186. * Check if the string is a rgb or rgba color.
  8187. * `includePercentValues` defaults to true. If you don't want to allow to set rgb or rgba values with percents, like rgb(5%,5%,5%), or rgba(90%,90%,90%,.3), then set it to false.
  8188. * If given value is not a string, then it returns false.
  8189. */
  8190. function isRgbColor(value, includePercentValues) {
  8191. return typeof value === 'string' && isRgbColorValidator(value, includePercentValues);
  8192. }
  8193. /**
  8194. * Check if the string is a rgb or rgba color.
  8195. * `includePercentValues` defaults to true. If you don't want to allow to set rgb or rgba values with percents, like rgb(5%,5%,5%), or rgba(90%,90%,90%,.3), then set it to false.
  8196. * If given value is not a string, then it returns false.
  8197. */
  8198. function IsRgbColor(includePercentValues, validationOptions) {
  8199. return ValidateBy({
  8200. name: IS_RGB_COLOR,
  8201. constraints: [includePercentValues],
  8202. validator: {
  8203. validate: function (value, args) { return isRgbColor(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  8204. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be RGB color'; }, validationOptions),
  8205. },
  8206. }, validationOptions);
  8207. }
  8208. var isSemVer$1 = {exports: {}};
  8209. var multilineRegex = {exports: {}};
  8210. (function (module, exports) {
  8211. Object.defineProperty(exports, "__esModule", {
  8212. value: true
  8213. });
  8214. exports.default = multilineRegexp;
  8215. /**
  8216. * Build RegExp object from an array
  8217. * of multiple/multi-line regexp parts
  8218. *
  8219. * @param {string[]} parts
  8220. * @param {string} flags
  8221. * @return {object} - RegExp object
  8222. */
  8223. function multilineRegexp(parts, flags) {
  8224. var regexpAsStringLiteral = parts.join('');
  8225. return new RegExp(regexpAsStringLiteral, flags);
  8226. }
  8227. module.exports = exports.default;
  8228. module.exports.default = exports.default;
  8229. } (multilineRegex, multilineRegex.exports));
  8230. (function (module, exports) {
  8231. Object.defineProperty(exports, "__esModule", {
  8232. value: true
  8233. });
  8234. exports.default = isSemVer;
  8235. var _assertString = _interopRequireDefault(assertString.exports);
  8236. var _multilineRegex = _interopRequireDefault(multilineRegex.exports);
  8237. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8238. /**
  8239. * Regular Expression to match
  8240. * semantic versioning (SemVer)
  8241. * built from multi-line, multi-parts regexp
  8242. * Reference: https://semver.org/
  8243. */
  8244. var semanticVersioningRegex = (0, _multilineRegex.default)(['^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)', '(?:-((?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*))*))', '?(?:\\+([0-9a-z-]+(?:\\.[0-9a-z-]+)*))?$'], 'i');
  8245. function isSemVer(str) {
  8246. (0, _assertString.default)(str);
  8247. return semanticVersioningRegex.test(str);
  8248. }
  8249. module.exports = exports.default;
  8250. module.exports.default = exports.default;
  8251. } (isSemVer$1, isSemVer$1.exports));
  8252. var isSemVerValidator = /*@__PURE__*/getDefaultExportFromCjs(isSemVer$1.exports);
  8253. var IS_SEM_VER = 'isSemVer';
  8254. /**
  8255. * Check if the string is a Semantic Versioning Specification (SemVer).
  8256. * If given value is not a string, then it returns false.
  8257. */
  8258. function isSemVer(value) {
  8259. return typeof value === 'string' && isSemVerValidator(value);
  8260. }
  8261. /**
  8262. * Check if the string is a Semantic Versioning Specification (SemVer).
  8263. * If given value is not a string, then it returns false.
  8264. */
  8265. function IsSemVer(validationOptions) {
  8266. return ValidateBy({
  8267. name: IS_SEM_VER,
  8268. validator: {
  8269. validate: function (value, args) { return isSemVer(value); },
  8270. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a Semantic Versioning Specification'; }, validationOptions),
  8271. },
  8272. }, validationOptions);
  8273. }
  8274. var validator$1 = {exports: {}};
  8275. var toDate = {exports: {}};
  8276. (function (module, exports) {
  8277. Object.defineProperty(exports, "__esModule", {
  8278. value: true
  8279. });
  8280. exports.default = toDate;
  8281. var _assertString = _interopRequireDefault(assertString.exports);
  8282. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8283. function toDate(date) {
  8284. (0, _assertString.default)(date);
  8285. date = Date.parse(date);
  8286. return !isNaN(date) ? new Date(date) : null;
  8287. }
  8288. module.exports = exports.default;
  8289. module.exports.default = exports.default;
  8290. } (toDate, toDate.exports));
  8291. var toInt = {exports: {}};
  8292. (function (module, exports) {
  8293. Object.defineProperty(exports, "__esModule", {
  8294. value: true
  8295. });
  8296. exports.default = toInt;
  8297. var _assertString = _interopRequireDefault(assertString.exports);
  8298. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8299. function toInt(str, radix) {
  8300. (0, _assertString.default)(str);
  8301. return parseInt(str, radix || 10);
  8302. }
  8303. module.exports = exports.default;
  8304. module.exports.default = exports.default;
  8305. } (toInt, toInt.exports));
  8306. var toBoolean = {exports: {}};
  8307. (function (module, exports) {
  8308. Object.defineProperty(exports, "__esModule", {
  8309. value: true
  8310. });
  8311. exports.default = toBoolean;
  8312. var _assertString = _interopRequireDefault(assertString.exports);
  8313. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8314. function toBoolean(str, strict) {
  8315. (0, _assertString.default)(str);
  8316. if (strict) {
  8317. return str === '1' || /^true$/i.test(str);
  8318. }
  8319. return str !== '0' && !/^false$/i.test(str) && str !== '';
  8320. }
  8321. module.exports = exports.default;
  8322. module.exports.default = exports.default;
  8323. } (toBoolean, toBoolean.exports));
  8324. var equals = {exports: {}};
  8325. (function (module, exports) {
  8326. Object.defineProperty(exports, "__esModule", {
  8327. value: true
  8328. });
  8329. exports.default = equals;
  8330. var _assertString = _interopRequireDefault(assertString.exports);
  8331. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8332. function equals(str, comparison) {
  8333. (0, _assertString.default)(str);
  8334. return str === comparison;
  8335. }
  8336. module.exports = exports.default;
  8337. module.exports.default = exports.default;
  8338. } (equals, equals.exports));
  8339. var isIPRange = {exports: {}};
  8340. (function (module, exports) {
  8341. Object.defineProperty(exports, "__esModule", {
  8342. value: true
  8343. });
  8344. exports.default = isIPRange;
  8345. var _assertString = _interopRequireDefault(assertString.exports);
  8346. var _isIP = _interopRequireDefault(isIP$1.exports);
  8347. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8348. var subnetMaybe = /^\d{1,3}$/;
  8349. var v4Subnet = 32;
  8350. var v6Subnet = 128;
  8351. function isIPRange(str) {
  8352. var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  8353. (0, _assertString.default)(str);
  8354. var parts = str.split('/'); // parts[0] -> ip, parts[1] -> subnet
  8355. if (parts.length !== 2) {
  8356. return false;
  8357. }
  8358. if (!subnetMaybe.test(parts[1])) {
  8359. return false;
  8360. } // Disallow preceding 0 i.e. 01, 02, ...
  8361. if (parts[1].length > 1 && parts[1].startsWith('0')) {
  8362. return false;
  8363. }
  8364. var isValidIP = (0, _isIP.default)(parts[0], version);
  8365. if (!isValidIP) {
  8366. return false;
  8367. } // Define valid subnet according to IP's version
  8368. var expectedSubnet = null;
  8369. switch (String(version)) {
  8370. case '4':
  8371. expectedSubnet = v4Subnet;
  8372. break;
  8373. case '6':
  8374. expectedSubnet = v6Subnet;
  8375. break;
  8376. default:
  8377. expectedSubnet = (0, _isIP.default)(parts[0], '6') ? v6Subnet : v4Subnet;
  8378. }
  8379. return parts[1] <= expectedSubnet && parts[1] >= 0;
  8380. }
  8381. module.exports = exports.default;
  8382. module.exports.default = exports.default;
  8383. } (isIPRange, isIPRange.exports));
  8384. var isDate$1 = {exports: {}};
  8385. (function (module, exports) {
  8386. Object.defineProperty(exports, "__esModule", {
  8387. value: true
  8388. });
  8389. exports.default = isDate;
  8390. var _merge = _interopRequireDefault(merge.exports);
  8391. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8392. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  8393. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  8394. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  8395. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  8396. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
  8397. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  8398. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  8399. var default_date_options = {
  8400. format: 'YYYY/MM/DD',
  8401. delimiters: ['/', '-'],
  8402. strictMode: false
  8403. };
  8404. function isValidFormat(format) {
  8405. return /(^(y{4}|y{2})[.\/-](m{1,2})[.\/-](d{1,2})$)|(^(m{1,2})[.\/-](d{1,2})[.\/-]((y{4}|y{2})$))|(^(d{1,2})[.\/-](m{1,2})[.\/-]((y{4}|y{2})$))/gi.test(format);
  8406. }
  8407. function zip(date, format) {
  8408. var zippedArr = [],
  8409. len = Math.min(date.length, format.length);
  8410. for (var i = 0; i < len; i++) {
  8411. zippedArr.push([date[i], format[i]]);
  8412. }
  8413. return zippedArr;
  8414. }
  8415. function isDate(input, options) {
  8416. if (typeof options === 'string') {
  8417. // Allow backward compatbility for old format isDate(input [, format])
  8418. options = (0, _merge.default)({
  8419. format: options
  8420. }, default_date_options);
  8421. } else {
  8422. options = (0, _merge.default)(options, default_date_options);
  8423. }
  8424. if (typeof input === 'string' && isValidFormat(options.format)) {
  8425. var formatDelimiter = options.delimiters.find(function (delimiter) {
  8426. return options.format.indexOf(delimiter) !== -1;
  8427. });
  8428. var dateDelimiter = options.strictMode ? formatDelimiter : options.delimiters.find(function (delimiter) {
  8429. return input.indexOf(delimiter) !== -1;
  8430. });
  8431. var dateAndFormat = zip(input.split(dateDelimiter), options.format.toLowerCase().split(formatDelimiter));
  8432. var dateObj = {};
  8433. var _iterator = _createForOfIteratorHelper(dateAndFormat),
  8434. _step;
  8435. try {
  8436. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  8437. var _step$value = _slicedToArray(_step.value, 2),
  8438. dateWord = _step$value[0],
  8439. formatWord = _step$value[1];
  8440. if (dateWord.length !== formatWord.length) {
  8441. return false;
  8442. }
  8443. dateObj[formatWord.charAt(0)] = dateWord;
  8444. }
  8445. } catch (err) {
  8446. _iterator.e(err);
  8447. } finally {
  8448. _iterator.f();
  8449. }
  8450. return new Date("".concat(dateObj.m, "/").concat(dateObj.d, "/").concat(dateObj.y)).getDate() === +dateObj.d;
  8451. }
  8452. if (!options.strictMode) {
  8453. return Object.prototype.toString.call(input) === '[object Date]' && isFinite(input);
  8454. }
  8455. return false;
  8456. }
  8457. module.exports = exports.default;
  8458. module.exports.default = exports.default;
  8459. } (isDate$1, isDate$1.exports));
  8460. var isIMEI = {exports: {}};
  8461. (function (module, exports) {
  8462. Object.defineProperty(exports, "__esModule", {
  8463. value: true
  8464. });
  8465. exports.default = isIMEI;
  8466. var _assertString = _interopRequireDefault(assertString.exports);
  8467. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8468. var imeiRegexWithoutHypens = /^[0-9]{15}$/;
  8469. var imeiRegexWithHypens = /^\d{2}-\d{6}-\d{6}-\d{1}$/;
  8470. function isIMEI(str, options) {
  8471. (0, _assertString.default)(str);
  8472. options = options || {}; // default regex for checking imei is the one without hyphens
  8473. var imeiRegex = imeiRegexWithoutHypens;
  8474. if (options.allow_hyphens) {
  8475. imeiRegex = imeiRegexWithHypens;
  8476. }
  8477. if (!imeiRegex.test(str)) {
  8478. return false;
  8479. }
  8480. str = str.replace(/-/g, '');
  8481. var sum = 0,
  8482. mul = 2,
  8483. l = 14;
  8484. for (var i = 0; i < l; i++) {
  8485. var digit = str.substring(l - i - 1, l - i);
  8486. var tp = parseInt(digit, 10) * mul;
  8487. if (tp >= 10) {
  8488. sum += tp % 10 + 1;
  8489. } else {
  8490. sum += tp;
  8491. }
  8492. if (mul === 1) {
  8493. mul += 1;
  8494. } else {
  8495. mul -= 1;
  8496. }
  8497. }
  8498. var chk = (10 - sum % 10) % 10;
  8499. if (chk !== parseInt(str.substring(14, 15), 10)) {
  8500. return false;
  8501. }
  8502. return true;
  8503. }
  8504. module.exports = exports.default;
  8505. module.exports.default = exports.default;
  8506. } (isIMEI, isIMEI.exports));
  8507. var isMD5 = {exports: {}};
  8508. (function (module, exports) {
  8509. Object.defineProperty(exports, "__esModule", {
  8510. value: true
  8511. });
  8512. exports.default = isMD5;
  8513. var _assertString = _interopRequireDefault(assertString.exports);
  8514. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8515. var md5 = /^[a-f0-9]{32}$/;
  8516. function isMD5(str) {
  8517. (0, _assertString.default)(str);
  8518. return md5.test(str);
  8519. }
  8520. module.exports = exports.default;
  8521. module.exports.default = exports.default;
  8522. } (isMD5, isMD5.exports));
  8523. var isEmpty = {exports: {}};
  8524. (function (module, exports) {
  8525. Object.defineProperty(exports, "__esModule", {
  8526. value: true
  8527. });
  8528. exports.default = isEmpty;
  8529. var _assertString = _interopRequireDefault(assertString.exports);
  8530. var _merge = _interopRequireDefault(merge.exports);
  8531. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8532. var default_is_empty_options = {
  8533. ignore_whitespace: false
  8534. };
  8535. function isEmpty(str, options) {
  8536. (0, _assertString.default)(str);
  8537. options = (0, _merge.default)(options, default_is_empty_options);
  8538. return (options.ignore_whitespace ? str.trim().length : str.length) === 0;
  8539. }
  8540. module.exports = exports.default;
  8541. module.exports.default = exports.default;
  8542. } (isEmpty, isEmpty.exports));
  8543. var isAfter = {exports: {}};
  8544. (function (module, exports) {
  8545. Object.defineProperty(exports, "__esModule", {
  8546. value: true
  8547. });
  8548. exports.default = isAfter;
  8549. var _assertString = _interopRequireDefault(assertString.exports);
  8550. var _toDate = _interopRequireDefault(toDate.exports);
  8551. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8552. function isAfter(str) {
  8553. var date = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : String(new Date());
  8554. (0, _assertString.default)(str);
  8555. var comparison = (0, _toDate.default)(date);
  8556. var original = (0, _toDate.default)(str);
  8557. return !!(original && comparison && original > comparison);
  8558. }
  8559. module.exports = exports.default;
  8560. module.exports.default = exports.default;
  8561. } (isAfter, isAfter.exports));
  8562. var isBefore = {exports: {}};
  8563. (function (module, exports) {
  8564. Object.defineProperty(exports, "__esModule", {
  8565. value: true
  8566. });
  8567. exports.default = isBefore;
  8568. var _assertString = _interopRequireDefault(assertString.exports);
  8569. var _toDate = _interopRequireDefault(toDate.exports);
  8570. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8571. function isBefore(str) {
  8572. var date = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : String(new Date());
  8573. (0, _assertString.default)(str);
  8574. var comparison = (0, _toDate.default)(date);
  8575. var original = (0, _toDate.default)(str);
  8576. return !!(original && comparison && original < comparison);
  8577. }
  8578. module.exports = exports.default;
  8579. module.exports.default = exports.default;
  8580. } (isBefore, isBefore.exports));
  8581. var isIn = {exports: {}};
  8582. (function (module, exports) {
  8583. Object.defineProperty(exports, "__esModule", {
  8584. value: true
  8585. });
  8586. exports.default = isIn;
  8587. var _assertString = _interopRequireDefault(assertString.exports);
  8588. var _toString = _interopRequireDefault(toString$1.exports);
  8589. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8590. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8591. function isIn(str, options) {
  8592. (0, _assertString.default)(str);
  8593. var i;
  8594. if (Object.prototype.toString.call(options) === '[object Array]') {
  8595. var array = [];
  8596. for (i in options) {
  8597. // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
  8598. // istanbul ignore else
  8599. if ({}.hasOwnProperty.call(options, i)) {
  8600. array[i] = (0, _toString.default)(options[i]);
  8601. }
  8602. }
  8603. return array.indexOf(str) >= 0;
  8604. } else if (_typeof(options) === 'object') {
  8605. return options.hasOwnProperty(str);
  8606. } else if (options && typeof options.indexOf === 'function') {
  8607. return options.indexOf(str) >= 0;
  8608. }
  8609. return false;
  8610. }
  8611. module.exports = exports.default;
  8612. module.exports.default = exports.default;
  8613. } (isIn, isIn.exports));
  8614. var isTaxID = {exports: {}};
  8615. var algorithms = {};
  8616. Object.defineProperty(algorithms, "__esModule", {
  8617. value: true
  8618. });
  8619. algorithms.iso7064Check = iso7064Check;
  8620. algorithms.luhnCheck = luhnCheck;
  8621. algorithms.reverseMultiplyAndSum = reverseMultiplyAndSum;
  8622. algorithms.verhoeffCheck = verhoeffCheck;
  8623. /**
  8624. * Algorithmic validation functions
  8625. * May be used as is or implemented in the workflow of other validators.
  8626. */
  8627. /*
  8628. * ISO 7064 validation function
  8629. * Called with a string of numbers (incl. check digit)
  8630. * to validate according to ISO 7064 (MOD 11, 10).
  8631. */
  8632. function iso7064Check(str) {
  8633. var checkvalue = 10;
  8634. for (var i = 0; i < str.length - 1; i++) {
  8635. checkvalue = (parseInt(str[i], 10) + checkvalue) % 10 === 0 ? 10 * 2 % 11 : (parseInt(str[i], 10) + checkvalue) % 10 * 2 % 11;
  8636. }
  8637. checkvalue = checkvalue === 1 ? 0 : 11 - checkvalue;
  8638. return checkvalue === parseInt(str[10], 10);
  8639. }
  8640. /*
  8641. * Luhn (mod 10) validation function
  8642. * Called with a string of numbers (incl. check digit)
  8643. * to validate according to the Luhn algorithm.
  8644. */
  8645. function luhnCheck(str) {
  8646. var checksum = 0;
  8647. var second = false;
  8648. for (var i = str.length - 1; i >= 0; i--) {
  8649. if (second) {
  8650. var product = parseInt(str[i], 10) * 2;
  8651. if (product > 9) {
  8652. // sum digits of product and add to checksum
  8653. checksum += product.toString().split('').map(function (a) {
  8654. return parseInt(a, 10);
  8655. }).reduce(function (a, b) {
  8656. return a + b;
  8657. }, 0);
  8658. } else {
  8659. checksum += product;
  8660. }
  8661. } else {
  8662. checksum += parseInt(str[i], 10);
  8663. }
  8664. second = !second;
  8665. }
  8666. return checksum % 10 === 0;
  8667. }
  8668. /*
  8669. * Reverse TIN multiplication and summation helper function
  8670. * Called with an array of single-digit integers and a base multiplier
  8671. * to calculate the sum of the digits multiplied in reverse.
  8672. * Normally used in variations of MOD 11 algorithmic checks.
  8673. */
  8674. function reverseMultiplyAndSum(digits, base) {
  8675. var total = 0;
  8676. for (var i = 0; i < digits.length; i++) {
  8677. total += digits[i] * (base - i);
  8678. }
  8679. return total;
  8680. }
  8681. /*
  8682. * Verhoeff validation helper function
  8683. * Called with a string of numbers
  8684. * to validate according to the Verhoeff algorithm.
  8685. */
  8686. function verhoeffCheck(str) {
  8687. var d_table = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 0, 6, 7, 8, 9, 5], [2, 3, 4, 0, 1, 7, 8, 9, 5, 6], [3, 4, 0, 1, 2, 8, 9, 5, 6, 7], [4, 0, 1, 2, 3, 9, 5, 6, 7, 8], [5, 9, 8, 7, 6, 0, 4, 3, 2, 1], [6, 5, 9, 8, 7, 1, 0, 4, 3, 2], [7, 6, 5, 9, 8, 2, 1, 0, 4, 3], [8, 7, 6, 5, 9, 3, 2, 1, 0, 4], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]];
  8688. var p_table = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 5, 7, 6, 2, 8, 3, 0, 9, 4], [5, 8, 0, 3, 7, 9, 6, 1, 4, 2], [8, 9, 1, 6, 0, 4, 3, 5, 2, 7], [9, 4, 5, 3, 1, 2, 6, 8, 7, 0], [4, 2, 8, 6, 5, 7, 3, 9, 0, 1], [2, 7, 9, 3, 8, 0, 6, 4, 1, 5], [7, 0, 4, 6, 9, 1, 3, 2, 5, 8]]; // Copy (to prevent replacement) and reverse
  8689. var str_copy = str.split('').reverse().join('');
  8690. var checksum = 0;
  8691. for (var i = 0; i < str_copy.length; i++) {
  8692. checksum = d_table[checksum][p_table[i % 8][parseInt(str_copy[i], 10)]];
  8693. }
  8694. return checksum === 0;
  8695. }
  8696. (function (module, exports) {
  8697. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8698. Object.defineProperty(exports, "__esModule", {
  8699. value: true
  8700. });
  8701. exports.default = isTaxID;
  8702. var _assertString = _interopRequireDefault(assertString.exports);
  8703. var algorithms$1 = _interopRequireWildcard(algorithms);
  8704. var _isDate = _interopRequireDefault(isDate$1.exports);
  8705. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  8706. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  8707. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8708. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  8709. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  8710. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  8711. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
  8712. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  8713. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  8714. /**
  8715. * TIN Validation
  8716. * Validates Tax Identification Numbers (TINs) from the US, EU member states and the United Kingdom.
  8717. *
  8718. * EU-UK:
  8719. * National TIN validity is calculated using public algorithms as made available by DG TAXUD.
  8720. *
  8721. * See `https://ec.europa.eu/taxation_customs/tin/specs/FS-TIN%20Algorithms-Public.docx` for more information.
  8722. *
  8723. * US:
  8724. * An Employer Identification Number (EIN), also known as a Federal Tax Identification Number,
  8725. * is used to identify a business entity.
  8726. *
  8727. * NOTES:
  8728. * - Prefix 47 is being reserved for future use
  8729. * - Prefixes 26, 27, 45, 46 and 47 were previously assigned by the Philadelphia campus.
  8730. *
  8731. * See `http://www.irs.gov/Businesses/Small-Businesses-&-Self-Employed/How-EINs-are-Assigned-and-Valid-EIN-Prefixes`
  8732. * for more information.
  8733. */
  8734. // Locale functions
  8735. /*
  8736. * bg-BG validation function
  8737. * (Edinen graždanski nomer (EGN/ЕГН), persons only)
  8738. * Checks if birth date (first six digits) is valid and calculates check (last) digit
  8739. */
  8740. function bgBgCheck(tin) {
  8741. // Extract full year, normalize month and check birth date validity
  8742. var century_year = tin.slice(0, 2);
  8743. var month = parseInt(tin.slice(2, 4), 10);
  8744. if (month > 40) {
  8745. month -= 40;
  8746. century_year = "20".concat(century_year);
  8747. } else if (month > 20) {
  8748. month -= 20;
  8749. century_year = "18".concat(century_year);
  8750. } else {
  8751. century_year = "19".concat(century_year);
  8752. }
  8753. if (month < 10) {
  8754. month = "0".concat(month);
  8755. }
  8756. var date = "".concat(century_year, "/").concat(month, "/").concat(tin.slice(4, 6));
  8757. if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  8758. return false;
  8759. } // split digits into an array for further processing
  8760. var digits = tin.split('').map(function (a) {
  8761. return parseInt(a, 10);
  8762. }); // Calculate checksum by multiplying digits with fixed values
  8763. var multip_lookup = [2, 4, 8, 5, 10, 9, 7, 3, 6];
  8764. var checksum = 0;
  8765. for (var i = 0; i < multip_lookup.length; i++) {
  8766. checksum += digits[i] * multip_lookup[i];
  8767. }
  8768. checksum = checksum % 11 === 10 ? 0 : checksum % 11;
  8769. return checksum === digits[9];
  8770. }
  8771. /*
  8772. * cs-CZ validation function
  8773. * (Rodné číslo (RČ), persons only)
  8774. * Checks if birth date (first six digits) is valid and divisibility by 11
  8775. * Material not in DG TAXUD document sourced from:
  8776. * -`https://lorenc.info/3MA381/overeni-spravnosti-rodneho-cisla.htm`
  8777. * -`https://www.mvcr.cz/clanek/rady-a-sluzby-dokumenty-rodne-cislo.aspx`
  8778. */
  8779. function csCzCheck(tin) {
  8780. tin = tin.replace(/\W/, ''); // Extract full year from TIN length
  8781. var full_year = parseInt(tin.slice(0, 2), 10);
  8782. if (tin.length === 10) {
  8783. if (full_year < 54) {
  8784. full_year = "20".concat(full_year);
  8785. } else {
  8786. full_year = "19".concat(full_year);
  8787. }
  8788. } else {
  8789. if (tin.slice(6) === '000') {
  8790. return false;
  8791. } // Three-zero serial not assigned before 1954
  8792. if (full_year < 54) {
  8793. full_year = "19".concat(full_year);
  8794. } else {
  8795. return false; // No 18XX years seen in any of the resources
  8796. }
  8797. } // Add missing zero if needed
  8798. if (full_year.length === 3) {
  8799. full_year = [full_year.slice(0, 2), '0', full_year.slice(2)].join('');
  8800. } // Extract month from TIN and normalize
  8801. var month = parseInt(tin.slice(2, 4), 10);
  8802. if (month > 50) {
  8803. month -= 50;
  8804. }
  8805. if (month > 20) {
  8806. // Month-plus-twenty was only introduced in 2004
  8807. if (parseInt(full_year, 10) < 2004) {
  8808. return false;
  8809. }
  8810. month -= 20;
  8811. }
  8812. if (month < 10) {
  8813. month = "0".concat(month);
  8814. } // Check date validity
  8815. var date = "".concat(full_year, "/").concat(month, "/").concat(tin.slice(4, 6));
  8816. if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  8817. return false;
  8818. } // Verify divisibility by 11
  8819. if (tin.length === 10) {
  8820. if (parseInt(tin, 10) % 11 !== 0) {
  8821. // Some numbers up to and including 1985 are still valid if
  8822. // check (last) digit equals 0 and modulo of first 9 digits equals 10
  8823. var checkdigit = parseInt(tin.slice(0, 9), 10) % 11;
  8824. if (parseInt(full_year, 10) < 1986 && checkdigit === 10) {
  8825. if (parseInt(tin.slice(9), 10) !== 0) {
  8826. return false;
  8827. }
  8828. } else {
  8829. return false;
  8830. }
  8831. }
  8832. }
  8833. return true;
  8834. }
  8835. /*
  8836. * de-AT validation function
  8837. * (Abgabenkontonummer, persons/entities)
  8838. * Verify TIN validity by calling luhnCheck()
  8839. */
  8840. function deAtCheck(tin) {
  8841. return algorithms$1.luhnCheck(tin);
  8842. }
  8843. /*
  8844. * de-DE validation function
  8845. * (Steueridentifikationsnummer (Steuer-IdNr.), persons only)
  8846. * Tests for single duplicate/triplicate value, then calculates ISO 7064 check (last) digit
  8847. * Partial implementation of spec (same result with both algorithms always)
  8848. */
  8849. function deDeCheck(tin) {
  8850. // Split digits into an array for further processing
  8851. var digits = tin.split('').map(function (a) {
  8852. return parseInt(a, 10);
  8853. }); // Fill array with strings of number positions
  8854. var occurences = [];
  8855. for (var i = 0; i < digits.length - 1; i++) {
  8856. occurences.push('');
  8857. for (var j = 0; j < digits.length - 1; j++) {
  8858. if (digits[i] === digits[j]) {
  8859. occurences[i] += j;
  8860. }
  8861. }
  8862. } // Remove digits with one occurence and test for only one duplicate/triplicate
  8863. occurences = occurences.filter(function (a) {
  8864. return a.length > 1;
  8865. });
  8866. if (occurences.length !== 2 && occurences.length !== 3) {
  8867. return false;
  8868. } // In case of triplicate value only two digits are allowed next to each other
  8869. if (occurences[0].length === 3) {
  8870. var trip_locations = occurences[0].split('').map(function (a) {
  8871. return parseInt(a, 10);
  8872. });
  8873. var recurrent = 0; // Amount of neighbour occurences
  8874. for (var _i = 0; _i < trip_locations.length - 1; _i++) {
  8875. if (trip_locations[_i] + 1 === trip_locations[_i + 1]) {
  8876. recurrent += 1;
  8877. }
  8878. }
  8879. if (recurrent === 2) {
  8880. return false;
  8881. }
  8882. }
  8883. return algorithms$1.iso7064Check(tin);
  8884. }
  8885. /*
  8886. * dk-DK validation function
  8887. * (CPR-nummer (personnummer), persons only)
  8888. * Checks if birth date (first six digits) is valid and assigned to century (seventh) digit,
  8889. * and calculates check (last) digit
  8890. */
  8891. function dkDkCheck(tin) {
  8892. tin = tin.replace(/\W/, ''); // Extract year, check if valid for given century digit and add century
  8893. var year = parseInt(tin.slice(4, 6), 10);
  8894. var century_digit = tin.slice(6, 7);
  8895. switch (century_digit) {
  8896. case '0':
  8897. case '1':
  8898. case '2':
  8899. case '3':
  8900. year = "19".concat(year);
  8901. break;
  8902. case '4':
  8903. case '9':
  8904. if (year < 37) {
  8905. year = "20".concat(year);
  8906. } else {
  8907. year = "19".concat(year);
  8908. }
  8909. break;
  8910. default:
  8911. if (year < 37) {
  8912. year = "20".concat(year);
  8913. } else if (year > 58) {
  8914. year = "18".concat(year);
  8915. } else {
  8916. return false;
  8917. }
  8918. break;
  8919. } // Add missing zero if needed
  8920. if (year.length === 3) {
  8921. year = [year.slice(0, 2), '0', year.slice(2)].join('');
  8922. } // Check date validity
  8923. var date = "".concat(year, "/").concat(tin.slice(2, 4), "/").concat(tin.slice(0, 2));
  8924. if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  8925. return false;
  8926. } // Split digits into an array for further processing
  8927. var digits = tin.split('').map(function (a) {
  8928. return parseInt(a, 10);
  8929. });
  8930. var checksum = 0;
  8931. var weight = 4; // Multiply by weight and add to checksum
  8932. for (var i = 0; i < 9; i++) {
  8933. checksum += digits[i] * weight;
  8934. weight -= 1;
  8935. if (weight === 1) {
  8936. weight = 7;
  8937. }
  8938. }
  8939. checksum %= 11;
  8940. if (checksum === 1) {
  8941. return false;
  8942. }
  8943. return checksum === 0 ? digits[9] === 0 : digits[9] === 11 - checksum;
  8944. }
  8945. /*
  8946. * el-CY validation function
  8947. * (Arithmos Forologikou Mitroou (AFM/ΑΦΜ), persons only)
  8948. * Verify TIN validity by calculating ASCII value of check (last) character
  8949. */
  8950. function elCyCheck(tin) {
  8951. // split digits into an array for further processing
  8952. var digits = tin.slice(0, 8).split('').map(function (a) {
  8953. return parseInt(a, 10);
  8954. });
  8955. var checksum = 0; // add digits in even places
  8956. for (var i = 1; i < digits.length; i += 2) {
  8957. checksum += digits[i];
  8958. } // add digits in odd places
  8959. for (var _i2 = 0; _i2 < digits.length; _i2 += 2) {
  8960. if (digits[_i2] < 2) {
  8961. checksum += 1 - digits[_i2];
  8962. } else {
  8963. checksum += 2 * (digits[_i2] - 2) + 5;
  8964. if (digits[_i2] > 4) {
  8965. checksum += 2;
  8966. }
  8967. }
  8968. }
  8969. return String.fromCharCode(checksum % 26 + 65) === tin.charAt(8);
  8970. }
  8971. /*
  8972. * el-GR validation function
  8973. * (Arithmos Forologikou Mitroou (AFM/ΑΦΜ), persons/entities)
  8974. * Verify TIN validity by calculating check (last) digit
  8975. * Algorithm not in DG TAXUD document- sourced from:
  8976. * - `http://epixeirisi.gr/%CE%9A%CE%A1%CE%99%CE%A3%CE%99%CE%9C%CE%91-%CE%98%CE%95%CE%9C%CE%91%CE%A4%CE%91-%CE%A6%CE%9F%CE%A1%CE%9F%CE%9B%CE%9F%CE%93%CE%99%CE%91%CE%A3-%CE%9A%CE%91%CE%99-%CE%9B%CE%9F%CE%93%CE%99%CE%A3%CE%A4%CE%99%CE%9A%CE%97%CE%A3/23791/%CE%91%CF%81%CE%B9%CE%B8%CE%BC%CF%8C%CF%82-%CE%A6%CE%BF%CF%81%CE%BF%CE%BB%CE%BF%CE%B3%CE%B9%CE%BA%CE%BF%CF%8D-%CE%9C%CE%B7%CF%84%CF%81%CF%8E%CE%BF%CF%85`
  8977. */
  8978. function elGrCheck(tin) {
  8979. // split digits into an array for further processing
  8980. var digits = tin.split('').map(function (a) {
  8981. return parseInt(a, 10);
  8982. });
  8983. var checksum = 0;
  8984. for (var i = 0; i < 8; i++) {
  8985. checksum += digits[i] * Math.pow(2, 8 - i);
  8986. }
  8987. return checksum % 11 % 10 === digits[8];
  8988. }
  8989. /*
  8990. * en-GB validation function (should go here if needed)
  8991. * (National Insurance Number (NINO) or Unique Taxpayer Reference (UTR),
  8992. * persons/entities respectively)
  8993. */
  8994. /*
  8995. * en-IE validation function
  8996. * (Personal Public Service Number (PPS No), persons only)
  8997. * Verify TIN validity by calculating check (second to last) character
  8998. */
  8999. function enIeCheck(tin) {
  9000. var checksum = algorithms$1.reverseMultiplyAndSum(tin.split('').slice(0, 7).map(function (a) {
  9001. return parseInt(a, 10);
  9002. }), 8);
  9003. if (tin.length === 9 && tin[8] !== 'W') {
  9004. checksum += (tin[8].charCodeAt(0) - 64) * 9;
  9005. }
  9006. checksum %= 23;
  9007. if (checksum === 0) {
  9008. return tin[7].toUpperCase() === 'W';
  9009. }
  9010. return tin[7].toUpperCase() === String.fromCharCode(64 + checksum);
  9011. } // Valid US IRS campus prefixes
  9012. var enUsCampusPrefix = {
  9013. andover: ['10', '12'],
  9014. atlanta: ['60', '67'],
  9015. austin: ['50', '53'],
  9016. brookhaven: ['01', '02', '03', '04', '05', '06', '11', '13', '14', '16', '21', '22', '23', '25', '34', '51', '52', '54', '55', '56', '57', '58', '59', '65'],
  9017. cincinnati: ['30', '32', '35', '36', '37', '38', '61'],
  9018. fresno: ['15', '24'],
  9019. internet: ['20', '26', '27', '45', '46', '47'],
  9020. kansas: ['40', '44'],
  9021. memphis: ['94', '95'],
  9022. ogden: ['80', '90'],
  9023. philadelphia: ['33', '39', '41', '42', '43', '46', '48', '62', '63', '64', '66', '68', '71', '72', '73', '74', '75', '76', '77', '81', '82', '83', '84', '85', '86', '87', '88', '91', '92', '93', '98', '99'],
  9024. sba: ['31']
  9025. }; // Return an array of all US IRS campus prefixes
  9026. function enUsGetPrefixes() {
  9027. var prefixes = [];
  9028. for (var location in enUsCampusPrefix) {
  9029. // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
  9030. // istanbul ignore else
  9031. if (enUsCampusPrefix.hasOwnProperty(location)) {
  9032. prefixes.push.apply(prefixes, _toConsumableArray(enUsCampusPrefix[location]));
  9033. }
  9034. }
  9035. return prefixes;
  9036. }
  9037. /*
  9038. * en-US validation function
  9039. * Verify that the TIN starts with a valid IRS campus prefix
  9040. */
  9041. function enUsCheck(tin) {
  9042. return enUsGetPrefixes().indexOf(tin.substr(0, 2)) !== -1;
  9043. }
  9044. /*
  9045. * es-ES validation function
  9046. * (Documento Nacional de Identidad (DNI)
  9047. * or Número de Identificación de Extranjero (NIE), persons only)
  9048. * Verify TIN validity by calculating check (last) character
  9049. */
  9050. function esEsCheck(tin) {
  9051. // Split characters into an array for further processing
  9052. var chars = tin.toUpperCase().split(''); // Replace initial letter if needed
  9053. if (isNaN(parseInt(chars[0], 10)) && chars.length > 1) {
  9054. var lead_replace = 0;
  9055. switch (chars[0]) {
  9056. case 'Y':
  9057. lead_replace = 1;
  9058. break;
  9059. case 'Z':
  9060. lead_replace = 2;
  9061. break;
  9062. }
  9063. chars.splice(0, 1, lead_replace); // Fill with zeros if smaller than proper
  9064. } else {
  9065. while (chars.length < 9) {
  9066. chars.unshift(0);
  9067. }
  9068. } // Calculate checksum and check according to lookup
  9069. var lookup = ['T', 'R', 'W', 'A', 'G', 'M', 'Y', 'F', 'P', 'D', 'X', 'B', 'N', 'J', 'Z', 'S', 'Q', 'V', 'H', 'L', 'C', 'K', 'E'];
  9070. chars = chars.join('');
  9071. var checksum = parseInt(chars.slice(0, 8), 10) % 23;
  9072. return chars[8] === lookup[checksum];
  9073. }
  9074. /*
  9075. * et-EE validation function
  9076. * (Isikukood (IK), persons only)
  9077. * Checks if birth date (century digit and six following) is valid and calculates check (last) digit
  9078. * Material not in DG TAXUD document sourced from:
  9079. * - `https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/Estonia-TIN.pdf`
  9080. */
  9081. function etEeCheck(tin) {
  9082. // Extract year and add century
  9083. var full_year = tin.slice(1, 3);
  9084. var century_digit = tin.slice(0, 1);
  9085. switch (century_digit) {
  9086. case '1':
  9087. case '2':
  9088. full_year = "18".concat(full_year);
  9089. break;
  9090. case '3':
  9091. case '4':
  9092. full_year = "19".concat(full_year);
  9093. break;
  9094. default:
  9095. full_year = "20".concat(full_year);
  9096. break;
  9097. } // Check date validity
  9098. var date = "".concat(full_year, "/").concat(tin.slice(3, 5), "/").concat(tin.slice(5, 7));
  9099. if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  9100. return false;
  9101. } // Split digits into an array for further processing
  9102. var digits = tin.split('').map(function (a) {
  9103. return parseInt(a, 10);
  9104. });
  9105. var checksum = 0;
  9106. var weight = 1; // Multiply by weight and add to checksum
  9107. for (var i = 0; i < 10; i++) {
  9108. checksum += digits[i] * weight;
  9109. weight += 1;
  9110. if (weight === 10) {
  9111. weight = 1;
  9112. }
  9113. } // Do again if modulo 11 of checksum is 10
  9114. if (checksum % 11 === 10) {
  9115. checksum = 0;
  9116. weight = 3;
  9117. for (var _i3 = 0; _i3 < 10; _i3++) {
  9118. checksum += digits[_i3] * weight;
  9119. weight += 1;
  9120. if (weight === 10) {
  9121. weight = 1;
  9122. }
  9123. }
  9124. if (checksum % 11 === 10) {
  9125. return digits[10] === 0;
  9126. }
  9127. }
  9128. return checksum % 11 === digits[10];
  9129. }
  9130. /*
  9131. * fi-FI validation function
  9132. * (Henkilötunnus (HETU), persons only)
  9133. * Checks if birth date (first six digits plus century symbol) is valid
  9134. * and calculates check (last) digit
  9135. */
  9136. function fiFiCheck(tin) {
  9137. // Extract year and add century
  9138. var full_year = tin.slice(4, 6);
  9139. var century_symbol = tin.slice(6, 7);
  9140. switch (century_symbol) {
  9141. case '+':
  9142. full_year = "18".concat(full_year);
  9143. break;
  9144. case '-':
  9145. full_year = "19".concat(full_year);
  9146. break;
  9147. default:
  9148. full_year = "20".concat(full_year);
  9149. break;
  9150. } // Check date validity
  9151. var date = "".concat(full_year, "/").concat(tin.slice(2, 4), "/").concat(tin.slice(0, 2));
  9152. if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  9153. return false;
  9154. } // Calculate check character
  9155. var checksum = parseInt(tin.slice(0, 6) + tin.slice(7, 10), 10) % 31;
  9156. if (checksum < 10) {
  9157. return checksum === parseInt(tin.slice(10), 10);
  9158. }
  9159. checksum -= 10;
  9160. var letters_lookup = ['A', 'B', 'C', 'D', 'E', 'F', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y'];
  9161. return letters_lookup[checksum] === tin.slice(10);
  9162. }
  9163. /*
  9164. * fr/nl-BE validation function
  9165. * (Numéro national (N.N.), persons only)
  9166. * Checks if birth date (first six digits) is valid and calculates check (last two) digits
  9167. */
  9168. function frBeCheck(tin) {
  9169. // Zero month/day value is acceptable
  9170. if (tin.slice(2, 4) !== '00' || tin.slice(4, 6) !== '00') {
  9171. // Extract date from first six digits of TIN
  9172. var date = "".concat(tin.slice(0, 2), "/").concat(tin.slice(2, 4), "/").concat(tin.slice(4, 6));
  9173. if (!(0, _isDate.default)(date, 'YY/MM/DD')) {
  9174. return false;
  9175. }
  9176. }
  9177. var checksum = 97 - parseInt(tin.slice(0, 9), 10) % 97;
  9178. var checkdigits = parseInt(tin.slice(9, 11), 10);
  9179. if (checksum !== checkdigits) {
  9180. checksum = 97 - parseInt("2".concat(tin.slice(0, 9)), 10) % 97;
  9181. if (checksum !== checkdigits) {
  9182. return false;
  9183. }
  9184. }
  9185. return true;
  9186. }
  9187. /*
  9188. * fr-FR validation function
  9189. * (Numéro fiscal de référence (numéro SPI), persons only)
  9190. * Verify TIN validity by calculating check (last three) digits
  9191. */
  9192. function frFrCheck(tin) {
  9193. tin = tin.replace(/\s/g, '');
  9194. var checksum = parseInt(tin.slice(0, 10), 10) % 511;
  9195. var checkdigits = parseInt(tin.slice(10, 13), 10);
  9196. return checksum === checkdigits;
  9197. }
  9198. /*
  9199. * fr/lb-LU validation function
  9200. * (numéro d’identification personnelle, persons only)
  9201. * Verify birth date validity and run Luhn and Verhoeff checks
  9202. */
  9203. function frLuCheck(tin) {
  9204. // Extract date and check validity
  9205. var date = "".concat(tin.slice(0, 4), "/").concat(tin.slice(4, 6), "/").concat(tin.slice(6, 8));
  9206. if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  9207. return false;
  9208. } // Run Luhn check
  9209. if (!algorithms$1.luhnCheck(tin.slice(0, 12))) {
  9210. return false;
  9211. } // Remove Luhn check digit and run Verhoeff check
  9212. return algorithms$1.verhoeffCheck("".concat(tin.slice(0, 11)).concat(tin[12]));
  9213. }
  9214. /*
  9215. * hr-HR validation function
  9216. * (Osobni identifikacijski broj (OIB), persons/entities)
  9217. * Verify TIN validity by calling iso7064Check(digits)
  9218. */
  9219. function hrHrCheck(tin) {
  9220. return algorithms$1.iso7064Check(tin);
  9221. }
  9222. /*
  9223. * hu-HU validation function
  9224. * (Adóazonosító jel, persons only)
  9225. * Verify TIN validity by calculating check (last) digit
  9226. */
  9227. function huHuCheck(tin) {
  9228. // split digits into an array for further processing
  9229. var digits = tin.split('').map(function (a) {
  9230. return parseInt(a, 10);
  9231. });
  9232. var checksum = 8;
  9233. for (var i = 1; i < 9; i++) {
  9234. checksum += digits[i] * (i + 1);
  9235. }
  9236. return checksum % 11 === digits[9];
  9237. }
  9238. /*
  9239. * lt-LT validation function (should go here if needed)
  9240. * (Asmens kodas, persons/entities respectively)
  9241. * Current validation check is alias of etEeCheck- same format applies
  9242. */
  9243. /*
  9244. * it-IT first/last name validity check
  9245. * Accepts it-IT TIN-encoded names as a three-element character array and checks their validity
  9246. * Due to lack of clarity between resources ("Are only Italian consonants used?
  9247. * What happens if a person has X in their name?" etc.) only two test conditions
  9248. * have been implemented:
  9249. * Vowels may only be followed by other vowels or an X character
  9250. * and X characters after vowels may only be followed by other X characters.
  9251. */
  9252. function itItNameCheck(name) {
  9253. // true at the first occurence of a vowel
  9254. var vowelflag = false; // true at the first occurence of an X AFTER vowel
  9255. // (to properly handle last names with X as consonant)
  9256. var xflag = false;
  9257. for (var i = 0; i < 3; i++) {
  9258. if (!vowelflag && /[AEIOU]/.test(name[i])) {
  9259. vowelflag = true;
  9260. } else if (!xflag && vowelflag && name[i] === 'X') {
  9261. xflag = true;
  9262. } else if (i > 0) {
  9263. if (vowelflag && !xflag) {
  9264. if (!/[AEIOU]/.test(name[i])) {
  9265. return false;
  9266. }
  9267. }
  9268. if (xflag) {
  9269. if (!/X/.test(name[i])) {
  9270. return false;
  9271. }
  9272. }
  9273. }
  9274. }
  9275. return true;
  9276. }
  9277. /*
  9278. * it-IT validation function
  9279. * (Codice fiscale (TIN-IT), persons only)
  9280. * Verify name, birth date and codice catastale validity
  9281. * and calculate check character.
  9282. * Material not in DG-TAXUD document sourced from:
  9283. * `https://en.wikipedia.org/wiki/Italian_fiscal_code`
  9284. */
  9285. function itItCheck(tin) {
  9286. // Capitalize and split characters into an array for further processing
  9287. var chars = tin.toUpperCase().split(''); // Check first and last name validity calling itItNameCheck()
  9288. if (!itItNameCheck(chars.slice(0, 3))) {
  9289. return false;
  9290. }
  9291. if (!itItNameCheck(chars.slice(3, 6))) {
  9292. return false;
  9293. } // Convert letters in number spaces back to numbers if any
  9294. var number_locations = [6, 7, 9, 10, 12, 13, 14];
  9295. var number_replace = {
  9296. L: '0',
  9297. M: '1',
  9298. N: '2',
  9299. P: '3',
  9300. Q: '4',
  9301. R: '5',
  9302. S: '6',
  9303. T: '7',
  9304. U: '8',
  9305. V: '9'
  9306. };
  9307. for (var _i4 = 0, _number_locations = number_locations; _i4 < _number_locations.length; _i4++) {
  9308. var i = _number_locations[_i4];
  9309. if (chars[i] in number_replace) {
  9310. chars.splice(i, 1, number_replace[chars[i]]);
  9311. }
  9312. } // Extract month and day, and check date validity
  9313. var month_replace = {
  9314. A: '01',
  9315. B: '02',
  9316. C: '03',
  9317. D: '04',
  9318. E: '05',
  9319. H: '06',
  9320. L: '07',
  9321. M: '08',
  9322. P: '09',
  9323. R: '10',
  9324. S: '11',
  9325. T: '12'
  9326. };
  9327. var month = month_replace[chars[8]];
  9328. var day = parseInt(chars[9] + chars[10], 10);
  9329. if (day > 40) {
  9330. day -= 40;
  9331. }
  9332. if (day < 10) {
  9333. day = "0".concat(day);
  9334. }
  9335. var date = "".concat(chars[6]).concat(chars[7], "/").concat(month, "/").concat(day);
  9336. if (!(0, _isDate.default)(date, 'YY/MM/DD')) {
  9337. return false;
  9338. } // Calculate check character by adding up even and odd characters as numbers
  9339. var checksum = 0;
  9340. for (var _i5 = 1; _i5 < chars.length - 1; _i5 += 2) {
  9341. var char_to_int = parseInt(chars[_i5], 10);
  9342. if (isNaN(char_to_int)) {
  9343. char_to_int = chars[_i5].charCodeAt(0) - 65;
  9344. }
  9345. checksum += char_to_int;
  9346. }
  9347. var odd_convert = {
  9348. // Maps of characters at odd places
  9349. A: 1,
  9350. B: 0,
  9351. C: 5,
  9352. D: 7,
  9353. E: 9,
  9354. F: 13,
  9355. G: 15,
  9356. H: 17,
  9357. I: 19,
  9358. J: 21,
  9359. K: 2,
  9360. L: 4,
  9361. M: 18,
  9362. N: 20,
  9363. O: 11,
  9364. P: 3,
  9365. Q: 6,
  9366. R: 8,
  9367. S: 12,
  9368. T: 14,
  9369. U: 16,
  9370. V: 10,
  9371. W: 22,
  9372. X: 25,
  9373. Y: 24,
  9374. Z: 23,
  9375. 0: 1,
  9376. 1: 0
  9377. };
  9378. for (var _i6 = 0; _i6 < chars.length - 1; _i6 += 2) {
  9379. var _char_to_int = 0;
  9380. if (chars[_i6] in odd_convert) {
  9381. _char_to_int = odd_convert[chars[_i6]];
  9382. } else {
  9383. var multiplier = parseInt(chars[_i6], 10);
  9384. _char_to_int = 2 * multiplier + 1;
  9385. if (multiplier > 4) {
  9386. _char_to_int += 2;
  9387. }
  9388. }
  9389. checksum += _char_to_int;
  9390. }
  9391. if (String.fromCharCode(65 + checksum % 26) !== chars[15]) {
  9392. return false;
  9393. }
  9394. return true;
  9395. }
  9396. /*
  9397. * lv-LV validation function
  9398. * (Personas kods (PK), persons only)
  9399. * Check validity of birth date and calculate check (last) digit
  9400. * Support only for old format numbers (not starting with '32', issued before 2017/07/01)
  9401. * Material not in DG TAXUD document sourced from:
  9402. * `https://boot.ritakafija.lv/forums/index.php?/topic/88314-personas-koda-algoritms-%C4%8Deksumma/`
  9403. */
  9404. function lvLvCheck(tin) {
  9405. tin = tin.replace(/\W/, ''); // Extract date from TIN
  9406. var day = tin.slice(0, 2);
  9407. if (day !== '32') {
  9408. // No date/checksum check if new format
  9409. var month = tin.slice(2, 4);
  9410. if (month !== '00') {
  9411. // No date check if unknown month
  9412. var full_year = tin.slice(4, 6);
  9413. switch (tin[6]) {
  9414. case '0':
  9415. full_year = "18".concat(full_year);
  9416. break;
  9417. case '1':
  9418. full_year = "19".concat(full_year);
  9419. break;
  9420. default:
  9421. full_year = "20".concat(full_year);
  9422. break;
  9423. } // Check date validity
  9424. var date = "".concat(full_year, "/").concat(tin.slice(2, 4), "/").concat(day);
  9425. if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  9426. return false;
  9427. }
  9428. } // Calculate check digit
  9429. var checksum = 1101;
  9430. var multip_lookup = [1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
  9431. for (var i = 0; i < tin.length - 1; i++) {
  9432. checksum -= parseInt(tin[i], 10) * multip_lookup[i];
  9433. }
  9434. return parseInt(tin[10], 10) === checksum % 11;
  9435. }
  9436. return true;
  9437. }
  9438. /*
  9439. * mt-MT validation function
  9440. * (Identity Card Number or Unique Taxpayer Reference, persons/entities)
  9441. * Verify Identity Card Number structure (no other tests found)
  9442. */
  9443. function mtMtCheck(tin) {
  9444. if (tin.length !== 9) {
  9445. // No tests for UTR
  9446. var chars = tin.toUpperCase().split(''); // Fill with zeros if smaller than proper
  9447. while (chars.length < 8) {
  9448. chars.unshift(0);
  9449. } // Validate format according to last character
  9450. switch (tin[7]) {
  9451. case 'A':
  9452. case 'P':
  9453. if (parseInt(chars[6], 10) === 0) {
  9454. return false;
  9455. }
  9456. break;
  9457. default:
  9458. {
  9459. var first_part = parseInt(chars.join('').slice(0, 5), 10);
  9460. if (first_part > 32000) {
  9461. return false;
  9462. }
  9463. var second_part = parseInt(chars.join('').slice(5, 7), 10);
  9464. if (first_part === second_part) {
  9465. return false;
  9466. }
  9467. }
  9468. }
  9469. }
  9470. return true;
  9471. }
  9472. /*
  9473. * nl-NL validation function
  9474. * (Burgerservicenummer (BSN) or Rechtspersonen Samenwerkingsverbanden Informatie Nummer (RSIN),
  9475. * persons/entities respectively)
  9476. * Verify TIN validity by calculating check (last) digit (variant of MOD 11)
  9477. */
  9478. function nlNlCheck(tin) {
  9479. return algorithms$1.reverseMultiplyAndSum(tin.split('').slice(0, 8).map(function (a) {
  9480. return parseInt(a, 10);
  9481. }), 9) % 11 === parseInt(tin[8], 10);
  9482. }
  9483. /*
  9484. * pl-PL validation function
  9485. * (Powszechny Elektroniczny System Ewidencji Ludności (PESEL)
  9486. * or Numer identyfikacji podatkowej (NIP), persons/entities)
  9487. * Verify TIN validity by validating birth date (PESEL) and calculating check (last) digit
  9488. */
  9489. function plPlCheck(tin) {
  9490. // NIP
  9491. if (tin.length === 10) {
  9492. // Calculate last digit by multiplying with lookup
  9493. var lookup = [6, 5, 7, 2, 3, 4, 5, 6, 7];
  9494. var _checksum = 0;
  9495. for (var i = 0; i < lookup.length; i++) {
  9496. _checksum += parseInt(tin[i], 10) * lookup[i];
  9497. }
  9498. _checksum %= 11;
  9499. if (_checksum === 10) {
  9500. return false;
  9501. }
  9502. return _checksum === parseInt(tin[9], 10);
  9503. } // PESEL
  9504. // Extract full year using month
  9505. var full_year = tin.slice(0, 2);
  9506. var month = parseInt(tin.slice(2, 4), 10);
  9507. if (month > 80) {
  9508. full_year = "18".concat(full_year);
  9509. month -= 80;
  9510. } else if (month > 60) {
  9511. full_year = "22".concat(full_year);
  9512. month -= 60;
  9513. } else if (month > 40) {
  9514. full_year = "21".concat(full_year);
  9515. month -= 40;
  9516. } else if (month > 20) {
  9517. full_year = "20".concat(full_year);
  9518. month -= 20;
  9519. } else {
  9520. full_year = "19".concat(full_year);
  9521. } // Add leading zero to month if needed
  9522. if (month < 10) {
  9523. month = "0".concat(month);
  9524. } // Check date validity
  9525. var date = "".concat(full_year, "/").concat(month, "/").concat(tin.slice(4, 6));
  9526. if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  9527. return false;
  9528. } // Calculate last digit by mulitplying with odd one-digit numbers except 5
  9529. var checksum = 0;
  9530. var multiplier = 1;
  9531. for (var _i7 = 0; _i7 < tin.length - 1; _i7++) {
  9532. checksum += parseInt(tin[_i7], 10) * multiplier % 10;
  9533. multiplier += 2;
  9534. if (multiplier > 10) {
  9535. multiplier = 1;
  9536. } else if (multiplier === 5) {
  9537. multiplier += 2;
  9538. }
  9539. }
  9540. checksum = 10 - checksum % 10;
  9541. return checksum === parseInt(tin[10], 10);
  9542. }
  9543. /*
  9544. * pt-BR validation function
  9545. * (Cadastro de Pessoas Físicas (CPF, persons)
  9546. * Cadastro Nacional de Pessoas Jurídicas (CNPJ, entities)
  9547. * Both inputs will be validated
  9548. */
  9549. function ptBrCheck(tin) {
  9550. if (tin.length === 11) {
  9551. var _sum;
  9552. var remainder;
  9553. _sum = 0;
  9554. if ( // Reject known invalid CPFs
  9555. tin === '11111111111' || tin === '22222222222' || tin === '33333333333' || tin === '44444444444' || tin === '55555555555' || tin === '66666666666' || tin === '77777777777' || tin === '88888888888' || tin === '99999999999' || tin === '00000000000') return false;
  9556. for (var i = 1; i <= 9; i++) {
  9557. _sum += parseInt(tin.substring(i - 1, i), 10) * (11 - i);
  9558. }
  9559. remainder = _sum * 10 % 11;
  9560. if (remainder === 10) remainder = 0;
  9561. if (remainder !== parseInt(tin.substring(9, 10), 10)) return false;
  9562. _sum = 0;
  9563. for (var _i8 = 1; _i8 <= 10; _i8++) {
  9564. _sum += parseInt(tin.substring(_i8 - 1, _i8), 10) * (12 - _i8);
  9565. }
  9566. remainder = _sum * 10 % 11;
  9567. if (remainder === 10) remainder = 0;
  9568. if (remainder !== parseInt(tin.substring(10, 11), 10)) return false;
  9569. return true;
  9570. }
  9571. if ( // Reject know invalid CNPJs
  9572. tin === '00000000000000' || tin === '11111111111111' || tin === '22222222222222' || tin === '33333333333333' || tin === '44444444444444' || tin === '55555555555555' || tin === '66666666666666' || tin === '77777777777777' || tin === '88888888888888' || tin === '99999999999999') {
  9573. return false;
  9574. }
  9575. var length = tin.length - 2;
  9576. var identifiers = tin.substring(0, length);
  9577. var verificators = tin.substring(length);
  9578. var sum = 0;
  9579. var pos = length - 7;
  9580. for (var _i9 = length; _i9 >= 1; _i9--) {
  9581. sum += identifiers.charAt(length - _i9) * pos;
  9582. pos -= 1;
  9583. if (pos < 2) {
  9584. pos = 9;
  9585. }
  9586. }
  9587. var result = sum % 11 < 2 ? 0 : 11 - sum % 11;
  9588. if (result !== parseInt(verificators.charAt(0), 10)) {
  9589. return false;
  9590. }
  9591. length += 1;
  9592. identifiers = tin.substring(0, length);
  9593. sum = 0;
  9594. pos = length - 7;
  9595. for (var _i10 = length; _i10 >= 1; _i10--) {
  9596. sum += identifiers.charAt(length - _i10) * pos;
  9597. pos -= 1;
  9598. if (pos < 2) {
  9599. pos = 9;
  9600. }
  9601. }
  9602. result = sum % 11 < 2 ? 0 : 11 - sum % 11;
  9603. if (result !== parseInt(verificators.charAt(1), 10)) {
  9604. return false;
  9605. }
  9606. return true;
  9607. }
  9608. /*
  9609. * pt-PT validation function
  9610. * (Número de identificação fiscal (NIF), persons/entities)
  9611. * Verify TIN validity by calculating check (last) digit (variant of MOD 11)
  9612. */
  9613. function ptPtCheck(tin) {
  9614. var checksum = 11 - algorithms$1.reverseMultiplyAndSum(tin.split('').slice(0, 8).map(function (a) {
  9615. return parseInt(a, 10);
  9616. }), 9) % 11;
  9617. if (checksum > 9) {
  9618. return parseInt(tin[8], 10) === 0;
  9619. }
  9620. return checksum === parseInt(tin[8], 10);
  9621. }
  9622. /*
  9623. * ro-RO validation function
  9624. * (Cod Numeric Personal (CNP) or Cod de înregistrare fiscală (CIF),
  9625. * persons only)
  9626. * Verify CNP validity by calculating check (last) digit (test not found for CIF)
  9627. * Material not in DG TAXUD document sourced from:
  9628. * `https://en.wikipedia.org/wiki/National_identification_number#Romania`
  9629. */
  9630. function roRoCheck(tin) {
  9631. if (tin.slice(0, 4) !== '9000') {
  9632. // No test found for this format
  9633. // Extract full year using century digit if possible
  9634. var full_year = tin.slice(1, 3);
  9635. switch (tin[0]) {
  9636. case '1':
  9637. case '2':
  9638. full_year = "19".concat(full_year);
  9639. break;
  9640. case '3':
  9641. case '4':
  9642. full_year = "18".concat(full_year);
  9643. break;
  9644. case '5':
  9645. case '6':
  9646. full_year = "20".concat(full_year);
  9647. break;
  9648. } // Check date validity
  9649. var date = "".concat(full_year, "/").concat(tin.slice(3, 5), "/").concat(tin.slice(5, 7));
  9650. if (date.length === 8) {
  9651. if (!(0, _isDate.default)(date, 'YY/MM/DD')) {
  9652. return false;
  9653. }
  9654. } else if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  9655. return false;
  9656. } // Calculate check digit
  9657. var digits = tin.split('').map(function (a) {
  9658. return parseInt(a, 10);
  9659. });
  9660. var multipliers = [2, 7, 9, 1, 4, 6, 3, 5, 8, 2, 7, 9];
  9661. var checksum = 0;
  9662. for (var i = 0; i < multipliers.length; i++) {
  9663. checksum += digits[i] * multipliers[i];
  9664. }
  9665. if (checksum % 11 === 10) {
  9666. return digits[12] === 1;
  9667. }
  9668. return digits[12] === checksum % 11;
  9669. }
  9670. return true;
  9671. }
  9672. /*
  9673. * sk-SK validation function
  9674. * (Rodné číslo (RČ) or bezvýznamové identifikačné číslo (BIČ), persons only)
  9675. * Checks validity of pre-1954 birth numbers (rodné číslo) only
  9676. * Due to the introduction of the pseudo-random BIČ it is not possible to test
  9677. * post-1954 birth numbers without knowing whether they are BIČ or RČ beforehand
  9678. */
  9679. function skSkCheck(tin) {
  9680. if (tin.length === 9) {
  9681. tin = tin.replace(/\W/, '');
  9682. if (tin.slice(6) === '000') {
  9683. return false;
  9684. } // Three-zero serial not assigned before 1954
  9685. // Extract full year from TIN length
  9686. var full_year = parseInt(tin.slice(0, 2), 10);
  9687. if (full_year > 53) {
  9688. return false;
  9689. }
  9690. if (full_year < 10) {
  9691. full_year = "190".concat(full_year);
  9692. } else {
  9693. full_year = "19".concat(full_year);
  9694. } // Extract month from TIN and normalize
  9695. var month = parseInt(tin.slice(2, 4), 10);
  9696. if (month > 50) {
  9697. month -= 50;
  9698. }
  9699. if (month < 10) {
  9700. month = "0".concat(month);
  9701. } // Check date validity
  9702. var date = "".concat(full_year, "/").concat(month, "/").concat(tin.slice(4, 6));
  9703. if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  9704. return false;
  9705. }
  9706. }
  9707. return true;
  9708. }
  9709. /*
  9710. * sl-SI validation function
  9711. * (Davčna številka, persons/entities)
  9712. * Verify TIN validity by calculating check (last) digit (variant of MOD 11)
  9713. */
  9714. function slSiCheck(tin) {
  9715. var checksum = 11 - algorithms$1.reverseMultiplyAndSum(tin.split('').slice(0, 7).map(function (a) {
  9716. return parseInt(a, 10);
  9717. }), 8) % 11;
  9718. if (checksum === 10) {
  9719. return parseInt(tin[7], 10) === 0;
  9720. }
  9721. return checksum === parseInt(tin[7], 10);
  9722. }
  9723. /*
  9724. * sv-SE validation function
  9725. * (Personnummer or samordningsnummer, persons only)
  9726. * Checks validity of birth date and calls luhnCheck() to validate check (last) digit
  9727. */
  9728. function svSeCheck(tin) {
  9729. // Make copy of TIN and normalize to two-digit year form
  9730. var tin_copy = tin.slice(0);
  9731. if (tin.length > 11) {
  9732. tin_copy = tin_copy.slice(2);
  9733. } // Extract date of birth
  9734. var full_year = '';
  9735. var month = tin_copy.slice(2, 4);
  9736. var day = parseInt(tin_copy.slice(4, 6), 10);
  9737. if (tin.length > 11) {
  9738. full_year = tin.slice(0, 4);
  9739. } else {
  9740. full_year = tin.slice(0, 2);
  9741. if (tin.length === 11 && day < 60) {
  9742. // Extract full year from centenarian symbol
  9743. // Should work just fine until year 10000 or so
  9744. var current_year = new Date().getFullYear().toString();
  9745. var current_century = parseInt(current_year.slice(0, 2), 10);
  9746. current_year = parseInt(current_year, 10);
  9747. if (tin[6] === '-') {
  9748. if (parseInt("".concat(current_century).concat(full_year), 10) > current_year) {
  9749. full_year = "".concat(current_century - 1).concat(full_year);
  9750. } else {
  9751. full_year = "".concat(current_century).concat(full_year);
  9752. }
  9753. } else {
  9754. full_year = "".concat(current_century - 1).concat(full_year);
  9755. if (current_year - parseInt(full_year, 10) < 100) {
  9756. return false;
  9757. }
  9758. }
  9759. }
  9760. } // Normalize day and check date validity
  9761. if (day > 60) {
  9762. day -= 60;
  9763. }
  9764. if (day < 10) {
  9765. day = "0".concat(day);
  9766. }
  9767. var date = "".concat(full_year, "/").concat(month, "/").concat(day);
  9768. if (date.length === 8) {
  9769. if (!(0, _isDate.default)(date, 'YY/MM/DD')) {
  9770. return false;
  9771. }
  9772. } else if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  9773. return false;
  9774. }
  9775. return algorithms$1.luhnCheck(tin.replace(/\W/, ''));
  9776. } // Locale lookup objects
  9777. /*
  9778. * Tax id regex formats for various locales
  9779. *
  9780. * Where not explicitly specified in DG-TAXUD document both
  9781. * uppercase and lowercase letters are acceptable.
  9782. */
  9783. var taxIdFormat = {
  9784. 'bg-BG': /^\d{10}$/,
  9785. 'cs-CZ': /^\d{6}\/{0,1}\d{3,4}$/,
  9786. 'de-AT': /^\d{9}$/,
  9787. 'de-DE': /^[1-9]\d{10}$/,
  9788. 'dk-DK': /^\d{6}-{0,1}\d{4}$/,
  9789. 'el-CY': /^[09]\d{7}[A-Z]$/,
  9790. 'el-GR': /^([0-4]|[7-9])\d{8}$/,
  9791. 'en-GB': /^\d{10}$|^(?!GB|NK|TN|ZZ)(?![DFIQUV])[A-Z](?![DFIQUVO])[A-Z]\d{6}[ABCD ]$/i,
  9792. 'en-IE': /^\d{7}[A-W][A-IW]{0,1}$/i,
  9793. 'en-US': /^\d{2}[- ]{0,1}\d{7}$/,
  9794. 'es-ES': /^(\d{0,8}|[XYZKLM]\d{7})[A-HJ-NP-TV-Z]$/i,
  9795. 'et-EE': /^[1-6]\d{6}(00[1-9]|0[1-9][0-9]|[1-6][0-9]{2}|70[0-9]|710)\d$/,
  9796. 'fi-FI': /^\d{6}[-+A]\d{3}[0-9A-FHJ-NPR-Y]$/i,
  9797. 'fr-BE': /^\d{11}$/,
  9798. 'fr-FR': /^[0-3]\d{12}$|^[0-3]\d\s\d{2}(\s\d{3}){3}$/,
  9799. // Conforms both to official spec and provided example
  9800. 'fr-LU': /^\d{13}$/,
  9801. 'hr-HR': /^\d{11}$/,
  9802. 'hu-HU': /^8\d{9}$/,
  9803. 'it-IT': /^[A-Z]{6}[L-NP-V0-9]{2}[A-EHLMPRST][L-NP-V0-9]{2}[A-ILMZ][L-NP-V0-9]{3}[A-Z]$/i,
  9804. 'lv-LV': /^\d{6}-{0,1}\d{5}$/,
  9805. // Conforms both to DG TAXUD spec and original research
  9806. 'mt-MT': /^\d{3,7}[APMGLHBZ]$|^([1-8])\1\d{7}$/i,
  9807. 'nl-NL': /^\d{9}$/,
  9808. 'pl-PL': /^\d{10,11}$/,
  9809. 'pt-BR': /(?:^\d{11}$)|(?:^\d{14}$)/,
  9810. 'pt-PT': /^\d{9}$/,
  9811. 'ro-RO': /^\d{13}$/,
  9812. 'sk-SK': /^\d{6}\/{0,1}\d{3,4}$/,
  9813. 'sl-SI': /^[1-9]\d{7}$/,
  9814. 'sv-SE': /^(\d{6}[-+]{0,1}\d{4}|(18|19|20)\d{6}[-+]{0,1}\d{4})$/
  9815. }; // taxIdFormat locale aliases
  9816. taxIdFormat['lb-LU'] = taxIdFormat['fr-LU'];
  9817. taxIdFormat['lt-LT'] = taxIdFormat['et-EE'];
  9818. taxIdFormat['nl-BE'] = taxIdFormat['fr-BE']; // Algorithmic tax id check functions for various locales
  9819. var taxIdCheck = {
  9820. 'bg-BG': bgBgCheck,
  9821. 'cs-CZ': csCzCheck,
  9822. 'de-AT': deAtCheck,
  9823. 'de-DE': deDeCheck,
  9824. 'dk-DK': dkDkCheck,
  9825. 'el-CY': elCyCheck,
  9826. 'el-GR': elGrCheck,
  9827. 'en-IE': enIeCheck,
  9828. 'en-US': enUsCheck,
  9829. 'es-ES': esEsCheck,
  9830. 'et-EE': etEeCheck,
  9831. 'fi-FI': fiFiCheck,
  9832. 'fr-BE': frBeCheck,
  9833. 'fr-FR': frFrCheck,
  9834. 'fr-LU': frLuCheck,
  9835. 'hr-HR': hrHrCheck,
  9836. 'hu-HU': huHuCheck,
  9837. 'it-IT': itItCheck,
  9838. 'lv-LV': lvLvCheck,
  9839. 'mt-MT': mtMtCheck,
  9840. 'nl-NL': nlNlCheck,
  9841. 'pl-PL': plPlCheck,
  9842. 'pt-BR': ptBrCheck,
  9843. 'pt-PT': ptPtCheck,
  9844. 'ro-RO': roRoCheck,
  9845. 'sk-SK': skSkCheck,
  9846. 'sl-SI': slSiCheck,
  9847. 'sv-SE': svSeCheck
  9848. }; // taxIdCheck locale aliases
  9849. taxIdCheck['lb-LU'] = taxIdCheck['fr-LU'];
  9850. taxIdCheck['lt-LT'] = taxIdCheck['et-EE'];
  9851. taxIdCheck['nl-BE'] = taxIdCheck['fr-BE']; // Regexes for locales where characters should be omitted before checking format
  9852. var allsymbols = /[-\\\/!@#$%\^&\*\(\)\+\=\[\]]+/g;
  9853. var sanitizeRegexes = {
  9854. 'de-AT': allsymbols,
  9855. 'de-DE': /[\/\\]/g,
  9856. 'fr-BE': allsymbols
  9857. }; // sanitizeRegexes locale aliases
  9858. sanitizeRegexes['nl-BE'] = sanitizeRegexes['fr-BE'];
  9859. /*
  9860. * Validator function
  9861. * Return true if the passed string is a valid tax identification number
  9862. * for the specified locale.
  9863. * Throw an error exception if the locale is not supported.
  9864. */
  9865. function isTaxID(str) {
  9866. var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US';
  9867. (0, _assertString.default)(str); // Copy TIN to avoid replacement if sanitized
  9868. var strcopy = str.slice(0);
  9869. if (locale in taxIdFormat) {
  9870. if (locale in sanitizeRegexes) {
  9871. strcopy = strcopy.replace(sanitizeRegexes[locale], '');
  9872. }
  9873. if (!taxIdFormat[locale].test(strcopy)) {
  9874. return false;
  9875. }
  9876. if (locale in taxIdCheck) {
  9877. return taxIdCheck[locale](strcopy);
  9878. } // Fallthrough; not all locales have algorithmic checks
  9879. return true;
  9880. }
  9881. throw new Error("Invalid locale '".concat(locale, "'"));
  9882. }
  9883. module.exports = exports.default;
  9884. module.exports.default = exports.default;
  9885. } (isTaxID, isTaxID.exports));
  9886. var isTaxIDValidator = /*@__PURE__*/getDefaultExportFromCjs(isTaxID.exports);
  9887. var isISO4217$1 = {};
  9888. Object.defineProperty(isISO4217$1, "__esModule", {
  9889. value: true
  9890. });
  9891. var _default = isISO4217$1.default = isISO4217;
  9892. isISO4217$1.CurrencyCodes = void 0;
  9893. var _assertString$1 = _interopRequireDefault$1(assertString.exports);
  9894. function _interopRequireDefault$1(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9895. // from https://en.wikipedia.org/wiki/ISO_4217
  9896. var validISO4217CurrencyCodes = new Set(['AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', 'AWG', 'AZN', 'BAM', 'BBD', 'BDT', 'BGN', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BOV', 'BRL', 'BSD', 'BTN', 'BWP', 'BYN', 'BZD', 'CAD', 'CDF', 'CHE', 'CHF', 'CHW', 'CLF', 'CLP', 'CNY', 'COP', 'COU', 'CRC', 'CUC', 'CUP', 'CVE', 'CZK', 'DJF', 'DKK', 'DOP', 'DZD', 'EGP', 'ERN', 'ETB', 'EUR', 'FJD', 'FKP', 'GBP', 'GEL', 'GHS', 'GIP', 'GMD', 'GNF', 'GTQ', 'GYD', 'HKD', 'HNL', 'HRK', 'HTG', 'HUF', 'IDR', 'ILS', 'INR', 'IQD', 'IRR', 'ISK', 'JMD', 'JOD', 'JPY', 'KES', 'KGS', 'KHR', 'KMF', 'KPW', 'KRW', 'KWD', 'KYD', 'KZT', 'LAK', 'LBP', 'LKR', 'LRD', 'LSL', 'LYD', 'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRU', 'MUR', 'MVR', 'MWK', 'MXN', 'MXV', 'MYR', 'MZN', 'NAD', 'NGN', 'NIO', 'NOK', 'NPR', 'NZD', 'OMR', 'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN', 'PYG', 'QAR', 'RON', 'RSD', 'RUB', 'RWF', 'SAR', 'SBD', 'SCR', 'SDG', 'SEK', 'SGD', 'SHP', 'SLL', 'SOS', 'SRD', 'SSP', 'STN', 'SVC', 'SYP', 'SZL', 'THB', 'TJS', 'TMT', 'TND', 'TOP', 'TRY', 'TTD', 'TWD', 'TZS', 'UAH', 'UGX', 'USD', 'USN', 'UYI', 'UYU', 'UYW', 'UZS', 'VES', 'VND', 'VUV', 'WST', 'XAF', 'XAG', 'XAU', 'XBA', 'XBB', 'XBC', 'XBD', 'XCD', 'XDR', 'XOF', 'XPD', 'XPF', 'XPT', 'XSU', 'XTS', 'XUA', 'XXX', 'YER', 'ZAR', 'ZMW', 'ZWL']);
  9897. function isISO4217(str) {
  9898. (0, _assertString$1.default)(str);
  9899. return validISO4217CurrencyCodes.has(str.toUpperCase());
  9900. }
  9901. var CurrencyCodes = validISO4217CurrencyCodes;
  9902. isISO4217$1.CurrencyCodes = CurrencyCodes;
  9903. var isBase58$1 = {exports: {}};
  9904. (function (module, exports) {
  9905. Object.defineProperty(exports, "__esModule", {
  9906. value: true
  9907. });
  9908. exports.default = isBase58;
  9909. var _assertString = _interopRequireDefault(assertString.exports);
  9910. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9911. // Accepted chars - 123456789ABCDEFGH JKLMN PQRSTUVWXYZabcdefghijk mnopqrstuvwxyz
  9912. var base58Reg = /^[A-HJ-NP-Za-km-z1-9]*$/;
  9913. function isBase58(str) {
  9914. (0, _assertString.default)(str);
  9915. if (base58Reg.test(str)) {
  9916. return true;
  9917. }
  9918. return false;
  9919. }
  9920. module.exports = exports.default;
  9921. module.exports.default = exports.default;
  9922. } (isBase58$1, isBase58$1.exports));
  9923. var isBase58Validator = /*@__PURE__*/getDefaultExportFromCjs(isBase58$1.exports);
  9924. var ltrim = {exports: {}};
  9925. (function (module, exports) {
  9926. Object.defineProperty(exports, "__esModule", {
  9927. value: true
  9928. });
  9929. exports.default = ltrim;
  9930. var _assertString = _interopRequireDefault(assertString.exports);
  9931. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9932. function ltrim(str, chars) {
  9933. (0, _assertString.default)(str); // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
  9934. var pattern = chars ? new RegExp("^[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+"), 'g') : /^\s+/g;
  9935. return str.replace(pattern, '');
  9936. }
  9937. module.exports = exports.default;
  9938. module.exports.default = exports.default;
  9939. } (ltrim, ltrim.exports));
  9940. var rtrim = {exports: {}};
  9941. (function (module, exports) {
  9942. Object.defineProperty(exports, "__esModule", {
  9943. value: true
  9944. });
  9945. exports.default = rtrim;
  9946. var _assertString = _interopRequireDefault(assertString.exports);
  9947. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9948. function rtrim(str, chars) {
  9949. (0, _assertString.default)(str);
  9950. if (chars) {
  9951. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
  9952. var pattern = new RegExp("[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+$"), 'g');
  9953. return str.replace(pattern, '');
  9954. } // Use a faster and more safe than regex trim method https://blog.stevenlevithan.com/archives/faster-trim-javascript
  9955. var strIndex = str.length - 1;
  9956. while (/\s/.test(str.charAt(strIndex))) {
  9957. strIndex -= 1;
  9958. }
  9959. return str.slice(0, strIndex + 1);
  9960. }
  9961. module.exports = exports.default;
  9962. module.exports.default = exports.default;
  9963. } (rtrim, rtrim.exports));
  9964. var trim = {exports: {}};
  9965. (function (module, exports) {
  9966. Object.defineProperty(exports, "__esModule", {
  9967. value: true
  9968. });
  9969. exports.default = trim;
  9970. var _rtrim = _interopRequireDefault(rtrim.exports);
  9971. var _ltrim = _interopRequireDefault(ltrim.exports);
  9972. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9973. function trim(str, chars) {
  9974. return (0, _rtrim.default)((0, _ltrim.default)(str, chars), chars);
  9975. }
  9976. module.exports = exports.default;
  9977. module.exports.default = exports.default;
  9978. } (trim, trim.exports));
  9979. var _escape = {exports: {}};
  9980. (function (module, exports) {
  9981. Object.defineProperty(exports, "__esModule", {
  9982. value: true
  9983. });
  9984. exports.default = escape;
  9985. var _assertString = _interopRequireDefault(assertString.exports);
  9986. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9987. function escape(str) {
  9988. (0, _assertString.default)(str);
  9989. return str.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\//g, '&#x2F;').replace(/\\/g, '&#x5C;').replace(/`/g, '&#96;');
  9990. }
  9991. module.exports = exports.default;
  9992. module.exports.default = exports.default;
  9993. } (_escape, _escape.exports));
  9994. var _unescape = {exports: {}};
  9995. (function (module, exports) {
  9996. Object.defineProperty(exports, "__esModule", {
  9997. value: true
  9998. });
  9999. exports.default = unescape;
  10000. var _assertString = _interopRequireDefault(assertString.exports);
  10001. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10002. function unescape(str) {
  10003. (0, _assertString.default)(str);
  10004. return str.replace(/&quot;/g, '"').replace(/&#x27;/g, "'").replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&#x2F;/g, '/').replace(/&#x5C;/g, '\\').replace(/&#96;/g, '`').replace(/&amp;/g, '&'); // &amp; replacement has to be the last one to prevent
  10005. // bugs with intermediate strings containing escape sequences
  10006. // See: https://github.com/validatorjs/validator.js/issues/1827
  10007. }
  10008. module.exports = exports.default;
  10009. module.exports.default = exports.default;
  10010. } (_unescape, _unescape.exports));
  10011. var stripLow = {exports: {}};
  10012. var blacklist = {exports: {}};
  10013. (function (module, exports) {
  10014. Object.defineProperty(exports, "__esModule", {
  10015. value: true
  10016. });
  10017. exports.default = blacklist;
  10018. var _assertString = _interopRequireDefault(assertString.exports);
  10019. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10020. function blacklist(str, chars) {
  10021. (0, _assertString.default)(str);
  10022. return str.replace(new RegExp("[".concat(chars, "]+"), 'g'), '');
  10023. }
  10024. module.exports = exports.default;
  10025. module.exports.default = exports.default;
  10026. } (blacklist, blacklist.exports));
  10027. (function (module, exports) {
  10028. Object.defineProperty(exports, "__esModule", {
  10029. value: true
  10030. });
  10031. exports.default = stripLow;
  10032. var _assertString = _interopRequireDefault(assertString.exports);
  10033. var _blacklist = _interopRequireDefault(blacklist.exports);
  10034. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10035. function stripLow(str, keep_new_lines) {
  10036. (0, _assertString.default)(str);
  10037. var chars = keep_new_lines ? '\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F' : '\\x00-\\x1F\\x7F';
  10038. return (0, _blacklist.default)(str, chars);
  10039. }
  10040. module.exports = exports.default;
  10041. module.exports.default = exports.default;
  10042. } (stripLow, stripLow.exports));
  10043. var whitelist = {exports: {}};
  10044. (function (module, exports) {
  10045. Object.defineProperty(exports, "__esModule", {
  10046. value: true
  10047. });
  10048. exports.default = whitelist;
  10049. var _assertString = _interopRequireDefault(assertString.exports);
  10050. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10051. function whitelist(str, chars) {
  10052. (0, _assertString.default)(str);
  10053. return str.replace(new RegExp("[^".concat(chars, "]+"), 'g'), '');
  10054. }
  10055. module.exports = exports.default;
  10056. module.exports.default = exports.default;
  10057. } (whitelist, whitelist.exports));
  10058. var isWhitelisted = {exports: {}};
  10059. (function (module, exports) {
  10060. Object.defineProperty(exports, "__esModule", {
  10061. value: true
  10062. });
  10063. exports.default = isWhitelisted;
  10064. var _assertString = _interopRequireDefault(assertString.exports);
  10065. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10066. function isWhitelisted(str, chars) {
  10067. (0, _assertString.default)(str);
  10068. for (var i = str.length - 1; i >= 0; i--) {
  10069. if (chars.indexOf(str[i]) === -1) {
  10070. return false;
  10071. }
  10072. }
  10073. return true;
  10074. }
  10075. module.exports = exports.default;
  10076. module.exports.default = exports.default;
  10077. } (isWhitelisted, isWhitelisted.exports));
  10078. var normalizeEmail = {exports: {}};
  10079. (function (module, exports) {
  10080. Object.defineProperty(exports, "__esModule", {
  10081. value: true
  10082. });
  10083. exports.default = normalizeEmail;
  10084. var _merge = _interopRequireDefault(merge.exports);
  10085. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10086. var default_normalize_email_options = {
  10087. // The following options apply to all email addresses
  10088. // Lowercases the local part of the email address.
  10089. // Please note this may violate RFC 5321 as per http://stackoverflow.com/a/9808332/192024).
  10090. // The domain is always lowercased, as per RFC 1035
  10091. all_lowercase: true,
  10092. // The following conversions are specific to GMail
  10093. // Lowercases the local part of the GMail address (known to be case-insensitive)
  10094. gmail_lowercase: true,
  10095. // Removes dots from the local part of the email address, as that's ignored by GMail
  10096. gmail_remove_dots: true,
  10097. // Removes the subaddress (e.g. "+foo") from the email address
  10098. gmail_remove_subaddress: true,
  10099. // Conversts the googlemail.com domain to gmail.com
  10100. gmail_convert_googlemaildotcom: true,
  10101. // The following conversions are specific to Outlook.com / Windows Live / Hotmail
  10102. // Lowercases the local part of the Outlook.com address (known to be case-insensitive)
  10103. outlookdotcom_lowercase: true,
  10104. // Removes the subaddress (e.g. "+foo") from the email address
  10105. outlookdotcom_remove_subaddress: true,
  10106. // The following conversions are specific to Yahoo
  10107. // Lowercases the local part of the Yahoo address (known to be case-insensitive)
  10108. yahoo_lowercase: true,
  10109. // Removes the subaddress (e.g. "-foo") from the email address
  10110. yahoo_remove_subaddress: true,
  10111. // The following conversions are specific to Yandex
  10112. // Lowercases the local part of the Yandex address (known to be case-insensitive)
  10113. yandex_lowercase: true,
  10114. // The following conversions are specific to iCloud
  10115. // Lowercases the local part of the iCloud address (known to be case-insensitive)
  10116. icloud_lowercase: true,
  10117. // Removes the subaddress (e.g. "+foo") from the email address
  10118. icloud_remove_subaddress: true
  10119. }; // List of domains used by iCloud
  10120. var icloud_domains = ['icloud.com', 'me.com']; // List of domains used by Outlook.com and its predecessors
  10121. // This list is likely incomplete.
  10122. // Partial reference:
  10123. // https://blogs.office.com/2013/04/17/outlook-com-gets-two-step-verification-sign-in-by-alias-and-new-international-domains/
  10124. var outlookdotcom_domains = ['hotmail.at', 'hotmail.be', 'hotmail.ca', 'hotmail.cl', 'hotmail.co.il', 'hotmail.co.nz', 'hotmail.co.th', 'hotmail.co.uk', 'hotmail.com', 'hotmail.com.ar', 'hotmail.com.au', 'hotmail.com.br', 'hotmail.com.gr', 'hotmail.com.mx', 'hotmail.com.pe', 'hotmail.com.tr', 'hotmail.com.vn', 'hotmail.cz', 'hotmail.de', 'hotmail.dk', 'hotmail.es', 'hotmail.fr', 'hotmail.hu', 'hotmail.id', 'hotmail.ie', 'hotmail.in', 'hotmail.it', 'hotmail.jp', 'hotmail.kr', 'hotmail.lv', 'hotmail.my', 'hotmail.ph', 'hotmail.pt', 'hotmail.sa', 'hotmail.sg', 'hotmail.sk', 'live.be', 'live.co.uk', 'live.com', 'live.com.ar', 'live.com.mx', 'live.de', 'live.es', 'live.eu', 'live.fr', 'live.it', 'live.nl', 'msn.com', 'outlook.at', 'outlook.be', 'outlook.cl', 'outlook.co.il', 'outlook.co.nz', 'outlook.co.th', 'outlook.com', 'outlook.com.ar', 'outlook.com.au', 'outlook.com.br', 'outlook.com.gr', 'outlook.com.pe', 'outlook.com.tr', 'outlook.com.vn', 'outlook.cz', 'outlook.de', 'outlook.dk', 'outlook.es', 'outlook.fr', 'outlook.hu', 'outlook.id', 'outlook.ie', 'outlook.in', 'outlook.it', 'outlook.jp', 'outlook.kr', 'outlook.lv', 'outlook.my', 'outlook.ph', 'outlook.pt', 'outlook.sa', 'outlook.sg', 'outlook.sk', 'passport.com']; // List of domains used by Yahoo Mail
  10125. // This list is likely incomplete
  10126. var yahoo_domains = ['rocketmail.com', 'yahoo.ca', 'yahoo.co.uk', 'yahoo.com', 'yahoo.de', 'yahoo.fr', 'yahoo.in', 'yahoo.it', 'ymail.com']; // List of domains used by yandex.ru
  10127. var yandex_domains = ['yandex.ru', 'yandex.ua', 'yandex.kz', 'yandex.com', 'yandex.by', 'ya.ru']; // replace single dots, but not multiple consecutive dots
  10128. function dotsReplacer(match) {
  10129. if (match.length > 1) {
  10130. return match;
  10131. }
  10132. return '';
  10133. }
  10134. function normalizeEmail(email, options) {
  10135. options = (0, _merge.default)(options, default_normalize_email_options);
  10136. var raw_parts = email.split('@');
  10137. var domain = raw_parts.pop();
  10138. var user = raw_parts.join('@');
  10139. var parts = [user, domain]; // The domain is always lowercased, as it's case-insensitive per RFC 1035
  10140. parts[1] = parts[1].toLowerCase();
  10141. if (parts[1] === 'gmail.com' || parts[1] === 'googlemail.com') {
  10142. // Address is GMail
  10143. if (options.gmail_remove_subaddress) {
  10144. parts[0] = parts[0].split('+')[0];
  10145. }
  10146. if (options.gmail_remove_dots) {
  10147. // this does not replace consecutive dots like example..email@gmail.com
  10148. parts[0] = parts[0].replace(/\.+/g, dotsReplacer);
  10149. }
  10150. if (!parts[0].length) {
  10151. return false;
  10152. }
  10153. if (options.all_lowercase || options.gmail_lowercase) {
  10154. parts[0] = parts[0].toLowerCase();
  10155. }
  10156. parts[1] = options.gmail_convert_googlemaildotcom ? 'gmail.com' : parts[1];
  10157. } else if (icloud_domains.indexOf(parts[1]) >= 0) {
  10158. // Address is iCloud
  10159. if (options.icloud_remove_subaddress) {
  10160. parts[0] = parts[0].split('+')[0];
  10161. }
  10162. if (!parts[0].length) {
  10163. return false;
  10164. }
  10165. if (options.all_lowercase || options.icloud_lowercase) {
  10166. parts[0] = parts[0].toLowerCase();
  10167. }
  10168. } else if (outlookdotcom_domains.indexOf(parts[1]) >= 0) {
  10169. // Address is Outlook.com
  10170. if (options.outlookdotcom_remove_subaddress) {
  10171. parts[0] = parts[0].split('+')[0];
  10172. }
  10173. if (!parts[0].length) {
  10174. return false;
  10175. }
  10176. if (options.all_lowercase || options.outlookdotcom_lowercase) {
  10177. parts[0] = parts[0].toLowerCase();
  10178. }
  10179. } else if (yahoo_domains.indexOf(parts[1]) >= 0) {
  10180. // Address is Yahoo
  10181. if (options.yahoo_remove_subaddress) {
  10182. var components = parts[0].split('-');
  10183. parts[0] = components.length > 1 ? components.slice(0, -1).join('-') : components[0];
  10184. }
  10185. if (!parts[0].length) {
  10186. return false;
  10187. }
  10188. if (options.all_lowercase || options.yahoo_lowercase) {
  10189. parts[0] = parts[0].toLowerCase();
  10190. }
  10191. } else if (yandex_domains.indexOf(parts[1]) >= 0) {
  10192. if (options.all_lowercase || options.yandex_lowercase) {
  10193. parts[0] = parts[0].toLowerCase();
  10194. }
  10195. parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preferred
  10196. } else if (options.all_lowercase) {
  10197. // Any other address
  10198. parts[0] = parts[0].toLowerCase();
  10199. }
  10200. return parts.join('@');
  10201. }
  10202. module.exports = exports.default;
  10203. module.exports.default = exports.default;
  10204. } (normalizeEmail, normalizeEmail.exports));
  10205. var isSlug = {exports: {}};
  10206. (function (module, exports) {
  10207. Object.defineProperty(exports, "__esModule", {
  10208. value: true
  10209. });
  10210. exports.default = isSlug;
  10211. var _assertString = _interopRequireDefault(assertString.exports);
  10212. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10213. var charsetRegex = /^[^\s-_](?!.*?[-_]{2,})[a-z0-9-\\][^\s]*[^-_\s]$/;
  10214. function isSlug(str) {
  10215. (0, _assertString.default)(str);
  10216. return charsetRegex.test(str);
  10217. }
  10218. module.exports = exports.default;
  10219. module.exports.default = exports.default;
  10220. } (isSlug, isSlug.exports));
  10221. var isLicensePlate = {exports: {}};
  10222. (function (module, exports) {
  10223. Object.defineProperty(exports, "__esModule", {
  10224. value: true
  10225. });
  10226. exports.default = isLicensePlate;
  10227. var _assertString = _interopRequireDefault(assertString.exports);
  10228. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10229. var validators = {
  10230. 'cs-CZ': function csCZ(str) {
  10231. return /^(([ABCDEFHKIJKLMNPRSTUVXYZ]|[0-9])-?){5,8}$/.test(str);
  10232. },
  10233. 'de-DE': function deDE(str) {
  10234. return /^((AW|UL|AK|GA|AÖ|LF|AZ|AM|AS|ZE|AN|AB|A|KG|KH|BA|EW|BZ|HY|KM|BT|HP|B|BC|BI|BO|FN|TT|ÜB|BN|AH|BS|FR|HB|ZZ|BB|BK|BÖ|OC|OK|CW|CE|C|CO|LH|CB|KW|LC|LN|DA|DI|DE|DH|SY|NÖ|DO|DD|DU|DN|D|EI|EA|EE|FI|EM|EL|EN|PF|ED|EF|ER|AU|ZP|E|ES|NT|EU|FL|FO|FT|FF|F|FS|FD|FÜ|GE|G|GI|GF|GS|ZR|GG|GP|GR|NY|ZI|GÖ|GZ|GT|HA|HH|HM|HU|WL|HZ|WR|RN|HK|HD|HN|HS|GK|HE|HF|RZ|HI|HG|HO|HX|IK|IL|IN|J|JL|KL|KA|KS|KF|KE|KI|KT|KO|KN|KR|KC|KU|K|LD|LL|LA|L|OP|LM|LI|LB|LU|LÖ|HL|LG|MD|GN|MZ|MA|ML|MR|MY|AT|DM|MC|NZ|RM|RG|MM|ME|MB|MI|FG|DL|HC|MW|RL|MK|MG|MÜ|WS|MH|M|MS|NU|NB|ND|NM|NK|NW|NR|NI|NF|DZ|EB|OZ|TG|TO|N|OA|GM|OB|CA|EH|FW|OF|OL|OE|OG|BH|LR|OS|AA|GD|OH|KY|NP|WK|PB|PA|PE|PI|PS|P|PM|PR|RA|RV|RE|R|H|SB|WN|RS|RD|RT|BM|NE|GV|RP|SU|GL|RO|GÜ|RH|EG|RW|PN|SK|MQ|RU|SZ|RI|SL|SM|SC|HR|FZ|VS|SW|SN|CR|SE|SI|SO|LP|SG|NH|SP|IZ|ST|BF|TE|HV|OD|SR|S|AC|DW|ZW|TF|TS|TR|TÜ|UM|PZ|TP|UE|UN|UH|MN|KK|VB|V|AE|PL|RC|VG|GW|PW|VR|VK|KB|WA|WT|BE|WM|WE|AP|MO|WW|FB|WZ|WI|WB|JE|WF|WO|W|WÜ|BL|Z|GC)[- ]?[A-Z]{1,2}[- ]?\d{1,4}|(AIC|FDB|ABG|SLN|SAW|KLZ|BUL|ESB|NAB|SUL|WST|ABI|AZE|BTF|KÖT|DKB|FEU|ROT|ALZ|SMÜ|WER|AUR|NOR|DÜW|BRK|HAB|TÖL|WOR|BAD|BAR|BER|BIW|EBS|KEM|MÜB|PEG|BGL|BGD|REI|WIL|BKS|BIR|WAT|BOR|BOH|BOT|BRB|BLK|HHM|NEB|NMB|WSF|LEO|HDL|WMS|WZL|BÜS|CHA|KÖZ|ROD|WÜM|CLP|NEC|COC|ZEL|COE|CUX|DAH|LDS|DEG|DEL|RSL|DLG|DGF|LAN|HEI|MED|DON|KIB|ROK|JÜL|MON|SLE|EBE|EIC|HIG|WBS|BIT|PRÜ|LIB|EMD|WIT|ERH|HÖS|ERZ|ANA|ASZ|MAB|MEK|STL|SZB|FDS|HCH|HOR|WOL|FRG|GRA|WOS|FRI|FFB|GAP|GER|BRL|CLZ|GTH|NOH|HGW|GRZ|LÖB|NOL|WSW|DUD|HMÜ|OHA|KRU|HAL|HAM|HBS|QLB|HVL|NAU|HAS|EBN|GEO|HOH|HDH|ERK|HER|WAN|HEF|ROF|HBN|ALF|HSK|USI|NAI|REH|SAN|KÜN|ÖHR|HOL|WAR|ARN|BRG|GNT|HOG|WOH|KEH|MAI|PAR|RID|ROL|KLE|GEL|KUS|KYF|ART|SDH|LDK|DIL|MAL|VIB|LER|BNA|GHA|GRM|MTL|WUR|LEV|LIF|STE|WEL|LIP|VAI|LUP|HGN|LBZ|LWL|PCH|STB|DAN|MKK|SLÜ|MSP|TBB|MGH|MTK|BIN|MSH|EIL|HET|SGH|BID|MYK|MSE|MST|MÜR|WRN|MEI|GRH|RIE|MZG|MIL|OBB|BED|FLÖ|MOL|FRW|SEE|SRB|AIB|MOS|BCH|ILL|SOB|NMS|NEA|SEF|UFF|NEW|VOH|NDH|TDO|NWM|GDB|GVM|WIS|NOM|EIN|GAN|LAU|HEB|OHV|OSL|SFB|ERB|LOS|BSK|KEL|BSB|MEL|WTL|OAL|FÜS|MOD|OHZ|OPR|BÜR|PAF|PLÖ|CAS|GLA|REG|VIT|ECK|SIM|GOA|EMS|DIZ|GOH|RÜD|SWA|NES|KÖN|MET|LRO|BÜZ|DBR|ROS|TET|HRO|ROW|BRV|HIP|PAN|GRI|SHK|EIS|SRO|SOK|LBS|SCZ|MER|QFT|SLF|SLS|HOM|SLK|ASL|BBG|SBK|SFT|SHG|MGN|MEG|ZIG|SAD|NEN|OVI|SHA|BLB|SIG|SON|SPN|FOR|GUB|SPB|IGB|WND|STD|STA|SDL|OBG|HST|BOG|SHL|PIR|FTL|SEB|SÖM|SÜW|TIR|SAB|TUT|ANG|SDT|LÜN|LSZ|MHL|VEC|VER|VIE|OVL|ANK|OVP|SBG|UEM|UER|WLG|GMN|NVP|RDG|RÜG|DAU|FKB|WAF|WAK|SLZ|WEN|SOG|APD|WUG|GUN|ESW|WIZ|WES|DIN|BRA|BÜD|WHV|HWI|GHC|WTM|WOB|WUN|MAK|SEL|OCH|HOT|WDA)[- ]?(([A-Z][- ]?\d{1,4})|([A-Z]{2}[- ]?\d{1,3})))[- ]?(E|H)?$/.test(str);
  10235. },
  10236. 'de-LI': function deLI(str) {
  10237. return /^FL[- ]?\d{1,5}[UZ]?$/.test(str);
  10238. },
  10239. 'fi-FI': function fiFI(str) {
  10240. return /^(?=.{4,7})(([A-Z]{1,3}|[0-9]{1,3})[\s-]?([A-Z]{1,3}|[0-9]{1,5}))$/.test(str);
  10241. },
  10242. 'pt-PT': function ptPT(str) {
  10243. return /^([A-Z]{2}|[0-9]{2})[ -·]?([A-Z]{2}|[0-9]{2})[ -·]?([A-Z]{2}|[0-9]{2})$/.test(str);
  10244. },
  10245. 'sq-AL': function sqAL(str) {
  10246. return /^[A-Z]{2}[- ]?((\d{3}[- ]?(([A-Z]{2})|T))|(R[- ]?\d{3}))$/.test(str);
  10247. },
  10248. 'pt-BR': function ptBR(str) {
  10249. return /^[A-Z]{3}[ -]?[0-9][A-Z][0-9]{2}|[A-Z]{3}[ -]?[0-9]{4}$/.test(str);
  10250. }
  10251. };
  10252. function isLicensePlate(str, locale) {
  10253. (0, _assertString.default)(str);
  10254. if (locale in validators) {
  10255. return validators[locale](str);
  10256. } else if (locale === 'any') {
  10257. for (var key in validators) {
  10258. /* eslint guard-for-in: 0 */
  10259. var validator = validators[key];
  10260. if (validator(str)) {
  10261. return true;
  10262. }
  10263. }
  10264. return false;
  10265. }
  10266. throw new Error("Invalid locale '".concat(locale, "'"));
  10267. }
  10268. module.exports = exports.default;
  10269. module.exports.default = exports.default;
  10270. } (isLicensePlate, isLicensePlate.exports));
  10271. var isStrongPassword$1 = {exports: {}};
  10272. (function (module, exports) {
  10273. Object.defineProperty(exports, "__esModule", {
  10274. value: true
  10275. });
  10276. exports.default = isStrongPassword;
  10277. var _merge = _interopRequireDefault(merge.exports);
  10278. var _assertString = _interopRequireDefault(assertString.exports);
  10279. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10280. var upperCaseRegex = /^[A-Z]$/;
  10281. var lowerCaseRegex = /^[a-z]$/;
  10282. var numberRegex = /^[0-9]$/;
  10283. var symbolRegex = /^[-#!$@%^&*()_+|~=`{}\[\]:";'<>?,.\/ ]$/;
  10284. var defaultOptions = {
  10285. minLength: 8,
  10286. minLowercase: 1,
  10287. minUppercase: 1,
  10288. minNumbers: 1,
  10289. minSymbols: 1,
  10290. returnScore: false,
  10291. pointsPerUnique: 1,
  10292. pointsPerRepeat: 0.5,
  10293. pointsForContainingLower: 10,
  10294. pointsForContainingUpper: 10,
  10295. pointsForContainingNumber: 10,
  10296. pointsForContainingSymbol: 10
  10297. };
  10298. /* Counts number of occurrences of each char in a string
  10299. * could be moved to util/ ?
  10300. */
  10301. function countChars(str) {
  10302. var result = {};
  10303. Array.from(str).forEach(function (char) {
  10304. var curVal = result[char];
  10305. if (curVal) {
  10306. result[char] += 1;
  10307. } else {
  10308. result[char] = 1;
  10309. }
  10310. });
  10311. return result;
  10312. }
  10313. /* Return information about a password */
  10314. function analyzePassword(password) {
  10315. var charMap = countChars(password);
  10316. var analysis = {
  10317. length: password.length,
  10318. uniqueChars: Object.keys(charMap).length,
  10319. uppercaseCount: 0,
  10320. lowercaseCount: 0,
  10321. numberCount: 0,
  10322. symbolCount: 0
  10323. };
  10324. Object.keys(charMap).forEach(function (char) {
  10325. /* istanbul ignore else */
  10326. if (upperCaseRegex.test(char)) {
  10327. analysis.uppercaseCount += charMap[char];
  10328. } else if (lowerCaseRegex.test(char)) {
  10329. analysis.lowercaseCount += charMap[char];
  10330. } else if (numberRegex.test(char)) {
  10331. analysis.numberCount += charMap[char];
  10332. } else if (symbolRegex.test(char)) {
  10333. analysis.symbolCount += charMap[char];
  10334. }
  10335. });
  10336. return analysis;
  10337. }
  10338. function scorePassword(analysis, scoringOptions) {
  10339. var points = 0;
  10340. points += analysis.uniqueChars * scoringOptions.pointsPerUnique;
  10341. points += (analysis.length - analysis.uniqueChars) * scoringOptions.pointsPerRepeat;
  10342. if (analysis.lowercaseCount > 0) {
  10343. points += scoringOptions.pointsForContainingLower;
  10344. }
  10345. if (analysis.uppercaseCount > 0) {
  10346. points += scoringOptions.pointsForContainingUpper;
  10347. }
  10348. if (analysis.numberCount > 0) {
  10349. points += scoringOptions.pointsForContainingNumber;
  10350. }
  10351. if (analysis.symbolCount > 0) {
  10352. points += scoringOptions.pointsForContainingSymbol;
  10353. }
  10354. return points;
  10355. }
  10356. function isStrongPassword(str) {
  10357. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  10358. (0, _assertString.default)(str);
  10359. var analysis = analyzePassword(str);
  10360. options = (0, _merge.default)(options || {}, defaultOptions);
  10361. if (options.returnScore) {
  10362. return scorePassword(analysis, options);
  10363. }
  10364. return analysis.length >= options.minLength && analysis.lowercaseCount >= options.minLowercase && analysis.uppercaseCount >= options.minUppercase && analysis.numberCount >= options.minNumbers && analysis.symbolCount >= options.minSymbols;
  10365. }
  10366. module.exports = exports.default;
  10367. module.exports.default = exports.default;
  10368. } (isStrongPassword$1, isStrongPassword$1.exports));
  10369. var isVAT$1 = {};
  10370. Object.defineProperty(isVAT$1, "__esModule", {
  10371. value: true
  10372. });
  10373. isVAT$1.default = isVAT;
  10374. isVAT$1.vatMatchers = void 0;
  10375. var _assertString = _interopRequireDefault(assertString.exports);
  10376. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10377. var vatMatchers = {
  10378. GB: /^GB((\d{3} \d{4} ([0-8][0-9]|9[0-6]))|(\d{9} \d{3})|(((GD[0-4])|(HA[5-9]))[0-9]{2}))$/,
  10379. IT: /^(IT)?[0-9]{11}$/,
  10380. NL: /^(NL)?[0-9]{9}B[0-9]{2}$/
  10381. };
  10382. isVAT$1.vatMatchers = vatMatchers;
  10383. function isVAT(str, countryCode) {
  10384. (0, _assertString.default)(str);
  10385. (0, _assertString.default)(countryCode);
  10386. if (countryCode in vatMatchers) {
  10387. return vatMatchers[countryCode].test(str);
  10388. }
  10389. throw new Error("Invalid country code: '".concat(countryCode, "'"));
  10390. }
  10391. (function (module, exports) {
  10392. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  10393. Object.defineProperty(exports, "__esModule", {
  10394. value: true
  10395. });
  10396. exports.default = void 0;
  10397. var _toDate = _interopRequireDefault(toDate.exports);
  10398. var _toFloat = _interopRequireDefault(toFloat.exports);
  10399. var _toInt = _interopRequireDefault(toInt.exports);
  10400. var _toBoolean = _interopRequireDefault(toBoolean.exports);
  10401. var _equals = _interopRequireDefault(equals.exports);
  10402. var _contains = _interopRequireDefault(contains$1.exports);
  10403. var _matches = _interopRequireDefault(matches$1.exports);
  10404. var _isEmail = _interopRequireDefault(isEmail$1.exports);
  10405. var _isURL = _interopRequireDefault(isURL$1.exports);
  10406. var _isMACAddress = _interopRequireDefault(isMACAddress$1.exports);
  10407. var _isIP = _interopRequireDefault(isIP$1.exports);
  10408. var _isIPRange = _interopRequireDefault(isIPRange.exports);
  10409. var _isFQDN = _interopRequireDefault(isFQDN$1.exports);
  10410. var _isDate = _interopRequireDefault(isDate$1.exports);
  10411. var _isBoolean = _interopRequireDefault(isBoolean$1.exports);
  10412. var _isLocale = _interopRequireDefault(isLocale$1.exports);
  10413. var _isAlpha = _interopRequireWildcard(isAlpha$2);
  10414. var _isAlphanumeric = _interopRequireWildcard(isAlphanumeric$2);
  10415. var _isNumeric = _interopRequireDefault(isNumeric.exports);
  10416. var _isPassportNumber = _interopRequireDefault(isPassportNumber$1.exports);
  10417. var _isPort = _interopRequireDefault(isPort$1.exports);
  10418. var _isLowercase = _interopRequireDefault(isLowercase$1.exports);
  10419. var _isUppercase = _interopRequireDefault(isUppercase$1.exports);
  10420. var _isIMEI = _interopRequireDefault(isIMEI.exports);
  10421. var _isAscii = _interopRequireDefault(isAscii$1.exports);
  10422. var _isFullWidth = _interopRequireDefault(isFullWidth$2);
  10423. var _isHalfWidth = _interopRequireDefault(isHalfWidth$2);
  10424. var _isVariableWidth = _interopRequireDefault(isVariableWidth$1.exports);
  10425. var _isMultibyte = _interopRequireDefault(isMultibyte$1.exports);
  10426. var _isSemVer = _interopRequireDefault(isSemVer$1.exports);
  10427. var _isSurrogatePair = _interopRequireDefault(isSurrogatePair$1.exports);
  10428. var _isInt = _interopRequireDefault(isInt$1.exports);
  10429. var _isFloat = _interopRequireWildcard(isFloat$1);
  10430. var _isDecimal = _interopRequireDefault(isDecimal$1.exports);
  10431. var _isHexadecimal = _interopRequireDefault(isHexadecimal$1.exports);
  10432. var _isOctal = _interopRequireDefault(isOctal$1.exports);
  10433. var _isDivisibleBy = _interopRequireDefault(isDivisibleBy$1.exports);
  10434. var _isHexColor = _interopRequireDefault(isHexColor$1.exports);
  10435. var _isRgbColor = _interopRequireDefault(isRgbColor$1.exports);
  10436. var _isHSL = _interopRequireDefault(isHSL$1.exports);
  10437. var _isISRC = _interopRequireDefault(isISRC$1.exports);
  10438. var _isIBAN = _interopRequireWildcard(isIBAN$2);
  10439. var _isBIC = _interopRequireDefault(isBIC$1.exports);
  10440. var _isMD = _interopRequireDefault(isMD5.exports);
  10441. var _isHash = _interopRequireDefault(isHash$1.exports);
  10442. var _isJWT = _interopRequireDefault(isJWT$1.exports);
  10443. var _isJSON = _interopRequireDefault(isJSON$1.exports);
  10444. var _isEmpty = _interopRequireDefault(isEmpty.exports);
  10445. var _isLength = _interopRequireDefault(isLength.exports);
  10446. var _isByteLength = _interopRequireDefault(isByteLength$1.exports);
  10447. var _isUUID = _interopRequireDefault(isUUID$1.exports);
  10448. var _isMongoId = _interopRequireDefault(isMongoId$1.exports);
  10449. var _isAfter = _interopRequireDefault(isAfter.exports);
  10450. var _isBefore = _interopRequireDefault(isBefore.exports);
  10451. var _isIn = _interopRequireDefault(isIn.exports);
  10452. var _isCreditCard = _interopRequireDefault(isCreditCard$1.exports);
  10453. var _isIdentityCard = _interopRequireDefault(isIdentityCard$1.exports);
  10454. var _isEAN = _interopRequireDefault(isEAN$1.exports);
  10455. var _isISIN = _interopRequireDefault(isISIN$1.exports);
  10456. var _isISBN = _interopRequireDefault(isISBN$1.exports);
  10457. var _isISSN = _interopRequireDefault(isISSN$1.exports);
  10458. var _isTaxID = _interopRequireDefault(isTaxID.exports);
  10459. var _isMobilePhone = _interopRequireWildcard(isMobilePhone$2);
  10460. var _isEthereumAddress = _interopRequireDefault(isEthereumAddress$1.exports);
  10461. var _isCurrency = _interopRequireDefault(isCurrency$1.exports);
  10462. var _isBtcAddress = _interopRequireDefault(isBtcAddress$1.exports);
  10463. var _isISO = _interopRequireDefault(isISO8601$1.exports);
  10464. var _isRFC = _interopRequireDefault(isRFC3339$1.exports);
  10465. var _isISO31661Alpha = _interopRequireDefault(isISO31661Alpha2$2);
  10466. var _isISO31661Alpha2 = _interopRequireDefault(isISO31661Alpha3$1.exports);
  10467. var _isISO2 = _interopRequireDefault(isISO4217$1);
  10468. var _isBase = _interopRequireDefault(isBase32$1.exports);
  10469. var _isBase2 = _interopRequireDefault(isBase58$1.exports);
  10470. var _isBase3 = _interopRequireDefault(isBase64$1.exports);
  10471. var _isDataURI = _interopRequireDefault(isDataURI$1.exports);
  10472. var _isMagnetURI = _interopRequireDefault(isMagnetURI$1.exports);
  10473. var _isMimeType = _interopRequireDefault(isMimeType$1.exports);
  10474. var _isLatLong = _interopRequireDefault(isLatLong$1.exports);
  10475. var _isPostalCode = _interopRequireWildcard(isPostalCode$2);
  10476. var _ltrim = _interopRequireDefault(ltrim.exports);
  10477. var _rtrim = _interopRequireDefault(rtrim.exports);
  10478. var _trim = _interopRequireDefault(trim.exports);
  10479. var _escape$1 = _interopRequireDefault(_escape.exports);
  10480. var _unescape$1 = _interopRequireDefault(_unescape.exports);
  10481. var _stripLow = _interopRequireDefault(stripLow.exports);
  10482. var _whitelist = _interopRequireDefault(whitelist.exports);
  10483. var _blacklist = _interopRequireDefault(blacklist.exports);
  10484. var _isWhitelisted = _interopRequireDefault(isWhitelisted.exports);
  10485. var _normalizeEmail = _interopRequireDefault(normalizeEmail.exports);
  10486. var _isSlug = _interopRequireDefault(isSlug.exports);
  10487. var _isLicensePlate = _interopRequireDefault(isLicensePlate.exports);
  10488. var _isStrongPassword = _interopRequireDefault(isStrongPassword$1.exports);
  10489. var _isVAT = _interopRequireDefault(isVAT$1);
  10490. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  10491. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  10492. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10493. var version = '13.7.0';
  10494. var validator = {
  10495. version: version,
  10496. toDate: _toDate.default,
  10497. toFloat: _toFloat.default,
  10498. toInt: _toInt.default,
  10499. toBoolean: _toBoolean.default,
  10500. equals: _equals.default,
  10501. contains: _contains.default,
  10502. matches: _matches.default,
  10503. isEmail: _isEmail.default,
  10504. isURL: _isURL.default,
  10505. isMACAddress: _isMACAddress.default,
  10506. isIP: _isIP.default,
  10507. isIPRange: _isIPRange.default,
  10508. isFQDN: _isFQDN.default,
  10509. isBoolean: _isBoolean.default,
  10510. isIBAN: _isIBAN.default,
  10511. isBIC: _isBIC.default,
  10512. isAlpha: _isAlpha.default,
  10513. isAlphaLocales: _isAlpha.locales,
  10514. isAlphanumeric: _isAlphanumeric.default,
  10515. isAlphanumericLocales: _isAlphanumeric.locales,
  10516. isNumeric: _isNumeric.default,
  10517. isPassportNumber: _isPassportNumber.default,
  10518. isPort: _isPort.default,
  10519. isLowercase: _isLowercase.default,
  10520. isUppercase: _isUppercase.default,
  10521. isAscii: _isAscii.default,
  10522. isFullWidth: _isFullWidth.default,
  10523. isHalfWidth: _isHalfWidth.default,
  10524. isVariableWidth: _isVariableWidth.default,
  10525. isMultibyte: _isMultibyte.default,
  10526. isSemVer: _isSemVer.default,
  10527. isSurrogatePair: _isSurrogatePair.default,
  10528. isInt: _isInt.default,
  10529. isIMEI: _isIMEI.default,
  10530. isFloat: _isFloat.default,
  10531. isFloatLocales: _isFloat.locales,
  10532. isDecimal: _isDecimal.default,
  10533. isHexadecimal: _isHexadecimal.default,
  10534. isOctal: _isOctal.default,
  10535. isDivisibleBy: _isDivisibleBy.default,
  10536. isHexColor: _isHexColor.default,
  10537. isRgbColor: _isRgbColor.default,
  10538. isHSL: _isHSL.default,
  10539. isISRC: _isISRC.default,
  10540. isMD5: _isMD.default,
  10541. isHash: _isHash.default,
  10542. isJWT: _isJWT.default,
  10543. isJSON: _isJSON.default,
  10544. isEmpty: _isEmpty.default,
  10545. isLength: _isLength.default,
  10546. isLocale: _isLocale.default,
  10547. isByteLength: _isByteLength.default,
  10548. isUUID: _isUUID.default,
  10549. isMongoId: _isMongoId.default,
  10550. isAfter: _isAfter.default,
  10551. isBefore: _isBefore.default,
  10552. isIn: _isIn.default,
  10553. isCreditCard: _isCreditCard.default,
  10554. isIdentityCard: _isIdentityCard.default,
  10555. isEAN: _isEAN.default,
  10556. isISIN: _isISIN.default,
  10557. isISBN: _isISBN.default,
  10558. isISSN: _isISSN.default,
  10559. isMobilePhone: _isMobilePhone.default,
  10560. isMobilePhoneLocales: _isMobilePhone.locales,
  10561. isPostalCode: _isPostalCode.default,
  10562. isPostalCodeLocales: _isPostalCode.locales,
  10563. isEthereumAddress: _isEthereumAddress.default,
  10564. isCurrency: _isCurrency.default,
  10565. isBtcAddress: _isBtcAddress.default,
  10566. isISO8601: _isISO.default,
  10567. isRFC3339: _isRFC.default,
  10568. isISO31661Alpha2: _isISO31661Alpha.default,
  10569. isISO31661Alpha3: _isISO31661Alpha2.default,
  10570. isISO4217: _isISO2.default,
  10571. isBase32: _isBase.default,
  10572. isBase58: _isBase2.default,
  10573. isBase64: _isBase3.default,
  10574. isDataURI: _isDataURI.default,
  10575. isMagnetURI: _isMagnetURI.default,
  10576. isMimeType: _isMimeType.default,
  10577. isLatLong: _isLatLong.default,
  10578. ltrim: _ltrim.default,
  10579. rtrim: _rtrim.default,
  10580. trim: _trim.default,
  10581. escape: _escape$1.default,
  10582. unescape: _unescape$1.default,
  10583. stripLow: _stripLow.default,
  10584. whitelist: _whitelist.default,
  10585. blacklist: _blacklist.default,
  10586. isWhitelisted: _isWhitelisted.default,
  10587. normalizeEmail: _normalizeEmail.default,
  10588. toString: toString,
  10589. isSlug: _isSlug.default,
  10590. isStrongPassword: _isStrongPassword.default,
  10591. isTaxID: _isTaxID.default,
  10592. isDate: _isDate.default,
  10593. isLicensePlate: _isLicensePlate.default,
  10594. isVAT: _isVAT.default,
  10595. ibanLocales: _isIBAN.locales
  10596. };
  10597. var _default = validator;
  10598. exports.default = _default;
  10599. module.exports = exports.default;
  10600. module.exports.default = exports.default;
  10601. } (validator$1, validator$1.exports));
  10602. var validator = /*@__PURE__*/getDefaultExportFromCjs(validator$1.exports);
  10603. var IS_STRONG_PASSWORD = 'isStrongPassword';
  10604. /**
  10605. * Checks if the string is a strong password.
  10606. * If given value is not a string, then it returns false.
  10607. */
  10608. function isStrongPassword(value, options) {
  10609. return typeof value === 'string' && validator.isStrongPassword(value, options);
  10610. }
  10611. /**
  10612. * Checks if the string is a strong password.
  10613. * If given value is not a string, then it returns false.
  10614. */
  10615. function IsStrongPassword(options, validationOptions) {
  10616. return ValidateBy({
  10617. name: IS_STRONG_PASSWORD,
  10618. constraints: [options],
  10619. validator: {
  10620. validate: function (value, args) { return isStrongPassword(value, args.constraints[0]); },
  10621. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property is not strong enough'; }, validationOptions),
  10622. },
  10623. }, validationOptions);
  10624. }
  10625. var IS_TIMEZONE = 'isTimeZone';
  10626. /**
  10627. * Checks if the string represents a valid IANA timezone
  10628. * If the given value is not a valid IANA timezone, then it returns false.
  10629. */
  10630. function isTimeZone(value) {
  10631. try {
  10632. if (typeof value !== 'string') {
  10633. return false;
  10634. }
  10635. /** Specifying an invalid time-zone will raise a `RangeError: Invalid time zone specified` error. */
  10636. Intl.DateTimeFormat(undefined, { timeZone: value });
  10637. return true;
  10638. }
  10639. catch (exception) {
  10640. return false;
  10641. }
  10642. }
  10643. /**
  10644. * Checks if the string represents a valid IANA timezone
  10645. * If the given value is not a valid IANA timezone, then it returns false.
  10646. */
  10647. function IsTimeZone(validationOptions) {
  10648. return ValidateBy({
  10649. name: IS_TIMEZONE,
  10650. validator: {
  10651. validate: function (value, args) { return isTimeZone(value); },
  10652. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a valid IANA time-zone'; }, validationOptions),
  10653. },
  10654. }, validationOptions);
  10655. }
  10656. var IS_BASE58 = 'isBase58';
  10657. /**
  10658. * Checks if a string is base58 encoded.
  10659. * If given value is not a string, then it returns false.
  10660. */
  10661. function isBase58(value) {
  10662. return typeof value === 'string' && isBase58Validator(value);
  10663. }
  10664. /**
  10665. * Checks if a string is base58 encoded.
  10666. * If given value is not a string, then it returns false.
  10667. */
  10668. function IsBase58(validationOptions) {
  10669. return ValidateBy({
  10670. name: IS_BASE58,
  10671. validator: {
  10672. validate: function (value, args) { return isBase58(value); },
  10673. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be base58 encoded'; }, validationOptions),
  10674. },
  10675. }, validationOptions);
  10676. }
  10677. var IS_TAX_ID = 'isTaxId';
  10678. /**
  10679. * Checks if the string is a valid tax ID. Default locale is `en-US`.
  10680. * If given value is not a string, then it returns false.
  10681. *
  10682. * Supported locales: bg-BG, cs-CZ, de-AT, de-DE, dk-DK, el-CY, el-GR, en-CA,
  10683. * en-IE, en-US, es-ES, et-EE, fi-FI, fr-BE, fr-FR, fr-LU, hr-HR, hu-HU, it-IT,
  10684. * lv-LV, mt-MT, nl-NL, pl-PL, pt-BR, pt-PT, ro-RO, sk-SK, sl-SI, sv-SE.
  10685. */
  10686. function isTaxId(value, locale) {
  10687. return typeof value === 'string' && isTaxIDValidator(value, locale || 'en-US');
  10688. }
  10689. /**
  10690. * Checks if the string is a valid tax ID. Default locale is `en-US`.
  10691. * If given value is not a string, then it returns false.
  10692. *
  10693. * Supported locales: bg-BG, cs-CZ, de-AT, de-DE, dk-DK, el-CY, el-GR, en-CA,
  10694. * en-IE, en-US, es-ES, et-EE, fi-FI, fr-BE, fr-FR, fr-LU, hr-HR, hu-HU, it-IT,
  10695. * lv-LV, mt-MT, nl-NL, pl-PL, pt-BR, pt-PT, ro-RO, sk-SK, sl-SI, sv-SE.
  10696. */
  10697. function IsTaxId(locale, validationOptions) {
  10698. return ValidateBy({
  10699. name: IS_TAX_ID,
  10700. constraints: [locale],
  10701. validator: {
  10702. validate: function (value, args) { return isTaxId(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  10703. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a Tax Identification Number'; }, validationOptions),
  10704. },
  10705. }, validationOptions);
  10706. }
  10707. var IS_ISO4217_CURRENCY_CODE = 'isISO4217CurrencyCode';
  10708. /**
  10709. * Check if the string is a valid [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) officially assigned currency code.
  10710. */
  10711. function isISO4217CurrencyCode(value) {
  10712. return typeof value === 'string' && _default(value);
  10713. }
  10714. /**
  10715. * Check if the string is a valid [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) officially assigned currency code.
  10716. */
  10717. function IsISO4217CurrencyCode(validationOptions) {
  10718. return ValidateBy({
  10719. name: IS_ISO4217_CURRENCY_CODE,
  10720. validator: {
  10721. validate: function (value, args) { return isISO4217CurrencyCode(value); },
  10722. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a valid ISO4217 currency code'; }, validationOptions),
  10723. },
  10724. }, validationOptions);
  10725. }
  10726. var IS_BOOLEAN = 'isBoolean';
  10727. /**
  10728. * Checks if a given value is a boolean.
  10729. */
  10730. function isBoolean(value) {
  10731. return value instanceof Boolean || typeof value === 'boolean';
  10732. }
  10733. /**
  10734. * Checks if a value is a boolean.
  10735. */
  10736. function IsBoolean(validationOptions) {
  10737. return ValidateBy({
  10738. name: IS_BOOLEAN,
  10739. validator: {
  10740. validate: function (value, args) { return isBoolean(value); },
  10741. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a boolean value'; }, validationOptions),
  10742. },
  10743. }, validationOptions);
  10744. }
  10745. var IS_DATE = 'isDate';
  10746. /**
  10747. * Checks if a given value is a date.
  10748. */
  10749. function isDate(value) {
  10750. return value instanceof Date && !isNaN(value.getTime());
  10751. }
  10752. /**
  10753. * Checks if a value is a date.
  10754. */
  10755. function IsDate(validationOptions) {
  10756. return ValidateBy({
  10757. name: IS_DATE,
  10758. validator: {
  10759. validate: function (value, args) { return isDate(value); },
  10760. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a Date instance'; }, validationOptions),
  10761. },
  10762. }, validationOptions);
  10763. }
  10764. var IS_NUMBER = 'isNumber';
  10765. /**
  10766. * Checks if a given value is a number.
  10767. */
  10768. function isNumber(value, options) {
  10769. if (options === void 0) { options = {}; }
  10770. if (typeof value !== 'number') {
  10771. return false;
  10772. }
  10773. if (value === Infinity || value === -Infinity) {
  10774. return !!options.allowInfinity;
  10775. }
  10776. if (Number.isNaN(value)) {
  10777. return !!options.allowNaN;
  10778. }
  10779. if (options.maxDecimalPlaces !== undefined) {
  10780. var decimalPlaces = 0;
  10781. if (value % 1 !== 0) {
  10782. decimalPlaces = value.toString().split('.')[1].length;
  10783. }
  10784. if (decimalPlaces > options.maxDecimalPlaces) {
  10785. return false;
  10786. }
  10787. }
  10788. return Number.isFinite(value);
  10789. }
  10790. /**
  10791. * Checks if a value is a number.
  10792. */
  10793. function IsNumber(options, validationOptions) {
  10794. if (options === void 0) { options = {}; }
  10795. return ValidateBy({
  10796. name: IS_NUMBER,
  10797. constraints: [options],
  10798. validator: {
  10799. validate: function (value, args) { return isNumber(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  10800. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a number conforming to the specified constraints'; }, validationOptions),
  10801. },
  10802. }, validationOptions);
  10803. }
  10804. var __read = (undefined && undefined.__read) || function (o, n) {
  10805. var m = typeof Symbol === "function" && o[Symbol.iterator];
  10806. if (!m) return o;
  10807. var i = m.call(o), r, ar = [], e;
  10808. try {
  10809. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  10810. }
  10811. catch (error) { e = { error: error }; }
  10812. finally {
  10813. try {
  10814. if (r && !r.done && (m = i["return"])) m.call(i);
  10815. }
  10816. finally { if (e) throw e.error; }
  10817. }
  10818. return ar;
  10819. };
  10820. var IS_ENUM = 'isEnum';
  10821. /**
  10822. * Checks if a given value is the member of the provided enum.
  10823. */
  10824. function isEnum(value, entity) {
  10825. var enumValues = Object.keys(entity).map(function (k) { return entity[k]; });
  10826. return enumValues.includes(value);
  10827. }
  10828. /**
  10829. * Returns the possible values from an enum (both simple number indexed and string indexed enums).
  10830. */
  10831. function validEnumValues(entity) {
  10832. return Object.entries(entity)
  10833. .filter(function (_a) {
  10834. var _b = __read(_a, 2), key = _b[0]; _b[1];
  10835. return isNaN(parseInt(key));
  10836. })
  10837. .map(function (_a) {
  10838. var _b = __read(_a, 2); _b[0]; var value = _b[1];
  10839. return value;
  10840. });
  10841. }
  10842. /**
  10843. * Checks if a given value is the member of the provided enum.
  10844. */
  10845. function IsEnum(entity, validationOptions) {
  10846. return ValidateBy({
  10847. name: IS_ENUM,
  10848. constraints: [entity, validEnumValues(entity)],
  10849. validator: {
  10850. validate: function (value, args) { return isEnum(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  10851. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be one of the following values: $constraint2'; }, validationOptions),
  10852. },
  10853. }, validationOptions);
  10854. }
  10855. var IS_INT = 'isInt';
  10856. /**
  10857. * Checks if value is an integer.
  10858. */
  10859. function isInt(val) {
  10860. return typeof val === 'number' && Number.isInteger(val);
  10861. }
  10862. /**
  10863. * Checks if value is an integer.
  10864. */
  10865. function IsInt(validationOptions) {
  10866. return ValidateBy({
  10867. name: IS_INT,
  10868. validator: {
  10869. validate: function (value, args) { return isInt(value); },
  10870. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be an integer number'; }, validationOptions),
  10871. },
  10872. }, validationOptions);
  10873. }
  10874. var IS_STRING = 'isString';
  10875. /**
  10876. * Checks if a given value is a real string.
  10877. */
  10878. function isString(value) {
  10879. return value instanceof String || typeof value === 'string';
  10880. }
  10881. /**
  10882. * Checks if a given value is a real string.
  10883. */
  10884. function IsString(validationOptions) {
  10885. return ValidateBy({
  10886. name: IS_STRING,
  10887. validator: {
  10888. validate: function (value, args) { return isString(value); },
  10889. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a string'; }, validationOptions),
  10890. },
  10891. }, validationOptions);
  10892. }
  10893. var IS_ARRAY = 'isArray';
  10894. /**
  10895. * Checks if a given value is an array
  10896. */
  10897. function isArray(value) {
  10898. return Array.isArray(value);
  10899. }
  10900. /**
  10901. * Checks if a given value is an array
  10902. */
  10903. function IsArray(validationOptions) {
  10904. return ValidateBy({
  10905. name: IS_ARRAY,
  10906. validator: {
  10907. validate: function (value, args) { return isArray(value); },
  10908. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be an array'; }, validationOptions),
  10909. },
  10910. }, validationOptions);
  10911. }
  10912. var IS_OBJECT = 'isObject';
  10913. /**
  10914. * Checks if the value is valid Object.
  10915. * Returns false if the value is not an object.
  10916. */
  10917. function isObject(value) {
  10918. return value != null && (typeof value === 'object' || typeof value === 'function') && !Array.isArray(value);
  10919. }
  10920. /**
  10921. * Checks if the value is valid Object.
  10922. * Returns false if the value is not an object.
  10923. */
  10924. function IsObject(validationOptions) {
  10925. return ValidateBy({
  10926. name: IS_OBJECT,
  10927. validator: {
  10928. validate: function (value, args) { return isObject(value); },
  10929. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be an object'; }, validationOptions),
  10930. },
  10931. }, validationOptions);
  10932. }
  10933. var ARRAY_CONTAINS = 'arrayContains';
  10934. /**
  10935. * Checks if array contains all values from the given array of values.
  10936. * If null or undefined is given then this function returns false.
  10937. */
  10938. function arrayContains(array, values) {
  10939. if (!Array.isArray(array))
  10940. return false;
  10941. return values.every(function (value) { return array.indexOf(value) !== -1; });
  10942. }
  10943. /**
  10944. * Checks if array contains all values from the given array of values.
  10945. * If null or undefined is given then this function returns false.
  10946. */
  10947. function ArrayContains(values, validationOptions) {
  10948. return ValidateBy({
  10949. name: ARRAY_CONTAINS,
  10950. constraints: [values],
  10951. validator: {
  10952. validate: function (value, args) { return arrayContains(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  10953. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must contain $constraint1 values'; }, validationOptions),
  10954. },
  10955. }, validationOptions);
  10956. }
  10957. var ARRAY_NOT_CONTAINS = 'arrayNotContains';
  10958. /**
  10959. * Checks if array does not contain any of the given values.
  10960. * If null or undefined is given then this function returns false.
  10961. */
  10962. function arrayNotContains(array, values) {
  10963. if (!Array.isArray(array))
  10964. return false;
  10965. return values.every(function (value) { return array.indexOf(value) === -1; });
  10966. }
  10967. /**
  10968. * Checks if array does not contain any of the given values.
  10969. * If null or undefined is given then this function returns false.
  10970. */
  10971. function ArrayNotContains(values, validationOptions) {
  10972. return ValidateBy({
  10973. name: ARRAY_NOT_CONTAINS,
  10974. constraints: [values],
  10975. validator: {
  10976. validate: function (value, args) { return arrayNotContains(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  10977. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property should not contain $constraint1 values'; }, validationOptions),
  10978. },
  10979. }, validationOptions);
  10980. }
  10981. var ARRAY_NOT_EMPTY = 'arrayNotEmpty';
  10982. /**
  10983. * Checks if given array is not empty.
  10984. * If null or undefined is given then this function returns false.
  10985. */
  10986. function arrayNotEmpty(array) {
  10987. return Array.isArray(array) && array.length > 0;
  10988. }
  10989. /**
  10990. * Checks if given array is not empty.
  10991. * If null or undefined is given then this function returns false.
  10992. */
  10993. function ArrayNotEmpty(validationOptions) {
  10994. return ValidateBy({
  10995. name: ARRAY_NOT_EMPTY,
  10996. validator: {
  10997. validate: function (value, args) { return arrayNotEmpty(value); },
  10998. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property should not be empty'; }, validationOptions),
  10999. },
  11000. }, validationOptions);
  11001. }
  11002. var ARRAY_MIN_SIZE = 'arrayMinSize';
  11003. /**
  11004. * Checks if the array's length is greater than or equal to the specified number.
  11005. * If null or undefined is given then this function returns false.
  11006. */
  11007. function arrayMinSize(array, min) {
  11008. return Array.isArray(array) && array.length >= min;
  11009. }
  11010. /**
  11011. * Checks if the array's length is greater than or equal to the specified number.
  11012. * If null or undefined is given then this function returns false.
  11013. */
  11014. function ArrayMinSize(min, validationOptions) {
  11015. return ValidateBy({
  11016. name: ARRAY_MIN_SIZE,
  11017. constraints: [min],
  11018. validator: {
  11019. validate: function (value, args) { return arrayMinSize(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  11020. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must contain at least $constraint1 elements'; }, validationOptions),
  11021. },
  11022. }, validationOptions);
  11023. }
  11024. var ARRAY_MAX_SIZE = 'arrayMaxSize';
  11025. /**
  11026. * Checks if the array's length is less or equal to the specified number.
  11027. * If null or undefined is given then this function returns false.
  11028. */
  11029. function arrayMaxSize(array, max) {
  11030. return Array.isArray(array) && array.length <= max;
  11031. }
  11032. /**
  11033. * Checks if the array's length is less or equal to the specified number.
  11034. * If null or undefined is given then this function returns false.
  11035. */
  11036. function ArrayMaxSize(max, validationOptions) {
  11037. return ValidateBy({
  11038. name: ARRAY_MAX_SIZE,
  11039. constraints: [max],
  11040. validator: {
  11041. validate: function (value, args) { return arrayMaxSize(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  11042. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must contain no more than $constraint1 elements'; }, validationOptions),
  11043. },
  11044. }, validationOptions);
  11045. }
  11046. var ARRAY_UNIQUE = 'arrayUnique';
  11047. /**
  11048. * Checks if all array's values are unique. Comparison for objects is reference-based.
  11049. * If null or undefined is given then this function returns false.
  11050. */
  11051. function arrayUnique(array, identifier) {
  11052. if (!Array.isArray(array))
  11053. return false;
  11054. if (identifier) {
  11055. array = array.map(function (o) { return (o != null ? identifier(o) : o); });
  11056. }
  11057. var uniqueItems = array.filter(function (a, b, c) { return c.indexOf(a) === b; });
  11058. return array.length === uniqueItems.length;
  11059. }
  11060. /**
  11061. * Checks if all array's values are unique. Comparison for objects is reference-based.
  11062. * If null or undefined is given then this function returns false.
  11063. */
  11064. function ArrayUnique(identifierOrOptions, validationOptions) {
  11065. var identifier = typeof identifierOrOptions === 'function' ? identifierOrOptions : undefined;
  11066. var options = typeof identifierOrOptions !== 'function' ? identifierOrOptions : validationOptions;
  11067. return ValidateBy({
  11068. name: ARRAY_UNIQUE,
  11069. validator: {
  11070. validate: function (value, args) { return arrayUnique(value, identifier); },
  11071. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + "All $property's elements must be unique"; }, options),
  11072. },
  11073. }, options);
  11074. }
  11075. var IS_NOT_EMPTY_OBJECT = 'isNotEmptyObject';
  11076. /**
  11077. * Checks if the value is valid Object & not empty.
  11078. * Returns false if the value is not an object or an empty valid object.
  11079. */
  11080. function isNotEmptyObject(value, options) {
  11081. if (!isObject(value)) {
  11082. return false;
  11083. }
  11084. if ((options === null || options === void 0 ? void 0 : options.nullable) === true) {
  11085. return !Object.values(value).every(function (propertyValue) { return propertyValue === null || propertyValue === undefined; });
  11086. }
  11087. for (var key in value) {
  11088. if (value.hasOwnProperty(key)) {
  11089. return true;
  11090. }
  11091. }
  11092. return false;
  11093. }
  11094. /**
  11095. * Checks if the value is valid Object & not empty.
  11096. * Returns false if the value is not an object or an empty valid object.
  11097. */
  11098. function IsNotEmptyObject(options, validationOptions) {
  11099. return ValidateBy({
  11100. name: IS_NOT_EMPTY_OBJECT,
  11101. constraints: [options],
  11102. validator: {
  11103. validate: function (value, args) { return isNotEmptyObject(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  11104. defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a non-empty object'; }, validationOptions),
  11105. },
  11106. }, validationOptions);
  11107. }
  11108. var IS_INSTANCE = 'isInstance';
  11109. /**
  11110. * Checks if the value is an instance of the specified object.
  11111. */
  11112. function isInstance(object, targetTypeConstructor) {
  11113. return (targetTypeConstructor && typeof targetTypeConstructor === 'function' && object instanceof targetTypeConstructor);
  11114. }
  11115. /**
  11116. * Checks if the value is an instance of the specified object.
  11117. */
  11118. function IsInstance(targetType, validationOptions) {
  11119. return ValidateBy({
  11120. name: IS_INSTANCE,
  11121. constraints: [targetType],
  11122. validator: {
  11123. validate: function (value, args) { return isInstance(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
  11124. defaultMessage: buildMessage(function (eachPrefix, args) {
  11125. if (args === null || args === void 0 ? void 0 : args.constraints[0]) {
  11126. return eachPrefix + "$property must be an instance of ".concat(args === null || args === void 0 ? void 0 : args.constraints[0].name);
  11127. }
  11128. else {
  11129. return eachPrefix + "".concat(IS_INSTANCE, " decorator expects and object as value, but got falsy value.");
  11130. }
  11131. }, validationOptions),
  11132. },
  11133. }, validationOptions);
  11134. }
  11135. /**
  11136. * Validates given object by object's decorators or given validation schema.
  11137. */
  11138. function validate(schemaNameOrObject, objectOrValidationOptions, maybeValidatorOptions) {
  11139. if (typeof schemaNameOrObject === 'string') {
  11140. return getFromContainer(Validator).validate(schemaNameOrObject, objectOrValidationOptions, maybeValidatorOptions);
  11141. }
  11142. else {
  11143. return getFromContainer(Validator).validate(schemaNameOrObject, objectOrValidationOptions);
  11144. }
  11145. }
  11146. /**
  11147. * Validates given object by object's decorators or given validation schema and reject on error.
  11148. */
  11149. function validateOrReject(schemaNameOrObject, objectOrValidationOptions, maybeValidatorOptions) {
  11150. if (typeof schemaNameOrObject === 'string') {
  11151. return getFromContainer(Validator).validateOrReject(schemaNameOrObject, objectOrValidationOptions, maybeValidatorOptions);
  11152. }
  11153. else {
  11154. return getFromContainer(Validator).validateOrReject(schemaNameOrObject, objectOrValidationOptions);
  11155. }
  11156. }
  11157. /**
  11158. * Validates given object by object's decorators or given validation schema.
  11159. * Note that this method completely ignores async validations.
  11160. * If you want to properly perform validation you need to call validate method instead.
  11161. */
  11162. function validateSync(schemaNameOrObject, objectOrValidationOptions, maybeValidatorOptions) {
  11163. if (typeof schemaNameOrObject === 'string') {
  11164. return getFromContainer(Validator).validateSync(schemaNameOrObject, objectOrValidationOptions, maybeValidatorOptions);
  11165. }
  11166. else {
  11167. return getFromContainer(Validator).validateSync(schemaNameOrObject, objectOrValidationOptions);
  11168. }
  11169. }
  11170. /**
  11171. * Registers a new validation schema.
  11172. */
  11173. function registerSchema(schema) {
  11174. getMetadataStorage().addValidationSchema(schema);
  11175. }
  11176. exports.ARRAY_CONTAINS = ARRAY_CONTAINS;
  11177. exports.ARRAY_MAX_SIZE = ARRAY_MAX_SIZE;
  11178. exports.ARRAY_MIN_SIZE = ARRAY_MIN_SIZE;
  11179. exports.ARRAY_NOT_CONTAINS = ARRAY_NOT_CONTAINS;
  11180. exports.ARRAY_NOT_EMPTY = ARRAY_NOT_EMPTY;
  11181. exports.ARRAY_UNIQUE = ARRAY_UNIQUE;
  11182. exports.Allow = Allow;
  11183. exports.ArrayContains = ArrayContains;
  11184. exports.ArrayMaxSize = ArrayMaxSize;
  11185. exports.ArrayMinSize = ArrayMinSize;
  11186. exports.ArrayNotContains = ArrayNotContains;
  11187. exports.ArrayNotEmpty = ArrayNotEmpty;
  11188. exports.ArrayUnique = ArrayUnique;
  11189. exports.CONTAINS = CONTAINS;
  11190. exports.Contains = Contains;
  11191. exports.EQUALS = EQUALS;
  11192. exports.Equals = Equals;
  11193. exports.IS_ALPHA = IS_ALPHA;
  11194. exports.IS_ALPHANUMERIC = IS_ALPHANUMERIC;
  11195. exports.IS_ARRAY = IS_ARRAY;
  11196. exports.IS_ASCII = IS_ASCII;
  11197. exports.IS_BASE32 = IS_BASE32;
  11198. exports.IS_BASE58 = IS_BASE58;
  11199. exports.IS_BASE64 = IS_BASE64;
  11200. exports.IS_BIC = IS_BIC;
  11201. exports.IS_BOOLEAN = IS_BOOLEAN;
  11202. exports.IS_BOOLEAN_STRING = IS_BOOLEAN_STRING;
  11203. exports.IS_BTC_ADDRESS = IS_BTC_ADDRESS;
  11204. exports.IS_BYTE_LENGTH = IS_BYTE_LENGTH;
  11205. exports.IS_CREDIT_CARD = IS_CREDIT_CARD;
  11206. exports.IS_CURRENCY = IS_CURRENCY;
  11207. exports.IS_DATA_URI = IS_DATA_URI;
  11208. exports.IS_DATE = IS_DATE;
  11209. exports.IS_DATE_STRING = IS_DATE_STRING;
  11210. exports.IS_DECIMAL = IS_DECIMAL;
  11211. exports.IS_DEFINED = IS_DEFINED;
  11212. exports.IS_DIVISIBLE_BY = IS_DIVISIBLE_BY;
  11213. exports.IS_EAN = IS_EAN;
  11214. exports.IS_EMAIL = IS_EMAIL;
  11215. exports.IS_EMPTY = IS_EMPTY;
  11216. exports.IS_ENUM = IS_ENUM;
  11217. exports.IS_ETHEREUM_ADDRESS = IS_ETHEREUM_ADDRESS;
  11218. exports.IS_FIREBASE_PUSH_ID = IS_FIREBASE_PUSH_ID;
  11219. exports.IS_FQDN = IS_FQDN;
  11220. exports.IS_FULL_WIDTH = IS_FULL_WIDTH;
  11221. exports.IS_HALF_WIDTH = IS_HALF_WIDTH;
  11222. exports.IS_HASH = IS_HASH;
  11223. exports.IS_HEXADECIMAL = IS_HEXADECIMAL;
  11224. exports.IS_HEX_COLOR = IS_HEX_COLOR;
  11225. exports.IS_HSL = IS_HSL;
  11226. exports.IS_IBAN = IS_IBAN;
  11227. exports.IS_IDENTITY_CARD = IS_IDENTITY_CARD;
  11228. exports.IS_IN = IS_IN;
  11229. exports.IS_INSTANCE = IS_INSTANCE;
  11230. exports.IS_INT = IS_INT;
  11231. exports.IS_IP = IS_IP;
  11232. exports.IS_ISBN = IS_ISBN;
  11233. exports.IS_ISIN = IS_ISIN;
  11234. exports.IS_ISO31661_ALPHA_2 = IS_ISO31661_ALPHA_2;
  11235. exports.IS_ISO31661_ALPHA_3 = IS_ISO31661_ALPHA_3;
  11236. exports.IS_ISO4217_CURRENCY_CODE = IS_ISO4217_CURRENCY_CODE;
  11237. exports.IS_ISO8601 = IS_ISO8601;
  11238. exports.IS_ISRC = IS_ISRC;
  11239. exports.IS_ISSN = IS_ISSN;
  11240. exports.IS_JSON = IS_JSON;
  11241. exports.IS_JWT = IS_JWT;
  11242. exports.IS_LATITUDE = IS_LATITUDE;
  11243. exports.IS_LATLONG = IS_LATLONG;
  11244. exports.IS_LENGTH = IS_LENGTH;
  11245. exports.IS_LOCALE = IS_LOCALE;
  11246. exports.IS_LONGITUDE = IS_LONGITUDE;
  11247. exports.IS_LOWERCASE = IS_LOWERCASE;
  11248. exports.IS_MAC_ADDRESS = IS_MAC_ADDRESS;
  11249. exports.IS_MAGNET_URI = IS_MAGNET_URI;
  11250. exports.IS_MILITARY_TIME = IS_MILITARY_TIME;
  11251. exports.IS_MIME_TYPE = IS_MIME_TYPE;
  11252. exports.IS_MOBILE_PHONE = IS_MOBILE_PHONE;
  11253. exports.IS_MONGO_ID = IS_MONGO_ID;
  11254. exports.IS_MULTIBYTE = IS_MULTIBYTE;
  11255. exports.IS_NEGATIVE = IS_NEGATIVE;
  11256. exports.IS_NOT_EMPTY = IS_NOT_EMPTY;
  11257. exports.IS_NOT_EMPTY_OBJECT = IS_NOT_EMPTY_OBJECT;
  11258. exports.IS_NOT_IN = IS_NOT_IN;
  11259. exports.IS_NUMBER = IS_NUMBER;
  11260. exports.IS_NUMBER_STRING = IS_NUMBER_STRING;
  11261. exports.IS_OBJECT = IS_OBJECT;
  11262. exports.IS_OCTAL = IS_OCTAL;
  11263. exports.IS_PASSPORT_NUMBER = IS_PASSPORT_NUMBER;
  11264. exports.IS_PHONE_NUMBER = IS_PHONE_NUMBER;
  11265. exports.IS_PORT = IS_PORT;
  11266. exports.IS_POSITIVE = IS_POSITIVE;
  11267. exports.IS_POSTAL_CODE = IS_POSTAL_CODE;
  11268. exports.IS_RFC_3339 = IS_RFC_3339;
  11269. exports.IS_RGB_COLOR = IS_RGB_COLOR;
  11270. exports.IS_SEM_VER = IS_SEM_VER;
  11271. exports.IS_STRING = IS_STRING;
  11272. exports.IS_STRONG_PASSWORD = IS_STRONG_PASSWORD;
  11273. exports.IS_SURROGATE_PAIR = IS_SURROGATE_PAIR;
  11274. exports.IS_TAX_ID = IS_TAX_ID;
  11275. exports.IS_TIMEZONE = IS_TIMEZONE;
  11276. exports.IS_UPPERCASE = IS_UPPERCASE;
  11277. exports.IS_URL = IS_URL;
  11278. exports.IS_UUID = IS_UUID;
  11279. exports.IS_VARIABLE_WIDTH = IS_VARIABLE_WIDTH;
  11280. exports.IsAlpha = IsAlpha;
  11281. exports.IsAlphanumeric = IsAlphanumeric;
  11282. exports.IsArray = IsArray;
  11283. exports.IsAscii = IsAscii;
  11284. exports.IsBIC = IsBIC;
  11285. exports.IsBase32 = IsBase32;
  11286. exports.IsBase58 = IsBase58;
  11287. exports.IsBase64 = IsBase64;
  11288. exports.IsBoolean = IsBoolean;
  11289. exports.IsBooleanString = IsBooleanString;
  11290. exports.IsBtcAddress = IsBtcAddress;
  11291. exports.IsByteLength = IsByteLength;
  11292. exports.IsCreditCard = IsCreditCard;
  11293. exports.IsCurrency = IsCurrency;
  11294. exports.IsDataURI = IsDataURI;
  11295. exports.IsDate = IsDate;
  11296. exports.IsDateString = IsDateString;
  11297. exports.IsDecimal = IsDecimal;
  11298. exports.IsDefined = IsDefined;
  11299. exports.IsDivisibleBy = IsDivisibleBy;
  11300. exports.IsEAN = IsEAN;
  11301. exports.IsEmail = IsEmail;
  11302. exports.IsEmpty = IsEmpty;
  11303. exports.IsEnum = IsEnum;
  11304. exports.IsEthereumAddress = IsEthereumAddress;
  11305. exports.IsFQDN = IsFQDN;
  11306. exports.IsFirebasePushId = IsFirebasePushId;
  11307. exports.IsFullWidth = IsFullWidth;
  11308. exports.IsHSL = IsHSL;
  11309. exports.IsHalfWidth = IsHalfWidth;
  11310. exports.IsHash = IsHash;
  11311. exports.IsHexColor = IsHexColor;
  11312. exports.IsHexadecimal = IsHexadecimal;
  11313. exports.IsIBAN = IsIBAN;
  11314. exports.IsIP = IsIP;
  11315. exports.IsISBN = IsISBN;
  11316. exports.IsISIN = IsISIN;
  11317. exports.IsISO31661Alpha2 = IsISO31661Alpha2;
  11318. exports.IsISO31661Alpha3 = IsISO31661Alpha3;
  11319. exports.IsISO4217CurrencyCode = IsISO4217CurrencyCode;
  11320. exports.IsISO8601 = IsISO8601;
  11321. exports.IsISRC = IsISRC;
  11322. exports.IsISSN = IsISSN;
  11323. exports.IsIdentityCard = IsIdentityCard;
  11324. exports.IsIn = IsIn;
  11325. exports.IsInstance = IsInstance;
  11326. exports.IsInt = IsInt;
  11327. exports.IsJSON = IsJSON;
  11328. exports.IsJWT = IsJWT;
  11329. exports.IsLatLong = IsLatLong;
  11330. exports.IsLatitude = IsLatitude;
  11331. exports.IsLocale = IsLocale;
  11332. exports.IsLongitude = IsLongitude;
  11333. exports.IsLowercase = IsLowercase;
  11334. exports.IsMACAddress = IsMACAddress;
  11335. exports.IsMagnetURI = IsMagnetURI;
  11336. exports.IsMilitaryTime = IsMilitaryTime;
  11337. exports.IsMimeType = IsMimeType;
  11338. exports.IsMobilePhone = IsMobilePhone;
  11339. exports.IsMongoId = IsMongoId;
  11340. exports.IsMultibyte = IsMultibyte;
  11341. exports.IsNegative = IsNegative;
  11342. exports.IsNotEmpty = IsNotEmpty;
  11343. exports.IsNotEmptyObject = IsNotEmptyObject;
  11344. exports.IsNotIn = IsNotIn;
  11345. exports.IsNumber = IsNumber;
  11346. exports.IsNumberString = IsNumberString;
  11347. exports.IsObject = IsObject;
  11348. exports.IsOctal = IsOctal;
  11349. exports.IsOptional = IsOptional;
  11350. exports.IsPassportNumber = IsPassportNumber;
  11351. exports.IsPhoneNumber = IsPhoneNumber;
  11352. exports.IsPort = IsPort;
  11353. exports.IsPositive = IsPositive;
  11354. exports.IsPostalCode = IsPostalCode;
  11355. exports.IsRFC3339 = IsRFC3339;
  11356. exports.IsRgbColor = IsRgbColor;
  11357. exports.IsSemVer = IsSemVer;
  11358. exports.IsString = IsString;
  11359. exports.IsStrongPassword = IsStrongPassword;
  11360. exports.IsSurrogatePair = IsSurrogatePair;
  11361. exports.IsTaxId = IsTaxId;
  11362. exports.IsTimeZone = IsTimeZone;
  11363. exports.IsUUID = IsUUID;
  11364. exports.IsUppercase = IsUppercase;
  11365. exports.IsUrl = IsUrl;
  11366. exports.IsVariableWidth = IsVariableWidth;
  11367. exports.Length = Length;
  11368. exports.MATCHES = MATCHES;
  11369. exports.MAX = MAX;
  11370. exports.MAX_DATE = MAX_DATE;
  11371. exports.MAX_LENGTH = MAX_LENGTH;
  11372. exports.MIN = MIN;
  11373. exports.MIN_DATE = MIN_DATE;
  11374. exports.MIN_LENGTH = MIN_LENGTH;
  11375. exports.Matches = Matches;
  11376. exports.Max = Max;
  11377. exports.MaxDate = MaxDate;
  11378. exports.MaxLength = MaxLength;
  11379. exports.MetadataStorage = MetadataStorage;
  11380. exports.Min = Min;
  11381. exports.MinDate = MinDate;
  11382. exports.MinLength = MinLength;
  11383. exports.NOT_CONTAINS = NOT_CONTAINS;
  11384. exports.NOT_EQUALS = NOT_EQUALS;
  11385. exports.NotContains = NotContains;
  11386. exports.NotEquals = NotEquals;
  11387. exports.Validate = Validate;
  11388. exports.ValidateBy = ValidateBy;
  11389. exports.ValidateIf = ValidateIf;
  11390. exports.ValidateNested = ValidateNested;
  11391. exports.ValidatePromise = ValidatePromise;
  11392. exports.ValidationError = ValidationError;
  11393. exports.ValidationTypes = ValidationTypes;
  11394. exports.Validator = Validator;
  11395. exports.ValidatorConstraint = ValidatorConstraint;
  11396. exports.arrayContains = arrayContains;
  11397. exports.arrayMaxSize = arrayMaxSize;
  11398. exports.arrayMinSize = arrayMinSize;
  11399. exports.arrayNotContains = arrayNotContains;
  11400. exports.arrayNotEmpty = arrayNotEmpty;
  11401. exports.arrayUnique = arrayUnique;
  11402. exports.buildMessage = buildMessage;
  11403. exports.contains = contains;
  11404. exports.equals = equals$1;
  11405. exports.getFromContainer = getFromContainer;
  11406. exports.getMetadataStorage = getMetadataStorage;
  11407. exports.isAlpha = isAlpha;
  11408. exports.isAlphanumeric = isAlphanumeric;
  11409. exports.isArray = isArray;
  11410. exports.isAscii = isAscii;
  11411. exports.isBIC = isBIC;
  11412. exports.isBase32 = isBase32;
  11413. exports.isBase58 = isBase58;
  11414. exports.isBase64 = isBase64;
  11415. exports.isBoolean = isBoolean;
  11416. exports.isBooleanString = isBooleanString;
  11417. exports.isBtcAddress = isBtcAddress;
  11418. exports.isByteLength = isByteLength;
  11419. exports.isCreditCard = isCreditCard;
  11420. exports.isCurrency = isCurrency;
  11421. exports.isDataURI = isDataURI;
  11422. exports.isDate = isDate;
  11423. exports.isDateString = isDateString;
  11424. exports.isDecimal = isDecimal;
  11425. exports.isDefined = isDefined;
  11426. exports.isDivisibleBy = isDivisibleBy;
  11427. exports.isEAN = isEAN;
  11428. exports.isEmail = isEmail;
  11429. exports.isEmpty = isEmpty$1;
  11430. exports.isEnum = isEnum;
  11431. exports.isEthereumAddress = isEthereumAddress;
  11432. exports.isFQDN = isFQDN;
  11433. exports.isFirebasePushId = isFirebasePushId;
  11434. exports.isFullWidth = isFullWidth;
  11435. exports.isHSL = isHSL;
  11436. exports.isHalfWidth = isHalfWidth;
  11437. exports.isHash = isHash;
  11438. exports.isHexColor = isHexColor;
  11439. exports.isHexadecimal = isHexadecimal;
  11440. exports.isIBAN = isIBAN;
  11441. exports.isIP = isIP;
  11442. exports.isISBN = isISBN;
  11443. exports.isISIN = isISIN;
  11444. exports.isISO31661Alpha2 = isISO31661Alpha2;
  11445. exports.isISO31661Alpha3 = isISO31661Alpha3;
  11446. exports.isISO4217CurrencyCode = isISO4217CurrencyCode;
  11447. exports.isISO8601 = isISO8601;
  11448. exports.isISRC = isISRC;
  11449. exports.isISSN = isISSN;
  11450. exports.isIdentityCard = isIdentityCard;
  11451. exports.isIn = isIn$1;
  11452. exports.isInstance = isInstance;
  11453. exports.isInt = isInt;
  11454. exports.isJSON = isJSON;
  11455. exports.isJWT = isJWT;
  11456. exports.isLatLong = isLatLong;
  11457. exports.isLatitude = isLatitude;
  11458. exports.isLocale = isLocale;
  11459. exports.isLongitude = isLongitude;
  11460. exports.isLowercase = isLowercase;
  11461. exports.isMACAddress = isMACAddress;
  11462. exports.isMagnetURI = isMagnetURI;
  11463. exports.isMilitaryTime = isMilitaryTime;
  11464. exports.isMimeType = isMimeType;
  11465. exports.isMobilePhone = isMobilePhone;
  11466. exports.isMongoId = isMongoId;
  11467. exports.isMultibyte = isMultibyte;
  11468. exports.isNegative = isNegative;
  11469. exports.isNotEmpty = isNotEmpty;
  11470. exports.isNotEmptyObject = isNotEmptyObject;
  11471. exports.isNotIn = isNotIn;
  11472. exports.isNumber = isNumber;
  11473. exports.isNumberString = isNumberString;
  11474. exports.isObject = isObject;
  11475. exports.isOctal = isOctal;
  11476. exports.isPassportNumber = isPassportNumber;
  11477. exports.isPhoneNumber = isPhoneNumber;
  11478. exports.isPort = isPort;
  11479. exports.isPositive = isPositive;
  11480. exports.isPostalCode = isPostalCode;
  11481. exports.isRFC3339 = isRFC3339;
  11482. exports.isRgbColor = isRgbColor;
  11483. exports.isSemVer = isSemVer;
  11484. exports.isString = isString;
  11485. exports.isStrongPassword = isStrongPassword;
  11486. exports.isSurrogatePair = isSurrogatePair;
  11487. exports.isTaxId = isTaxId;
  11488. exports.isTimeZone = isTimeZone;
  11489. exports.isURL = isURL;
  11490. exports.isUUID = isUUID;
  11491. exports.isUppercase = isUppercase;
  11492. exports.isValidationOptions = isValidationOptions;
  11493. exports.isVariableWidth = isVariableWidth;
  11494. exports.length = length;
  11495. exports.matches = matches;
  11496. exports.max = max;
  11497. exports.maxDate = maxDate;
  11498. exports.maxLength = maxLength;
  11499. exports.min = min;
  11500. exports.minDate = minDate;
  11501. exports.minLength = minLength;
  11502. exports.notContains = notContains;
  11503. exports.notEquals = notEquals;
  11504. exports.registerDecorator = registerDecorator;
  11505. exports.registerSchema = registerSchema;
  11506. exports.useContainer = useContainer;
  11507. exports.validate = validate;
  11508. exports.validateOrReject = validateOrReject;
  11509. exports.validateSync = validateSync;
  11510. Object.defineProperty(exports, '__esModule', { value: true });
  11511. }));
  11512. //# sourceMappingURL=class-validator.umd.js.map