validator.js 200 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808
  1. /*!
  2. * Copyright (c) 2018 Chris O'Hara <cohara87@gmail.com>
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining
  5. * a copy of this software and associated documentation files (the
  6. * "Software"), to deal in the Software without restriction, including
  7. * without limitation the rights to use, copy, modify, merge, publish,
  8. * distribute, sublicense, and/or sell copies of the Software, and to
  9. * permit persons to whom the Software is furnished to do so, subject to
  10. * the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be
  13. * included in all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. (function (global, factory) {
  24. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  25. typeof define === 'function' && define.amd ? define(factory) :
  26. (global.validator = factory());
  27. }(this, (function () { 'use strict';
  28. function assertString(input) {
  29. if (input === undefined || input === null) throw new TypeError("Expected a string but received a ".concat(input));
  30. if (input.constructor.name !== 'String') throw new TypeError("Expected a string but received a ".concat(input.constructor.name));
  31. }
  32. function toDate(date) {
  33. assertString(date);
  34. date = Date.parse(date);
  35. return !isNaN(date) ? new Date(date) : null;
  36. }
  37. function isNullOrUndefined(value) {
  38. return value === null || value === undefined;
  39. }
  40. var alpha = {
  41. 'en-US': /^[A-Z]+$/i,
  42. 'az-AZ': /^[A-VXYZÇƏĞİıÖŞÜ]+$/i,
  43. 'bg-BG': /^[А-Я]+$/i,
  44. 'cs-CZ': /^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,
  45. 'da-DK': /^[A-ZÆØÅ]+$/i,
  46. 'de-DE': /^[A-ZÄÖÜß]+$/i,
  47. 'el-GR': /^[Α-ώ]+$/i,
  48. 'es-ES': /^[A-ZÁÉÍÑÓÚÜ]+$/i,
  49. 'fa-IR': /^[ابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی]+$/i,
  50. 'fi-FI': /^[A-ZÅÄÖ]+$/i,
  51. 'fr-FR': /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
  52. 'it-IT': /^[A-ZÀÉÈÌÎÓÒÙ]+$/i,
  53. 'ja-JP': /^[ぁ-んァ-ヶヲ-゚一-龠ー・。、]+$/i,
  54. 'nb-NO': /^[A-ZÆØÅ]+$/i,
  55. 'nl-NL': /^[A-ZÁÉËÏÓÖÜÚ]+$/i,
  56. 'nn-NO': /^[A-ZÆØÅ]+$/i,
  57. 'hu-HU': /^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i,
  58. 'pl-PL': /^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,
  59. 'pt-PT': /^[A-ZÃÁÀÂÄÇÉÊËÍÏÕÓÔÖÚÜ]+$/i,
  60. 'ru-RU': /^[А-ЯЁ]+$/i,
  61. 'kk-KZ': /^[А-ЯЁ\u04D8\u04B0\u0406\u04A2\u0492\u04AE\u049A\u04E8\u04BA]+$/i,
  62. 'sl-SI': /^[A-ZČĆĐŠŽ]+$/i,
  63. 'sk-SK': /^[A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,
  64. 'sr-RS@latin': /^[A-ZČĆŽŠĐ]+$/i,
  65. 'sr-RS': /^[А-ЯЂЈЉЊЋЏ]+$/i,
  66. 'sv-SE': /^[A-ZÅÄÖ]+$/i,
  67. 'th-TH': /^[ก-๐\s]+$/i,
  68. 'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i,
  69. 'uk-UA': /^[А-ЩЬЮЯЄIЇҐі]+$/i,
  70. 'vi-VN': /^[A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$/i,
  71. 'ko-KR': /^[ㄱ-ㅎㅏ-ㅣ가-힣]*$/,
  72. 'ku-IQ': /^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
  73. ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
  74. he: /^[א-ת]+$/,
  75. fa: /^['آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی']+$/i,
  76. bn: /^['ঀঁংঃঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহ়ঽািীুূৃৄেৈোৌ্ৎৗড়ঢ়য়ৠৡৢৣৰৱ৲৳৴৵৶৷৸৹৺৻']+$/,
  77. eo: /^[ABCĈD-GĜHĤIJĴK-PRSŜTUŬVZ]+$/i,
  78. 'hi-IN': /^[\u0900-\u0961]+[\u0972-\u097F]*$/i,
  79. 'si-LK': /^[\u0D80-\u0DFF]+$/,
  80. 'ta-IN': /^[\u0B80-\u0BFF]+$/i,
  81. 'te-IN': /^[\u0C00-\u0C7F]+$/i,
  82. 'kn-IN': /^[\u0C80-\u0CFF]+$/i,
  83. 'ml-IN': /^[\u0D00-\u0D7F]+$/i,
  84. 'gu-IN': /^[\u0A80-\u0AFF]+$/i,
  85. 'pa-IN': /^[\u0A00-\u0A7F]+$/i,
  86. 'or-IN': /^[\u0B00-\u0B7F]+$/i
  87. };
  88. var alphanumeric = {
  89. 'en-US': /^[0-9A-Z]+$/i,
  90. 'az-AZ': /^[0-9A-VXYZÇƏĞİıÖŞÜ]+$/i,
  91. 'bg-BG': /^[0-9А-Я]+$/i,
  92. 'cs-CZ': /^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,
  93. 'da-DK': /^[0-9A-ZÆØÅ]+$/i,
  94. 'de-DE': /^[0-9A-ZÄÖÜß]+$/i,
  95. 'el-GR': /^[0-9Α-ω]+$/i,
  96. 'es-ES': /^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,
  97. 'fi-FI': /^[0-9A-ZÅÄÖ]+$/i,
  98. 'fr-FR': /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
  99. 'it-IT': /^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i,
  100. 'ja-JP': /^[0-90-9ぁ-んァ-ヶヲ-゚一-龠ー・。、]+$/i,
  101. 'hu-HU': /^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i,
  102. 'nb-NO': /^[0-9A-ZÆØÅ]+$/i,
  103. 'nl-NL': /^[0-9A-ZÁÉËÏÓÖÜÚ]+$/i,
  104. 'nn-NO': /^[0-9A-ZÆØÅ]+$/i,
  105. 'pl-PL': /^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i,
  106. 'pt-PT': /^[0-9A-ZÃÁÀÂÄÇÉÊËÍÏÕÓÔÖÚÜ]+$/i,
  107. 'ru-RU': /^[0-9А-ЯЁ]+$/i,
  108. 'kk-KZ': /^[0-9А-ЯЁ\u04D8\u04B0\u0406\u04A2\u0492\u04AE\u049A\u04E8\u04BA]+$/i,
  109. 'sl-SI': /^[0-9A-ZČĆĐŠŽ]+$/i,
  110. 'sk-SK': /^[0-9A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,
  111. 'sr-RS@latin': /^[0-9A-ZČĆŽŠĐ]+$/i,
  112. 'sr-RS': /^[0-9А-ЯЂЈЉЊЋЏ]+$/i,
  113. 'sv-SE': /^[0-9A-ZÅÄÖ]+$/i,
  114. 'th-TH': /^[ก-๙\s]+$/i,
  115. 'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i,
  116. 'uk-UA': /^[0-9А-ЩЬЮЯЄIЇҐі]+$/i,
  117. 'ko-KR': /^[0-9ㄱ-ㅎㅏ-ㅣ가-힣]*$/,
  118. 'ku-IQ': /^[٠١٢٣٤٥٦٧٨٩0-9ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
  119. 'vi-VN': /^[0-9A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$/i,
  120. ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
  121. he: /^[0-9א-ת]+$/,
  122. fa: /^['0-9آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی۱۲۳۴۵۶۷۸۹۰']+$/i,
  123. bn: /^['ঀঁংঃঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহ়ঽািীুূৃৄেৈোৌ্ৎৗড়ঢ়য়ৠৡৢৣ০১২৩৪৫৬৭৮৯ৰৱ৲৳৴৵৶৷৸৹৺৻']+$/,
  124. eo: /^[0-9ABCĈD-GĜHĤIJĴK-PRSŜTUŬVZ]+$/i,
  125. 'hi-IN': /^[\u0900-\u0963]+[\u0966-\u097F]*$/i,
  126. 'si-LK': /^[0-9\u0D80-\u0DFF]+$/,
  127. 'ta-IN': /^[0-9\u0B80-\u0BFF.]+$/i,
  128. 'te-IN': /^[0-9\u0C00-\u0C7F.]+$/i,
  129. 'kn-IN': /^[0-9\u0C80-\u0CFF.]+$/i,
  130. 'ml-IN': /^[0-9\u0D00-\u0D7F.]+$/i,
  131. 'gu-IN': /^[0-9\u0A80-\u0AFF.]+$/i,
  132. 'pa-IN': /^[0-9\u0A00-\u0A7F.]+$/i,
  133. 'or-IN': /^[0-9\u0B00-\u0B7F.]+$/i
  134. };
  135. var decimal = {
  136. 'en-US': '.',
  137. ar: '٫'
  138. };
  139. var englishLocales = ['AU', 'GB', 'HK', 'IN', 'NZ', 'ZA', 'ZM'];
  140. for (var locale, i = 0; i < englishLocales.length; i++) {
  141. locale = "en-".concat(englishLocales[i]);
  142. alpha[locale] = alpha['en-US'];
  143. alphanumeric[locale] = alphanumeric['en-US'];
  144. decimal[locale] = decimal['en-US'];
  145. }
  146. // Source: http://www.localeplanet.com/java/
  147. var arabicLocales = ['AE', 'BH', 'DZ', 'EG', 'IQ', 'JO', 'KW', 'LB', 'LY', 'MA', 'QM', 'QA', 'SA', 'SD', 'SY', 'TN', 'YE'];
  148. for (var _locale, _i = 0; _i < arabicLocales.length; _i++) {
  149. _locale = "ar-".concat(arabicLocales[_i]);
  150. alpha[_locale] = alpha.ar;
  151. alphanumeric[_locale] = alphanumeric.ar;
  152. decimal[_locale] = decimal.ar;
  153. }
  154. var farsiLocales = ['IR', 'AF'];
  155. for (var _locale2, _i2 = 0; _i2 < farsiLocales.length; _i2++) {
  156. _locale2 = "fa-".concat(farsiLocales[_i2]);
  157. alphanumeric[_locale2] = alphanumeric.fa;
  158. decimal[_locale2] = decimal.ar;
  159. }
  160. var bengaliLocales = ['BD', 'IN'];
  161. for (var _locale3, _i3 = 0; _i3 < bengaliLocales.length; _i3++) {
  162. _locale3 = "bn-".concat(bengaliLocales[_i3]);
  163. alpha[_locale3] = alpha.bn;
  164. alphanumeric[_locale3] = alphanumeric.bn;
  165. decimal[_locale3] = decimal['en-US'];
  166. }
  167. // Source: https://en.wikipedia.org/wiki/Decimal_mark
  168. var dotDecimal = ['ar-EG', 'ar-LB', 'ar-LY'];
  169. var commaDecimal = ['bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-ZM', 'eo', 'es-ES', 'fr-CA', 'fr-FR', 'gu-IN', 'hi-IN', 'hu-HU', 'id-ID', 'it-IT', 'kk-KZ', 'kn-IN', 'ku-IQ', 'ml-IN', 'nb-NO', 'nl-NL', 'nn-NO', 'or-IN', 'pa-IN', 'pl-PL', 'pt-PT', 'ru-RU', 'si-LK', 'sl-SI', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'ta-IN', 'te-IN', 'tr-TR', 'uk-UA', 'vi-VN'];
  170. for (var _i4 = 0; _i4 < dotDecimal.length; _i4++) {
  171. decimal[dotDecimal[_i4]] = decimal['en-US'];
  172. }
  173. for (var _i5 = 0; _i5 < commaDecimal.length; _i5++) {
  174. decimal[commaDecimal[_i5]] = ',';
  175. }
  176. alpha['fr-CA'] = alpha['fr-FR'];
  177. alphanumeric['fr-CA'] = alphanumeric['fr-FR'];
  178. alpha['pt-BR'] = alpha['pt-PT'];
  179. alphanumeric['pt-BR'] = alphanumeric['pt-PT'];
  180. decimal['pt-BR'] = decimal['pt-PT'];
  181. // see #862
  182. alpha['pl-Pl'] = alpha['pl-PL'];
  183. alphanumeric['pl-Pl'] = alphanumeric['pl-PL'];
  184. decimal['pl-Pl'] = decimal['pl-PL'];
  185. // see #1455
  186. alpha['fa-AF'] = alpha.fa;
  187. function isFloat(str, options) {
  188. assertString(str);
  189. options = options || {};
  190. var _float = new RegExp("^(?:[-+])?(?:[0-9]+)?(?:\\".concat(options.locale ? decimal[options.locale] : '.', "[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$"));
  191. if (str === '' || str === '.' || str === ',' || str === '-' || str === '+') {
  192. return false;
  193. }
  194. var value = parseFloat(str.replace(',', '.'));
  195. return _float.test(str) && (!options.hasOwnProperty('min') || isNullOrUndefined(options.min) || value >= options.min) && (!options.hasOwnProperty('max') || isNullOrUndefined(options.max) || value <= options.max) && (!options.hasOwnProperty('lt') || isNullOrUndefined(options.lt) || value < options.lt) && (!options.hasOwnProperty('gt') || isNullOrUndefined(options.gt) || value > options.gt);
  196. }
  197. var locales = Object.keys(decimal);
  198. function toFloat(str) {
  199. if (!isFloat(str)) return NaN;
  200. return parseFloat(str);
  201. }
  202. function toInt(str, radix) {
  203. assertString(str);
  204. return parseInt(str, radix || 10);
  205. }
  206. function toBoolean(str, strict) {
  207. assertString(str);
  208. if (strict) {
  209. return str === '1' || /^true$/i.test(str);
  210. }
  211. return str !== '0' && !/^false$/i.test(str) && str !== '';
  212. }
  213. function equals(str, comparison) {
  214. assertString(str);
  215. return str === comparison;
  216. }
  217. function _arrayLikeToArray(r, a) {
  218. (null == a || a > r.length) && (a = r.length);
  219. for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
  220. return n;
  221. }
  222. function _arrayWithHoles(r) {
  223. if (Array.isArray(r)) return r;
  224. }
  225. function _arrayWithoutHoles(r) {
  226. if (Array.isArray(r)) return _arrayLikeToArray(r);
  227. }
  228. function _createForOfIteratorHelper(r, e) {
  229. var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
  230. if (!t) {
  231. if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
  232. t && (r = t);
  233. var n = 0,
  234. F = function () {};
  235. return {
  236. s: F,
  237. n: function () {
  238. return n >= r.length ? {
  239. done: !0
  240. } : {
  241. done: !1,
  242. value: r[n++]
  243. };
  244. },
  245. e: function (r) {
  246. throw r;
  247. },
  248. f: F
  249. };
  250. }
  251. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  252. }
  253. var o,
  254. a = !0,
  255. u = !1;
  256. return {
  257. s: function () {
  258. t = t.call(r);
  259. },
  260. n: function () {
  261. var r = t.next();
  262. return a = r.done, r;
  263. },
  264. e: function (r) {
  265. u = !0, o = r;
  266. },
  267. f: function () {
  268. try {
  269. a || null == t.return || t.return();
  270. } finally {
  271. if (u) throw o;
  272. }
  273. }
  274. };
  275. }
  276. function _iterableToArray(r) {
  277. if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
  278. }
  279. function _iterableToArrayLimit(r, l) {
  280. var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
  281. if (null != t) {
  282. var e,
  283. n,
  284. i,
  285. u,
  286. a = [],
  287. f = !0,
  288. o = !1;
  289. try {
  290. if (i = (t = t.call(r)).next, 0 === l) {
  291. if (Object(t) !== t) return;
  292. f = !1;
  293. } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
  294. } catch (r) {
  295. o = !0, n = r;
  296. } finally {
  297. try {
  298. if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
  299. } finally {
  300. if (o) throw n;
  301. }
  302. }
  303. return a;
  304. }
  305. }
  306. function _nonIterableRest() {
  307. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  308. }
  309. function _nonIterableSpread() {
  310. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  311. }
  312. function _setFunctionName(e, t, n) {
  313. "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : "");
  314. try {
  315. Object.defineProperty(e, "name", {
  316. configurable: !0,
  317. value: n ? n + " " + t : t
  318. });
  319. } catch (e) {}
  320. return e;
  321. }
  322. function _slicedToArray(r, e) {
  323. return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
  324. }
  325. function _toConsumableArray(r) {
  326. return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
  327. }
  328. function _toPrimitive(t, r) {
  329. if ("object" != typeof t || !t) return t;
  330. var e = t[Symbol.toPrimitive];
  331. if (void 0 !== e) {
  332. var i = e.call(t, r || "default");
  333. if ("object" != typeof i) return i;
  334. throw new TypeError("@@toPrimitive must return a primitive value.");
  335. }
  336. return ("string" === r ? String : Number)(t);
  337. }
  338. function _toPropertyKey(t) {
  339. var i = _toPrimitive(t, "string");
  340. return "symbol" == typeof i ? i : i + "";
  341. }
  342. function _typeof(o) {
  343. "@babel/helpers - typeof";
  344. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
  345. return typeof o;
  346. } : function (o) {
  347. return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
  348. }, _typeof(o);
  349. }
  350. function _unsupportedIterableToArray(r, a) {
  351. if (r) {
  352. if ("string" == typeof r) return _arrayLikeToArray(r, a);
  353. var t = {}.toString.call(r).slice(8, -1);
  354. return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
  355. }
  356. }
  357. function old_createMetadataMethodsForProperty(e, t, a, r) {
  358. return {
  359. getMetadata: function (o) {
  360. old_assertNotFinished(r, "getMetadata"), old_assertMetadataKey(o);
  361. var i = e[o];
  362. if (void 0 !== i) if (1 === t) {
  363. var n = i.public;
  364. if (void 0 !== n) return n[a];
  365. } else if (2 === t) {
  366. var l = i.private;
  367. if (void 0 !== l) return l.get(a);
  368. } else if (Object.hasOwnProperty.call(i, "constructor")) return i.constructor;
  369. },
  370. setMetadata: function (o, i) {
  371. old_assertNotFinished(r, "setMetadata"), old_assertMetadataKey(o);
  372. var n = e[o];
  373. if (void 0 === n && (n = e[o] = {}), 1 === t) {
  374. var l = n.public;
  375. void 0 === l && (l = n.public = {}), l[a] = i;
  376. } else if (2 === t) {
  377. var s = n.priv;
  378. void 0 === s && (s = n.private = new Map()), s.set(a, i);
  379. } else n.constructor = i;
  380. }
  381. };
  382. }
  383. function old_createAddInitializerMethod(e, t) {
  384. return function (a) {
  385. old_assertNotFinished(t, "addInitializer"), old_assertCallable(a, "An initializer"), e.push(a);
  386. };
  387. }
  388. function old_memberDec(e, t, a, r, o, i, n, l, s) {
  389. var c;
  390. switch (i) {
  391. case 1:
  392. c = "accessor";
  393. break;
  394. case 2:
  395. c = "method";
  396. break;
  397. case 3:
  398. c = "getter";
  399. break;
  400. case 4:
  401. c = "setter";
  402. break;
  403. default:
  404. c = "field";
  405. }
  406. var d,
  407. u,
  408. f = {
  409. kind: c,
  410. name: l ? "#" + t : _toPropertyKey(t),
  411. isStatic: n,
  412. isPrivate: l
  413. },
  414. p = {
  415. v: !1
  416. };
  417. if (0 !== i && (f.addInitializer = old_createAddInitializerMethod(o, p)), l) {
  418. d = 2, u = Symbol(t);
  419. var v = {};
  420. 0 === i ? (v.get = a.get, v.set = a.set) : 2 === i ? v.get = function () {
  421. return a.value;
  422. } : (1 !== i && 3 !== i || (v.get = function () {
  423. return a.get.call(this);
  424. }), 1 !== i && 4 !== i || (v.set = function (e) {
  425. a.set.call(this, e);
  426. })), f.access = v;
  427. } else d = 1, u = t;
  428. try {
  429. return e(s, Object.assign(f, old_createMetadataMethodsForProperty(r, d, u, p)));
  430. } finally {
  431. p.v = !0;
  432. }
  433. }
  434. function old_assertNotFinished(e, t) {
  435. if (e.v) throw Error("attempted to call " + t + " after decoration was finished");
  436. }
  437. function old_assertMetadataKey(e) {
  438. if ("symbol" != typeof e) throw new TypeError("Metadata keys must be symbols, received: " + e);
  439. }
  440. function old_assertCallable(e, t) {
  441. if ("function" != typeof e) throw new TypeError(t + " must be a function");
  442. }
  443. function old_assertValidReturnValue(e, t) {
  444. var a = typeof t;
  445. if (1 === e) {
  446. if ("object" !== a || null === t) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
  447. void 0 !== t.get && old_assertCallable(t.get, "accessor.get"), void 0 !== t.set && old_assertCallable(t.set, "accessor.set"), void 0 !== t.init && old_assertCallable(t.init, "accessor.init"), void 0 !== t.initializer && old_assertCallable(t.initializer, "accessor.initializer");
  448. } else if ("function" !== a) throw new TypeError((0 === e ? "field" : 10 === e ? "class" : "method") + " decorators must return a function or void 0");
  449. }
  450. function old_getInit(e) {
  451. var t;
  452. return null == (t = e.init) && (t = e.initializer) && void 0 !== console && console.warn(".initializer has been renamed to .init as of March 2022"), t;
  453. }
  454. function toString$1(input) {
  455. if (_typeof(input) === 'object' && input !== null) {
  456. if (typeof input.toString === 'function') {
  457. input = input.toString();
  458. } else {
  459. input = '[object Object]';
  460. }
  461. } else if (input === null || typeof input === 'undefined' || isNaN(input) && !input.length) {
  462. input = '';
  463. }
  464. return String(input);
  465. }
  466. function merge() {
  467. var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  468. var defaults = arguments.length > 1 ? arguments[1] : undefined;
  469. if (_typeof(obj) !== 'object' || obj === null) {
  470. obj = {};
  471. }
  472. for (var key in defaults) {
  473. if (typeof obj[key] === 'undefined') {
  474. obj[key] = defaults[key];
  475. }
  476. }
  477. return obj;
  478. }
  479. var defaultContainsOptions = {
  480. ignoreCase: false,
  481. minOccurrences: 1
  482. };
  483. function contains(str, elem, options) {
  484. assertString(str);
  485. options = merge(options, defaultContainsOptions);
  486. if (options.ignoreCase) {
  487. return str.toLowerCase().split(toString$1(elem).toLowerCase()).length > options.minOccurrences;
  488. }
  489. return str.split(toString$1(elem)).length > options.minOccurrences;
  490. }
  491. function matches(str, pattern, modifiers) {
  492. assertString(str);
  493. if (Object.prototype.toString.call(pattern) !== '[object RegExp]') {
  494. pattern = new RegExp(pattern, modifiers);
  495. }
  496. return !!str.match(pattern);
  497. }
  498. function isRegExp(obj) {
  499. return Object.prototype.toString.call(obj) === '[object RegExp]';
  500. }
  501. function checkHost(host, matches) {
  502. for (var i = 0; i < matches.length; i++) {
  503. var match = matches[i];
  504. if (host === match || isRegExp(match) && match.test(host)) {
  505. return true;
  506. }
  507. }
  508. return false;
  509. }
  510. /* eslint-disable prefer-rest-params */
  511. function isByteLength(str, options) {
  512. assertString(str);
  513. var min;
  514. var max;
  515. if (_typeof(options) === 'object') {
  516. min = options.min || 0;
  517. max = options.max;
  518. } else {
  519. // backwards compatibility: isByteLength(str, min [, max])
  520. min = arguments[1];
  521. max = arguments[2];
  522. }
  523. var len = encodeURI(str).split(/%..|./).length - 1;
  524. return len >= min && (typeof max === 'undefined' || len <= max);
  525. }
  526. var default_fqdn_options = {
  527. require_tld: true,
  528. allow_underscores: false,
  529. allow_trailing_dot: false,
  530. allow_numeric_tld: false,
  531. allow_wildcard: false,
  532. ignore_max_length: false
  533. };
  534. function isFQDN(str, options) {
  535. assertString(str);
  536. options = merge(options, default_fqdn_options);
  537. /* Remove the optional trailing dot before checking validity */
  538. if (options.allow_trailing_dot && str[str.length - 1] === '.') {
  539. str = str.substring(0, str.length - 1);
  540. }
  541. /* Remove the optional wildcard before checking validity */
  542. if (options.allow_wildcard === true && str.indexOf('*.') === 0) {
  543. str = str.substring(2);
  544. }
  545. var parts = str.split('.');
  546. var tld = parts[parts.length - 1];
  547. if (options.require_tld) {
  548. // disallow fqdns without tld
  549. if (parts.length < 2) {
  550. return false;
  551. }
  552. if (!options.allow_numeric_tld && !/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
  553. return false;
  554. }
  555. // disallow spaces
  556. if (/\s/.test(tld)) {
  557. return false;
  558. }
  559. }
  560. // reject numeric TLDs
  561. if (!options.allow_numeric_tld && /^\d+$/.test(tld)) {
  562. return false;
  563. }
  564. return parts.every(function (part) {
  565. if (part.length > 63 && !options.ignore_max_length) {
  566. return false;
  567. }
  568. if (!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(part)) {
  569. return false;
  570. }
  571. // disallow full-width chars
  572. if (/[\uff01-\uff5e]/.test(part)) {
  573. return false;
  574. }
  575. // disallow parts starting or ending with hyphen
  576. if (/^-|-$/.test(part)) {
  577. return false;
  578. }
  579. if (!options.allow_underscores && /_/.test(part)) {
  580. return false;
  581. }
  582. return true;
  583. });
  584. }
  585. /**
  586. 11.3. Examples
  587. The following addresses
  588. fe80::1234 (on the 1st link of the node)
  589. ff02::5678 (on the 5th link of the node)
  590. ff08::9abc (on the 10th organization of the node)
  591. would be represented as follows:
  592. fe80::1234%1
  593. ff02::5678%5
  594. ff08::9abc%10
  595. (Here we assume a natural translation from a zone index to the
  596. <zone_id> part, where the Nth zone of any scope is translated into
  597. "N".)
  598. If we use interface names as <zone_id>, those addresses could also be
  599. represented as follows:
  600. fe80::1234%ne0
  601. ff02::5678%pvc1.3
  602. ff08::9abc%interface10
  603. where the interface "ne0" belongs to the 1st link, "pvc1.3" belongs
  604. to the 5th link, and "interface10" belongs to the 10th organization.
  605. * * */
  606. var IPv4SegmentFormat = '(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
  607. var IPv4AddressFormat = "(".concat(IPv4SegmentFormat, "[.]){3}").concat(IPv4SegmentFormat);
  608. var IPv4AddressRegExp = new RegExp("^".concat(IPv4AddressFormat, "$"));
  609. var IPv6SegmentFormat = '(?:[0-9a-fA-F]{1,4})';
  610. 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,})?$');
  611. function isIP(ipAddress) {
  612. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  613. assertString(ipAddress);
  614. // accessing 'arguments' for backwards compatibility: isIP(ipAddress [, version])
  615. // eslint-disable-next-line prefer-rest-params
  616. var version = (_typeof(options) === 'object' ? options.version : arguments[1]) || '';
  617. if (!version) {
  618. return isIP(ipAddress, {
  619. version: 4
  620. }) || isIP(ipAddress, {
  621. version: 6
  622. });
  623. }
  624. if (version.toString() === '4') {
  625. return IPv4AddressRegExp.test(ipAddress);
  626. }
  627. if (version.toString() === '6') {
  628. return IPv6AddressRegExp.test(ipAddress);
  629. }
  630. return false;
  631. }
  632. var default_email_options = {
  633. allow_display_name: false,
  634. allow_underscores: false,
  635. require_display_name: false,
  636. allow_utf8_local_part: true,
  637. require_tld: true,
  638. blacklisted_chars: '',
  639. ignore_max_length: false,
  640. host_blacklist: [],
  641. host_whitelist: []
  642. };
  643. /* eslint-disable max-len */
  644. /* eslint-disable no-control-regex */
  645. var splitNameAddress = /^([^\x00-\x1F\x7F-\x9F\cX]+)</i;
  646. var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i;
  647. var gmailUserPart = /^[a-z\d]+$/;
  648. var quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i;
  649. var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i;
  650. 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;
  651. var defaultMaxEmailLength = 254;
  652. /* eslint-enable max-len */
  653. /* eslint-enable no-control-regex */
  654. /**
  655. * Validate display name according to the RFC2822: https://tools.ietf.org/html/rfc2822#appendix-A.1.2
  656. * @param {String} display_name
  657. */
  658. function validateDisplayName(display_name) {
  659. var display_name_without_quotes = display_name.replace(/^"(.+)"$/, '$1');
  660. // display name with only spaces is not valid
  661. if (!display_name_without_quotes.trim()) {
  662. return false;
  663. }
  664. // check whether display name contains illegal character
  665. var contains_illegal = /[\.";<>]/.test(display_name_without_quotes);
  666. if (contains_illegal) {
  667. // if contains illegal characters,
  668. // must to be enclosed in double-quotes, otherwise it's not a valid display name
  669. if (display_name_without_quotes === display_name) {
  670. return false;
  671. }
  672. // the quotes in display name must start with character symbol \
  673. var all_start_with_back_slash = display_name_without_quotes.split('"').length === display_name_without_quotes.split('\\"').length;
  674. if (!all_start_with_back_slash) {
  675. return false;
  676. }
  677. }
  678. return true;
  679. }
  680. function isEmail(str, options) {
  681. assertString(str);
  682. options = merge(options, default_email_options);
  683. if (options.require_display_name || options.allow_display_name) {
  684. var display_email = str.match(splitNameAddress);
  685. if (display_email) {
  686. var display_name = display_email[1];
  687. // Remove display name and angle brackets to get email address
  688. // Can be done in the regex but will introduce a ReDOS (See #1597 for more info)
  689. str = str.replace(display_name, '').replace(/(^<|>$)/g, '');
  690. // sometimes need to trim the last space to get the display name
  691. // because there may be a space between display name and email address
  692. // eg. myname <address@gmail.com>
  693. // the display name is `myname` instead of `myname `, so need to trim the last space
  694. if (display_name.endsWith(' ')) {
  695. display_name = display_name.slice(0, -1);
  696. }
  697. if (!validateDisplayName(display_name)) {
  698. return false;
  699. }
  700. } else if (options.require_display_name) {
  701. return false;
  702. }
  703. }
  704. if (!options.ignore_max_length && str.length > defaultMaxEmailLength) {
  705. return false;
  706. }
  707. var parts = str.split('@');
  708. var domain = parts.pop();
  709. var lower_domain = domain.toLowerCase();
  710. if (options.host_blacklist.length > 0 && checkHost(lower_domain, options.host_blacklist)) {
  711. return false;
  712. }
  713. if (options.host_whitelist.length > 0 && !checkHost(lower_domain, options.host_whitelist)) {
  714. return false;
  715. }
  716. var user = parts.join('@');
  717. if (options.domain_specific_validation && (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com')) {
  718. /*
  719. Previously we removed dots for gmail addresses before validating.
  720. This was removed because it allows `multiple..dots@gmail.com`
  721. to be reported as valid, but it is not.
  722. Gmail only normalizes single dots, removing them from here is pointless,
  723. should be done in normalizeEmail
  724. */
  725. user = user.toLowerCase();
  726. // Removing sub-address from username before gmail validation
  727. var username = user.split('+')[0];
  728. // Dots are not included in gmail length restriction
  729. if (!isByteLength(username.replace(/\./g, ''), {
  730. min: 6,
  731. max: 30
  732. })) {
  733. return false;
  734. }
  735. var _user_parts = username.split('.');
  736. for (var i = 0; i < _user_parts.length; i++) {
  737. if (!gmailUserPart.test(_user_parts[i])) {
  738. return false;
  739. }
  740. }
  741. }
  742. if (options.ignore_max_length === false && (!isByteLength(user, {
  743. max: 64
  744. }) || !isByteLength(domain, {
  745. max: 254
  746. }))) {
  747. return false;
  748. }
  749. if (!isFQDN(domain, {
  750. require_tld: options.require_tld,
  751. ignore_max_length: options.ignore_max_length,
  752. allow_underscores: options.allow_underscores
  753. })) {
  754. if (!options.allow_ip_domain) {
  755. return false;
  756. }
  757. if (!isIP(domain)) {
  758. if (!domain.startsWith('[') || !domain.endsWith(']')) {
  759. return false;
  760. }
  761. var noBracketdomain = domain.slice(1, -1);
  762. if (noBracketdomain.length === 0 || !isIP(noBracketdomain)) {
  763. return false;
  764. }
  765. }
  766. }
  767. if (options.blacklisted_chars) {
  768. if (user.search(new RegExp("[".concat(options.blacklisted_chars, "]+"), 'g')) !== -1) return false;
  769. }
  770. if (user[0] === '"' && user[user.length - 1] === '"') {
  771. user = user.slice(1, user.length - 1);
  772. return options.allow_utf8_local_part ? quotedEmailUserUtf8.test(user) : quotedEmailUser.test(user);
  773. }
  774. var pattern = options.allow_utf8_local_part ? emailUserUtf8Part : emailUserPart;
  775. var user_parts = user.split('.');
  776. for (var _i = 0; _i < user_parts.length; _i++) {
  777. if (!pattern.test(user_parts[_i])) {
  778. return false;
  779. }
  780. }
  781. return true;
  782. }
  783. var includes = function includes(str, val) {
  784. return str.indexOf(val) !== -1;
  785. };
  786. /*
  787. options for isURL method
  788. protocols - valid protocols can be modified with this option.
  789. require_tld - If set to false isURL will not check if the URL's host includes a top-level domain.
  790. require_protocol - if set to true isURL will return false if protocol is not present in the URL.
  791. require_host - if set to false isURL will not check if host is present in the URL.
  792. require_port - if set to true isURL will check if port is present in the URL.
  793. require_valid_protocol - isURL will check if the URL's protocol is present in the protocols option.
  794. allow_underscores - if set to true, the validator will allow underscores in the URL.
  795. host_whitelist - if set to an array of strings or regexp, and the domain matches none of the strings
  796. defined in it, the validation fails.
  797. host_blacklist - if set to an array of strings or regexp, and the domain matches any of the strings
  798. defined in it, the validation fails.
  799. allow_trailing_dot - if set to true, the validator will allow the domain to end with
  800. a `.` character.
  801. allow_protocol_relative_urls - if set to true protocol relative URLs will be allowed.
  802. allow_fragments - if set to false isURL will return false if fragments are present.
  803. allow_query_components - if set to false isURL will return false if query components are present.
  804. disallow_auth - if set to true, the validator will fail if the URL contains an authentication
  805. component, e.g. `http://username:password@example.com`
  806. validate_length - if set to false isURL will skip string length validation. `max_allowed_length`
  807. will be ignored if this is set as `false`.
  808. max_allowed_length - if set, isURL will not allow URLs longer than the specified value (default is
  809. 2084 that IE maximum URL length).
  810. */
  811. var default_url_options = {
  812. protocols: ['http', 'https', 'ftp'],
  813. require_tld: true,
  814. require_protocol: false,
  815. require_host: true,
  816. require_port: false,
  817. require_valid_protocol: true,
  818. allow_underscores: false,
  819. allow_trailing_dot: false,
  820. allow_protocol_relative_urls: false,
  821. allow_fragments: true,
  822. allow_query_components: true,
  823. validate_length: true,
  824. max_allowed_length: 2084
  825. };
  826. var wrapped_ipv6 = /^\[([^\]]+)\](?::([0-9]+))?$/;
  827. function isURL(url, options) {
  828. assertString(url);
  829. if (!url || /[\s<>]/.test(url)) {
  830. return false;
  831. }
  832. if (url.indexOf('mailto:') === 0) {
  833. return false;
  834. }
  835. options = merge(options, default_url_options);
  836. if (options.validate_length && url.length > options.max_allowed_length) {
  837. return false;
  838. }
  839. if (!options.allow_fragments && includes(url, '#')) {
  840. return false;
  841. }
  842. if (!options.allow_query_components && (includes(url, '?') || includes(url, '&'))) {
  843. return false;
  844. }
  845. var protocol, auth, host, hostname, port, port_str, split, ipv6;
  846. split = url.split('#');
  847. url = split.shift();
  848. split = url.split('?');
  849. url = split.shift();
  850. // Replaced the 'split("://")' logic with a regex to match the protocol.
  851. // This correctly identifies schemes like `javascript:` which don't use `//`.
  852. // However, we need to be careful not to confuse authentication credentials (user:password@host)
  853. // with protocols. A colon before an @ symbol might be part of auth, not a protocol separator.
  854. var protocol_match = url.match(/^([a-z][a-z0-9+\-.]*):/i);
  855. var had_explicit_protocol = false;
  856. var cleanUpProtocol = function cleanUpProtocol(potential_protocol) {
  857. had_explicit_protocol = true;
  858. protocol = potential_protocol.toLowerCase();
  859. if (options.require_valid_protocol && options.protocols.indexOf(protocol) === -1) {
  860. // The identified protocol is not in the allowed list.
  861. return false;
  862. }
  863. // Remove the protocol from the URL string.
  864. return url.substring(protocol_match[0].length);
  865. };
  866. if (protocol_match) {
  867. var potential_protocol = protocol_match[1];
  868. var after_colon = url.substring(protocol_match[0].length);
  869. // Check if what follows looks like authentication credentials (user:password@host)
  870. // rather than a protocol. This happens when:
  871. // 1. There's no `//` after the colon (protocols like `http://` have this)
  872. // 2. There's an `@` symbol before any `/`
  873. // 3. The part before `@` contains only valid auth characters (alphanumeric, -, _, ., %, :)
  874. var starts_with_slashes = after_colon.slice(0, 2) === '//';
  875. if (!starts_with_slashes) {
  876. var first_slash_position = after_colon.indexOf('/');
  877. var before_slash = first_slash_position === -1 ? after_colon : after_colon.substring(0, first_slash_position);
  878. var at_position = before_slash.indexOf('@');
  879. if (at_position !== -1) {
  880. var before_at = before_slash.substring(0, at_position);
  881. var valid_auth_regex = /^[a-zA-Z0-9\-_.%:]*$/;
  882. var is_valid_auth = valid_auth_regex.test(before_at);
  883. // Check if this contains URL-encoded content that could be malicious
  884. // For example: javascript:%61%6c%65%72%74%28%31%29@example.com
  885. // The encoded part decodes to: alert(1)
  886. var has_encoded_content = /%[0-9a-fA-F]{2}/.test(before_at);
  887. if (is_valid_auth && !has_encoded_content) {
  888. // This looks like authentication (e.g., user:password@host), not a protocol
  889. if (options.require_protocol) {
  890. return false;
  891. }
  892. // Don't consume the colon; let the auth parsing handle it later
  893. } else {
  894. // This looks like a malicious protocol (e.g., javascript:alert();@host)
  895. // or URL-encoded protocol handler (e.g., javascript:%61%6c%65%72%74%28%31%29@host)
  896. url = cleanUpProtocol(potential_protocol);
  897. if (url === false) {
  898. return false;
  899. }
  900. }
  901. } else {
  902. // No @ symbol found. Check if this could be a port number instead of a protocol.
  903. // If what's after the colon is numeric (or starts with a digit and contains only
  904. // valid port characters until a path separator), it's likely hostname:port, not a protocol.
  905. var looks_like_port = /^[0-9]/.test(after_colon);
  906. if (looks_like_port) {
  907. // This looks like hostname:port, not a protocol
  908. if (options.require_protocol) {
  909. return false;
  910. }
  911. // Don't consume anything; let it be parsed as hostname:port
  912. } else {
  913. // This is definitely a protocol
  914. url = cleanUpProtocol(potential_protocol);
  915. if (url === false) {
  916. return false;
  917. }
  918. }
  919. }
  920. } else {
  921. // Starts with '//', this is definitely a protocol like http://
  922. url = cleanUpProtocol(potential_protocol);
  923. if (url === false) {
  924. return false;
  925. }
  926. }
  927. } else if (options.require_protocol) {
  928. return false;
  929. }
  930. // Handle leading '//' only as protocol-relative when there was NO explicit protocol.
  931. // If there was an explicit protocol, '//' is the normal separator
  932. // and should be stripped unconditionally.
  933. if (url.slice(0, 2) === '//') {
  934. if (!had_explicit_protocol && !options.allow_protocol_relative_urls) {
  935. return false;
  936. }
  937. url = url.slice(2);
  938. }
  939. if (url === '') {
  940. return false;
  941. }
  942. split = url.split('/');
  943. url = split.shift();
  944. if (url === '' && !options.require_host) {
  945. return true;
  946. }
  947. split = url.split('@');
  948. if (split.length > 1) {
  949. if (options.disallow_auth) {
  950. return false;
  951. }
  952. if (split[0] === '') {
  953. return false;
  954. }
  955. auth = split.shift();
  956. if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) {
  957. return false;
  958. }
  959. var _auth$split = auth.split(':'),
  960. _auth$split2 = _slicedToArray(_auth$split, 2),
  961. user = _auth$split2[0],
  962. password = _auth$split2[1];
  963. if (user === '' && password === '') {
  964. return false;
  965. }
  966. }
  967. hostname = split.join('@');
  968. port_str = null;
  969. ipv6 = null;
  970. var ipv6_match = hostname.match(wrapped_ipv6);
  971. if (ipv6_match) {
  972. host = '';
  973. ipv6 = ipv6_match[1];
  974. port_str = ipv6_match[2] || null;
  975. } else {
  976. split = hostname.split(':');
  977. host = split.shift();
  978. if (split.length) {
  979. port_str = split.join(':');
  980. }
  981. }
  982. if (port_str !== null && port_str.length > 0) {
  983. port = parseInt(port_str, 10);
  984. if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) {
  985. return false;
  986. }
  987. } else if (options.require_port) {
  988. return false;
  989. }
  990. if (options.host_whitelist) {
  991. return checkHost(host, options.host_whitelist);
  992. }
  993. if (host === '' && !options.require_host) {
  994. return true;
  995. }
  996. if (!isIP(host) && !isFQDN(host, options) && (!ipv6 || !isIP(ipv6, 6))) {
  997. return false;
  998. }
  999. host = host || ipv6;
  1000. if (options.host_blacklist && checkHost(host, options.host_blacklist)) {
  1001. return false;
  1002. }
  1003. return true;
  1004. }
  1005. var macAddress48 = /^(?:[0-9a-fA-F]{2}([-:\s]))([0-9a-fA-F]{2}\1){4}([0-9a-fA-F]{2})$/;
  1006. var macAddress48NoSeparators = /^([0-9a-fA-F]){12}$/;
  1007. var macAddress48WithDots = /^([0-9a-fA-F]{4}\.){2}([0-9a-fA-F]{4})$/;
  1008. var macAddress64 = /^(?:[0-9a-fA-F]{2}([-:\s]))([0-9a-fA-F]{2}\1){6}([0-9a-fA-F]{2})$/;
  1009. var macAddress64NoSeparators = /^([0-9a-fA-F]){16}$/;
  1010. var macAddress64WithDots = /^([0-9a-fA-F]{4}\.){3}([0-9a-fA-F]{4})$/;
  1011. function isMACAddress(str, options) {
  1012. assertString(str);
  1013. if (options !== null && options !== void 0 && options.eui) {
  1014. options.eui = String(options.eui);
  1015. }
  1016. /**
  1017. * @deprecated `no_colons` TODO: remove it in the next major
  1018. */
  1019. if (options !== null && options !== void 0 && options.no_colons || options !== null && options !== void 0 && options.no_separators) {
  1020. if (options.eui === '48') {
  1021. return macAddress48NoSeparators.test(str);
  1022. }
  1023. if (options.eui === '64') {
  1024. return macAddress64NoSeparators.test(str);
  1025. }
  1026. return macAddress48NoSeparators.test(str) || macAddress64NoSeparators.test(str);
  1027. }
  1028. if ((options === null || options === void 0 ? void 0 : options.eui) === '48') {
  1029. return macAddress48.test(str) || macAddress48WithDots.test(str);
  1030. }
  1031. if ((options === null || options === void 0 ? void 0 : options.eui) === '64') {
  1032. return macAddress64.test(str) || macAddress64WithDots.test(str);
  1033. }
  1034. return isMACAddress(str, {
  1035. eui: '48'
  1036. }) || isMACAddress(str, {
  1037. eui: '64'
  1038. });
  1039. }
  1040. var subnetMaybe = /^\d{1,3}$/;
  1041. var v4Subnet = 32;
  1042. var v6Subnet = 128;
  1043. function isIPRange(str) {
  1044. var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  1045. assertString(str);
  1046. var parts = str.split('/');
  1047. // parts[0] -> ip, parts[1] -> subnet
  1048. if (parts.length !== 2) {
  1049. return false;
  1050. }
  1051. if (!subnetMaybe.test(parts[1])) {
  1052. return false;
  1053. }
  1054. // Disallow preceding 0 i.e. 01, 02, ...
  1055. if (parts[1].length > 1 && parts[1].startsWith('0')) {
  1056. return false;
  1057. }
  1058. var isValidIP = isIP(parts[0], version);
  1059. if (!isValidIP) {
  1060. return false;
  1061. }
  1062. // Define valid subnet according to IP's version
  1063. var expectedSubnet = null;
  1064. switch (String(version)) {
  1065. case '4':
  1066. expectedSubnet = v4Subnet;
  1067. break;
  1068. case '6':
  1069. expectedSubnet = v6Subnet;
  1070. break;
  1071. default:
  1072. expectedSubnet = isIP(parts[0], '6') ? v6Subnet : v4Subnet;
  1073. }
  1074. return parts[1] <= expectedSubnet && parts[1] >= 0;
  1075. }
  1076. var default_date_options = {
  1077. format: 'YYYY/MM/DD',
  1078. delimiters: ['/', '-'],
  1079. strictMode: false
  1080. };
  1081. function isValidFormat(format) {
  1082. 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);
  1083. }
  1084. function zip(date, format) {
  1085. var zippedArr = [],
  1086. len = Math.max(date.length, format.length);
  1087. for (var i = 0; i < len; i++) {
  1088. zippedArr.push([date[i], format[i]]);
  1089. }
  1090. return zippedArr;
  1091. }
  1092. function isDate(input, options) {
  1093. if (typeof options === 'string') {
  1094. // Allow backward compatibility for old format isDate(input [, format])
  1095. options = merge({
  1096. format: options
  1097. }, default_date_options);
  1098. } else {
  1099. options = merge(options, default_date_options);
  1100. }
  1101. if (typeof input === 'string' && isValidFormat(options.format)) {
  1102. if (options.strictMode && input.length !== options.format.length) return false;
  1103. var formatDelimiter = options.delimiters.find(function (delimiter) {
  1104. return options.format.indexOf(delimiter) !== -1;
  1105. });
  1106. var dateDelimiter = options.strictMode ? formatDelimiter : options.delimiters.find(function (delimiter) {
  1107. return input.indexOf(delimiter) !== -1;
  1108. });
  1109. var dateAndFormat = zip(input.split(dateDelimiter), options.format.toLowerCase().split(formatDelimiter));
  1110. var dateObj = {};
  1111. var _iterator = _createForOfIteratorHelper(dateAndFormat),
  1112. _step;
  1113. try {
  1114. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  1115. var _step$value = _slicedToArray(_step.value, 2),
  1116. dateWord = _step$value[0],
  1117. formatWord = _step$value[1];
  1118. if (!dateWord || !formatWord || dateWord.length !== formatWord.length) {
  1119. return false;
  1120. }
  1121. dateObj[formatWord.charAt(0)] = dateWord;
  1122. }
  1123. } catch (err) {
  1124. _iterator.e(err);
  1125. } finally {
  1126. _iterator.f();
  1127. }
  1128. var fullYear = dateObj.y;
  1129. // Check if the year starts with a hyphen
  1130. if (fullYear.startsWith('-')) {
  1131. return false; // Hyphen before year is not allowed
  1132. }
  1133. if (dateObj.y.length === 2) {
  1134. var parsedYear = parseInt(dateObj.y, 10);
  1135. if (isNaN(parsedYear)) {
  1136. return false;
  1137. }
  1138. var currentYearLastTwoDigits = new Date().getFullYear() % 100;
  1139. if (parsedYear < currentYearLastTwoDigits) {
  1140. fullYear = "20".concat(dateObj.y);
  1141. } else {
  1142. fullYear = "19".concat(dateObj.y);
  1143. }
  1144. }
  1145. var month = dateObj.m;
  1146. if (dateObj.m.length === 1) {
  1147. month = "0".concat(dateObj.m);
  1148. }
  1149. var day = dateObj.d;
  1150. if (dateObj.d.length === 1) {
  1151. day = "0".concat(dateObj.d);
  1152. }
  1153. return new Date("".concat(fullYear, "-").concat(month, "-").concat(day, "T00:00:00.000Z")).getUTCDate() === +dateObj.d;
  1154. }
  1155. if (!options.strictMode) {
  1156. return Object.prototype.toString.call(input) === '[object Date]' && isFinite(input);
  1157. }
  1158. return false;
  1159. }
  1160. var default_time_options = {
  1161. hourFormat: 'hour24',
  1162. mode: 'default'
  1163. };
  1164. var formats = {
  1165. hour24: {
  1166. "default": /^([01]?[0-9]|2[0-3]):([0-5][0-9])$/,
  1167. withSeconds: /^([01]?[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/,
  1168. withOptionalSeconds: /^([01]?[0-9]|2[0-3]):([0-5][0-9])(?::([0-5][0-9]))?$/
  1169. },
  1170. hour12: {
  1171. "default": /^(0?[1-9]|1[0-2]):([0-5][0-9]) (A|P)M$/,
  1172. withSeconds: /^(0?[1-9]|1[0-2]):([0-5][0-9]):([0-5][0-9]) (A|P)M$/,
  1173. withOptionalSeconds: /^(0?[1-9]|1[0-2]):([0-5][0-9])(?::([0-5][0-9]))? (A|P)M$/
  1174. }
  1175. };
  1176. function isTime(input, options) {
  1177. options = merge(options, default_time_options);
  1178. if (typeof input !== 'string') return false;
  1179. return formats[options.hourFormat][options.mode].test(input);
  1180. }
  1181. var includes$2 = function includes(arr, val) {
  1182. return arr.some(function (arrVal) {
  1183. return val === arrVal;
  1184. });
  1185. };
  1186. var defaultOptions = {
  1187. loose: false
  1188. };
  1189. var strictBooleans = ['true', 'false', '1', '0'];
  1190. var looseBooleans = [].concat(strictBooleans, ['yes', 'no']);
  1191. function isBoolean(str) {
  1192. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
  1193. assertString(str);
  1194. if (options.loose) {
  1195. return includes$2(looseBooleans, str.toLowerCase());
  1196. }
  1197. return includes$2(strictBooleans, str);
  1198. }
  1199. /*
  1200. = 3ALPHA ; selected ISO 639 codes
  1201. *2("-" 3ALPHA) ; permanently reserved
  1202. */
  1203. var extlang = '([A-Za-z]{3}(-[A-Za-z]{3}){0,2})';
  1204. /*
  1205. = 2*3ALPHA ; shortest ISO 639 code
  1206. ["-" extlang] ; sometimes followed by
  1207. ; extended language subtags
  1208. / 4ALPHA ; or reserved for future use
  1209. / 5*8ALPHA ; or registered language subtag
  1210. */
  1211. var language = "(([a-zA-Z]{2,3}(-".concat(extlang, ")?)|([a-zA-Z]{5,8}))");
  1212. /*
  1213. = 4ALPHA ; ISO 15924 code
  1214. */
  1215. var script = '([A-Za-z]{4})';
  1216. /*
  1217. = 2ALPHA ; ISO 3166-1 code
  1218. / 3DIGIT ; UN M.49 code
  1219. */
  1220. var region = '([A-Za-z]{2}|\\d{3})';
  1221. /*
  1222. = 5*8alphanum ; registered variants
  1223. / (DIGIT 3alphanum)
  1224. */
  1225. var variant = '([A-Za-z0-9]{5,8}|(\\d[A-Z-a-z0-9]{3}))';
  1226. /*
  1227. = DIGIT ; 0 - 9
  1228. / %x41-57 ; A - W
  1229. / %x59-5A ; Y - Z
  1230. / %x61-77 ; a - w
  1231. / %x79-7A ; y - z
  1232. */
  1233. var singleton = '(\\d|[A-W]|[Y-Z]|[a-w]|[y-z])';
  1234. /*
  1235. = singleton 1*("-" (2*8alphanum))
  1236. ; Single alphanumerics
  1237. ; "x" reserved for private use
  1238. */
  1239. var extension = "(".concat(singleton, "(-[A-Za-z0-9]{2,8})+)");
  1240. /*
  1241. = "x" 1*("-" (1*8alphanum))
  1242. */
  1243. var privateuse = '(x(-[A-Za-z0-9]{1,8})+)';
  1244. // irregular tags do not match the 'langtag' production and would not
  1245. // otherwise be considered 'well-formed'. These tags are all valid, but
  1246. // most are deprecated in favor of more modern subtags or subtag combination
  1247. var irregular = '((en-GB-oed)|(i-ami)|(i-bnn)|(i-default)|(i-enochian)|' + '(i-hak)|(i-klingon)|(i-lux)|(i-mingo)|(i-navajo)|(i-pwn)|(i-tao)|' + '(i-tay)|(i-tsu)|(sgn-BE-FR)|(sgn-BE-NL)|(sgn-CH-DE))';
  1248. // regular tags match the 'langtag' production, but their subtags are not
  1249. // extended language or variant subtags: their meaning is defined by
  1250. // their registration and all of these are deprecated in favor of a more
  1251. // modern subtag or sequence of subtags
  1252. var regular = '((art-lojban)|(cel-gaulish)|(no-bok)|(no-nyn)|(zh-guoyu)|' + '(zh-hakka)|(zh-min)|(zh-min-nan)|(zh-xiang))';
  1253. /*
  1254. = irregular ; non-redundant tags registered
  1255. / regular ; during the RFC 3066 era
  1256. */
  1257. var grandfathered = "(".concat(irregular, "|").concat(regular, ")");
  1258. /*
  1259. RFC 5646 defines delimitation of subtags via a hyphen:
  1260. "Subtag" refers to a specific section of a tag, delimited by a
  1261. hyphen, such as the subtags 'zh', 'Hant', and 'CN' in the tag "zh-
  1262. Hant-CN". Examples of subtags in this document are enclosed in
  1263. single quotes ('Hant')
  1264. However, we need to add "_" to maintain the existing behaviour.
  1265. */
  1266. var delimiter = '(-|_)';
  1267. /*
  1268. = language
  1269. ["-" script]
  1270. ["-" region]
  1271. *("-" variant)
  1272. *("-" extension)
  1273. ["-" privateuse]
  1274. */
  1275. var langtag = "".concat(language, "(").concat(delimiter).concat(script, ")?(").concat(delimiter).concat(region, ")?(").concat(delimiter).concat(variant, ")*(").concat(delimiter).concat(extension, ")*(").concat(delimiter).concat(privateuse, ")?");
  1276. /*
  1277. Regex implementation based on BCP RFC 5646
  1278. Tags for Identifying Languages
  1279. https://www.rfc-editor.org/rfc/rfc5646.html
  1280. */
  1281. var languageTagRegex = new RegExp("(^".concat(privateuse, "$)|(^").concat(grandfathered, "$)|(^").concat(langtag, "$)"));
  1282. function isLocale(str) {
  1283. assertString(str);
  1284. return languageTagRegex.test(str);
  1285. }
  1286. // http://www.brainjar.com/js/validation/
  1287. // https://www.aba.com/news-research/research-analysis/routing-number-policy-procedures
  1288. // series reserved for future use are excluded
  1289. var isRoutingReg = /^(?!(1[3-9])|(20)|(3[3-9])|(4[0-9])|(5[0-9])|(60)|(7[3-9])|(8[1-9])|(9[0-2])|(9[3-9]))[0-9]{9}$/;
  1290. function isAbaRouting(str) {
  1291. assertString(str);
  1292. if (!isRoutingReg.test(str)) return false;
  1293. var checkSumVal = 0;
  1294. for (var i = 0; i < str.length; i++) {
  1295. if (i % 3 === 0) checkSumVal += str[i] * 3;else if (i % 3 === 1) checkSumVal += str[i] * 7;else checkSumVal += str[i] * 1;
  1296. }
  1297. return checkSumVal % 10 === 0;
  1298. }
  1299. function isAlpha(_str) {
  1300. var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US';
  1301. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  1302. assertString(_str);
  1303. var str = _str;
  1304. var ignore = options.ignore;
  1305. if (ignore) {
  1306. if (ignore instanceof RegExp) {
  1307. str = str.replace(ignore, '');
  1308. } else if (typeof ignore === 'string') {
  1309. str = str.replace(new RegExp("[".concat(ignore.replace(/[-[\]{}()*+?.,\\^$|#\\s]/g, '\\$&'), "]"), 'g'), ''); // escape regex for ignore
  1310. } else {
  1311. throw new Error('ignore should be instance of a String or RegExp');
  1312. }
  1313. }
  1314. if (locale in alpha) {
  1315. return alpha[locale].test(str);
  1316. }
  1317. throw new Error("Invalid locale '".concat(locale, "'"));
  1318. }
  1319. var locales$1 = Object.keys(alpha);
  1320. function isAlphanumeric(_str) {
  1321. var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US';
  1322. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  1323. assertString(_str);
  1324. var str = _str;
  1325. var ignore = options.ignore;
  1326. if (ignore) {
  1327. if (ignore instanceof RegExp) {
  1328. str = str.replace(ignore, '');
  1329. } else if (typeof ignore === 'string') {
  1330. str = str.replace(new RegExp("[".concat(ignore.replace(/[-[\]{}()*+?.,\\^$|#\\s]/g, '\\$&'), "]"), 'g'), ''); // escape regex for ignore
  1331. } else {
  1332. throw new Error('ignore should be instance of a String or RegExp');
  1333. }
  1334. }
  1335. if (locale in alphanumeric) {
  1336. return alphanumeric[locale].test(str);
  1337. }
  1338. throw new Error("Invalid locale '".concat(locale, "'"));
  1339. }
  1340. var locales$2 = Object.keys(alphanumeric);
  1341. var numericNoSymbols = /^[0-9]+$/;
  1342. function isNumeric(str, options) {
  1343. assertString(str);
  1344. if (options && options.no_symbols) {
  1345. return numericNoSymbols.test(str);
  1346. }
  1347. return new RegExp("^[+-]?([0-9]*[".concat((options || {}).locale ? decimal[options.locale] : '.', "])?[0-9]+$")).test(str);
  1348. }
  1349. /**
  1350. * Reference:
  1351. * https://en.wikipedia.org/ -- Wikipedia
  1352. * https://docs.microsoft.com/en-us/microsoft-365/compliance/eu-passport-number -- EU Passport Number
  1353. * https://countrycode.org/ -- Country Codes
  1354. */
  1355. var passportRegexByCountryCode = {
  1356. AM: /^[A-Z]{2}\d{7}$/,
  1357. // ARMENIA
  1358. AR: /^[A-Z]{3}\d{6}$/,
  1359. // ARGENTINA
  1360. AT: /^[A-Z]\d{7}$/,
  1361. // AUSTRIA
  1362. AU: /^[A-Z]\d{7}$/,
  1363. // AUSTRALIA
  1364. AZ: /^[A-Z]{1}\d{8}$/,
  1365. // AZERBAIJAN
  1366. BE: /^[A-Z]{2}\d{6}$/,
  1367. // BELGIUM
  1368. BG: /^\d{9}$/,
  1369. // BULGARIA
  1370. BR: /^[A-Z]{2}\d{6}$/,
  1371. // BRAZIL
  1372. BY: /^[A-Z]{2}\d{7}$/,
  1373. // BELARUS
  1374. CA: /^[A-Z]{2}\d{6}$|^[A-Z]\d{6}[A-Z]{2}$/,
  1375. // CANADA
  1376. CH: /^[A-Z]\d{7}$/,
  1377. // SWITZERLAND
  1378. CN: /^G\d{8}$|^E(?![IO])[A-Z0-9]\d{7}$/,
  1379. // CHINA [G=Ordinary, E=Electronic] followed by 8-digits, or E followed by any UPPERCASE letter (except I and O) followed by 7 digits
  1380. CY: /^[A-Z](\d{6}|\d{8})$/,
  1381. // CYPRUS
  1382. CZ: /^\d{8}$/,
  1383. // CZECH REPUBLIC
  1384. DE: /^[CFGHJKLMNPRTVWXYZ0-9]{9}$/,
  1385. // GERMANY
  1386. DK: /^\d{9}$/,
  1387. // DENMARK
  1388. DZ: /^\d{9}$/,
  1389. // ALGERIA
  1390. EE: /^([A-Z]\d{7}|[A-Z]{2}\d{7})$/,
  1391. // ESTONIA (K followed by 7-digits), e-passports have 2 UPPERCASE followed by 7 digits
  1392. ES: /^[A-Z0-9]{2}([A-Z0-9]?)\d{6}$/,
  1393. // SPAIN
  1394. FI: /^[A-Z]{2}\d{7}$/,
  1395. // FINLAND
  1396. FR: /^\d{2}[A-Z]{2}\d{5}$/,
  1397. // FRANCE
  1398. GB: /^\d{9}$/,
  1399. // UNITED KINGDOM
  1400. GR: /^[A-Z]{2}\d{7}$/,
  1401. // GREECE
  1402. HR: /^\d{9}$/,
  1403. // CROATIA
  1404. HU: /^[A-Z]{2}(\d{6}|\d{7})$/,
  1405. // HUNGARY
  1406. IE: /^[A-Z0-9]{2}\d{7}$/,
  1407. // IRELAND
  1408. IN: /^[A-Z]{1}-?\d{7}$/,
  1409. // INDIA
  1410. ID: /^[A-C]\d{7}$/,
  1411. // INDONESIA
  1412. IR: /^[A-Z]\d{8}$/,
  1413. // IRAN
  1414. IS: /^(A)\d{7}$/,
  1415. // ICELAND
  1416. IT: /^[A-Z0-9]{2}\d{7}$/,
  1417. // ITALY
  1418. JM: /^[Aa]\d{7}$/,
  1419. // JAMAICA
  1420. JP: /^[A-Z]{2}\d{7}$/,
  1421. // JAPAN
  1422. KR: /^[MS]\d{8}$/,
  1423. // SOUTH KOREA, REPUBLIC OF KOREA, [S=PS Passports, M=PM Passports]
  1424. KZ: /^[a-zA-Z]\d{7}$/,
  1425. // KAZAKHSTAN
  1426. LI: /^[a-zA-Z]\d{5}$/,
  1427. // LIECHTENSTEIN
  1428. LT: /^[A-Z0-9]{8}$/,
  1429. // LITHUANIA
  1430. LU: /^[A-Z0-9]{8}$/,
  1431. // LUXEMBURG
  1432. LV: /^[A-Z0-9]{2}\d{7}$/,
  1433. // LATVIA
  1434. LY: /^[A-Z0-9]{8}$/,
  1435. // LIBYA
  1436. MT: /^\d{7}$/,
  1437. // MALTA
  1438. MZ: /^([A-Z]{2}\d{7})|(\d{2}[A-Z]{2}\d{5})$/,
  1439. // MOZAMBIQUE
  1440. MY: /^[AHK]\d{8}$/,
  1441. // MALAYSIA
  1442. MX: /^[A-Z]\d{8}$/,
  1443. // MEXICO
  1444. NL: /^[A-Z]{2}[A-Z0-9]{6}\d$/,
  1445. // NETHERLANDS
  1446. NZ: /^([Ll]([Aa]|[Dd]|[Ff]|[Hh])|[Ee]([Aa]|[Pp])|[Nn])\d{6}$/,
  1447. // NEW ZEALAND
  1448. PH: /^([A-Z](\d{6}|\d{7}[A-Z]))|([A-Z]{2}(\d{6}|\d{7}))$/,
  1449. // PHILIPPINES
  1450. PK: /^[A-Z]{2}\d{7}$/,
  1451. // PAKISTAN
  1452. PL: /^[A-Z]{2}\d{7}$/,
  1453. // POLAND
  1454. PT: /^[A-Z]\d{6}$/,
  1455. // PORTUGAL
  1456. RO: /^\d{8,9}$/,
  1457. // ROMANIA
  1458. RU: /^\d{9}$/,
  1459. // RUSSIAN FEDERATION
  1460. SE: /^\d{8}$/,
  1461. // SWEDEN
  1462. SL: /^(P)[A-Z]\d{7}$/,
  1463. // SLOVENIA
  1464. SK: /^[0-9A-Z]\d{7}$/,
  1465. // SLOVAKIA
  1466. TH: /^[A-Z]{1,2}\d{6,7}$/,
  1467. // THAILAND
  1468. TR: /^[A-Z]\d{8}$/,
  1469. // TURKEY
  1470. UA: /^[A-Z]{2}\d{6}$/,
  1471. // UKRAINE
  1472. US: /^\d{9}$|^[A-Z]\d{8}$/,
  1473. // UNITED STATES
  1474. ZA: /^[TAMD]\d{8}$/ // SOUTH AFRICA
  1475. };
  1476. var locales$3 = Object.keys(passportRegexByCountryCode);
  1477. /**
  1478. * Check if str is a valid passport number
  1479. * relative to provided ISO Country Code.
  1480. *
  1481. * @param {string} str
  1482. * @param {string} countryCode
  1483. * @return {boolean}
  1484. */
  1485. function isPassportNumber(str, countryCode) {
  1486. assertString(str);
  1487. /** Remove All Whitespaces, Convert to UPPERCASE */
  1488. var normalizedStr = str.replace(/\s/g, '').toUpperCase();
  1489. return countryCode.toUpperCase() in passportRegexByCountryCode && passportRegexByCountryCode[countryCode].test(normalizedStr);
  1490. }
  1491. var _int = /^(?:[-+]?(?:0|[1-9][0-9]*))$/;
  1492. var intLeadingZeroes = /^[-+]?[0-9]+$/;
  1493. function isInt(str, options) {
  1494. assertString(str);
  1495. options = options || {};
  1496. // Get the regex to use for testing, based on whether
  1497. // leading zeroes are allowed or not.
  1498. var regex = options.allow_leading_zeroes === false ? _int : intLeadingZeroes;
  1499. // Check min/max/lt/gt
  1500. var minCheckPassed = !options.hasOwnProperty('min') || isNullOrUndefined(options.min) || str >= options.min;
  1501. var maxCheckPassed = !options.hasOwnProperty('max') || isNullOrUndefined(options.max) || str <= options.max;
  1502. var ltCheckPassed = !options.hasOwnProperty('lt') || isNullOrUndefined(options.lt) || str < options.lt;
  1503. var gtCheckPassed = !options.hasOwnProperty('gt') || isNullOrUndefined(options.gt) || str > options.gt;
  1504. return regex.test(str) && minCheckPassed && maxCheckPassed && ltCheckPassed && gtCheckPassed;
  1505. }
  1506. function isPort(str) {
  1507. return isInt(str, {
  1508. allow_leading_zeroes: false,
  1509. min: 0,
  1510. max: 65535
  1511. });
  1512. }
  1513. function isLowercase(str) {
  1514. assertString(str);
  1515. return str === str.toLowerCase();
  1516. }
  1517. function isUppercase(str) {
  1518. assertString(str);
  1519. return str === str.toUpperCase();
  1520. }
  1521. var imeiRegexWithoutHyphens = /^[0-9]{15}$/;
  1522. var imeiRegexWithHyphens = /^\d{2}-\d{6}-\d{6}-\d{1}$/;
  1523. function isIMEI(str, options) {
  1524. assertString(str);
  1525. options = options || {};
  1526. // default regex for checking imei is the one without hyphens
  1527. var imeiRegex = imeiRegexWithoutHyphens;
  1528. if (options.allow_hyphens) {
  1529. imeiRegex = imeiRegexWithHyphens;
  1530. }
  1531. if (!imeiRegex.test(str)) {
  1532. return false;
  1533. }
  1534. str = str.replace(/-/g, '');
  1535. var sum = 0,
  1536. mul = 2,
  1537. l = 14;
  1538. for (var i = 0; i < l; i++) {
  1539. var digit = str.substring(l - i - 1, l - i);
  1540. var tp = parseInt(digit, 10) * mul;
  1541. if (tp >= 10) {
  1542. sum += tp % 10 + 1;
  1543. } else {
  1544. sum += tp;
  1545. }
  1546. if (mul === 1) {
  1547. mul += 1;
  1548. } else {
  1549. mul -= 1;
  1550. }
  1551. }
  1552. var chk = (10 - sum % 10) % 10;
  1553. if (chk !== parseInt(str.substring(14, 15), 10)) {
  1554. return false;
  1555. }
  1556. return true;
  1557. }
  1558. /* eslint-disable no-control-regex */
  1559. var ascii = /^[\x00-\x7F]+$/;
  1560. /* eslint-enable no-control-regex */
  1561. function isAscii(str) {
  1562. assertString(str);
  1563. return ascii.test(str);
  1564. }
  1565. var fullWidth = /[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;
  1566. function isFullWidth(str) {
  1567. assertString(str);
  1568. return fullWidth.test(str);
  1569. }
  1570. var halfWidth = /[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;
  1571. function isHalfWidth(str) {
  1572. assertString(str);
  1573. return halfWidth.test(str);
  1574. }
  1575. function isVariableWidth(str) {
  1576. assertString(str);
  1577. return fullWidth.test(str) && halfWidth.test(str);
  1578. }
  1579. /* eslint-disable no-control-regex */
  1580. var multibyte = /[^\x00-\x7F]/;
  1581. /* eslint-enable no-control-regex */
  1582. function isMultibyte(str) {
  1583. assertString(str);
  1584. return multibyte.test(str);
  1585. }
  1586. /**
  1587. * Build RegExp object from an array
  1588. * of multiple/multi-line regexp parts
  1589. *
  1590. * @param {string[]} parts
  1591. * @param {string} flags
  1592. * @return {object} - RegExp object
  1593. */
  1594. function multilineRegexp(parts, flags) {
  1595. var regexpAsStringLiteral = parts.join('');
  1596. return new RegExp(regexpAsStringLiteral, flags);
  1597. }
  1598. /**
  1599. * Regular Expression to match
  1600. * semantic versioning (SemVer)
  1601. * built from multi-line, multi-parts regexp
  1602. * Reference: https://semver.org/
  1603. */
  1604. var semanticVersioningRegex = multilineRegexp(['^(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');
  1605. function isSemVer(str) {
  1606. assertString(str);
  1607. return semanticVersioningRegex.test(str);
  1608. }
  1609. var surrogatePair = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
  1610. function isSurrogatePair(str) {
  1611. assertString(str);
  1612. return surrogatePair.test(str);
  1613. }
  1614. function decimalRegExp(options) {
  1615. var regExp = new RegExp("^[-+]?([0-9]+)?(\\".concat(decimal[options.locale], "[0-9]{").concat(options.decimal_digits, "})").concat(options.force_decimal ? '' : '?', "$"));
  1616. return regExp;
  1617. }
  1618. var default_decimal_options = {
  1619. force_decimal: false,
  1620. decimal_digits: '1,',
  1621. locale: 'en-US'
  1622. };
  1623. var blacklist = ['', '-', '+'];
  1624. function isDecimal(str, options) {
  1625. assertString(str);
  1626. options = merge(options, default_decimal_options);
  1627. if (options.locale in decimal) {
  1628. return !includes$2(blacklist, str.replace(/ /g, '')) && decimalRegExp(options).test(str);
  1629. }
  1630. throw new Error("Invalid locale '".concat(options.locale, "'"));
  1631. }
  1632. var hexadecimal = /^(0x|0h)?[0-9A-F]+$/i;
  1633. function isHexadecimal(str) {
  1634. assertString(str);
  1635. return hexadecimal.test(str);
  1636. }
  1637. var octal = /^(0o)?[0-7]+$/i;
  1638. function isOctal(str) {
  1639. assertString(str);
  1640. return octal.test(str);
  1641. }
  1642. function isDivisibleBy(str, num) {
  1643. assertString(str);
  1644. return toFloat(str) % parseInt(num, 10) === 0;
  1645. }
  1646. var hexcolor = /^#?([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$/i;
  1647. var hexcolor_with_prefix = /^#([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$/i;
  1648. var default_is_hexcolor_options = {
  1649. require_hashtag: false
  1650. };
  1651. function isHexColor(str, options) {
  1652. assertString(str);
  1653. options = merge(options, default_is_hexcolor_options);
  1654. var hexcolor_regex = options.require_hashtag ? hexcolor_with_prefix : hexcolor;
  1655. return hexcolor_regex.test(str);
  1656. }
  1657. /* eslint-disable prefer-rest-params */
  1658. 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])\)$/;
  1659. 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\d?|1(\.0)?|0(\.0)?)\)$/;
  1660. var rgbColorPercent = /^rgb\((([0-9]%|[1-9][0-9]%|100%),){2}([0-9]%|[1-9][0-9]%|100%)\)$/;
  1661. var rgbaColorPercent = /^rgba\((([0-9]%|[1-9][0-9]%|100%),){3}(0?\.\d\d?|1(\.0)?|0(\.0)?)\)$/;
  1662. var startsWithRgb = /^rgba?/;
  1663. function isRgbColor(str, options) {
  1664. assertString(str);
  1665. // default options to true for percent and false for spaces
  1666. var allowSpaces = false;
  1667. var includePercentValues = true;
  1668. if (_typeof(options) !== 'object') {
  1669. if (arguments.length >= 2) {
  1670. includePercentValues = arguments[1];
  1671. }
  1672. } else {
  1673. allowSpaces = options.allowSpaces !== undefined ? options.allowSpaces : allowSpaces;
  1674. includePercentValues = options.includePercentValues !== undefined ? options.includePercentValues : includePercentValues;
  1675. }
  1676. if (allowSpaces) {
  1677. // make sure it starts with continuous rgba? without spaces before stripping
  1678. if (!startsWithRgb.test(str)) {
  1679. return false;
  1680. }
  1681. // strip all whitespace
  1682. str = str.replace(/\s/g, '');
  1683. }
  1684. if (!includePercentValues) {
  1685. return rgbColor.test(str) || rgbaColor.test(str);
  1686. }
  1687. return rgbColor.test(str) || rgbaColor.test(str) || rgbColorPercent.test(str) || rgbaColorPercent.test(str);
  1688. }
  1689. 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;
  1690. 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;
  1691. function isHSL(str) {
  1692. assertString(str);
  1693. // Strip duplicate spaces before calling the validation regex (See #1598 for more info)
  1694. var strippedStr = str.replace(/\s+/g, ' ').replace(/\s?(hsla?\(|\)|,)\s?/ig, '$1');
  1695. if (strippedStr.indexOf(',') !== -1) {
  1696. return hslComma.test(strippedStr);
  1697. }
  1698. return hslSpace.test(strippedStr);
  1699. }
  1700. // see http://isrc.ifpi.org/en/isrc-standard/code-syntax
  1701. var isrc = /^[A-Z]{2}[0-9A-Z]{3}\d{2}\d{5}$/;
  1702. function isISRC(str) {
  1703. assertString(str);
  1704. return isrc.test(str);
  1705. }
  1706. /**
  1707. * List of country codes with
  1708. * corresponding IBAN regular expression
  1709. * Reference: https://en.wikipedia.org/wiki/International_Bank_Account_Number
  1710. */
  1711. var ibanRegexThroughCountryCode = {
  1712. AD: /^(AD[0-9]{2})\d{8}[A-Z0-9]{12}$/,
  1713. AE: /^(AE[0-9]{2})\d{3}\d{16}$/,
  1714. AL: /^(AL[0-9]{2})\d{8}[A-Z0-9]{16}$/,
  1715. AT: /^(AT[0-9]{2})\d{16}$/,
  1716. AZ: /^(AZ[0-9]{2})[A-Z0-9]{4}\d{20}$/,
  1717. BA: /^(BA[0-9]{2})\d{16}$/,
  1718. BE: /^(BE[0-9]{2})\d{12}$/,
  1719. BG: /^(BG[0-9]{2})[A-Z]{4}\d{6}[A-Z0-9]{8}$/,
  1720. BH: /^(BH[0-9]{2})[A-Z]{4}[A-Z0-9]{14}$/,
  1721. BR: /^(BR[0-9]{2})\d{23}[A-Z]{1}[A-Z0-9]{1}$/,
  1722. BY: /^(BY[0-9]{2})[A-Z0-9]{4}\d{20}$/,
  1723. CH: /^(CH[0-9]{2})\d{5}[A-Z0-9]{12}$/,
  1724. CR: /^(CR[0-9]{2})\d{18}$/,
  1725. CY: /^(CY[0-9]{2})\d{8}[A-Z0-9]{16}$/,
  1726. CZ: /^(CZ[0-9]{2})\d{20}$/,
  1727. DE: /^(DE[0-9]{2})\d{18}$/,
  1728. DK: /^(DK[0-9]{2})\d{14}$/,
  1729. DO: /^(DO[0-9]{2})[A-Z]{4}\d{20}$/,
  1730. DZ: /^(DZ\d{24})$/,
  1731. EE: /^(EE[0-9]{2})\d{16}$/,
  1732. EG: /^(EG[0-9]{2})\d{25}$/,
  1733. ES: /^(ES[0-9]{2})\d{20}$/,
  1734. FI: /^(FI[0-9]{2})\d{14}$/,
  1735. FO: /^(FO[0-9]{2})\d{14}$/,
  1736. FR: /^(FR[0-9]{2})\d{10}[A-Z0-9]{11}\d{2}$/,
  1737. GB: /^(GB[0-9]{2})[A-Z]{4}\d{14}$/,
  1738. GE: /^(GE[0-9]{2})[A-Z0-9]{2}\d{16}$/,
  1739. GI: /^(GI[0-9]{2})[A-Z]{4}[A-Z0-9]{15}$/,
  1740. GL: /^(GL[0-9]{2})\d{14}$/,
  1741. GR: /^(GR[0-9]{2})\d{7}[A-Z0-9]{16}$/,
  1742. GT: /^(GT[0-9]{2})[A-Z0-9]{4}[A-Z0-9]{20}$/,
  1743. HR: /^(HR[0-9]{2})\d{17}$/,
  1744. HU: /^(HU[0-9]{2})\d{24}$/,
  1745. IE: /^(IE[0-9]{2})[A-Z]{4}\d{14}$/,
  1746. IL: /^(IL[0-9]{2})\d{19}$/,
  1747. IQ: /^(IQ[0-9]{2})[A-Z]{4}\d{15}$/,
  1748. IR: /^(IR[0-9]{2})\d{22}$/,
  1749. IS: /^(IS[0-9]{2})\d{22}$/,
  1750. IT: /^(IT[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/,
  1751. JO: /^(JO[0-9]{2})[A-Z]{4}\d{22}$/,
  1752. KW: /^(KW[0-9]{2})[A-Z]{4}[A-Z0-9]{22}$/,
  1753. KZ: /^(KZ[0-9]{2})\d{3}[A-Z0-9]{13}$/,
  1754. LB: /^(LB[0-9]{2})\d{4}[A-Z0-9]{20}$/,
  1755. LC: /^(LC[0-9]{2})[A-Z]{4}[A-Z0-9]{24}$/,
  1756. LI: /^(LI[0-9]{2})\d{5}[A-Z0-9]{12}$/,
  1757. LT: /^(LT[0-9]{2})\d{16}$/,
  1758. LU: /^(LU[0-9]{2})\d{3}[A-Z0-9]{13}$/,
  1759. LV: /^(LV[0-9]{2})[A-Z]{4}[A-Z0-9]{13}$/,
  1760. MA: /^(MA[0-9]{26})$/,
  1761. MC: /^(MC[0-9]{2})\d{10}[A-Z0-9]{11}\d{2}$/,
  1762. MD: /^(MD[0-9]{2})[A-Z0-9]{20}$/,
  1763. ME: /^(ME[0-9]{2})\d{18}$/,
  1764. MK: /^(MK[0-9]{2})\d{3}[A-Z0-9]{10}\d{2}$/,
  1765. MR: /^(MR[0-9]{2})\d{23}$/,
  1766. MT: /^(MT[0-9]{2})[A-Z]{4}\d{5}[A-Z0-9]{18}$/,
  1767. MU: /^(MU[0-9]{2})[A-Z]{4}\d{19}[A-Z]{3}$/,
  1768. MZ: /^(MZ[0-9]{2})\d{21}$/,
  1769. NL: /^(NL[0-9]{2})[A-Z]{4}\d{10}$/,
  1770. NO: /^(NO[0-9]{2})\d{11}$/,
  1771. PK: /^(PK[0-9]{2})[A-Z0-9]{4}\d{16}$/,
  1772. PL: /^(PL[0-9]{2})\d{24}$/,
  1773. PS: /^(PS[0-9]{2})[A-Z]{4}[A-Z0-9]{21}$/,
  1774. PT: /^(PT[0-9]{2})\d{21}$/,
  1775. QA: /^(QA[0-9]{2})[A-Z]{4}[A-Z0-9]{21}$/,
  1776. RO: /^(RO[0-9]{2})[A-Z]{4}[A-Z0-9]{16}$/,
  1777. RS: /^(RS[0-9]{2})\d{18}$/,
  1778. SA: /^(SA[0-9]{2})\d{2}[A-Z0-9]{18}$/,
  1779. SC: /^(SC[0-9]{2})[A-Z]{4}\d{20}[A-Z]{3}$/,
  1780. SE: /^(SE[0-9]{2})\d{20}$/,
  1781. SI: /^(SI[0-9]{2})\d{15}$/,
  1782. SK: /^(SK[0-9]{2})\d{20}$/,
  1783. SM: /^(SM[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/,
  1784. SV: /^(SV[0-9]{2})[A-Z0-9]{4}\d{20}$/,
  1785. TL: /^(TL[0-9]{2})\d{19}$/,
  1786. TN: /^(TN[0-9]{2})\d{20}$/,
  1787. TR: /^(TR[0-9]{2})\d{5}[A-Z0-9]{17}$/,
  1788. UA: /^(UA[0-9]{2})\d{6}[A-Z0-9]{19}$/,
  1789. VA: /^(VA[0-9]{2})\d{18}$/,
  1790. VG: /^(VG[0-9]{2})[A-Z]{4}\d{16}$/,
  1791. XK: /^(XK[0-9]{2})\d{16}$/
  1792. };
  1793. /**
  1794. * Check if the country codes passed are valid using the
  1795. * ibanRegexThroughCountryCode as a reference
  1796. *
  1797. * @param {array} countryCodeArray
  1798. * @return {boolean}
  1799. */
  1800. function hasOnlyValidCountryCodes(countryCodeArray) {
  1801. var countryCodeArrayFilteredWithObjectIbanCode = countryCodeArray.filter(function (countryCode) {
  1802. return !(countryCode in ibanRegexThroughCountryCode);
  1803. });
  1804. return countryCodeArrayFilteredWithObjectIbanCode.length === 0;
  1805. }
  1806. /**
  1807. * Check whether string has correct universal IBAN format
  1808. * The IBAN consists of up to 34 alphanumeric characters, as follows:
  1809. * Country Code using ISO 3166-1 alpha-2, two letters
  1810. * check digits, two digits and
  1811. * Basic Bank Account Number (BBAN), up to 30 alphanumeric characters.
  1812. * NOTE: Permitted IBAN characters are: digits [0-9] and the 26 latin alphabetic [A-Z]
  1813. *
  1814. * @param {string} str - string under validation
  1815. * @param {object} options - object to pass the countries to be either whitelisted or blacklisted
  1816. * @return {boolean}
  1817. */
  1818. function hasValidIbanFormat(str, options) {
  1819. // Strip white spaces and hyphens
  1820. var strippedStr = str.replace(/[\s\-]+/gi, '').toUpperCase();
  1821. var isoCountryCode = strippedStr.slice(0, 2).toUpperCase();
  1822. var isoCountryCodeInIbanRegexCodeObject = isoCountryCode in ibanRegexThroughCountryCode;
  1823. if (options.whitelist) {
  1824. if (!hasOnlyValidCountryCodes(options.whitelist)) {
  1825. return false;
  1826. }
  1827. var isoCountryCodeInWhiteList = includes$2(options.whitelist, isoCountryCode);
  1828. if (!isoCountryCodeInWhiteList) {
  1829. return false;
  1830. }
  1831. }
  1832. if (options.blacklist) {
  1833. var isoCountryCodeInBlackList = includes$2(options.blacklist, isoCountryCode);
  1834. if (isoCountryCodeInBlackList) {
  1835. return false;
  1836. }
  1837. }
  1838. return isoCountryCodeInIbanRegexCodeObject && ibanRegexThroughCountryCode[isoCountryCode].test(strippedStr);
  1839. }
  1840. /**
  1841. * Check whether string has valid IBAN Checksum
  1842. * by performing basic mod-97 operation and
  1843. * the remainder should equal 1
  1844. * -- Start by rearranging the IBAN by moving the four initial characters to the end of the string
  1845. * -- Replace each letter in the string with two digits, A -> 10, B = 11, Z = 35
  1846. * -- Interpret the string as a decimal integer and
  1847. * -- compute the remainder on division by 97 (mod 97)
  1848. * Reference: https://en.wikipedia.org/wiki/International_Bank_Account_Number
  1849. *
  1850. * @param {string} str
  1851. * @return {boolean}
  1852. */
  1853. function hasValidIbanChecksum(str) {
  1854. var strippedStr = str.replace(/[^A-Z0-9]+/gi, '').toUpperCase(); // Keep only digits and A-Z latin alphabetic
  1855. var rearranged = strippedStr.slice(4) + strippedStr.slice(0, 4);
  1856. var alphaCapsReplacedWithDigits = rearranged.replace(/[A-Z]/g, function (_char) {
  1857. return _char.charCodeAt(0) - 55;
  1858. });
  1859. var remainder = alphaCapsReplacedWithDigits.match(/\d{1,7}/g).reduce(function (acc, value) {
  1860. return Number(acc + value) % 97;
  1861. }, '');
  1862. return remainder === 1;
  1863. }
  1864. function isIBAN(str) {
  1865. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1866. assertString(str);
  1867. return hasValidIbanFormat(str, options) && hasValidIbanChecksum(str);
  1868. }
  1869. var locales$4 = Object.keys(ibanRegexThroughCountryCode);
  1870. // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
  1871. 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']);
  1872. var alpha2CountryCode = /^[a-zA-Z]{2}$/;
  1873. function isISO31661Alpha2(str) {
  1874. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1875. assertString(str);
  1876. var userAssignedCodes = options.userAssignedCodes;
  1877. var validUserAssignedCodes = (userAssignedCodes || []).reduce(function (accumulator, userAssignedCode) {
  1878. if (alpha2CountryCode.test(userAssignedCode)) {
  1879. accumulator.push(userAssignedCode.toUpperCase());
  1880. }
  1881. return accumulator;
  1882. }, []);
  1883. if (validUserAssignedCodes.includes(str.toUpperCase())) {
  1884. return true;
  1885. }
  1886. return validISO31661Alpha2CountriesCodes.has(str.toUpperCase());
  1887. }
  1888. var CountryCodes = validISO31661Alpha2CountriesCodes;
  1889. // https://en.wikipedia.org/wiki/ISO_9362
  1890. var isBICReg = /^[A-Za-z]{6}[A-Za-z0-9]{2}([A-Za-z0-9]{3})?$/;
  1891. function isBIC(str) {
  1892. assertString(str);
  1893. // toUpperCase() should be removed when a new major version goes out that changes
  1894. // the regex to [A-Z] (per the spec).
  1895. var countryCode = str.slice(4, 6).toUpperCase();
  1896. if (!CountryCodes.has(countryCode) && countryCode !== 'XK') {
  1897. return false;
  1898. }
  1899. return isBICReg.test(str);
  1900. }
  1901. var md5 = /^[a-f0-9]{32}$/;
  1902. function isMD5(str) {
  1903. assertString(str);
  1904. return md5.test(str);
  1905. }
  1906. var lengths = {
  1907. md5: 32,
  1908. md4: 32,
  1909. sha1: 40,
  1910. sha256: 64,
  1911. sha384: 96,
  1912. sha512: 128,
  1913. ripemd128: 32,
  1914. ripemd160: 40,
  1915. tiger128: 32,
  1916. tiger160: 40,
  1917. tiger192: 48,
  1918. crc32: 8,
  1919. crc32b: 8
  1920. };
  1921. function isHash(str, algorithm) {
  1922. assertString(str);
  1923. var hash = new RegExp("^[a-fA-F0-9]{".concat(lengths[algorithm], "}$"));
  1924. return hash.test(str);
  1925. }
  1926. var base64WithPadding = /^[A-Za-z0-9+/]+={0,2}$/;
  1927. var base64WithoutPadding = /^[A-Za-z0-9+/]+$/;
  1928. var base64UrlWithPadding = /^[A-Za-z0-9_-]+={0,2}$/;
  1929. var base64UrlWithoutPadding = /^[A-Za-z0-9_-]+$/;
  1930. function isBase64(str, options) {
  1931. var _options;
  1932. assertString(str);
  1933. options = merge(options, {
  1934. urlSafe: false,
  1935. padding: !((_options = options) !== null && _options !== void 0 && _options.urlSafe)
  1936. });
  1937. if (str === '') return true;
  1938. if (options.padding && str.length % 4 !== 0) return false;
  1939. var regex;
  1940. if (options.urlSafe) {
  1941. regex = options.padding ? base64UrlWithPadding : base64UrlWithoutPadding;
  1942. } else {
  1943. regex = options.padding ? base64WithPadding : base64WithoutPadding;
  1944. }
  1945. return (!options.padding || str.length % 4 === 0) && regex.test(str);
  1946. }
  1947. function isJWT(str) {
  1948. assertString(str);
  1949. var dotSplit = str.split('.');
  1950. var len = dotSplit.length;
  1951. if (len !== 3) {
  1952. return false;
  1953. }
  1954. return dotSplit.reduce(function (acc, currElem) {
  1955. return acc && isBase64(currElem, {
  1956. urlSafe: true
  1957. });
  1958. }, true);
  1959. }
  1960. var default_json_options = {
  1961. allow_primitives: false,
  1962. allow_any_value: false
  1963. };
  1964. function isJSON(str, options) {
  1965. assertString(str);
  1966. try {
  1967. options = merge(options, default_json_options);
  1968. var obj = JSON.parse(str);
  1969. // When allow_any_value is true, accept anything that JSON.parse successfully parses
  1970. if (options.allow_any_value) {
  1971. return true;
  1972. }
  1973. var primitives = [];
  1974. if (options.allow_primitives) {
  1975. primitives = [null, false, true];
  1976. }
  1977. return includes$2(primitives, obj) || !!obj && _typeof(obj) === 'object';
  1978. } catch (e) {/* ignore */}
  1979. return false;
  1980. }
  1981. var default_is_empty_options = {
  1982. ignore_whitespace: false
  1983. };
  1984. function isEmpty(str, options) {
  1985. assertString(str);
  1986. options = merge(options, default_is_empty_options);
  1987. return (options.ignore_whitespace ? str.trim().length : str.length) === 0;
  1988. }
  1989. /* eslint-disable prefer-rest-params */
  1990. function isLength(str, options) {
  1991. assertString(str);
  1992. var min;
  1993. var max;
  1994. if (_typeof(options) === 'object') {
  1995. min = options.min || 0;
  1996. max = options.max;
  1997. } else {
  1998. // backwards compatibility: isLength(str, min [, max])
  1999. min = arguments[1] || 0;
  2000. max = arguments[2];
  2001. }
  2002. var presentationSequences = str.match(/[^\uFE0F\uFE0E][\uFE0F\uFE0E]/g) || [];
  2003. var surrogatePairs = str.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g) || [];
  2004. var len = str.length - presentationSequences.length - surrogatePairs.length;
  2005. var isInsideRange = len >= min && (typeof max === 'undefined' || len <= max);
  2006. if (isInsideRange && Array.isArray(options === null || options === void 0 ? void 0 : options.discreteLengths)) {
  2007. return options.discreteLengths.some(function (discreteLen) {
  2008. return discreteLen === len;
  2009. });
  2010. }
  2011. return isInsideRange;
  2012. }
  2013. function isULID(str) {
  2014. assertString(str);
  2015. return /^[0-7][0-9A-HJKMNP-TV-Z]{25}$/i.test(str);
  2016. }
  2017. var uuid = {
  2018. 1: /^[0-9A-F]{8}-[0-9A-F]{4}-1[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
  2019. 2: /^[0-9A-F]{8}-[0-9A-F]{4}-2[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
  2020. 3: /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
  2021. 4: /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
  2022. 5: /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
  2023. 6: /^[0-9A-F]{8}-[0-9A-F]{4}-6[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
  2024. 7: /^[0-9A-F]{8}-[0-9A-F]{4}-7[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
  2025. 8: /^[0-9A-F]{8}-[0-9A-F]{4}-8[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
  2026. nil: /^00000000-0000-0000-0000-000000000000$/i,
  2027. max: /^ffffffff-ffff-ffff-ffff-ffffffffffff$/i,
  2028. loose: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
  2029. // From https://github.com/uuidjs/uuid/blob/main/src/regex.js
  2030. all: /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i
  2031. };
  2032. function isUUID(str, version) {
  2033. assertString(str);
  2034. if (version === undefined || version === null) {
  2035. version = 'all';
  2036. }
  2037. return version in uuid ? uuid[version].test(str) : false;
  2038. }
  2039. function isMongoId(str) {
  2040. assertString(str);
  2041. return isHexadecimal(str) && str.length === 24;
  2042. }
  2043. function isAfter(date, options) {
  2044. // For backwards compatibility:
  2045. // isAfter(str [, date]), i.e. `options` could be used as argument for the legacy `date`
  2046. var comparisonDate = (_typeof(options) === 'object' ? options.comparisonDate : options) || Date().toString();
  2047. var comparison = toDate(comparisonDate);
  2048. var original = toDate(date);
  2049. return !!(original && comparison && original > comparison);
  2050. }
  2051. function isBefore(date, options) {
  2052. // For backwards compatibility:
  2053. // isBefore(str [, date]), i.e. `options` could be used as argument for the legacy `date`
  2054. var comparisonDate = (_typeof(options) === 'object' ? options.comparisonDate : options) || Date().toString();
  2055. var comparison = toDate(comparisonDate);
  2056. var original = toDate(date);
  2057. return !!(original && comparison && original < comparison);
  2058. }
  2059. function isIn(str, options) {
  2060. assertString(str);
  2061. var i;
  2062. if (Object.prototype.toString.call(options) === '[object Array]') {
  2063. var array = [];
  2064. for (i in options) {
  2065. // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
  2066. // istanbul ignore else
  2067. if ({}.hasOwnProperty.call(options, i)) {
  2068. array[i] = toString$1(options[i]);
  2069. }
  2070. }
  2071. return array.indexOf(str) >= 0;
  2072. } else if (_typeof(options) === 'object') {
  2073. return options.hasOwnProperty(str);
  2074. } else if (options && typeof options.indexOf === 'function') {
  2075. return options.indexOf(str) >= 0;
  2076. }
  2077. return false;
  2078. }
  2079. function isLuhnNumber(str) {
  2080. assertString(str);
  2081. var sanitized = str.replace(/[- ]+/g, '');
  2082. var sum = 0;
  2083. var digit;
  2084. var tmpNum;
  2085. var shouldDouble;
  2086. for (var i = sanitized.length - 1; i >= 0; i--) {
  2087. digit = sanitized.substring(i, i + 1);
  2088. tmpNum = parseInt(digit, 10);
  2089. if (shouldDouble) {
  2090. tmpNum *= 2;
  2091. if (tmpNum >= 10) {
  2092. sum += tmpNum % 10 + 1;
  2093. } else {
  2094. sum += tmpNum;
  2095. }
  2096. } else {
  2097. sum += tmpNum;
  2098. }
  2099. shouldDouble = !shouldDouble;
  2100. }
  2101. return !!(sum % 10 === 0 ? sanitized : false);
  2102. }
  2103. var cards = {
  2104. amex: /^3[47][0-9]{13}$/,
  2105. dinersclub: /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
  2106. discover: /^6(?:011|5[0-9][0-9])[0-9]{12,15}$/,
  2107. jcb: /^(?:2131|1800|35\d{3})\d{11}$/,
  2108. mastercard: /^5[1-5][0-9]{2}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$/,
  2109. // /^[25][1-7][0-9]{14}$/;
  2110. unionpay: /^(6[27][0-9]{14}|^(81[0-9]{14,17}))$/,
  2111. visa: /^(?:4[0-9]{12})(?:[0-9]{3,6})?$/
  2112. };
  2113. var allCards = function () {
  2114. var tmpCardsArray = [];
  2115. for (var cardProvider in cards) {
  2116. // istanbul ignore else
  2117. if (cards.hasOwnProperty(cardProvider)) {
  2118. tmpCardsArray.push(cards[cardProvider]);
  2119. }
  2120. }
  2121. return tmpCardsArray;
  2122. }();
  2123. function isCreditCard(card) {
  2124. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2125. assertString(card);
  2126. var provider = options.provider;
  2127. var sanitized = card.replace(/[- ]+/g, '');
  2128. if (provider && provider.toLowerCase() in cards) {
  2129. // specific provider in the list
  2130. if (!cards[provider.toLowerCase()].test(sanitized)) {
  2131. return false;
  2132. }
  2133. } else if (provider && !(provider.toLowerCase() in cards)) {
  2134. /* specific provider not in the list */
  2135. throw new Error("".concat(provider, " is not a valid credit card provider."));
  2136. } else if (!allCards.some(function (cardProvider) {
  2137. return cardProvider.test(sanitized);
  2138. })) {
  2139. // no specific provider
  2140. return false;
  2141. }
  2142. return isLuhnNumber(card);
  2143. }
  2144. var validators = {
  2145. PL: function PL(str) {
  2146. assertString(str);
  2147. var weightOfDigits = {
  2148. 1: 1,
  2149. 2: 3,
  2150. 3: 7,
  2151. 4: 9,
  2152. 5: 1,
  2153. 6: 3,
  2154. 7: 7,
  2155. 8: 9,
  2156. 9: 1,
  2157. 10: 3,
  2158. 11: 0
  2159. };
  2160. if (str != null && str.length === 11 && isInt(str, {
  2161. allow_leading_zeroes: true
  2162. })) {
  2163. var digits = str.split('').slice(0, -1);
  2164. var sum = digits.reduce(function (acc, digit, index) {
  2165. return acc + Number(digit) * weightOfDigits[index + 1];
  2166. }, 0);
  2167. var modulo = sum % 10;
  2168. var lastDigit = Number(str.charAt(str.length - 1));
  2169. if (modulo === 0 && lastDigit === 0 || lastDigit === 10 - modulo) {
  2170. return true;
  2171. }
  2172. }
  2173. return false;
  2174. },
  2175. ES: function ES(str) {
  2176. assertString(str);
  2177. var DNI = /^[0-9X-Z][0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKE]$/;
  2178. var charsValue = {
  2179. X: 0,
  2180. Y: 1,
  2181. Z: 2
  2182. };
  2183. 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'];
  2184. // sanitize user input
  2185. var sanitized = str.trim().toUpperCase();
  2186. // validate the data structure
  2187. if (!DNI.test(sanitized)) {
  2188. return false;
  2189. }
  2190. // validate the control digit
  2191. var number = sanitized.slice(0, -1).replace(/[X,Y,Z]/g, function (_char) {
  2192. return charsValue[_char];
  2193. });
  2194. return sanitized.endsWith(controlDigits[number % 23]);
  2195. },
  2196. FI: function FI(str) {
  2197. // https://dvv.fi/en/personal-identity-code#:~:text=control%20character%20for%20a-,personal,-identity%20code%20calculated
  2198. assertString(str);
  2199. if (str.length !== 11) {
  2200. return false;
  2201. }
  2202. if (!str.match(/^\d{6}[\-A\+]\d{3}[0-9ABCDEFHJKLMNPRSTUVWXY]{1}$/)) {
  2203. return false;
  2204. }
  2205. var checkDigits = '0123456789ABCDEFHJKLMNPRSTUVWXY';
  2206. var idAsNumber = parseInt(str.slice(0, 6), 10) * 1000 + parseInt(str.slice(7, 10), 10);
  2207. var remainder = idAsNumber % 31;
  2208. var checkDigit = checkDigits[remainder];
  2209. return checkDigit === str.slice(10, 11);
  2210. },
  2211. IN: function IN(str) {
  2212. var DNI = /^[1-9]\d{3}\s?\d{4}\s?\d{4}$/;
  2213. // multiplication table
  2214. 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]];
  2215. // permutation table
  2216. 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]];
  2217. // sanitize user input
  2218. var sanitized = str.trim();
  2219. // validate the data structure
  2220. if (!DNI.test(sanitized)) {
  2221. return false;
  2222. }
  2223. var c = 0;
  2224. var invertedArray = sanitized.replace(/\s/g, '').split('').map(Number).reverse();
  2225. invertedArray.forEach(function (val, i) {
  2226. c = d[c][p[i % 8][val]];
  2227. });
  2228. return c === 0;
  2229. },
  2230. IR: function IR(str) {
  2231. if (!str.match(/^\d{10}$/)) return false;
  2232. str = "0000".concat(str).slice(str.length - 6);
  2233. if (parseInt(str.slice(3, 9), 10) === 0) return false;
  2234. var lastNumber = parseInt(str.slice(9, 10), 10);
  2235. var sum = 0;
  2236. for (var i = 0; i < 9; i++) {
  2237. sum += parseInt(str.slice(i, i + 1), 10) * (10 - i);
  2238. }
  2239. sum %= 11;
  2240. return sum < 2 && lastNumber === sum || sum >= 2 && lastNumber === 11 - sum;
  2241. },
  2242. IT: function IT(str) {
  2243. if (str.length !== 9) return false;
  2244. if (str === 'CA00000AA') return false; // https://it.wikipedia.org/wiki/Carta_d%27identit%C3%A0_elettronica_italiana
  2245. return str.search(/C[A-Z]\d{5}[A-Z]{2}/i) > -1;
  2246. },
  2247. NO: function NO(str) {
  2248. var sanitized = str.trim();
  2249. if (isNaN(Number(sanitized))) return false;
  2250. if (sanitized.length !== 11) return false;
  2251. if (sanitized === '00000000000') return false;
  2252. // https://no.wikipedia.org/wiki/F%C3%B8dselsnummer
  2253. var f = sanitized.split('').map(Number);
  2254. 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;
  2255. 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;
  2256. if (k1 !== f[9] || k2 !== f[10]) return false;
  2257. return true;
  2258. },
  2259. TH: function TH(str) {
  2260. if (!str.match(/^[1-8]\d{12}$/)) return false;
  2261. // validate check digit
  2262. var sum = 0;
  2263. for (var i = 0; i < 12; i++) {
  2264. sum += parseInt(str[i], 10) * (13 - i);
  2265. }
  2266. return str[12] === ((11 - sum % 11) % 10).toString();
  2267. },
  2268. LK: function LK(str) {
  2269. var old_nic = /^[1-9]\d{8}[vx]$/i;
  2270. var new_nic = /^[1-9]\d{11}$/i;
  2271. if (str.length === 10 && old_nic.test(str)) return true;else if (str.length === 12 && new_nic.test(str)) return true;
  2272. return false;
  2273. },
  2274. 'he-IL': function heIL(str) {
  2275. var DNI = /^\d{9}$/;
  2276. // sanitize user input
  2277. var sanitized = str.trim();
  2278. // validate the data structure
  2279. if (!DNI.test(sanitized)) {
  2280. return false;
  2281. }
  2282. var id = sanitized;
  2283. var sum = 0,
  2284. incNum;
  2285. for (var i = 0; i < id.length; i++) {
  2286. incNum = Number(id[i]) * (i % 2 + 1); // Multiply number by 1 or 2
  2287. sum += incNum > 9 ? incNum - 9 : incNum; // Sum the digits up and add to total
  2288. }
  2289. return sum % 10 === 0;
  2290. },
  2291. 'ar-LY': function arLY(str) {
  2292. // Libya National Identity Number NIN is 12 digits, the first digit is either 1 or 2
  2293. var NIN = /^(1|2)\d{11}$/;
  2294. // sanitize user input
  2295. var sanitized = str.trim();
  2296. return NIN.test(sanitized);
  2297. },
  2298. 'ar-TN': function arTN(str) {
  2299. var DNI = /^\d{8}$/;
  2300. // sanitize user input
  2301. var sanitized = str.trim();
  2302. return DNI.test(sanitized);
  2303. },
  2304. 'zh-CN': function zhCN(str) {
  2305. var provincesAndCities = ['11',
  2306. // 北京
  2307. '12',
  2308. // 天津
  2309. '13',
  2310. // 河北
  2311. '14',
  2312. // 山西
  2313. '15',
  2314. // 内蒙古
  2315. '21',
  2316. // 辽宁
  2317. '22',
  2318. // 吉林
  2319. '23',
  2320. // 黑龙江
  2321. '31',
  2322. // 上海
  2323. '32',
  2324. // 江苏
  2325. '33',
  2326. // 浙江
  2327. '34',
  2328. // 安徽
  2329. '35',
  2330. // 福建
  2331. '36',
  2332. // 江西
  2333. '37',
  2334. // 山东
  2335. '41',
  2336. // 河南
  2337. '42',
  2338. // 湖北
  2339. '43',
  2340. // 湖南
  2341. '44',
  2342. // 广东
  2343. '45',
  2344. // 广西
  2345. '46',
  2346. // 海南
  2347. '50',
  2348. // 重庆
  2349. '51',
  2350. // 四川
  2351. '52',
  2352. // 贵州
  2353. '53',
  2354. // 云南
  2355. '54',
  2356. // 西藏
  2357. '61',
  2358. // 陕西
  2359. '62',
  2360. // 甘肃
  2361. '63',
  2362. // 青海
  2363. '64',
  2364. // 宁夏
  2365. '65',
  2366. // 新疆
  2367. '71',
  2368. // 台湾
  2369. '81',
  2370. // 香港
  2371. '82',
  2372. // 澳门
  2373. '91' // 国外
  2374. ];
  2375. var powers = ['7', '9', '10', '5', '8', '4', '2', '1', '6', '3', '7', '9', '10', '5', '8', '4', '2'];
  2376. var parityBit = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
  2377. var checkAddressCode = function checkAddressCode(addressCode) {
  2378. return includes$2(provincesAndCities, addressCode);
  2379. };
  2380. var checkBirthDayCode = function checkBirthDayCode(birDayCode) {
  2381. var yyyy = parseInt(birDayCode.substring(0, 4), 10);
  2382. var mm = parseInt(birDayCode.substring(4, 6), 10);
  2383. var dd = parseInt(birDayCode.substring(6), 10);
  2384. var xdata = new Date(yyyy, mm - 1, dd);
  2385. if (xdata > new Date()) {
  2386. return false;
  2387. // eslint-disable-next-line max-len
  2388. } else if (xdata.getFullYear() === yyyy && xdata.getMonth() === mm - 1 && xdata.getDate() === dd) {
  2389. return true;
  2390. }
  2391. return false;
  2392. };
  2393. var getParityBit = function getParityBit(idCardNo) {
  2394. var id17 = idCardNo.substring(0, 17);
  2395. var power = 0;
  2396. for (var i = 0; i < 17; i++) {
  2397. power += parseInt(id17.charAt(i), 10) * parseInt(powers[i], 10);
  2398. }
  2399. var mod = power % 11;
  2400. return parityBit[mod];
  2401. };
  2402. var checkParityBit = function checkParityBit(idCardNo) {
  2403. return getParityBit(idCardNo) === idCardNo.charAt(17).toUpperCase();
  2404. };
  2405. var check15IdCardNo = function check15IdCardNo(idCardNo) {
  2406. 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);
  2407. if (!check) return false;
  2408. var addressCode = idCardNo.substring(0, 2);
  2409. check = checkAddressCode(addressCode);
  2410. if (!check) return false;
  2411. var birDayCode = "19".concat(idCardNo.substring(6, 12));
  2412. check = checkBirthDayCode(birDayCode);
  2413. if (!check) return false;
  2414. return true;
  2415. };
  2416. var check18IdCardNo = function check18IdCardNo(idCardNo) {
  2417. 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);
  2418. if (!check) return false;
  2419. var addressCode = idCardNo.substring(0, 2);
  2420. check = checkAddressCode(addressCode);
  2421. if (!check) return false;
  2422. var birDayCode = idCardNo.substring(6, 14);
  2423. check = checkBirthDayCode(birDayCode);
  2424. if (!check) return false;
  2425. return checkParityBit(idCardNo);
  2426. };
  2427. var checkIdCardNo = function checkIdCardNo(idCardNo) {
  2428. var check = /^\d{15}|(\d{17}(\d|x|X))$/.test(idCardNo);
  2429. if (!check) return false;
  2430. if (idCardNo.length === 15) {
  2431. return check15IdCardNo(idCardNo);
  2432. }
  2433. return check18IdCardNo(idCardNo);
  2434. };
  2435. return checkIdCardNo(str);
  2436. },
  2437. 'zh-HK': function zhHK(str) {
  2438. // sanitize user input
  2439. str = str.trim();
  2440. // HKID number starts with 1 or 2 letters, followed by 6 digits,
  2441. // then a checksum contained in square / round brackets or nothing
  2442. var regexHKID = /^[A-Z]{1,2}[0-9]{6}((\([0-9A]\))|(\[[0-9A]\])|([0-9A]))$/;
  2443. var regexIsDigit = /^[0-9]$/;
  2444. // convert the user input to all uppercase and apply regex
  2445. str = str.toUpperCase();
  2446. if (!regexHKID.test(str)) return false;
  2447. str = str.replace(/\[|\]|\(|\)/g, '');
  2448. if (str.length === 8) str = "3".concat(str);
  2449. var checkSumVal = 0;
  2450. for (var i = 0; i <= 7; i++) {
  2451. var convertedChar = void 0;
  2452. if (!regexIsDigit.test(str[i])) convertedChar = (str[i].charCodeAt(0) - 55) % 11;else convertedChar = str[i];
  2453. checkSumVal += convertedChar * (9 - i);
  2454. }
  2455. checkSumVal %= 11;
  2456. var checkSumConverted;
  2457. if (checkSumVal === 0) checkSumConverted = '0';else if (checkSumVal === 1) checkSumConverted = 'A';else checkSumConverted = String(11 - checkSumVal);
  2458. if (checkSumConverted === str[str.length - 1]) return true;
  2459. return false;
  2460. },
  2461. 'zh-TW': function zhTW(str) {
  2462. var ALPHABET_CODES = {
  2463. A: 10,
  2464. B: 11,
  2465. C: 12,
  2466. D: 13,
  2467. E: 14,
  2468. F: 15,
  2469. G: 16,
  2470. H: 17,
  2471. I: 34,
  2472. J: 18,
  2473. K: 19,
  2474. L: 20,
  2475. M: 21,
  2476. N: 22,
  2477. O: 35,
  2478. P: 23,
  2479. Q: 24,
  2480. R: 25,
  2481. S: 26,
  2482. T: 27,
  2483. U: 28,
  2484. V: 29,
  2485. W: 32,
  2486. X: 30,
  2487. Y: 31,
  2488. Z: 33
  2489. };
  2490. var sanitized = str.trim().toUpperCase();
  2491. if (!/^[A-Z][0-9]{9}$/.test(sanitized)) return false;
  2492. return Array.from(sanitized).reduce(function (sum, number, index) {
  2493. if (index === 0) {
  2494. var code = ALPHABET_CODES[number];
  2495. return code % 10 * 9 + Math.floor(code / 10);
  2496. }
  2497. if (index === 9) {
  2498. return (10 - sum % 10 - Number(number)) % 10 === 0;
  2499. }
  2500. return sum + Number(number) * (9 - index);
  2501. }, 0);
  2502. },
  2503. PK: function PK(str) {
  2504. // Pakistani National Identity Number CNIC is 13 digits
  2505. var CNIC = /^[1-7][0-9]{4}-[0-9]{7}-[1-9]$/;
  2506. // sanitize user input
  2507. var sanitized = str.trim();
  2508. // validate the data structure
  2509. return CNIC.test(sanitized);
  2510. }
  2511. };
  2512. function isIdentityCard(str, locale) {
  2513. assertString(str);
  2514. if (locale in validators) {
  2515. return validators[locale](str);
  2516. } else if (locale === 'any') {
  2517. for (var key in validators) {
  2518. // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
  2519. // istanbul ignore else
  2520. if (validators.hasOwnProperty(key)) {
  2521. var validator = validators[key];
  2522. if (validator(str)) {
  2523. return true;
  2524. }
  2525. }
  2526. }
  2527. return false;
  2528. }
  2529. throw new Error("Invalid locale '".concat(locale, "'"));
  2530. }
  2531. /**
  2532. * The most commonly used EAN standard is
  2533. * the thirteen-digit EAN-13, while the
  2534. * less commonly used 8-digit EAN-8 barcode was
  2535. * introduced for use on small packages.
  2536. * Also EAN/UCC-14 is used for Grouping of individual
  2537. * trade items above unit level(Intermediate, Carton or Pallet).
  2538. * For more info about EAN-14 checkout: https://www.gtin.info/itf-14-barcodes/
  2539. * EAN consists of:
  2540. * GS1 prefix, manufacturer code, product code and check digit
  2541. * Reference: https://en.wikipedia.org/wiki/International_Article_Number
  2542. * Reference: https://www.gtin.info/
  2543. */
  2544. /**
  2545. * Define EAN Lengths; 8 for EAN-8; 13 for EAN-13; 14 for EAN-14
  2546. * and Regular Expression for valid EANs (EAN-8, EAN-13, EAN-14),
  2547. * with exact numeric matching of 8 or 13 or 14 digits [0-9]
  2548. */
  2549. var LENGTH_EAN_8 = 8;
  2550. var LENGTH_EAN_14 = 14;
  2551. var validEanRegex = /^(\d{8}|\d{13}|\d{14})$/;
  2552. /**
  2553. * Get position weight given:
  2554. * EAN length and digit index/position
  2555. *
  2556. * @param {number} length
  2557. * @param {number} index
  2558. * @return {number}
  2559. */
  2560. function getPositionWeightThroughLengthAndIndex(length, index) {
  2561. if (length === LENGTH_EAN_8 || length === LENGTH_EAN_14) {
  2562. return index % 2 === 0 ? 3 : 1;
  2563. }
  2564. return index % 2 === 0 ? 1 : 3;
  2565. }
  2566. /**
  2567. * Calculate EAN Check Digit
  2568. * Reference: https://en.wikipedia.org/wiki/International_Article_Number#Calculation_of_checksum_digit
  2569. *
  2570. * @param {string} ean
  2571. * @return {number}
  2572. */
  2573. function calculateCheckDigit(ean) {
  2574. var checksum = ean.slice(0, -1).split('').map(function (_char, index) {
  2575. return Number(_char) * getPositionWeightThroughLengthAndIndex(ean.length, index);
  2576. }).reduce(function (acc, partialSum) {
  2577. return acc + partialSum;
  2578. }, 0);
  2579. var remainder = 10 - checksum % 10;
  2580. return remainder < 10 ? remainder : 0;
  2581. }
  2582. /**
  2583. * Check if string is valid EAN:
  2584. * Matches EAN-8/EAN-13/EAN-14 regex
  2585. * Has valid check digit.
  2586. *
  2587. * @param {string} str
  2588. * @return {boolean}
  2589. */
  2590. function isEAN(str) {
  2591. assertString(str);
  2592. var actualCheckDigit = Number(str.slice(-1));
  2593. return validEanRegex.test(str) && actualCheckDigit === calculateCheckDigit(str);
  2594. }
  2595. var isin = /^[A-Z]{2}[0-9A-Z]{9}[0-9]$/;
  2596. // this link details how the check digit is calculated:
  2597. // https://www.isin.org/isin-format/. it is a little bit
  2598. // odd in that it works with digits, not numbers. in order
  2599. // to make only one pass through the ISIN characters, the
  2600. // each alpha character is handled as 2 characters within
  2601. // the loop.
  2602. function isISIN(str) {
  2603. assertString(str);
  2604. if (!isin.test(str)) {
  2605. return false;
  2606. }
  2607. var _double = true;
  2608. var sum = 0;
  2609. // convert values
  2610. for (var i = str.length - 2; i >= 0; i--) {
  2611. if (str[i] >= 'A' && str[i] <= 'Z') {
  2612. var value = str[i].charCodeAt(0) - 55;
  2613. var lo = value % 10;
  2614. var hi = Math.trunc(value / 10);
  2615. // letters have two digits, so handle the low order
  2616. // and high order digits separately.
  2617. for (var _i = 0, _arr = [lo, hi]; _i < _arr.length; _i++) {
  2618. var digit = _arr[_i];
  2619. if (_double) {
  2620. if (digit >= 5) {
  2621. sum += 1 + (digit - 5) * 2;
  2622. } else {
  2623. sum += digit * 2;
  2624. }
  2625. } else {
  2626. sum += digit;
  2627. }
  2628. _double = !_double;
  2629. }
  2630. } else {
  2631. var _digit = str[i].charCodeAt(0) - '0'.charCodeAt(0);
  2632. if (_double) {
  2633. if (_digit >= 5) {
  2634. sum += 1 + (_digit - 5) * 2;
  2635. } else {
  2636. sum += _digit * 2;
  2637. }
  2638. } else {
  2639. sum += _digit;
  2640. }
  2641. _double = !_double;
  2642. }
  2643. }
  2644. var check = Math.trunc((sum + 9) / 10) * 10 - sum;
  2645. return +str[str.length - 1] === check;
  2646. }
  2647. var possibleIsbn10 = /^(?:[0-9]{9}X|[0-9]{10})$/;
  2648. var possibleIsbn13 = /^(?:[0-9]{13})$/;
  2649. var factor = [1, 3];
  2650. function isISBN(isbn, options) {
  2651. assertString(isbn);
  2652. // For backwards compatibility:
  2653. // isISBN(str [, version]), i.e. `options` could be used as argument for the legacy `version`
  2654. var version = String((options === null || options === void 0 ? void 0 : options.version) || options);
  2655. if (!(options !== null && options !== void 0 && options.version || options)) {
  2656. return isISBN(isbn, {
  2657. version: 10
  2658. }) || isISBN(isbn, {
  2659. version: 13
  2660. });
  2661. }
  2662. var sanitizedIsbn = isbn.replace(/[\s-]+/g, '');
  2663. var checksum = 0;
  2664. if (version === '10') {
  2665. if (!possibleIsbn10.test(sanitizedIsbn)) {
  2666. return false;
  2667. }
  2668. for (var i = 0; i < version - 1; i++) {
  2669. checksum += (i + 1) * sanitizedIsbn.charAt(i);
  2670. }
  2671. if (sanitizedIsbn.charAt(9) === 'X') {
  2672. checksum += 10 * 10;
  2673. } else {
  2674. checksum += 10 * sanitizedIsbn.charAt(9);
  2675. }
  2676. if (checksum % 11 === 0) {
  2677. return true;
  2678. }
  2679. } else if (version === '13') {
  2680. if (!possibleIsbn13.test(sanitizedIsbn)) {
  2681. return false;
  2682. }
  2683. for (var _i = 0; _i < 12; _i++) {
  2684. checksum += factor[_i % 2] * sanitizedIsbn.charAt(_i);
  2685. }
  2686. if (sanitizedIsbn.charAt(12) - (10 - checksum % 10) % 10 === 0) {
  2687. return true;
  2688. }
  2689. }
  2690. return false;
  2691. }
  2692. var issn = '^\\d{4}-?\\d{3}[\\dX]$';
  2693. function isISSN(str) {
  2694. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2695. assertString(str);
  2696. var testIssn = issn;
  2697. testIssn = options.require_hyphen ? testIssn.replace('?', '') : testIssn;
  2698. testIssn = options.case_sensitive ? new RegExp(testIssn) : new RegExp(testIssn, 'i');
  2699. if (!testIssn.test(str)) {
  2700. return false;
  2701. }
  2702. var digits = str.replace('-', '').toUpperCase();
  2703. var checksum = 0;
  2704. for (var i = 0; i < digits.length; i++) {
  2705. var digit = digits[i];
  2706. checksum += (digit === 'X' ? 10 : +digit) * (8 - i);
  2707. }
  2708. return checksum % 11 === 0;
  2709. }
  2710. /**
  2711. * Algorithmic validation functions
  2712. * May be used as is or implemented in the workflow of other validators.
  2713. */
  2714. /*
  2715. * ISO 7064 validation function
  2716. * Called with a string of numbers (incl. check digit)
  2717. * to validate according to ISO 7064 (MOD 11, 10).
  2718. */
  2719. function iso7064Check(str) {
  2720. var checkvalue = 10;
  2721. for (var i = 0; i < str.length - 1; i++) {
  2722. checkvalue = (parseInt(str[i], 10) + checkvalue) % 10 === 0 ? 10 * 2 % 11 : (parseInt(str[i], 10) + checkvalue) % 10 * 2 % 11;
  2723. }
  2724. checkvalue = checkvalue === 1 ? 0 : 11 - checkvalue;
  2725. return checkvalue === parseInt(str[10], 10);
  2726. }
  2727. /*
  2728. * Luhn (mod 10) validation function
  2729. * Called with a string of numbers (incl. check digit)
  2730. * to validate according to the Luhn algorithm.
  2731. */
  2732. function luhnCheck(str) {
  2733. var checksum = 0;
  2734. var second = false;
  2735. for (var i = str.length - 1; i >= 0; i--) {
  2736. if (second) {
  2737. var product = parseInt(str[i], 10) * 2;
  2738. if (product > 9) {
  2739. // sum digits of product and add to checksum
  2740. checksum += product.toString().split('').map(function (a) {
  2741. return parseInt(a, 10);
  2742. }).reduce(function (a, b) {
  2743. return a + b;
  2744. }, 0);
  2745. } else {
  2746. checksum += product;
  2747. }
  2748. } else {
  2749. checksum += parseInt(str[i], 10);
  2750. }
  2751. second = !second;
  2752. }
  2753. return checksum % 10 === 0;
  2754. }
  2755. /*
  2756. * Reverse TIN multiplication and summation helper function
  2757. * Called with an array of single-digit integers and a base multiplier
  2758. * to calculate the sum of the digits multiplied in reverse.
  2759. * Normally used in variations of MOD 11 algorithmic checks.
  2760. */
  2761. function reverseMultiplyAndSum(digits, base) {
  2762. var total = 0;
  2763. for (var i = 0; i < digits.length; i++) {
  2764. total += digits[i] * (base - i);
  2765. }
  2766. return total;
  2767. }
  2768. /*
  2769. * Verhoeff validation helper function
  2770. * Called with a string of numbers
  2771. * to validate according to the Verhoeff algorithm.
  2772. */
  2773. function verhoeffCheck(str) {
  2774. 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]];
  2775. 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]];
  2776. // Copy (to prevent replacement) and reverse
  2777. var str_copy = str.split('').reverse().join('');
  2778. var checksum = 0;
  2779. for (var i = 0; i < str_copy.length; i++) {
  2780. checksum = d_table[checksum][p_table[i % 8][parseInt(str_copy[i], 10)]];
  2781. }
  2782. return checksum === 0;
  2783. }
  2784. /**
  2785. * TIN Validation
  2786. * Validates Tax Identification Numbers (TINs) from the US, EU member states and the United Kingdom.
  2787. *
  2788. * EU-UK:
  2789. * National TIN validity is calculated using public algorithms as made available by DG TAXUD.
  2790. *
  2791. * See `https://ec.europa.eu/taxation_customs/tin/specs/FS-TIN%20Algorithms-Public.docx` for more information.
  2792. *
  2793. * US:
  2794. * An Employer Identification Number (EIN), also known as a Federal Tax Identification Number,
  2795. * is used to identify a business entity.
  2796. *
  2797. * NOTES:
  2798. * - Prefix 47 is being reserved for future use
  2799. * - Prefixes 26, 27, 45, 46 and 47 were previously assigned by the Philadelphia campus.
  2800. *
  2801. * See `http://www.irs.gov/Businesses/Small-Businesses-&-Self-Employed/How-EINs-are-Assigned-and-Valid-EIN-Prefixes`
  2802. * for more information.
  2803. */
  2804. // Locale functions
  2805. /*
  2806. * bg-BG validation function
  2807. * (Edinen graždanski nomer (EGN/ЕГН), persons only)
  2808. * Checks if birth date (first six digits) is valid and calculates check (last) digit
  2809. */
  2810. function bgBgCheck(tin) {
  2811. // Extract full year, normalize month and check birth date validity
  2812. var century_year = tin.slice(0, 2);
  2813. var month = parseInt(tin.slice(2, 4), 10);
  2814. if (month > 40) {
  2815. month -= 40;
  2816. century_year = "20".concat(century_year);
  2817. } else if (month > 20) {
  2818. month -= 20;
  2819. century_year = "18".concat(century_year);
  2820. } else {
  2821. century_year = "19".concat(century_year);
  2822. }
  2823. if (month < 10) {
  2824. month = "0".concat(month);
  2825. }
  2826. var date = "".concat(century_year, "/").concat(month, "/").concat(tin.slice(4, 6));
  2827. if (!isDate(date, 'YYYY/MM/DD')) {
  2828. return false;
  2829. }
  2830. // split digits into an array for further processing
  2831. var digits = tin.split('').map(function (a) {
  2832. return parseInt(a, 10);
  2833. });
  2834. // Calculate checksum by multiplying digits with fixed values
  2835. var multip_lookup = [2, 4, 8, 5, 10, 9, 7, 3, 6];
  2836. var checksum = 0;
  2837. for (var i = 0; i < multip_lookup.length; i++) {
  2838. checksum += digits[i] * multip_lookup[i];
  2839. }
  2840. checksum = checksum % 11 === 10 ? 0 : checksum % 11;
  2841. return checksum === digits[9];
  2842. }
  2843. /**
  2844. * Check if an input is a valid Canadian SIN (Social Insurance Number)
  2845. *
  2846. * The Social Insurance Number (SIN) is a 9 digit number that
  2847. * you need to work in Canada or to have access to government programs and benefits.
  2848. *
  2849. * https://en.wikipedia.org/wiki/Social_Insurance_Number
  2850. * https://www.canada.ca/en/employment-social-development/services/sin.html
  2851. * https://www.codercrunch.com/challenge/819302488/sin-validator
  2852. *
  2853. * @param {string} input
  2854. * @return {boolean}
  2855. */
  2856. function isCanadianSIN(input) {
  2857. var digitsArray = input.split('');
  2858. var even = digitsArray.filter(function (_, idx) {
  2859. return idx % 2;
  2860. }).map(function (i) {
  2861. return Number(i) * 2;
  2862. }).join('').split('');
  2863. var total = digitsArray.filter(function (_, idx) {
  2864. return !(idx % 2);
  2865. }).concat(even).map(function (i) {
  2866. return Number(i);
  2867. }).reduce(function (acc, cur) {
  2868. return acc + cur;
  2869. });
  2870. return total % 10 === 0;
  2871. }
  2872. /*
  2873. * cs-CZ validation function
  2874. * (Rodné číslo (RČ), persons only)
  2875. * Checks if birth date (first six digits) is valid and divisibility by 11
  2876. * Material not in DG TAXUD document sourced from:
  2877. * -`https://lorenc.info/3MA381/overeni-spravnosti-rodneho-cisla.htm`
  2878. * -`https://www.mvcr.cz/clanek/rady-a-sluzby-dokumenty-rodne-cislo.aspx`
  2879. */
  2880. function csCzCheck(tin) {
  2881. tin = tin.replace(/\W/, '');
  2882. // Extract full year from TIN length
  2883. var full_year = parseInt(tin.slice(0, 2), 10);
  2884. if (tin.length === 10) {
  2885. if (full_year < 54) {
  2886. full_year = "20".concat(full_year);
  2887. } else {
  2888. full_year = "19".concat(full_year);
  2889. }
  2890. } else {
  2891. if (tin.slice(6) === '000') {
  2892. return false;
  2893. } // Three-zero serial not assigned before 1954
  2894. if (full_year < 54) {
  2895. full_year = "19".concat(full_year);
  2896. } else {
  2897. return false; // No 18XX years seen in any of the resources
  2898. }
  2899. }
  2900. // Add missing zero if needed
  2901. if (full_year.length === 3) {
  2902. full_year = [full_year.slice(0, 2), '0', full_year.slice(2)].join('');
  2903. }
  2904. // Extract month from TIN and normalize
  2905. var month = parseInt(tin.slice(2, 4), 10);
  2906. if (month > 50) {
  2907. month -= 50;
  2908. }
  2909. if (month > 20) {
  2910. // Month-plus-twenty was only introduced in 2004
  2911. if (parseInt(full_year, 10) < 2004) {
  2912. return false;
  2913. }
  2914. month -= 20;
  2915. }
  2916. if (month < 10) {
  2917. month = "0".concat(month);
  2918. }
  2919. // Check date validity
  2920. var date = "".concat(full_year, "/").concat(month, "/").concat(tin.slice(4, 6));
  2921. if (!isDate(date, 'YYYY/MM/DD')) {
  2922. return false;
  2923. }
  2924. // Verify divisibility by 11
  2925. if (tin.length === 10) {
  2926. if (parseInt(tin, 10) % 11 !== 0) {
  2927. // Some numbers up to and including 1985 are still valid if
  2928. // check (last) digit equals 0 and modulo of first 9 digits equals 10
  2929. var checkdigit = parseInt(tin.slice(0, 9), 10) % 11;
  2930. if (parseInt(full_year, 10) < 1986 && checkdigit === 10) {
  2931. if (parseInt(tin.slice(9), 10) !== 0) {
  2932. return false;
  2933. }
  2934. } else {
  2935. return false;
  2936. }
  2937. }
  2938. }
  2939. return true;
  2940. }
  2941. /*
  2942. * de-AT validation function
  2943. * (Abgabenkontonummer, persons/entities)
  2944. * Verify TIN validity by calling luhnCheck()
  2945. */
  2946. function deAtCheck(tin) {
  2947. return luhnCheck(tin);
  2948. }
  2949. /*
  2950. * de-DE validation function
  2951. * (Steueridentifikationsnummer (Steuer-IdNr.), persons only)
  2952. * Tests for single duplicate/triplicate value, then calculates ISO 7064 check (last) digit
  2953. * Partial implementation of spec (same result with both algorithms always)
  2954. */
  2955. function deDeCheck(tin) {
  2956. // Split digits into an array for further processing
  2957. var digits = tin.split('').map(function (a) {
  2958. return parseInt(a, 10);
  2959. });
  2960. // Fill array with strings of number positions
  2961. var occurrences = [];
  2962. for (var i = 0; i < digits.length - 1; i++) {
  2963. occurrences.push('');
  2964. for (var j = 0; j < digits.length - 1; j++) {
  2965. if (digits[i] === digits[j]) {
  2966. occurrences[i] += j;
  2967. }
  2968. }
  2969. }
  2970. // Remove digits with one occurrence and test for only one duplicate/triplicate
  2971. occurrences = occurrences.filter(function (a) {
  2972. return a.length > 1;
  2973. });
  2974. if (occurrences.length !== 2 && occurrences.length !== 3) {
  2975. return false;
  2976. }
  2977. // In case of triplicate value only two digits are allowed next to each other
  2978. if (occurrences[0].length === 3) {
  2979. var trip_locations = occurrences[0].split('').map(function (a) {
  2980. return parseInt(a, 10);
  2981. });
  2982. var recurrent = 0; // Amount of neighbor occurrences
  2983. for (var _i = 0; _i < trip_locations.length - 1; _i++) {
  2984. if (trip_locations[_i] + 1 === trip_locations[_i + 1]) {
  2985. recurrent += 1;
  2986. }
  2987. }
  2988. if (recurrent === 2) {
  2989. return false;
  2990. }
  2991. }
  2992. return iso7064Check(tin);
  2993. }
  2994. /*
  2995. * dk-DK validation function
  2996. * (CPR-nummer (personnummer), persons only)
  2997. * Checks if birth date (first six digits) is valid and assigned to century (seventh) digit,
  2998. * and calculates check (last) digit
  2999. */
  3000. function dkDkCheck(tin) {
  3001. tin = tin.replace(/\W/, '');
  3002. // Extract year, check if valid for given century digit and add century
  3003. var year = parseInt(tin.slice(4, 6), 10);
  3004. var century_digit = tin.slice(6, 7);
  3005. switch (century_digit) {
  3006. case '0':
  3007. case '1':
  3008. case '2':
  3009. case '3':
  3010. year = "19".concat(year);
  3011. break;
  3012. case '4':
  3013. case '9':
  3014. if (year < 37) {
  3015. year = "20".concat(year);
  3016. } else {
  3017. year = "19".concat(year);
  3018. }
  3019. break;
  3020. default:
  3021. if (year < 37) {
  3022. year = "20".concat(year);
  3023. } else if (year > 58) {
  3024. year = "18".concat(year);
  3025. } else {
  3026. return false;
  3027. }
  3028. break;
  3029. }
  3030. // Add missing zero if needed
  3031. if (year.length === 3) {
  3032. year = [year.slice(0, 2), '0', year.slice(2)].join('');
  3033. }
  3034. // Check date validity
  3035. var date = "".concat(year, "/").concat(tin.slice(2, 4), "/").concat(tin.slice(0, 2));
  3036. if (!isDate(date, 'YYYY/MM/DD')) {
  3037. return false;
  3038. }
  3039. // Split digits into an array for further processing
  3040. var digits = tin.split('').map(function (a) {
  3041. return parseInt(a, 10);
  3042. });
  3043. var checksum = 0;
  3044. var weight = 4;
  3045. // Multiply by weight and add to checksum
  3046. for (var i = 0; i < 9; i++) {
  3047. checksum += digits[i] * weight;
  3048. weight -= 1;
  3049. if (weight === 1) {
  3050. weight = 7;
  3051. }
  3052. }
  3053. checksum %= 11;
  3054. if (checksum === 1) {
  3055. return false;
  3056. }
  3057. return checksum === 0 ? digits[9] === 0 : digits[9] === 11 - checksum;
  3058. }
  3059. /*
  3060. * el-CY validation function
  3061. * (Arithmos Forologikou Mitroou (AFM/ΑΦΜ), persons only)
  3062. * Verify TIN validity by calculating ASCII value of check (last) character
  3063. */
  3064. function elCyCheck(tin) {
  3065. // split digits into an array for further processing
  3066. var digits = tin.slice(0, 8).split('').map(function (a) {
  3067. return parseInt(a, 10);
  3068. });
  3069. var checksum = 0;
  3070. // add digits in even places
  3071. for (var i = 1; i < digits.length; i += 2) {
  3072. checksum += digits[i];
  3073. }
  3074. // add digits in odd places
  3075. for (var _i2 = 0; _i2 < digits.length; _i2 += 2) {
  3076. if (digits[_i2] < 2) {
  3077. checksum += 1 - digits[_i2];
  3078. } else {
  3079. checksum += 2 * (digits[_i2] - 2) + 5;
  3080. if (digits[_i2] > 4) {
  3081. checksum += 2;
  3082. }
  3083. }
  3084. }
  3085. return String.fromCharCode(checksum % 26 + 65) === tin.charAt(8);
  3086. }
  3087. /*
  3088. * el-GR validation function
  3089. * (Arithmos Forologikou Mitroou (AFM/ΑΦΜ), persons/entities)
  3090. * Verify TIN validity by calculating check (last) digit
  3091. * Algorithm not in DG TAXUD document- sourced from:
  3092. * - `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`
  3093. */
  3094. function elGrCheck(tin) {
  3095. // split digits into an array for further processing
  3096. var digits = tin.split('').map(function (a) {
  3097. return parseInt(a, 10);
  3098. });
  3099. var checksum = 0;
  3100. for (var i = 0; i < 8; i++) {
  3101. checksum += digits[i] * Math.pow(2, 8 - i);
  3102. }
  3103. return checksum % 11 % 10 === digits[8];
  3104. }
  3105. /*
  3106. * en-GB validation function (should go here if needed)
  3107. * (National Insurance Number (NINO) or Unique Taxpayer Reference (UTR),
  3108. * persons/entities respectively)
  3109. */
  3110. /*
  3111. * en-IE validation function
  3112. * (Personal Public Service Number (PPS No), persons only)
  3113. * Verify TIN validity by calculating check (second to last) character
  3114. */
  3115. function enIeCheck(tin) {
  3116. var checksum = reverseMultiplyAndSum(tin.split('').slice(0, 7).map(function (a) {
  3117. return parseInt(a, 10);
  3118. }), 8);
  3119. if (tin.length === 9 && tin[8] !== 'W') {
  3120. checksum += (tin[8].charCodeAt(0) - 64) * 9;
  3121. }
  3122. checksum %= 23;
  3123. if (checksum === 0) {
  3124. return tin[7].toUpperCase() === 'W';
  3125. }
  3126. return tin[7].toUpperCase() === String.fromCharCode(64 + checksum);
  3127. }
  3128. // Valid US IRS campus prefixes
  3129. var enUsCampusPrefix = {
  3130. andover: ['10', '12'],
  3131. atlanta: ['60', '67'],
  3132. austin: ['50', '53'],
  3133. 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'],
  3134. cincinnati: ['30', '32', '35', '36', '37', '38', '61'],
  3135. fresno: ['15', '24'],
  3136. internet: ['20', '26', '27', '45', '46', '47'],
  3137. kansas: ['40', '44'],
  3138. memphis: ['94', '95'],
  3139. ogden: ['80', '90'],
  3140. 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'],
  3141. sba: ['31']
  3142. };
  3143. // Return an array of all US IRS campus prefixes
  3144. function enUsGetPrefixes() {
  3145. var prefixes = [];
  3146. for (var location in enUsCampusPrefix) {
  3147. // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
  3148. // istanbul ignore else
  3149. if (enUsCampusPrefix.hasOwnProperty(location)) {
  3150. prefixes.push.apply(prefixes, _toConsumableArray(enUsCampusPrefix[location]));
  3151. }
  3152. }
  3153. return prefixes;
  3154. }
  3155. /*
  3156. * en-US validation function
  3157. * Verify that the TIN starts with a valid IRS campus prefix
  3158. */
  3159. function enUsCheck(tin) {
  3160. return enUsGetPrefixes().indexOf(tin.slice(0, 2)) !== -1;
  3161. }
  3162. /*
  3163. * es-AR validation function
  3164. * Clave Única de Identificación Tributaria (CUIT/CUIL)
  3165. * Sourced from:
  3166. * - https://servicioscf.afip.gob.ar/publico/abc/ABCpaso2.aspx?id_nivel1=3036&id_nivel2=3040&p=Conceptos%20b%C3%A1sicos
  3167. * - https://es.wikipedia.org/wiki/Clave_%C3%9Anica_de_Identificaci%C3%B3n_Tributaria
  3168. */
  3169. function esArCheck(tin) {
  3170. var accum = 0;
  3171. var digits = tin.split('');
  3172. var digit = parseInt(digits.pop(), 10);
  3173. for (var i = 0; i < digits.length; i++) {
  3174. accum += digits[9 - i] * (2 + i % 6);
  3175. }
  3176. var verif = 11 - accum % 11;
  3177. if (verif === 11) {
  3178. verif = 0;
  3179. } else if (verif === 10) {
  3180. verif = 9;
  3181. }
  3182. return digit === verif;
  3183. }
  3184. /*
  3185. * es-ES validation function
  3186. * (Documento Nacional de Identidad (DNI)
  3187. * or Número de Identificación de Extranjero (NIE), persons only)
  3188. * Verify TIN validity by calculating check (last) character
  3189. */
  3190. function esEsCheck(tin) {
  3191. // Split characters into an array for further processing
  3192. var chars = tin.toUpperCase().split('');
  3193. // Replace initial letter if needed
  3194. if (isNaN(parseInt(chars[0], 10)) && chars.length > 1) {
  3195. var lead_replace = 0;
  3196. switch (chars[0]) {
  3197. case 'Y':
  3198. lead_replace = 1;
  3199. break;
  3200. case 'Z':
  3201. lead_replace = 2;
  3202. break;
  3203. default:
  3204. }
  3205. chars.splice(0, 1, lead_replace);
  3206. // Fill with zeros if smaller than proper
  3207. } else {
  3208. while (chars.length < 9) {
  3209. chars.unshift(0);
  3210. }
  3211. }
  3212. // Calculate checksum and check according to lookup
  3213. 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'];
  3214. chars = chars.join('');
  3215. var checksum = parseInt(chars.slice(0, 8), 10) % 23;
  3216. return chars[8] === lookup[checksum];
  3217. }
  3218. /*
  3219. * et-EE validation function
  3220. * (Isikukood (IK), persons only)
  3221. * Checks if birth date (century digit and six following) is valid and calculates check (last) digit
  3222. * Material not in DG TAXUD document sourced from:
  3223. * - `https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/Estonia-TIN.pdf`
  3224. */
  3225. function etEeCheck(tin) {
  3226. // Extract year and add century
  3227. var full_year = tin.slice(1, 3);
  3228. var century_digit = tin.slice(0, 1);
  3229. switch (century_digit) {
  3230. case '1':
  3231. case '2':
  3232. full_year = "18".concat(full_year);
  3233. break;
  3234. case '3':
  3235. case '4':
  3236. full_year = "19".concat(full_year);
  3237. break;
  3238. default:
  3239. full_year = "20".concat(full_year);
  3240. break;
  3241. }
  3242. // Check date validity
  3243. var date = "".concat(full_year, "/").concat(tin.slice(3, 5), "/").concat(tin.slice(5, 7));
  3244. if (!isDate(date, 'YYYY/MM/DD')) {
  3245. return false;
  3246. }
  3247. // Split digits into an array for further processing
  3248. var digits = tin.split('').map(function (a) {
  3249. return parseInt(a, 10);
  3250. });
  3251. var checksum = 0;
  3252. var weight = 1;
  3253. // Multiply by weight and add to checksum
  3254. for (var i = 0; i < 10; i++) {
  3255. checksum += digits[i] * weight;
  3256. weight += 1;
  3257. if (weight === 10) {
  3258. weight = 1;
  3259. }
  3260. }
  3261. // Do again if modulo 11 of checksum is 10
  3262. if (checksum % 11 === 10) {
  3263. checksum = 0;
  3264. weight = 3;
  3265. for (var _i3 = 0; _i3 < 10; _i3++) {
  3266. checksum += digits[_i3] * weight;
  3267. weight += 1;
  3268. if (weight === 10) {
  3269. weight = 1;
  3270. }
  3271. }
  3272. if (checksum % 11 === 10) {
  3273. return digits[10] === 0;
  3274. }
  3275. }
  3276. return checksum % 11 === digits[10];
  3277. }
  3278. /*
  3279. * fi-FI validation function
  3280. * (Henkilötunnus (HETU), persons only)
  3281. * Checks if birth date (first six digits plus century symbol) is valid
  3282. * and calculates check (last) digit
  3283. */
  3284. function fiFiCheck(tin) {
  3285. // Extract year and add century
  3286. var full_year = tin.slice(4, 6);
  3287. var century_symbol = tin.slice(6, 7);
  3288. switch (century_symbol) {
  3289. case '+':
  3290. full_year = "18".concat(full_year);
  3291. break;
  3292. case '-':
  3293. full_year = "19".concat(full_year);
  3294. break;
  3295. default:
  3296. full_year = "20".concat(full_year);
  3297. break;
  3298. }
  3299. // Check date validity
  3300. var date = "".concat(full_year, "/").concat(tin.slice(2, 4), "/").concat(tin.slice(0, 2));
  3301. if (!isDate(date, 'YYYY/MM/DD')) {
  3302. return false;
  3303. }
  3304. // Calculate check character
  3305. var checksum = parseInt(tin.slice(0, 6) + tin.slice(7, 10), 10) % 31;
  3306. if (checksum < 10) {
  3307. return checksum === parseInt(tin.slice(10), 10);
  3308. }
  3309. checksum -= 10;
  3310. var letters_lookup = ['A', 'B', 'C', 'D', 'E', 'F', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y'];
  3311. return letters_lookup[checksum] === tin.slice(10);
  3312. }
  3313. /*
  3314. * fr/nl-BE validation function
  3315. * (Numéro national (N.N.), persons only)
  3316. * Checks if birth date (first six digits) is valid and calculates check (last two) digits
  3317. */
  3318. function frBeCheck(tin) {
  3319. // Zero month/day value is acceptable
  3320. if (tin.slice(2, 4) !== '00' || tin.slice(4, 6) !== '00') {
  3321. // Extract date from first six digits of TIN
  3322. var date = "".concat(tin.slice(0, 2), "/").concat(tin.slice(2, 4), "/").concat(tin.slice(4, 6));
  3323. if (!isDate(date, 'YY/MM/DD')) {
  3324. return false;
  3325. }
  3326. }
  3327. var checksum = 97 - parseInt(tin.slice(0, 9), 10) % 97;
  3328. var checkdigits = parseInt(tin.slice(9, 11), 10);
  3329. if (checksum !== checkdigits) {
  3330. checksum = 97 - parseInt("2".concat(tin.slice(0, 9)), 10) % 97;
  3331. if (checksum !== checkdigits) {
  3332. return false;
  3333. }
  3334. }
  3335. return true;
  3336. }
  3337. /*
  3338. * fr-FR validation function
  3339. * (Numéro fiscal de référence (numéro SPI), persons only)
  3340. * Verify TIN validity by calculating check (last three) digits
  3341. */
  3342. function frFrCheck(tin) {
  3343. tin = tin.replace(/\s/g, '');
  3344. var checksum = parseInt(tin.slice(0, 10), 10) % 511;
  3345. var checkdigits = parseInt(tin.slice(10, 13), 10);
  3346. return checksum === checkdigits;
  3347. }
  3348. /*
  3349. * fr/lb-LU validation function
  3350. * (numéro d’identification personnelle, persons only)
  3351. * Verify birth date validity and run Luhn and Verhoeff checks
  3352. */
  3353. function frLuCheck(tin) {
  3354. // Extract date and check validity
  3355. var date = "".concat(tin.slice(0, 4), "/").concat(tin.slice(4, 6), "/").concat(tin.slice(6, 8));
  3356. if (!isDate(date, 'YYYY/MM/DD')) {
  3357. return false;
  3358. }
  3359. // Run Luhn check
  3360. if (!luhnCheck(tin.slice(0, 12))) {
  3361. return false;
  3362. }
  3363. // Remove Luhn check digit and run Verhoeff check
  3364. return verhoeffCheck("".concat(tin.slice(0, 11)).concat(tin[12]));
  3365. }
  3366. /*
  3367. * hr-HR validation function
  3368. * (Osobni identifikacijski broj (OIB), persons/entities)
  3369. * Verify TIN validity by calling iso7064Check(digits)
  3370. */
  3371. function hrHrCheck(tin) {
  3372. return iso7064Check(tin);
  3373. }
  3374. /*
  3375. * hu-HU validation function
  3376. * (Adóazonosító jel, persons only)
  3377. * Verify TIN validity by calculating check (last) digit
  3378. */
  3379. function huHuCheck(tin) {
  3380. // split digits into an array for further processing
  3381. var digits = tin.split('').map(function (a) {
  3382. return parseInt(a, 10);
  3383. });
  3384. var checksum = 8;
  3385. for (var i = 1; i < 9; i++) {
  3386. checksum += digits[i] * (i + 1);
  3387. }
  3388. return checksum % 11 === digits[9];
  3389. }
  3390. /*
  3391. * lt-LT validation function (should go here if needed)
  3392. * (Asmens kodas, persons/entities respectively)
  3393. * Current validation check is alias of etEeCheck- same format applies
  3394. */
  3395. /*
  3396. * it-IT first/last name validity check
  3397. * Accepts it-IT TIN-encoded names as a three-element character array and checks their validity
  3398. * Due to lack of clarity between resources ("Are only Italian consonants used?
  3399. * What happens if a person has X in their name?" etc.) only two test conditions
  3400. * have been implemented:
  3401. * Vowels may only be followed by other vowels or an X character
  3402. * and X characters after vowels may only be followed by other X characters.
  3403. */
  3404. function itItNameCheck(name) {
  3405. // true at the first occurrence of a vowel
  3406. var vowelflag = false;
  3407. // true at the first occurrence of an X AFTER vowel
  3408. // (to properly handle last names with X as consonant)
  3409. var xflag = false;
  3410. for (var i = 0; i < 3; i++) {
  3411. if (!vowelflag && /[AEIOU]/.test(name[i])) {
  3412. vowelflag = true;
  3413. } else if (!xflag && vowelflag && name[i] === 'X') {
  3414. xflag = true;
  3415. } else if (i > 0) {
  3416. if (vowelflag && !xflag) {
  3417. if (!/[AEIOU]/.test(name[i])) {
  3418. return false;
  3419. }
  3420. }
  3421. if (xflag) {
  3422. if (!/X/.test(name[i])) {
  3423. return false;
  3424. }
  3425. }
  3426. }
  3427. }
  3428. return true;
  3429. }
  3430. /*
  3431. * it-IT validation function
  3432. * (Codice fiscale (TIN-IT), persons only)
  3433. * Verify name, birth date and codice catastale validity
  3434. * and calculate check character.
  3435. * Material not in DG-TAXUD document sourced from:
  3436. * `https://en.wikipedia.org/wiki/Italian_fiscal_code`
  3437. */
  3438. function itItCheck(tin) {
  3439. // Capitalize and split characters into an array for further processing
  3440. var chars = tin.toUpperCase().split('');
  3441. // Check first and last name validity calling itItNameCheck()
  3442. if (!itItNameCheck(chars.slice(0, 3))) {
  3443. return false;
  3444. }
  3445. if (!itItNameCheck(chars.slice(3, 6))) {
  3446. return false;
  3447. }
  3448. // Convert letters in number spaces back to numbers if any
  3449. var number_locations = [6, 7, 9, 10, 12, 13, 14];
  3450. var number_replace = {
  3451. L: '0',
  3452. M: '1',
  3453. N: '2',
  3454. P: '3',
  3455. Q: '4',
  3456. R: '5',
  3457. S: '6',
  3458. T: '7',
  3459. U: '8',
  3460. V: '9'
  3461. };
  3462. for (var _i4 = 0, _number_locations = number_locations; _i4 < _number_locations.length; _i4++) {
  3463. var i = _number_locations[_i4];
  3464. if (chars[i] in number_replace) {
  3465. chars.splice(i, 1, number_replace[chars[i]]);
  3466. }
  3467. }
  3468. // Extract month and day, and check date validity
  3469. var month_replace = {
  3470. A: '01',
  3471. B: '02',
  3472. C: '03',
  3473. D: '04',
  3474. E: '05',
  3475. H: '06',
  3476. L: '07',
  3477. M: '08',
  3478. P: '09',
  3479. R: '10',
  3480. S: '11',
  3481. T: '12'
  3482. };
  3483. var month = month_replace[chars[8]];
  3484. var day = parseInt(chars[9] + chars[10], 10);
  3485. if (day > 40) {
  3486. day -= 40;
  3487. }
  3488. if (day < 10) {
  3489. day = "0".concat(day);
  3490. }
  3491. var date = "".concat(chars[6]).concat(chars[7], "/").concat(month, "/").concat(day);
  3492. if (!isDate(date, 'YY/MM/DD')) {
  3493. return false;
  3494. }
  3495. // Calculate check character by adding up even and odd characters as numbers
  3496. var checksum = 0;
  3497. for (var _i5 = 1; _i5 < chars.length - 1; _i5 += 2) {
  3498. var char_to_int = parseInt(chars[_i5], 10);
  3499. if (isNaN(char_to_int)) {
  3500. char_to_int = chars[_i5].charCodeAt(0) - 65;
  3501. }
  3502. checksum += char_to_int;
  3503. }
  3504. var odd_convert = {
  3505. // Maps of characters at odd places
  3506. A: 1,
  3507. B: 0,
  3508. C: 5,
  3509. D: 7,
  3510. E: 9,
  3511. F: 13,
  3512. G: 15,
  3513. H: 17,
  3514. I: 19,
  3515. J: 21,
  3516. K: 2,
  3517. L: 4,
  3518. M: 18,
  3519. N: 20,
  3520. O: 11,
  3521. P: 3,
  3522. Q: 6,
  3523. R: 8,
  3524. S: 12,
  3525. T: 14,
  3526. U: 16,
  3527. V: 10,
  3528. W: 22,
  3529. X: 25,
  3530. Y: 24,
  3531. Z: 23,
  3532. 0: 1,
  3533. 1: 0
  3534. };
  3535. for (var _i6 = 0; _i6 < chars.length - 1; _i6 += 2) {
  3536. var _char_to_int = 0;
  3537. if (chars[_i6] in odd_convert) {
  3538. _char_to_int = odd_convert[chars[_i6]];
  3539. } else {
  3540. var multiplier = parseInt(chars[_i6], 10);
  3541. _char_to_int = 2 * multiplier + 1;
  3542. if (multiplier > 4) {
  3543. _char_to_int += 2;
  3544. }
  3545. }
  3546. checksum += _char_to_int;
  3547. }
  3548. if (String.fromCharCode(65 + checksum % 26) !== chars[15]) {
  3549. return false;
  3550. }
  3551. return true;
  3552. }
  3553. /*
  3554. * lv-LV validation function
  3555. * (Personas kods (PK), persons only)
  3556. * Check validity of birth date and calculate check (last) digit
  3557. * Support only for old format numbers (not starting with '32', issued before 2017/07/01)
  3558. * Material not in DG TAXUD document sourced from:
  3559. * `https://boot.ritakafija.lv/forums/index.php?/topic/88314-personas-koda-algoritms-%C4%8Deksumma/`
  3560. */
  3561. function lvLvCheck(tin) {
  3562. tin = tin.replace(/\W/, '');
  3563. // Extract date from TIN
  3564. var day = tin.slice(0, 2);
  3565. if (day !== '32') {
  3566. // No date/checksum check if new format
  3567. var month = tin.slice(2, 4);
  3568. if (month !== '00') {
  3569. // No date check if unknown month
  3570. var full_year = tin.slice(4, 6);
  3571. switch (tin[6]) {
  3572. case '0':
  3573. full_year = "18".concat(full_year);
  3574. break;
  3575. case '1':
  3576. full_year = "19".concat(full_year);
  3577. break;
  3578. default:
  3579. full_year = "20".concat(full_year);
  3580. break;
  3581. }
  3582. // Check date validity
  3583. var date = "".concat(full_year, "/").concat(tin.slice(2, 4), "/").concat(day);
  3584. if (!isDate(date, 'YYYY/MM/DD')) {
  3585. return false;
  3586. }
  3587. }
  3588. // Calculate check digit
  3589. var checksum = 1101;
  3590. var multip_lookup = [1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
  3591. for (var i = 0; i < tin.length - 1; i++) {
  3592. checksum -= parseInt(tin[i], 10) * multip_lookup[i];
  3593. }
  3594. return parseInt(tin[10], 10) === checksum % 11;
  3595. }
  3596. return true;
  3597. }
  3598. /*
  3599. * mt-MT validation function
  3600. * (Identity Card Number or Unique Taxpayer Reference, persons/entities)
  3601. * Verify Identity Card Number structure (no other tests found)
  3602. */
  3603. function mtMtCheck(tin) {
  3604. if (tin.length !== 9) {
  3605. // No tests for UTR
  3606. var chars = tin.toUpperCase().split('');
  3607. // Fill with zeros if smaller than proper
  3608. while (chars.length < 8) {
  3609. chars.unshift(0);
  3610. }
  3611. // Validate format according to last character
  3612. switch (tin[7]) {
  3613. case 'A':
  3614. case 'P':
  3615. if (parseInt(chars[6], 10) === 0) {
  3616. return false;
  3617. }
  3618. break;
  3619. default:
  3620. {
  3621. var first_part = parseInt(chars.join('').slice(0, 5), 10);
  3622. if (first_part > 32000) {
  3623. return false;
  3624. }
  3625. var second_part = parseInt(chars.join('').slice(5, 7), 10);
  3626. if (first_part === second_part) {
  3627. return false;
  3628. }
  3629. }
  3630. }
  3631. }
  3632. return true;
  3633. }
  3634. /*
  3635. * nl-NL validation function
  3636. * (Burgerservicenummer (BSN) or Rechtspersonen Samenwerkingsverbanden Informatie Nummer (RSIN),
  3637. * persons/entities respectively)
  3638. * Verify TIN validity by calculating check (last) digit (variant of MOD 11)
  3639. */
  3640. function nlNlCheck(tin) {
  3641. return reverseMultiplyAndSum(tin.split('').slice(0, 8).map(function (a) {
  3642. return parseInt(a, 10);
  3643. }), 9) % 11 === parseInt(tin[8], 10);
  3644. }
  3645. /*
  3646. * pl-PL validation function
  3647. * (Powszechny Elektroniczny System Ewidencji Ludności (PESEL)
  3648. * or Numer identyfikacji podatkowej (NIP), persons/entities)
  3649. * Verify TIN validity by validating birth date (PESEL) and calculating check (last) digit
  3650. */
  3651. function plPlCheck(tin) {
  3652. // NIP
  3653. if (tin.length === 10) {
  3654. // Calculate last digit by multiplying with lookup
  3655. var lookup = [6, 5, 7, 2, 3, 4, 5, 6, 7];
  3656. var _checksum = 0;
  3657. for (var i = 0; i < lookup.length; i++) {
  3658. _checksum += parseInt(tin[i], 10) * lookup[i];
  3659. }
  3660. _checksum %= 11;
  3661. if (_checksum === 10) {
  3662. return false;
  3663. }
  3664. return _checksum === parseInt(tin[9], 10);
  3665. }
  3666. // PESEL
  3667. // Extract full year using month
  3668. var full_year = tin.slice(0, 2);
  3669. var month = parseInt(tin.slice(2, 4), 10);
  3670. if (month > 80) {
  3671. full_year = "18".concat(full_year);
  3672. month -= 80;
  3673. } else if (month > 60) {
  3674. full_year = "22".concat(full_year);
  3675. month -= 60;
  3676. } else if (month > 40) {
  3677. full_year = "21".concat(full_year);
  3678. month -= 40;
  3679. } else if (month > 20) {
  3680. full_year = "20".concat(full_year);
  3681. month -= 20;
  3682. } else {
  3683. full_year = "19".concat(full_year);
  3684. }
  3685. // Add leading zero to month if needed
  3686. if (month < 10) {
  3687. month = "0".concat(month);
  3688. }
  3689. // Check date validity
  3690. var date = "".concat(full_year, "/").concat(month, "/").concat(tin.slice(4, 6));
  3691. if (!isDate(date, 'YYYY/MM/DD')) {
  3692. return false;
  3693. }
  3694. // Calculate last digit by multiplying with odd one-digit numbers except 5
  3695. var checksum = 0;
  3696. var multiplier = 1;
  3697. for (var _i7 = 0; _i7 < tin.length - 1; _i7++) {
  3698. checksum += parseInt(tin[_i7], 10) * multiplier % 10;
  3699. multiplier += 2;
  3700. if (multiplier > 10) {
  3701. multiplier = 1;
  3702. } else if (multiplier === 5) {
  3703. multiplier += 2;
  3704. }
  3705. }
  3706. checksum = 10 - checksum % 10;
  3707. return checksum === parseInt(tin[10], 10);
  3708. }
  3709. /*
  3710. * pt-BR validation function
  3711. * (Cadastro de Pessoas Físicas (CPF, persons)
  3712. * Cadastro Nacional de Pessoas Jurídicas (CNPJ, entities)
  3713. * Both inputs will be validated.
  3714. * CPF accepts formatted (XXX.XXX.XXX-XX) and unformatted input;
  3715. * formatting is stripped before validation.
  3716. * CNPJ supports both numeric (legacy) and alphanumeric format (starting July 2026).
  3717. */
  3718. /**
  3719. * Convert a CNPJ character to its numeric value for check digit calculation.
  3720. * Numbers 0-9 map to values 0-9, letters A-Z map to values 17-42.
  3721. * This is done by subtracting 48 from the ASCII code.
  3722. */
  3723. function cnpjCharToValue(_char) {
  3724. return _char.charCodeAt(0) - 48;
  3725. }
  3726. /**
  3727. * Validate CNPJ (both numeric and alphanumeric formats).
  3728. * Algorithm: module 11 with weights 2-9 from right to left.
  3729. */
  3730. function validateCnpj(cnpj) {
  3731. // Get the 12 identifier characters and 2 check digits
  3732. var identifiers = cnpj.substring(0, 12).toUpperCase();
  3733. var checkDigits = cnpj.substring(12);
  3734. // Reject CNPJs with all same characters (e.g., '00000000000000', 'AAAAAAAAAAAAAA')
  3735. if (/^(.)\1+$/.test(cnpj.toUpperCase())) {
  3736. return false;
  3737. }
  3738. // Calculate first check digit
  3739. var sum = 0;
  3740. var weight = 5;
  3741. for (var i = 0; i < 12; i++) {
  3742. sum += cnpjCharToValue(identifiers.charAt(i)) * weight;
  3743. weight = weight === 2 ? 9 : weight - 1;
  3744. }
  3745. var remainder = sum % 11;
  3746. var firstDV = remainder < 2 ? 0 : 11 - remainder;
  3747. if (firstDV !== parseInt(checkDigits.charAt(0), 10)) {
  3748. return false;
  3749. }
  3750. // Calculate second check digit (includes first check digit)
  3751. sum = 0;
  3752. weight = 6;
  3753. for (var _i8 = 0; _i8 < 12; _i8++) {
  3754. sum += cnpjCharToValue(identifiers.charAt(_i8)) * weight;
  3755. weight = weight === 2 ? 9 : weight - 1;
  3756. }
  3757. sum += firstDV * 2;
  3758. remainder = sum % 11;
  3759. var secondDV = remainder < 2 ? 0 : 11 - remainder;
  3760. return secondDV === parseInt(checkDigits.charAt(1), 10);
  3761. }
  3762. function ptBrCheck(tin) {
  3763. // Strip CPF formatting (XXX.XXX.XXX-XX)
  3764. tin = tin.replace(/[.\-/]/g, '');
  3765. if (tin.length === 11) {
  3766. var sum;
  3767. var remainder;
  3768. sum = 0;
  3769. if (
  3770. // Reject known invalid CPFs
  3771. tin === '11111111111' || tin === '22222222222' || tin === '33333333333' || tin === '44444444444' || tin === '55555555555' || tin === '66666666666' || tin === '77777777777' || tin === '88888888888' || tin === '99999999999' || tin === '00000000000') return false;
  3772. for (var i = 1; i <= 9; i++) sum += parseInt(tin.substring(i - 1, i), 10) * (11 - i);
  3773. remainder = sum * 10 % 11;
  3774. if (remainder === 10) remainder = 0;
  3775. if (remainder !== parseInt(tin.substring(9, 10), 10)) return false;
  3776. sum = 0;
  3777. for (var _i9 = 1; _i9 <= 10; _i9++) sum += parseInt(tin.substring(_i9 - 1, _i9), 10) * (12 - _i9);
  3778. remainder = sum * 10 % 11;
  3779. if (remainder === 10) remainder = 0;
  3780. if (remainder !== parseInt(tin.substring(10, 11), 10)) return false;
  3781. return true;
  3782. }
  3783. // CNPJ validation (supports both numeric and alphanumeric formats)
  3784. return validateCnpj(tin);
  3785. }
  3786. /*
  3787. * pt-PT validation function
  3788. * (Número de identificação fiscal (NIF), persons/entities)
  3789. * Verify TIN validity by calculating check (last) digit (variant of MOD 11)
  3790. */
  3791. function ptPtCheck(tin) {
  3792. var checksum = 11 - reverseMultiplyAndSum(tin.split('').slice(0, 8).map(function (a) {
  3793. return parseInt(a, 10);
  3794. }), 9) % 11;
  3795. if (checksum > 9) {
  3796. return parseInt(tin[8], 10) === 0;
  3797. }
  3798. return checksum === parseInt(tin[8], 10);
  3799. }
  3800. /*
  3801. * ro-RO validation function
  3802. * (Cod Numeric Personal (CNP) or Cod de înregistrare fiscală (CIF),
  3803. * persons only)
  3804. * Verify CNP validity by calculating check (last) digit (test not found for CIF)
  3805. * Material not in DG TAXUD document sourced from:
  3806. * `https://en.wikipedia.org/wiki/National_identification_number#Romania`
  3807. */
  3808. function roRoCheck(tin) {
  3809. if (tin.slice(0, 4) !== '9000') {
  3810. // No test found for this format
  3811. // Extract full year using century digit if possible
  3812. var full_year = tin.slice(1, 3);
  3813. switch (tin[0]) {
  3814. case '1':
  3815. case '2':
  3816. full_year = "19".concat(full_year);
  3817. break;
  3818. case '3':
  3819. case '4':
  3820. full_year = "18".concat(full_year);
  3821. break;
  3822. case '5':
  3823. case '6':
  3824. full_year = "20".concat(full_year);
  3825. break;
  3826. default:
  3827. }
  3828. // Check date validity
  3829. var date = "".concat(full_year, "/").concat(tin.slice(3, 5), "/").concat(tin.slice(5, 7));
  3830. if (date.length === 8) {
  3831. if (!isDate(date, 'YY/MM/DD')) {
  3832. return false;
  3833. }
  3834. } else if (!isDate(date, 'YYYY/MM/DD')) {
  3835. return false;
  3836. }
  3837. // Calculate check digit
  3838. var digits = tin.split('').map(function (a) {
  3839. return parseInt(a, 10);
  3840. });
  3841. var multipliers = [2, 7, 9, 1, 4, 6, 3, 5, 8, 2, 7, 9];
  3842. var checksum = 0;
  3843. for (var i = 0; i < multipliers.length; i++) {
  3844. checksum += digits[i] * multipliers[i];
  3845. }
  3846. if (checksum % 11 === 10) {
  3847. return digits[12] === 1;
  3848. }
  3849. return digits[12] === checksum % 11;
  3850. }
  3851. return true;
  3852. }
  3853. /*
  3854. * sk-SK validation function
  3855. * (Rodné číslo (RČ) or bezvýznamové identifikačné číslo (BIČ), persons only)
  3856. * Checks validity of pre-1954 birth numbers (rodné číslo) only
  3857. * Due to the introduction of the pseudo-random BIČ it is not possible to test
  3858. * post-1954 birth numbers without knowing whether they are BIČ or RČ beforehand
  3859. */
  3860. function skSkCheck(tin) {
  3861. if (tin.length === 9) {
  3862. tin = tin.replace(/\W/, '');
  3863. if (tin.slice(6) === '000') {
  3864. return false;
  3865. } // Three-zero serial not assigned before 1954
  3866. // Extract full year from TIN length
  3867. var full_year = parseInt(tin.slice(0, 2), 10);
  3868. if (full_year > 53) {
  3869. return false;
  3870. }
  3871. if (full_year < 10) {
  3872. full_year = "190".concat(full_year);
  3873. } else {
  3874. full_year = "19".concat(full_year);
  3875. }
  3876. // Extract month from TIN and normalize
  3877. var month = parseInt(tin.slice(2, 4), 10);
  3878. if (month > 50) {
  3879. month -= 50;
  3880. }
  3881. if (month < 10) {
  3882. month = "0".concat(month);
  3883. }
  3884. // Check date validity
  3885. var date = "".concat(full_year, "/").concat(month, "/").concat(tin.slice(4, 6));
  3886. if (!isDate(date, 'YYYY/MM/DD')) {
  3887. return false;
  3888. }
  3889. }
  3890. return true;
  3891. }
  3892. /*
  3893. * sl-SI validation function
  3894. * (Davčna številka, persons/entities)
  3895. * Verify TIN validity by calculating check (last) digit (variant of MOD 11)
  3896. */
  3897. function slSiCheck(tin) {
  3898. var checksum = 11 - reverseMultiplyAndSum(tin.split('').slice(0, 7).map(function (a) {
  3899. return parseInt(a, 10);
  3900. }), 8) % 11;
  3901. if (checksum === 10) {
  3902. return parseInt(tin[7], 10) === 0;
  3903. }
  3904. return checksum === parseInt(tin[7], 10);
  3905. }
  3906. /*
  3907. * sv-SE validation function
  3908. * (Personnummer or samordningsnummer, persons only)
  3909. * Checks validity of birth date and calls luhnCheck() to validate check (last) digit
  3910. */
  3911. function svSeCheck(tin) {
  3912. // Make copy of TIN and normalize to two-digit year form
  3913. var tin_copy = tin.slice(0);
  3914. if (tin.length > 11) {
  3915. tin_copy = tin_copy.slice(2);
  3916. }
  3917. // Extract date of birth
  3918. var full_year = '';
  3919. var month = tin_copy.slice(2, 4);
  3920. var day = parseInt(tin_copy.slice(4, 6), 10);
  3921. if (tin.length > 11) {
  3922. full_year = tin.slice(0, 4);
  3923. } else {
  3924. full_year = tin.slice(0, 2);
  3925. if (tin.length === 11 && day < 60) {
  3926. // Extract full year from centenarian symbol
  3927. // Should work just fine until year 10000 or so
  3928. var current_year = new Date().getFullYear().toString();
  3929. var current_century = parseInt(current_year.slice(0, 2), 10);
  3930. current_year = parseInt(current_year, 10);
  3931. if (tin[6] === '-') {
  3932. if (parseInt("".concat(current_century).concat(full_year), 10) > current_year) {
  3933. full_year = "".concat(current_century - 1).concat(full_year);
  3934. } else {
  3935. full_year = "".concat(current_century).concat(full_year);
  3936. }
  3937. } else {
  3938. full_year = "".concat(current_century - 1).concat(full_year);
  3939. if (current_year - parseInt(full_year, 10) < 100) {
  3940. return false;
  3941. }
  3942. }
  3943. }
  3944. }
  3945. // Normalize day and check date validity
  3946. if (day > 60) {
  3947. day -= 60;
  3948. }
  3949. if (day < 10) {
  3950. day = "0".concat(day);
  3951. }
  3952. var date = "".concat(full_year, "/").concat(month, "/").concat(day);
  3953. if (date.length === 8) {
  3954. if (!isDate(date, 'YY/MM/DD')) {
  3955. return false;
  3956. }
  3957. } else if (!isDate(date, 'YYYY/MM/DD')) {
  3958. return false;
  3959. }
  3960. return luhnCheck(tin.replace(/\W/, ''));
  3961. }
  3962. /**
  3963. * uk-UA validation function
  3964. * Verify TIN validity by calculating check (last) digit (variant of MOD 11)
  3965. */
  3966. function ukUaCheck(tin) {
  3967. // Calculate check digit
  3968. var digits = tin.split('').map(function (a) {
  3969. return parseInt(a, 10);
  3970. });
  3971. var multipliers = [-1, 5, 7, 9, 4, 6, 10, 5, 7];
  3972. var checksum = 0;
  3973. for (var i = 0; i < multipliers.length; i++) {
  3974. checksum += digits[i] * multipliers[i];
  3975. }
  3976. return checksum % 11 === 10 ? digits[9] === 0 : digits[9] === checksum % 11;
  3977. }
  3978. // Locale lookup objects
  3979. /*
  3980. * Tax id regex formats for various locales
  3981. *
  3982. * Where not explicitly specified in DG-TAXUD document both
  3983. * uppercase and lowercase letters are acceptable.
  3984. */
  3985. var taxIdFormat = {
  3986. 'bg-BG': /^\d{10}$/,
  3987. 'cs-CZ': /^\d{6}\/{0,1}\d{3,4}$/,
  3988. 'de-AT': /^\d{9}$/,
  3989. 'de-DE': /^[1-9]\d{10}$/,
  3990. 'dk-DK': /^\d{6}-{0,1}\d{4}$/,
  3991. 'el-CY': /^[09]\d{7}[A-Z]$/,
  3992. 'el-GR': /^([0-4]|[7-9])\d{8}$/,
  3993. 'en-CA': /^\d{9}$/,
  3994. 'en-GB': /^\d{10}$|^(?!GB|NK|TN|ZZ)(?![DFIQUV])[A-Z](?![DFIQUVO])[A-Z]\d{6}[ABCD ]$/i,
  3995. 'en-IE': /^\d{7}[A-W][A-IW]{0,1}$/i,
  3996. 'en-US': /^\d{2}[- ]{0,1}\d{7}$/,
  3997. 'es-AR': /(20|23|24|27|30|33|34)[0-9]{8}[0-9]/,
  3998. 'es-ES': /^(\d{0,8}|[XYZKLM]\d{7})[A-HJ-NP-TV-Z]$/i,
  3999. 'et-EE': /^[1-6]\d{6}(00[1-9]|0[1-9][0-9]|[1-6][0-9]{2}|70[0-9]|710)\d$/,
  4000. 'fi-FI': /^\d{6}[-+A]\d{3}[0-9A-FHJ-NPR-Y]$/i,
  4001. 'fr-BE': /^\d{11}$/,
  4002. 'fr-FR': /^[0-3]\d{12}$|^[0-3]\d\s\d{2}(\s\d{3}){3}$/,
  4003. // Conforms both to official spec and provided example
  4004. 'fr-LU': /^\d{13}$/,
  4005. 'hr-HR': /^\d{11}$/,
  4006. 'hu-HU': /^8\d{9}$/,
  4007. '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,
  4008. 'lv-LV': /^\d{6}-{0,1}\d{5}$/,
  4009. // Conforms both to DG TAXUD spec and original research
  4010. 'mt-MT': /^\d{3,7}[APMGLHBZ]$|^([1-8])\1\d{7}$/i,
  4011. 'nl-NL': /^\d{9}$/,
  4012. 'pl-PL': /^\d{10,11}$/,
  4013. 'pt-BR': /(?:^\d{3}\.\d{3}\.\d{3}-\d{2}$)|(?:^\d{11}$)|(?:^[A-Z0-9]{12}\d{2}$)/i,
  4014. 'pt-PT': /^\d{9}$/,
  4015. 'ro-RO': /^\d{13}$/,
  4016. 'sk-SK': /^\d{6}\/{0,1}\d{3,4}$/,
  4017. 'sl-SI': /^[1-9]\d{7}$/,
  4018. 'sv-SE': /^(\d{6}[-+]{0,1}\d{4}|(18|19|20)\d{6}[-+]{0,1}\d{4})$/,
  4019. 'uk-UA': /^\d{10}$/
  4020. };
  4021. // taxIdFormat locale aliases
  4022. taxIdFormat['lb-LU'] = taxIdFormat['fr-LU'];
  4023. taxIdFormat['lt-LT'] = taxIdFormat['et-EE'];
  4024. taxIdFormat['nl-BE'] = taxIdFormat['fr-BE'];
  4025. taxIdFormat['fr-CA'] = taxIdFormat['en-CA'];
  4026. // Algorithmic tax id check functions for various locales
  4027. var taxIdCheck = {
  4028. 'bg-BG': bgBgCheck,
  4029. 'cs-CZ': csCzCheck,
  4030. 'de-AT': deAtCheck,
  4031. 'de-DE': deDeCheck,
  4032. 'dk-DK': dkDkCheck,
  4033. 'el-CY': elCyCheck,
  4034. 'el-GR': elGrCheck,
  4035. 'en-CA': isCanadianSIN,
  4036. 'en-IE': enIeCheck,
  4037. 'en-US': enUsCheck,
  4038. 'es-AR': esArCheck,
  4039. 'es-ES': esEsCheck,
  4040. 'et-EE': etEeCheck,
  4041. 'fi-FI': fiFiCheck,
  4042. 'fr-BE': frBeCheck,
  4043. 'fr-FR': frFrCheck,
  4044. 'fr-LU': frLuCheck,
  4045. 'hr-HR': hrHrCheck,
  4046. 'hu-HU': huHuCheck,
  4047. 'it-IT': itItCheck,
  4048. 'lv-LV': lvLvCheck,
  4049. 'mt-MT': mtMtCheck,
  4050. 'nl-NL': nlNlCheck,
  4051. 'pl-PL': plPlCheck,
  4052. 'pt-BR': ptBrCheck,
  4053. 'pt-PT': ptPtCheck,
  4054. 'ro-RO': roRoCheck,
  4055. 'sk-SK': skSkCheck,
  4056. 'sl-SI': slSiCheck,
  4057. 'sv-SE': svSeCheck,
  4058. 'uk-UA': ukUaCheck
  4059. };
  4060. // taxIdCheck locale aliases
  4061. taxIdCheck['lb-LU'] = taxIdCheck['fr-LU'];
  4062. taxIdCheck['lt-LT'] = taxIdCheck['et-EE'];
  4063. taxIdCheck['nl-BE'] = taxIdCheck['fr-BE'];
  4064. taxIdCheck['fr-CA'] = taxIdCheck['en-CA'];
  4065. // Regexes for locales where characters should be omitted before checking format
  4066. var allsymbols = /[-\\\/!@#$%\^&\*\(\)\+\=\[\]]+/g;
  4067. var sanitizeRegexes = {
  4068. 'de-AT': allsymbols,
  4069. 'de-DE': /[\/\\]/g,
  4070. 'fr-BE': allsymbols
  4071. };
  4072. // sanitizeRegexes locale aliases
  4073. sanitizeRegexes['nl-BE'] = sanitizeRegexes['fr-BE'];
  4074. /*
  4075. * Validator function
  4076. * Return true if the passed string is a valid tax identification number
  4077. * for the specified locale.
  4078. * Throw an error exception if the locale is not supported.
  4079. */
  4080. function isTaxID(str) {
  4081. var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US';
  4082. assertString(str);
  4083. // Copy TIN to avoid replacement if sanitized
  4084. var strcopy = str.slice(0);
  4085. if (locale in taxIdFormat) {
  4086. if (locale in sanitizeRegexes) {
  4087. strcopy = strcopy.replace(sanitizeRegexes[locale], '');
  4088. }
  4089. if (!taxIdFormat[locale].test(strcopy)) {
  4090. return false;
  4091. }
  4092. if (locale in taxIdCheck) {
  4093. return taxIdCheck[locale](strcopy);
  4094. }
  4095. // Fallthrough; not all locales have algorithmic checks
  4096. return true;
  4097. }
  4098. throw new Error("Invalid locale '".concat(locale, "'"));
  4099. }
  4100. /* eslint-disable max-len */
  4101. var phones = {
  4102. 'am-AM': /^(\+?374|0)(33|4[134]|55|77|88|9[13-689])\d{6}$/,
  4103. 'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/,
  4104. 'ar-BH': /^(\+?973)?(3|6)\d{7}$/,
  4105. 'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/,
  4106. 'ar-LB': /^(\+?961)?((3|81)\d{6}|7\d{7})$/,
  4107. 'ar-EG': /^((\+?20)|0)?1[0125]\d{8}$/,
  4108. 'ar-IQ': /^(\+?964|0)?7[0-9]\d{8}$/,
  4109. 'ar-JO': /^(\+?962|0)?7[789]\d{7}$/,
  4110. 'ar-KW': /^(\+?965)([569]\d{7}|41\d{6})$/,
  4111. 'ar-LY': /^((\+?218)|0)?(9[1-6]\d{7}|[1-8]\d{7,9})$/,
  4112. 'ar-MA': /^(?:(?:\+|00)212|0)[5-7]\d{8}$/,
  4113. 'ar-OM': /^((\+|00)968)?([79][1-9])\d{6}$/,
  4114. 'ar-PS': /^(\+?970|0)5[6|9](\d{7})$/,
  4115. 'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/,
  4116. 'ar-SD': /^((\+?249)|0)?(9[012369]|1[012])\d{7}$/,
  4117. 'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/,
  4118. 'ar-TN': /^(\+?216)?[2459]\d{7}$/,
  4119. 'az-AZ': /^(\+994|0)(10|5[015]|7[07]|99)\d{7}$/,
  4120. 'ar-QA': /^(\+?974|0)?([3567]\d{7})$/,
  4121. 'bs-BA': /^((((\+|00)3876)|06))((([0-3]|[5-6])\d{6})|(4\d{7}))$/,
  4122. 'be-BY': /^(\+?375)?(24|25|29|33|44)\d{7}$/,
  4123. 'bg-BG': /^(\+?359|0)?8[789]\d{7}$/,
  4124. 'bn-BD': /^(\+?880|0)1[13456789][0-9]{8}$/,
  4125. 'ca-AD': /^(\+376)?[346]\d{5}$/,
  4126. 'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
  4127. 'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,
  4128. 'de-DE': /^((\+49|0)1)(5[0-25-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7,9}$/,
  4129. 'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/,
  4130. 'de-CH': /^(\+41|0)([1-9])\d{1,9}$/,
  4131. 'de-LU': /^(\+352)?((6\d1)\d{6})$/,
  4132. 'dv-MV': /^(\+?960)?(7[2-9]|9[1-9])\d{5}$/,
  4133. 'el-GR': /^(\+?30|0)?6(8[5-9]|9(?![26])[0-9])\d{7}$/,
  4134. 'el-CY': /^(\+?357?)?(9(9|7|6|5|4)\d{6})$/,
  4135. 'en-AI': /^(\+?1|0)264(?:2(35|92)|4(?:6[1-2]|76|97)|5(?:3[6-9]|8[1-4])|7(?:2(4|9)|72))\d{4}$/,
  4136. 'en-AU': /^(\+?61|0)4\d{8}$/,
  4137. 'en-AG': /^(?:\+1|1)268(?:464|7(?:1[3-9]|[28]\d|3[0246]|64|7[0-689]))\d{4}$/,
  4138. 'en-BM': /^(\+?1)?441(((3|7)\d{6}$)|(5[0-3][0-9]\d{4}$)|(59\d{5}$))/,
  4139. 'en-BS': /^(\+?1[-\s]?|0)?\(?242\)?[-\s]?\d{3}[-\s]?\d{4}$/,
  4140. 'en-GB': /^(\+?44|0)7[1-9]\d{8}$/,
  4141. 'en-GG': /^(\+?44|0)1481\d{6}$/,
  4142. 'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|53|28|55|59)\d{7}$/,
  4143. 'en-GY': /^(\+592|0)6\d{6}$/,
  4144. 'en-HK': /^(\+?852[-\s]?)?[456789]\d{3}[-\s]?\d{4}$/,
  4145. 'en-MO': /^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/,
  4146. 'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
  4147. 'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
  4148. 'en-JM': /^(\+?876)?\d{7}$/,
  4149. 'en-KE': /^(\+?254|0)(7|1)\d{8}$/,
  4150. 'fr-CF': /^(\+?236| ?)(70|75|77|72|21|22)\d{6}$/,
  4151. 'en-SS': /^(\+?211|0)(9[1257])\d{7}$/,
  4152. 'en-KI': /^((\+686|686)?)?( )?((6|7)(2|3|8)[0-9]{6})$/,
  4153. 'en-KN': /^(?:\+1|1)869(?:46\d|48[89]|55[6-8]|66\d|76[02-7])\d{4}$/,
  4154. 'en-LS': /^(\+?266)(22|28|57|58|59|27|52)\d{6}$/,
  4155. 'en-MT': /^(\+?356|0)?(99|79|77|21|27|22|25)[0-9]{6}$/,
  4156. 'en-MU': /^(\+?230|0)?\d{8}$/,
  4157. 'en-MW': /^(\+?265|0)(((77|88|31|99|98|21)\d{7})|(((111)|1)\d{6})|(32000\d{4}))$/,
  4158. 'en-NA': /^(\+?264|0)(6|8)\d{7}$/,
  4159. 'en-NG': /^(\+?234|0)?[789]\d{9}$/,
  4160. 'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
  4161. 'en-PG': /^(\+?675|0)?(7\d|8[18])\d{6}$/,
  4162. 'en-PK': /^((00|\+)?92|0)3[0-6]\d{8}$/,
  4163. 'en-PH': /^(09|\+639)\d{9}$/,
  4164. 'en-RW': /^(\+?250|0)?[7]\d{8}$/,
  4165. 'en-SG': /^(\+65)?[3689]\d{7}$/,
  4166. 'en-SL': /^(\+?232|0)\d{8}$/,
  4167. 'en-TZ': /^(\+?255|0)?[67]\d{8}$/,
  4168. 'en-UG': /^(\+?256|0)?[7]\d{8}$/,
  4169. 'en-US': /^((\+1|1)?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/,
  4170. 'en-ZA': /^(\+?27|0)\d{9}$/,
  4171. 'en-ZM': /^(\+?26)?0[79][567]\d{7}$/,
  4172. 'en-ZW': /^(\+263)[0-9]{9}$/,
  4173. 'en-BW': /^(\+?267)?(7[1-8]{1})\d{6}$/,
  4174. 'es-AR': /^\+?549(11|[2368]\d)\d{8}$/,
  4175. 'es-BO': /^(\+?591)?(6|7)\d{7}$/,
  4176. 'es-CO': /^(\+?57)?3(0(0|1|2|4|5)|1\d|2[0-4]|5(0|1))\d{7}$/,
  4177. 'es-CL': /^(\+?56|0)[2-9]\d{1}\d{7}$/,
  4178. 'es-CR': /^(\+506)?[2-8]\d{7}$/,
  4179. 'es-CU': /^(\+53|0053)?5\d{7}$/,
  4180. 'es-DO': /^(\+?1)?8[024]9\d{7}$/,
  4181. 'es-HN': /^(\+?504)?[9|8|3|2]\d{7}$/,
  4182. 'es-EC': /^(\+?593|0)([2-7]|9[2-9])\d{7}$/,
  4183. 'es-ES': /^(\+?34)?[6|7]\d{8}$/,
  4184. 'es-GT': /^(\+?502)?[2|6|7]\d{7}$/,
  4185. 'es-PE': /^(\+?51)?9\d{8}$/,
  4186. 'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
  4187. 'es-NI': /^(\+?505)\d{7,8}$/,
  4188. 'es-PA': /^(\+?507)\d{7,8}$/,
  4189. 'es-PY': /^(\+?595|0)9[9876]\d{7}$/,
  4190. 'es-SV': /^(\+?503)?[67]\d{7}$/,
  4191. 'es-UY': /^(\+598|0)9[1-9][\d]{6}$/,
  4192. 'es-VE': /^(\+?58)?(2|4)\d{9}$/,
  4193. 'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/,
  4194. 'fa-IR': /^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/,
  4195. 'fi-FI': /^(\+?358|0)\s?(4[0-6]|50)\s?(\d\s?){4,8}$/,
  4196. 'fj-FJ': /^(\+?679)?\s?\d{3}\s?\d{4}$/,
  4197. 'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
  4198. 'fr-BF': /^(\+226|0)[67]\d{7}$/,
  4199. 'fr-BJ': /^(\+229)\d{8}$/,
  4200. 'fr-CD': /^(\+?243|0)?(8|9)\d{8}$/,
  4201. 'fr-CM': /^(\+?237)6[0-9]{8}$/,
  4202. 'fr-DJ': /^(?:\+253)?77[6-8]\d{5}$/,
  4203. 'fr-FR': /^(\+?33|0)[67]\d{8}$/,
  4204. 'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/,
  4205. 'fr-GP': /^(\+?590|0|00590)[67]\d{8}$/,
  4206. 'fr-MQ': /^(\+?596|0|00596)[67]\d{8}$/,
  4207. 'fr-PF': /^(\+?689)?8[789]\d{6}$/,
  4208. 'fr-RE': /^(\+?262|0|00262)[67]\d{8}$/,
  4209. 'fr-WF': /^(\+681)?\d{6}$/,
  4210. 'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/,
  4211. 'hu-HU': /^(\+?36|06)(20|30|31|50|70)\d{7}$/,
  4212. 'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/,
  4213. 'ir-IR': /^(\+98|0)?9\d{9}$/,
  4214. 'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/,
  4215. 'it-SM': /^((\+378)|(0549)|(\+390549)|(\+3780549))?6\d{5,9}$/,
  4216. 'ja-JP': /^(\+81[ \-]?(\(0\))?|0)[6789]0[ \-]?\d{4}[ \-]?\d{4}$/,
  4217. 'ka-GE': /^(\+?995)?(79\d{7}|5\d{8})$/,
  4218. 'kk-KZ': /^(\+?7|8)?7\d{9}$/,
  4219. 'kl-GL': /^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
  4220. 'ko-KR': /^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,
  4221. 'ky-KG': /^(\+996\s?)?(22[0-9]|50[0-9]|55[0-9]|70[0-9]|75[0-9]|77[0-9]|880|990|995|996|997|998)\s?\d{3}\s?\d{3}$/,
  4222. 'lt-LT': /^(\+370|8)\d{8}$/,
  4223. 'lv-LV': /^(\+?371)2\d{7}$/,
  4224. 'mg-MG': /^((\+?261|0)(2|3)\d)?\d{7}$/,
  4225. 'mn-MN': /^(\+|00|011)?976(77|81|88|91|94|95|96|99)\d{6}$/,
  4226. 'my-MM': /^(\+?959|09|9)(2[5-7]|3[1-2]|4[0-5]|6[6-9]|7[5-9]|9[6-9])[0-9]{7}$/,
  4227. 'ms-MY': /^(\+?60|0)1(([0145](-|\s)?\d{7,8})|([236-9](-|\s)?\d{7}))$/,
  4228. 'mz-MZ': /^(\+?258)?8[234567]\d{7}$/,
  4229. 'nb-NO': /^(\+?47)?[49]\d{7}$/,
  4230. 'ne-NP': /^(\+?977)?9[78]\d{8}$/,
  4231. 'nl-BE': /^(\+?32|0)4\d{8}$/,
  4232. 'nl-NL': /^(((\+|00)?31\(0\))|((\+|00)?31)|0)6{1}\d{8}$/,
  4233. 'nl-AW': /^(\+)?297(56|59|64|73|74|99)\d{5}$/,
  4234. 'nn-NO': /^(\+?47)?[49]\d{7}$/,
  4235. 'pl-PL': /^(\+?48)? ?([5-8]\d|45) ?\d{3} ?\d{2} ?\d{2}$/,
  4236. '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[1-9]{1}\d{3}\-?\d{4}))$/,
  4237. 'pt-PT': /^(\+?351)?9[1236]\d{7}$/,
  4238. 'pt-AO': /^(\+?244)?9\d{8}$/,
  4239. 'ro-MD': /^(\+?373|0)((6(0|1|2|6|7|8|9))|(7(6|7|8|9)))\d{6}$/,
  4240. 'ro-RO': /^(\+?40|0)\s?7\d{2}(\/|\s|\.|-)?\d{3}(\s|\.|-)?\d{3}$/,
  4241. 'ru-RU': /^(\+?7|8)?9\d{9}$/,
  4242. 'si-LK': /^(?:0|94|\+94)?(7(0|1|2|4|5|6|7|8)( |-)?)\d{7}$/,
  4243. 'sl-SI': /^(\+386\s?|0)(\d{1}\s?\d{3}\s?\d{2}\s?\d{2}|\d{2}\s?\d{3}\s?\d{3})$/,
  4244. 'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
  4245. 'so-SO': /^(\+?252|0)((6[0-9])\d{7}|(7[1-9])\d{7})$/,
  4246. 'sq-AL': /^(\+355|0)6[2-9]\d{7}$/,
  4247. 'sr-RS': /^(\+3816|06)[- \d]{5,9}$/,
  4248. 'sv-SE': /^(\+?46|0)[\s\-]?7[\s\-]?[02369]([\s\-]?\d){7}$/,
  4249. 'tg-TJ': /^(\+?992)?[5][5]\d{7}$/,
  4250. 'th-TH': /^(\+66|66|0)\d{9}$/,
  4251. 'tr-TR': /^(\+?90|0)?5\d{9}$/,
  4252. 'tk-TM': /^(\+993|993|8)\d{8}$/,
  4253. 'uk-UA': /^(\+?38)?0(50|6[36-8]|7[357]|9[1-9])\d{7}$/,
  4254. 'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/,
  4255. 'vi-VN': /^((\+?84)|0)((3([2-9]))|(5([25689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/,
  4256. 'zh-CN': /^((\+|00)86)?(1[3-9]|9[28])\d{9}$/,
  4257. 'zh-TW': /^(\+?886\-?|0)?9\d{8}$/,
  4258. 'dz-BT': /^(\+?975|0)?(17|16|77|02)\d{6}$/,
  4259. 'ar-YE': /^(((\+|00)9677|0?7)[0137]\d{7}|((\+|00)967|0)[1-7]\d{6})$/,
  4260. 'ar-EH': /^(\+?212|0)[\s\-]?(5288|5289)[\s\-]?\d{5}$/,
  4261. 'fa-AF': /^(\+93|0)?(2{1}[0-8]{1}|[3-5]{1}[0-4]{1})(\d{7})$/,
  4262. 'mk-MK': /^(\+?389|0)?((?:2[2-9]\d{6}|(?:3[1-4]|4[2-8])\d{6}|500\d{5}|5[2-9]\d{6}|7[0-9][2-9]\d{5}|8[1-9]\d{6}|800\d{5}|8009\d{4}))$/
  4263. };
  4264. /* eslint-enable max-len */
  4265. // aliases
  4266. phones['en-CA'] = phones['en-US'];
  4267. phones['fr-CA'] = phones['en-CA'];
  4268. phones['fr-BE'] = phones['nl-BE'];
  4269. phones['zh-HK'] = phones['en-HK'];
  4270. phones['zh-MO'] = phones['en-MO'];
  4271. phones['ga-IE'] = phones['en-IE'];
  4272. phones['fr-CH'] = phones['de-CH'];
  4273. phones['it-CH'] = phones['fr-CH'];
  4274. function isMobilePhone(str, locale, options) {
  4275. assertString(str);
  4276. if (options && options.strictMode && !str.startsWith('+')) {
  4277. return false;
  4278. }
  4279. if (Array.isArray(locale)) {
  4280. return locale.some(function (key) {
  4281. // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
  4282. // istanbul ignore else
  4283. if (phones.hasOwnProperty(key)) {
  4284. var phone = phones[key];
  4285. if (phone.test(str)) {
  4286. return true;
  4287. }
  4288. }
  4289. return false;
  4290. });
  4291. } else if (locale in phones) {
  4292. return phones[locale].test(str);
  4293. // alias falsey locale as 'any'
  4294. } else if (!locale || locale === 'any') {
  4295. for (var key in phones) {
  4296. // istanbul ignore else
  4297. if (phones.hasOwnProperty(key)) {
  4298. var phone = phones[key];
  4299. if (phone.test(str)) {
  4300. return true;
  4301. }
  4302. }
  4303. }
  4304. return false;
  4305. }
  4306. throw new Error("Invalid locale '".concat(locale, "'"));
  4307. }
  4308. var locales$5 = Object.keys(phones);
  4309. var eth = /^(0x)[0-9a-f]{40}$/i;
  4310. function isEthereumAddress(str) {
  4311. assertString(str);
  4312. return eth.test(str);
  4313. }
  4314. function currencyRegex(options) {
  4315. var decimal_digits = "\\d{".concat(options.digits_after_decimal[0], "}");
  4316. options.digits_after_decimal.forEach(function (digit, index) {
  4317. if (index !== 0) decimal_digits = "".concat(decimal_digits, "|\\d{").concat(digit, "}");
  4318. });
  4319. var symbol = "(".concat(options.symbol.replace(/\W/, function (m) {
  4320. return "\\".concat(m);
  4321. }), ")").concat(options.require_symbol ? '' : '?'),
  4322. negative = '-?',
  4323. whole_dollar_amount_without_sep = '[1-9]\\d*',
  4324. whole_dollar_amount_with_sep = "[1-9]\\d{0,2}(\\".concat(options.thousands_separator, "\\d{3})*"),
  4325. valid_whole_dollar_amounts = ['0', whole_dollar_amount_without_sep, whole_dollar_amount_with_sep],
  4326. whole_dollar_amount = "(".concat(valid_whole_dollar_amounts.join('|'), ")?"),
  4327. decimal_amount = "(\\".concat(options.decimal_separator, "(").concat(decimal_digits, "))").concat(options.require_decimal ? '' : '?');
  4328. var pattern = whole_dollar_amount + (options.allow_decimal || options.require_decimal ? decimal_amount : '');
  4329. // default is negative sign before symbol, but there are two other options (besides parens)
  4330. if (options.allow_negatives && !options.parens_for_negatives) {
  4331. if (options.negative_sign_after_digits) {
  4332. pattern += negative;
  4333. } else if (options.negative_sign_before_digits) {
  4334. pattern = negative + pattern;
  4335. }
  4336. }
  4337. // South African Rand, for example, uses R 123 (space) and R-123 (no space)
  4338. if (options.allow_negative_sign_placeholder) {
  4339. pattern = "( (?!\\-))?".concat(pattern);
  4340. } else if (options.allow_space_after_symbol) {
  4341. pattern = " ?".concat(pattern);
  4342. } else if (options.allow_space_after_digits) {
  4343. pattern += '( (?!$))?';
  4344. }
  4345. if (options.symbol_after_digits) {
  4346. pattern += symbol;
  4347. } else {
  4348. pattern = symbol + pattern;
  4349. }
  4350. if (options.allow_negatives) {
  4351. if (options.parens_for_negatives) {
  4352. pattern = "(\\(".concat(pattern, "\\)|").concat(pattern, ")");
  4353. } else if (!(options.negative_sign_before_digits || options.negative_sign_after_digits)) {
  4354. pattern = negative + pattern;
  4355. }
  4356. }
  4357. // ensure there's a dollar and/or decimal amount, and that
  4358. // it doesn't start with a space or a negative sign followed by a space
  4359. return new RegExp("^(?!-? )(?=.*\\d)".concat(pattern, "$"));
  4360. }
  4361. var default_currency_options = {
  4362. symbol: '$',
  4363. require_symbol: false,
  4364. allow_space_after_symbol: false,
  4365. symbol_after_digits: false,
  4366. allow_negatives: true,
  4367. parens_for_negatives: false,
  4368. negative_sign_before_digits: false,
  4369. negative_sign_after_digits: false,
  4370. allow_negative_sign_placeholder: false,
  4371. thousands_separator: ',',
  4372. decimal_separator: '.',
  4373. allow_decimal: true,
  4374. require_decimal: false,
  4375. digits_after_decimal: [2],
  4376. allow_space_after_digits: false
  4377. };
  4378. function isCurrency(str, options) {
  4379. assertString(str);
  4380. options = merge(options, default_currency_options);
  4381. return currencyRegex(options).test(str);
  4382. }
  4383. var bech32 = /^(bc1|tb1|bc1p|tb1p)[ac-hj-np-z02-9]{39,58}$/;
  4384. var base58 = /^(1|2|3|m)[A-HJ-NP-Za-km-z1-9]{25,39}$/;
  4385. function isBtcAddress(str) {
  4386. assertString(str);
  4387. return bech32.test(str) || base58.test(str);
  4388. }
  4389. // https://en.wikipedia.org/wiki/ISO_6346
  4390. // according to ISO6346 standard, checksum digit is mandatory for freight container but recommended
  4391. // for other container types (J and Z)
  4392. var isISO6346Str = /^[A-Z]{3}(U[0-9]{7})|([J,Z][0-9]{6,7})$/;
  4393. var isDigit = /^[0-9]$/;
  4394. function isISO6346(str) {
  4395. assertString(str);
  4396. str = str.toUpperCase();
  4397. if (!isISO6346Str.test(str)) return false;
  4398. if (str.length === 11) {
  4399. var sum = 0;
  4400. for (var i = 0; i < str.length - 1; i++) {
  4401. if (!isDigit.test(str[i])) {
  4402. var convertedCode = void 0;
  4403. var letterCode = str.charCodeAt(i) - 55;
  4404. if (letterCode < 11) convertedCode = letterCode;else if (letterCode >= 11 && letterCode <= 20) convertedCode = 12 + letterCode % 11;else if (letterCode >= 21 && letterCode <= 30) convertedCode = 23 + letterCode % 21;else convertedCode = 34 + letterCode % 31;
  4405. sum += convertedCode * Math.pow(2, i);
  4406. } else sum += str[i] * Math.pow(2, i);
  4407. }
  4408. var checkSumDigit = sum % 11;
  4409. if (checkSumDigit === 10) checkSumDigit = 0;
  4410. return Number(str[str.length - 1]) === checkSumDigit;
  4411. }
  4412. return true;
  4413. }
  4414. var isFreightContainerID = isISO6346;
  4415. var isISO6391Set = new Set(['aa', 'ab', 'ae', 'af', 'ak', 'am', 'an', 'ar', 'as', 'av', 'ay', 'az', 'az', 'ba', 'be', 'bg', 'bh', 'bi', 'bm', 'bn', 'bo', 'br', 'bs', 'ca', 'ce', 'ch', 'co', 'cr', 'cs', 'cu', 'cv', 'cy', 'da', 'de', 'dv', 'dz', 'ee', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fa', 'ff', 'fi', 'fj', 'fo', 'fr', 'fy', 'ga', 'gd', 'gl', 'gn', 'gu', 'gv', 'ha', 'he', 'hi', 'ho', 'hr', 'ht', 'hu', 'hy', 'hz', 'ia', 'id', 'ie', 'ig', 'ii', 'ik', 'io', 'is', 'it', 'iu', 'ja', 'jv', 'ka', 'kg', 'ki', 'kj', 'kk', 'kl', 'km', 'kn', 'ko', 'kr', 'ks', 'ku', 'kv', 'kw', 'ky', 'la', 'lb', 'lg', 'li', 'ln', 'lo', 'lt', 'lu', 'lv', 'mg', 'mh', 'mi', 'mk', 'ml', 'mn', 'mr', 'ms', 'mt', 'my', 'na', 'nb', 'nd', 'ne', 'ng', 'nl', 'nn', 'no', 'nr', 'nv', 'ny', 'oc', 'oj', 'om', 'or', 'os', 'pa', 'pi', 'pl', 'ps', 'pt', 'qu', 'rm', 'rn', 'ro', 'ru', 'rw', 'sa', 'sc', 'sd', 'se', 'sg', 'si', 'sk', 'sl', 'sm', 'sn', 'so', 'sq', 'sr', 'ss', 'st', 'su', 'sv', 'sw', 'ta', 'te', 'tg', 'th', 'ti', 'tk', 'tl', 'tn', 'to', 'tr', 'ts', 'tt', 'tw', 'ty', 'ug', 'uk', 'ur', 'uz', 've', 'vi', 'vo', 'wa', 'wo', 'xh', 'yi', 'yo', 'za', 'zh', 'zu']);
  4416. function isISO6391(str) {
  4417. assertString(str);
  4418. return isISO6391Set.has(str);
  4419. }
  4420. /* eslint-disable max-len */
  4421. // from http://goo.gl/0ejHHW
  4422. 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)?)?)?)?$/;
  4423. // same as above, except with a strict 'T' separator between date and time
  4424. 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)?)?)?)?$/;
  4425. /* eslint-enable max-len */
  4426. var isValidDate = function isValidDate(str) {
  4427. // str must have passed the ISO8601 check
  4428. // this check is meant to catch invalid dates
  4429. // like 2009-02-31
  4430. // first check for ordinal dates
  4431. var ordinalMatch = str.match(/^(\d{4})-?(\d{3})([ T]{1}\.*|$)/);
  4432. if (ordinalMatch) {
  4433. var oYear = Number(ordinalMatch[1]);
  4434. var oDay = Number(ordinalMatch[2]);
  4435. // if is leap year
  4436. if (oYear % 4 === 0 && oYear % 100 !== 0 || oYear % 400 === 0) return oDay <= 366;
  4437. return oDay <= 365;
  4438. }
  4439. var match = str.match(/(\d{4})-?(\d{0,2})-?(\d*)/).map(Number);
  4440. var year = match[1];
  4441. var month = match[2];
  4442. var day = match[3];
  4443. var monthString = month ? "0".concat(month).slice(-2) : month;
  4444. var dayString = day ? "0".concat(day).slice(-2) : day;
  4445. // create a date object and compare
  4446. var d = new Date("".concat(year, "-").concat(monthString || '01', "-").concat(dayString || '01'));
  4447. if (month && day) {
  4448. return d.getUTCFullYear() === year && d.getUTCMonth() + 1 === month && d.getUTCDate() === day;
  4449. }
  4450. return true;
  4451. };
  4452. function isISO8601(str) {
  4453. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  4454. assertString(str);
  4455. var check = options.strictSeparator ? iso8601StrictSeparator.test(str) : iso8601.test(str);
  4456. if (check && options.strict) return isValidDate(str);
  4457. return check;
  4458. }
  4459. /* Based on https://tools.ietf.org/html/rfc3339#section-5.6 */
  4460. var dateFullYear = /[0-9]{4}/;
  4461. var dateMonth = /(0[1-9]|1[0-2])/;
  4462. var dateMDay = /([12]\d|0[1-9]|3[01])/;
  4463. var timeHour = /([01][0-9]|2[0-3])/;
  4464. var timeMinute = /[0-5][0-9]/;
  4465. var timeSecond = /([0-5][0-9]|60)/;
  4466. var timeSecFrac = /(\.[0-9]+)?/;
  4467. var timeNumOffset = new RegExp("[-+]".concat(timeHour.source, ":").concat(timeMinute.source));
  4468. var timeOffset = new RegExp("([zZ]|".concat(timeNumOffset.source, ")"));
  4469. var partialTime = new RegExp("".concat(timeHour.source, ":").concat(timeMinute.source, ":").concat(timeSecond.source).concat(timeSecFrac.source));
  4470. var fullDate = new RegExp("".concat(dateFullYear.source, "-").concat(dateMonth.source, "-").concat(dateMDay.source));
  4471. var fullTime = new RegExp("".concat(partialTime.source).concat(timeOffset.source));
  4472. var rfc3339 = new RegExp("^".concat(fullDate.source, "[ tT]").concat(fullTime.source, "$"));
  4473. function isRFC3339(str) {
  4474. assertString(str);
  4475. return rfc3339.test(str);
  4476. }
  4477. // from https://www.unicode.org/iso15924/iso15924-codes.html
  4478. var validISO15924Codes = new Set(['Adlm', 'Afak', 'Aghb', 'Ahom', 'Arab', 'Aran', 'Armi', 'Armn', 'Avst', 'Bali', 'Bamu', 'Bass', 'Batk', 'Beng', 'Bhks', 'Blis', 'Bopo', 'Brah', 'Brai', 'Bugi', 'Buhd', 'Cakm', 'Cans', 'Cari', 'Cham', 'Cher', 'Chis', 'Chrs', 'Cirt', 'Copt', 'Cpmn', 'Cprt', 'Cyrl', 'Cyrs', 'Deva', 'Diak', 'Dogr', 'Dsrt', 'Dupl', 'Egyd', 'Egyh', 'Egyp', 'Elba', 'Elym', 'Ethi', 'Gara', 'Geok', 'Geor', 'Glag', 'Gong', 'Gonm', 'Goth', 'Gran', 'Grek', 'Gujr', 'Gukh', 'Guru', 'Hanb', 'Hang', 'Hani', 'Hano', 'Hans', 'Hant', 'Hatr', 'Hebr', 'Hira', 'Hluw', 'Hmng', 'Hmnp', 'Hrkt', 'Hung', 'Inds', 'Ital', 'Jamo', 'Java', 'Jpan', 'Jurc', 'Kali', 'Kana', 'Kawi', 'Khar', 'Khmr', 'Khoj', 'Kitl', 'Kits', 'Knda', 'Kore', 'Kpel', 'Krai', 'Kthi', 'Lana', 'Laoo', 'Latf', 'Latg', 'Latn', 'Leke', 'Lepc', 'Limb', 'Lina', 'Linb', 'Lisu', 'Loma', 'Lyci', 'Lydi', 'Mahj', 'Maka', 'Mand', 'Mani', 'Marc', 'Maya', 'Medf', 'Mend', 'Merc', 'Mero', 'Mlym', 'Modi', 'Mong', 'Moon', 'Mroo', 'Mtei', 'Mult', 'Mymr', 'Nagm', 'Nand', 'Narb', 'Nbat', 'Newa', 'Nkdb', 'Nkgb', 'Nkoo', 'Nshu', 'Ogam', 'Olck', 'Onao', 'Orkh', 'Orya', 'Osge', 'Osma', 'Ougr', 'Palm', 'Pauc', 'Pcun', 'Pelm', 'Perm', 'Phag', 'Phli', 'Phlp', 'Phlv', 'Phnx', 'Plrd', 'Piqd', 'Prti', 'Psin', 'Qaaa', 'Qaab', 'Qaac', 'Qaad', 'Qaae', 'Qaaf', 'Qaag', 'Qaah', 'Qaai', 'Qaaj', 'Qaak', 'Qaal', 'Qaam', 'Qaan', 'Qaao', 'Qaap', 'Qaaq', 'Qaar', 'Qaas', 'Qaat', 'Qaau', 'Qaav', 'Qaaw', 'Qaax', 'Qaay', 'Qaaz', 'Qaba', 'Qabb', 'Qabc', 'Qabd', 'Qabe', 'Qabf', 'Qabg', 'Qabh', 'Qabi', 'Qabj', 'Qabk', 'Qabl', 'Qabm', 'Qabn', 'Qabo', 'Qabp', 'Qabq', 'Qabr', 'Qabs', 'Qabt', 'Qabu', 'Qabv', 'Qabw', 'Qabx', 'Ranj', 'Rjng', 'Rohg', 'Roro', 'Runr', 'Samr', 'Sara', 'Sarb', 'Saur', 'Sgnw', 'Shaw', 'Shrd', 'Shui', 'Sidd', 'Sidt', 'Sind', 'Sinh', 'Sogd', 'Sogo', 'Sora', 'Soyo', 'Sund', 'Sunu', 'Sylo', 'Syrc', 'Syre', 'Syrj', 'Syrn', 'Tagb', 'Takr', 'Tale', 'Talu', 'Taml', 'Tang', 'Tavt', 'Tayo', 'Telu', 'Teng', 'Tfng', 'Tglg', 'Thaa', 'Thai', 'Tibt', 'Tirh', 'Tnsa', 'Todr', 'Tols', 'Toto', 'Tutg', 'Ugar', 'Vaii', 'Visp', 'Vith', 'Wara', 'Wcho', 'Wole', 'Xpeo', 'Xsux', 'Yezi', 'Yiii', 'Zanb', 'Zinh', 'Zmth', 'Zsye', 'Zsym', 'Zxxx', 'Zyyy', 'Zzzz']);
  4479. function isISO15924(str) {
  4480. assertString(str);
  4481. return validISO15924Codes.has(str);
  4482. }
  4483. // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
  4484. 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']);
  4485. var alpha3CountryCode = /^[a-zA-Z]{3}$/;
  4486. function isISO31661Alpha3(str) {
  4487. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  4488. assertString(str);
  4489. var userAssignedCodes = options.userAssignedCodes;
  4490. var validUserAssignedCodes = (userAssignedCodes || []).reduce(function (accumulator, userAssignedCode) {
  4491. if (alpha3CountryCode.test(userAssignedCode)) {
  4492. accumulator.push(userAssignedCode.toUpperCase());
  4493. }
  4494. return accumulator;
  4495. }, []);
  4496. if (validUserAssignedCodes.includes(str.toUpperCase())) {
  4497. return true;
  4498. }
  4499. return validISO31661Alpha3CountriesCodes.has(str.toUpperCase());
  4500. }
  4501. // from https://en.wikipedia.org/wiki/ISO_3166-1_numeric
  4502. var validISO31661NumericCountriesCodes = new Set(['004', '008', '010', '012', '016', '020', '024', '028', '031', '032', '036', '040', '044', '048', '050', '051', '052', '056', '060', '064', '068', '070', '072', '074', '076', '084', '086', '090', '092', '096', '100', '104', '108', '112', '116', '120', '124', '132', '136', '140', '144', '148', '152', '156', '158', '162', '166', '170', '174', '175', '178', '180', '184', '188', '191', '192', '196', '203', '204', '208', '212', '214', '218', '222', '226', '231', '232', '233', '234', '238', '239', '242', '246', '248', '250', '254', '258', '260', '262', '266', '268', '270', '275', '276', '288', '292', '296', '300', '304', '308', '312', '316', '320', '324', '328', '332', '334', '336', '340', '344', '348', '352', '356', '360', '364', '368', '372', '376', '380', '384', '388', '392', '398', '400', '404', '408', '410', '414', '417', '418', '422', '426', '428', '430', '434', '438', '440', '442', '446', '450', '454', '458', '462', '466', '470', '474', '478', '480', '484', '492', '496', '498', '499', '500', '504', '508', '512', '516', '520', '524', '528', '531', '533', '534', '535', '540', '548', '554', '558', '562', '566', '570', '574', '578', '580', '581', '583', '584', '585', '586', '591', '598', '600', '604', '608', '612', '616', '620', '624', '626', '630', '634', '638', '642', '643', '646', '652', '654', '659', '660', '662', '663', '666', '670', '674', '678', '682', '686', '688', '690', '694', '702', '703', '704', '705', '706', '710', '716', '724', '728', '729', '732', '740', '744', '748', '752', '756', '760', '762', '764', '768', '772', '776', '780', '784', '788', '792', '795', '796', '798', '800', '804', '807', '818', '826', '831', '832', '833', '834', '840', '850', '854', '858', '860', '862', '876', '882', '887', '894']);
  4503. function isISO31661Numeric(str) {
  4504. assertString(str);
  4505. return validISO31661NumericCountriesCodes.has(str);
  4506. }
  4507. // from https://en.wikipedia.org/wiki/ISO_4217
  4508. 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', 'CUP', 'CVE', 'CZK', 'DJF', 'DKK', 'DOP', 'DZD', 'EGP', 'ERN', 'ETB', 'EUR', 'FJD', 'FKP', 'GBP', 'GEL', 'GHS', 'GIP', 'GMD', 'GNF', 'GTQ', 'GYD', 'HKD', 'HNL', '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', 'SLE', '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', 'VED', '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']);
  4509. function isISO4217(str) {
  4510. assertString(str);
  4511. return validISO4217CurrencyCodes.has(str.toUpperCase());
  4512. }
  4513. var base32 = /^[A-Z2-7]+=*$/;
  4514. var crockfordBase32 = /^[A-HJKMNP-TV-Z0-9]+$/;
  4515. var defaultBase32Options = {
  4516. crockford: false
  4517. };
  4518. function isBase32(str, options) {
  4519. assertString(str);
  4520. options = merge(options, defaultBase32Options);
  4521. if (options.crockford) {
  4522. return crockfordBase32.test(str);
  4523. }
  4524. return str.length % 8 === 0 && base32.test(str);
  4525. }
  4526. // Accepted chars - 123456789ABCDEFGH JKLMN PQRSTUVWXYZabcdefghijk mnopqrstuvwxyz
  4527. var base58Reg = /^[A-HJ-NP-Za-km-z1-9]*$/;
  4528. function isBase58(str) {
  4529. assertString(str);
  4530. return base58Reg.test(str);
  4531. }
  4532. var validMediaType = /^[a-z]+\/[a-z0-9\-\+\._]+$/i;
  4533. var validAttribute = /^[a-z\-]+=[a-z0-9\-]+$/i;
  4534. var validData = /^[a-z0-9!\$&'\(\)\*\+,;=\-\._~:@\/\?%\s]*$/i;
  4535. function isDataURI(str) {
  4536. assertString(str);
  4537. var data = str.split(',');
  4538. if (data.length < 2) {
  4539. return false;
  4540. }
  4541. var attributes = data.shift().trim().split(';');
  4542. var schemeAndMediaType = attributes.shift();
  4543. if (schemeAndMediaType.slice(0, 5) !== 'data:') {
  4544. return false;
  4545. }
  4546. var mediaType = schemeAndMediaType.slice(5);
  4547. if (mediaType !== '' && !validMediaType.test(mediaType)) {
  4548. return false;
  4549. }
  4550. for (var i = 0; i < attributes.length; i++) {
  4551. if (!(i === attributes.length - 1 && attributes[i].toLowerCase() === 'base64') && !validAttribute.test(attributes[i])) {
  4552. return false;
  4553. }
  4554. }
  4555. for (var _i = 0; _i < data.length; _i++) {
  4556. if (!validData.test(data[_i])) {
  4557. return false;
  4558. }
  4559. }
  4560. return true;
  4561. }
  4562. var magnetURIComponent = /(?:^magnet:\?|[^?&]&)xt(?:\.1)?=urn:(?:(?:aich|bitprint|btih|ed2k|ed2khash|kzhash|md5|sha1|tree:tiger):[a-z0-9]{32}(?:[a-z0-9]{8})?|btmh:1220[a-z0-9]{64})(?:$|&)/i;
  4563. function isMagnetURI(url) {
  4564. assertString(url);
  4565. if (url.indexOf('magnet:?') !== 0) {
  4566. return false;
  4567. }
  4568. return magnetURIComponent.test(url);
  4569. }
  4570. function rtrim(str, chars) {
  4571. assertString(str);
  4572. if (chars) {
  4573. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
  4574. var pattern = new RegExp("[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+$"), 'g');
  4575. return str.replace(pattern, '');
  4576. }
  4577. // Use a faster and more safe than regex trim method https://blog.stevenlevithan.com/archives/faster-trim-javascript
  4578. var strIndex = str.length - 1;
  4579. while (/\s/.test(str.charAt(strIndex))) {
  4580. strIndex -= 1;
  4581. }
  4582. return str.slice(0, strIndex + 1);
  4583. }
  4584. function ltrim(str, chars) {
  4585. assertString(str);
  4586. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
  4587. var pattern = chars ? new RegExp("^[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+"), 'g') : /^\s+/g;
  4588. return str.replace(pattern, '');
  4589. }
  4590. function trim(str, chars) {
  4591. return rtrim(ltrim(str, chars), chars);
  4592. }
  4593. function parseMailtoQueryString(queryString) {
  4594. var allowedParams = new Set(['subject', 'body', 'cc', 'bcc']),
  4595. query = {
  4596. cc: '',
  4597. bcc: ''
  4598. };
  4599. var isParseFailed = false;
  4600. var queryParams = queryString.split('&');
  4601. if (queryParams.length > 4) {
  4602. return false;
  4603. }
  4604. var _iterator = _createForOfIteratorHelper(queryParams),
  4605. _step;
  4606. try {
  4607. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  4608. var q = _step.value;
  4609. var _q$split = q.split('='),
  4610. _q$split2 = _slicedToArray(_q$split, 2),
  4611. key = _q$split2[0],
  4612. value = _q$split2[1];
  4613. // checked for invalid and duplicated query params
  4614. if (key && !allowedParams.has(key)) {
  4615. isParseFailed = true;
  4616. break;
  4617. }
  4618. if (value && (key === 'cc' || key === 'bcc')) {
  4619. query[key] = value;
  4620. }
  4621. if (key) {
  4622. allowedParams["delete"](key);
  4623. }
  4624. }
  4625. } catch (err) {
  4626. _iterator.e(err);
  4627. } finally {
  4628. _iterator.f();
  4629. }
  4630. return isParseFailed ? false : query;
  4631. }
  4632. function isMailtoURI(url, options) {
  4633. assertString(url);
  4634. if (url.indexOf('mailto:') !== 0) {
  4635. return false;
  4636. }
  4637. var _url$replace$split = url.replace('mailto:', '').split('?'),
  4638. _url$replace$split2 = _slicedToArray(_url$replace$split, 2),
  4639. to = _url$replace$split2[0],
  4640. _url$replace$split2$ = _url$replace$split2[1],
  4641. queryString = _url$replace$split2$ === void 0 ? '' : _url$replace$split2$;
  4642. if (!to && !queryString) {
  4643. return true;
  4644. }
  4645. var query = parseMailtoQueryString(queryString);
  4646. if (!query) {
  4647. return false;
  4648. }
  4649. return "".concat(to, ",").concat(query.cc, ",").concat(query.bcc).split(',').every(function (email) {
  4650. email = trim(email, ' ');
  4651. if (email) {
  4652. return isEmail(email, options);
  4653. }
  4654. return true;
  4655. });
  4656. }
  4657. /*
  4658. Checks if the provided string matches to a correct Media type format (MIME type)
  4659. This function only checks is the string format follows the
  4660. established rules by the according RFC specifications.
  4661. This function supports 'charset' in textual media types
  4662. (https://tools.ietf.org/html/rfc6657).
  4663. This function does not check against all the media types listed
  4664. by the IANA (https://www.iana.org/assignments/media-types/media-types.xhtml)
  4665. because of lightness purposes : it would require to include
  4666. all these MIME types in this library, which would weigh it
  4667. significantly. This kind of effort maybe is not worth for the use that
  4668. this function has in this entire library.
  4669. More information in the RFC specifications :
  4670. - https://tools.ietf.org/html/rfc2045
  4671. - https://tools.ietf.org/html/rfc2046
  4672. - https://tools.ietf.org/html/rfc7231#section-3.1.1.1
  4673. - https://tools.ietf.org/html/rfc7231#section-3.1.1.5
  4674. */
  4675. // Match simple MIME types
  4676. // NB :
  4677. // Subtype length must not exceed 100 characters.
  4678. // This rule does not comply to the RFC specs (what is the max length ?).
  4679. var mimeTypeSimple = /^(application|audio|font|image|message|model|multipart|text|video)\/[a-zA-Z0-9\.\-\+_]{1,100}$/i; // eslint-disable-line max-len
  4680. // Handle "charset" in "text/*"
  4681. 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
  4682. // Handle "boundary" in "multipart/*"
  4683. 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
  4684. function isMimeType(str) {
  4685. assertString(str);
  4686. return mimeTypeSimple.test(str) || mimeTypeText.test(str) || mimeTypeMultipart.test(str);
  4687. }
  4688. var lat = /^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/;
  4689. var _long = /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/;
  4690. var latDMS = /^(([1-8]?\d)\D+([1-5]?\d|60)\D+([1-5]?\d|60)(\.\d+)?|90\D+0\D+0)\D+[NSns]?$/i;
  4691. 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;
  4692. var defaultLatLongOptions = {
  4693. checkDMS: false
  4694. };
  4695. function isLatLong(str, options) {
  4696. assertString(str);
  4697. options = merge(options, defaultLatLongOptions);
  4698. if (!includes(str, ',')) return false;
  4699. var pair = str.split(',');
  4700. if (pair[0].startsWith('(') && !pair[1].endsWith(')') || pair[1].endsWith(')') && !pair[0].startsWith('(')) return false;
  4701. if (options.checkDMS) {
  4702. return latDMS.test(pair[0]) && longDMS.test(pair[1]);
  4703. }
  4704. return lat.test(pair[0]) && _long.test(pair[1]);
  4705. }
  4706. // common patterns
  4707. var threeDigit = /^\d{3}$/;
  4708. var fourDigit = /^\d{4}$/;
  4709. var fiveDigit = /^\d{5}$/;
  4710. var sixDigit = /^\d{6}$/;
  4711. var patterns = {
  4712. AD: /^AD\d{3}$/,
  4713. AT: fourDigit,
  4714. AU: fourDigit,
  4715. AZ: /^AZ\d{4}$/,
  4716. BA: /^([7-8]\d{4}$)/,
  4717. BD: /^([1-8][0-9]{3}|9[0-4][0-9]{2})$/,
  4718. BE: fourDigit,
  4719. BG: fourDigit,
  4720. BR: /^\d{5}-?\d{3}$/,
  4721. BY: /^2[1-4]\d{4}$/,
  4722. CA: /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,
  4723. CH: fourDigit,
  4724. 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}$/,
  4725. CO: /^(05|08|11|13|15|17|18|19|20|23|25|27|41|44|47|50|52|54|63|66|68|70|73|76|81|85|86|88|91|94|95|97|99)(\d{4})$/,
  4726. CZ: /^\d{3}\s?\d{2}$/,
  4727. DE: fiveDigit,
  4728. DK: fourDigit,
  4729. DO: fiveDigit,
  4730. DZ: fiveDigit,
  4731. EE: fiveDigit,
  4732. ES: /^(5[0-2]{1}|[0-4]{1}\d{1})\d{3}$/,
  4733. FI: fiveDigit,
  4734. FR: /^(?:(?:0[1-9]|[1-8]\d|9[0-5])\d{3}|97[1-46]\d{2})$/,
  4735. GB: /^(gir\s?0aa|[a-z]{1,2}\d[\da-z]?\s?(\d[a-z]{2})?)$/i,
  4736. GR: /^\d{3}\s?\d{2}$/,
  4737. HR: /^([1-5]\d{4}$)/,
  4738. HT: /^HT\d{4}$/,
  4739. HU: fourDigit,
  4740. ID: fiveDigit,
  4741. IE: /^(?!.*(?:o))[A-Za-z]\d[\dw]\s\w{4}$/i,
  4742. IL: /^(\d{5}|\d{7})$/,
  4743. IN: /^((?!10|29|35|54|55|65|66|86|87|88|89)[1-9][0-9]{5})$/,
  4744. IR: /^(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}$/,
  4745. IS: threeDigit,
  4746. IT: fiveDigit,
  4747. JP: /^\d{3}\-\d{4}$/,
  4748. KE: fiveDigit,
  4749. KR: /^(\d{5}|\d{6})$/,
  4750. LI: /^(948[5-9]|949[0-7])$/,
  4751. LT: /^LT\-\d{5}$/,
  4752. LU: fourDigit,
  4753. LV: /^LV\-\d{4}$/,
  4754. LK: fiveDigit,
  4755. MC: /^980\d{2}$/,
  4756. MG: threeDigit,
  4757. MX: fiveDigit,
  4758. MT: /^[A-Za-z]{3}\s{0,1}\d{4}$/,
  4759. MY: fiveDigit,
  4760. NL: /^[1-9]\d{3}\s?(?!sa|sd|ss)[a-z]{2}$/i,
  4761. NO: fourDigit,
  4762. NP: /^(10|21|22|32|33|34|44|45|56|57)\d{3}$|^(977)$/i,
  4763. NZ: fourDigit,
  4764. // https://www.pakpost.gov.pk/postcodes.php
  4765. PK: fiveDigit,
  4766. PL: /^\d{2}\-\d{3}$/,
  4767. PR: /^00[679]\d{2}([ -]\d{4})?$/,
  4768. PT: /^\d{4}\-\d{3}?$/,
  4769. RO: sixDigit,
  4770. RU: sixDigit,
  4771. SA: fiveDigit,
  4772. SE: /^[1-9]\d{2}\s?\d{2}$/,
  4773. SG: sixDigit,
  4774. SI: fourDigit,
  4775. SK: /^\d{3}\s?\d{2}$/,
  4776. TH: fiveDigit,
  4777. TN: fourDigit,
  4778. TW: /^\d{3}(\d{2,3})?$/,
  4779. UA: fiveDigit,
  4780. US: /^\d{5}(-\d{4})?$/,
  4781. ZA: fourDigit,
  4782. ZM: fiveDigit
  4783. };
  4784. var locales$6 = Object.keys(patterns);
  4785. function isPostalCode(str, locale) {
  4786. assertString(str);
  4787. if (locale in patterns) {
  4788. return patterns[locale].test(str);
  4789. } else if (locale === 'any') {
  4790. for (var key in patterns) {
  4791. // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
  4792. // istanbul ignore else
  4793. if (patterns.hasOwnProperty(key)) {
  4794. var pattern = patterns[key];
  4795. if (pattern.test(str)) {
  4796. return true;
  4797. }
  4798. }
  4799. }
  4800. return false;
  4801. }
  4802. throw new Error("Invalid locale '".concat(locale, "'"));
  4803. }
  4804. function escape(str) {
  4805. assertString(str);
  4806. 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;');
  4807. }
  4808. function unescape(str) {
  4809. assertString(str);
  4810. 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, '&');
  4811. // &amp; replacement has to be the last one to prevent
  4812. // bugs with intermediate strings containing escape sequences
  4813. // See: https://github.com/validatorjs/validator.js/issues/1827
  4814. }
  4815. function blacklist$1(str, chars) {
  4816. assertString(str);
  4817. return str.replace(new RegExp("[".concat(chars, "]+"), 'g'), '');
  4818. }
  4819. function stripLow(str, keep_new_lines) {
  4820. assertString(str);
  4821. var chars = keep_new_lines ? '\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F' : '\\x00-\\x1F\\x7F';
  4822. return blacklist$1(str, chars);
  4823. }
  4824. function whitelist(str, chars) {
  4825. assertString(str);
  4826. return str.replace(new RegExp("[^".concat(chars, "]+"), 'g'), '');
  4827. }
  4828. function isWhitelisted(str, chars) {
  4829. assertString(str);
  4830. for (var i = str.length - 1; i >= 0; i--) {
  4831. if (chars.indexOf(str[i]) === -1) {
  4832. return false;
  4833. }
  4834. }
  4835. return true;
  4836. }
  4837. var default_normalize_email_options = {
  4838. // The following options apply to all email addresses
  4839. // Lowercases the local part of the email address.
  4840. // Please note this may violate RFC 5321 as per http://stackoverflow.com/a/9808332/192024).
  4841. // The domain is always lowercased, as per RFC 1035
  4842. all_lowercase: true,
  4843. // The following conversions are specific to GMail
  4844. // Lowercases the local part of the GMail address (known to be case-insensitive)
  4845. gmail_lowercase: true,
  4846. // Removes dots from the local part of the email address, as that's ignored by GMail
  4847. gmail_remove_dots: true,
  4848. // Removes the subaddress (e.g. "+foo") from the email address
  4849. gmail_remove_subaddress: true,
  4850. // Conversts the googlemail.com domain to gmail.com
  4851. gmail_convert_googlemaildotcom: true,
  4852. // The following conversions are specific to Outlook.com / Windows Live / Hotmail
  4853. // Lowercases the local part of the Outlook.com address (known to be case-insensitive)
  4854. outlookdotcom_lowercase: true,
  4855. // Removes the subaddress (e.g. "+foo") from the email address
  4856. outlookdotcom_remove_subaddress: true,
  4857. // The following conversions are specific to Yahoo
  4858. // Lowercases the local part of the Yahoo address (known to be case-insensitive)
  4859. yahoo_lowercase: true,
  4860. // Removes the subaddress (e.g. "-foo") from the email address
  4861. yahoo_remove_subaddress: true,
  4862. // The following conversions are specific to Yandex
  4863. // Lowercases the local part of the Yandex address (known to be case-insensitive)
  4864. yandex_lowercase: true,
  4865. // all yandex domains are equal, this explicitly sets the domain to 'yandex.ru'
  4866. yandex_convert_yandexru: true,
  4867. // The following conversions are specific to iCloud
  4868. // Lowercases the local part of the iCloud address (known to be case-insensitive)
  4869. icloud_lowercase: true,
  4870. // Removes the subaddress (e.g. "+foo") from the email address
  4871. icloud_remove_subaddress: true
  4872. };
  4873. // List of domains used by iCloud
  4874. var icloud_domains = ['icloud.com', 'me.com'];
  4875. // List of domains used by Outlook.com and its predecessors
  4876. // This list is likely incomplete.
  4877. // Partial reference:
  4878. // https://blogs.office.com/2013/04/17/outlook-com-gets-two-step-verification-sign-in-by-alias-and-new-international-domains/
  4879. 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'];
  4880. // List of domains used by Yahoo Mail
  4881. // This list is likely incomplete
  4882. var yahoo_domains = ['rocketmail.com', 'yahoo.ca', 'yahoo.co.uk', 'yahoo.com', 'yahoo.de', 'yahoo.fr', 'yahoo.in', 'yahoo.it', 'ymail.com'];
  4883. // List of domains used by yandex.ru
  4884. var yandex_domains = ['yandex.ru', 'yandex.ua', 'yandex.kz', 'yandex.com', 'yandex.by', 'ya.ru'];
  4885. // replace single dots, but not multiple consecutive dots
  4886. function dotsReplacer(match) {
  4887. if (match.length > 1) {
  4888. return match;
  4889. }
  4890. return '';
  4891. }
  4892. function normalizeEmail(email, options) {
  4893. options = merge(options, default_normalize_email_options);
  4894. var raw_parts = email.split('@');
  4895. var domain = raw_parts.pop();
  4896. var user = raw_parts.join('@');
  4897. var parts = [user, domain];
  4898. // The domain is always lowercased, as it's case-insensitive per RFC 1035
  4899. parts[1] = parts[1].toLowerCase();
  4900. if (parts[1] === 'gmail.com' || parts[1] === 'googlemail.com') {
  4901. // Address is GMail
  4902. if (options.gmail_remove_subaddress) {
  4903. parts[0] = parts[0].split('+')[0];
  4904. }
  4905. if (options.gmail_remove_dots) {
  4906. // this does not replace consecutive dots like example..email@gmail.com
  4907. parts[0] = parts[0].replace(/\.+/g, dotsReplacer);
  4908. }
  4909. if (!parts[0].length) {
  4910. return false;
  4911. }
  4912. if (options.all_lowercase || options.gmail_lowercase) {
  4913. parts[0] = parts[0].toLowerCase();
  4914. }
  4915. parts[1] = options.gmail_convert_googlemaildotcom ? 'gmail.com' : parts[1];
  4916. } else if (icloud_domains.indexOf(parts[1]) >= 0) {
  4917. // Address is iCloud
  4918. if (options.icloud_remove_subaddress) {
  4919. parts[0] = parts[0].split('+')[0];
  4920. }
  4921. if (!parts[0].length) {
  4922. return false;
  4923. }
  4924. if (options.all_lowercase || options.icloud_lowercase) {
  4925. parts[0] = parts[0].toLowerCase();
  4926. }
  4927. } else if (outlookdotcom_domains.indexOf(parts[1]) >= 0) {
  4928. // Address is Outlook.com
  4929. if (options.outlookdotcom_remove_subaddress) {
  4930. parts[0] = parts[0].split('+')[0];
  4931. }
  4932. if (!parts[0].length) {
  4933. return false;
  4934. }
  4935. if (options.all_lowercase || options.outlookdotcom_lowercase) {
  4936. parts[0] = parts[0].toLowerCase();
  4937. }
  4938. } else if (yahoo_domains.indexOf(parts[1]) >= 0) {
  4939. // Address is Yahoo
  4940. if (options.yahoo_remove_subaddress) {
  4941. var components = parts[0].split('-');
  4942. parts[0] = components.length > 1 ? components.slice(0, -1).join('-') : components[0];
  4943. }
  4944. if (!parts[0].length) {
  4945. return false;
  4946. }
  4947. if (options.all_lowercase || options.yahoo_lowercase) {
  4948. parts[0] = parts[0].toLowerCase();
  4949. }
  4950. } else if (yandex_domains.indexOf(parts[1]) >= 0) {
  4951. if (options.all_lowercase || options.yandex_lowercase) {
  4952. parts[0] = parts[0].toLowerCase();
  4953. }
  4954. parts[1] = options.yandex_convert_yandexru ? 'yandex.ru' : parts[1];
  4955. } else if (options.all_lowercase) {
  4956. // Any other address
  4957. parts[0] = parts[0].toLowerCase();
  4958. }
  4959. return parts.join('@');
  4960. }
  4961. var charsetRegex = /^[a-z0-9](?!.*[-_]{2,})(?:[a-z0-9_-]*[a-z0-9])?$/;
  4962. function isSlug(str) {
  4963. assertString(str);
  4964. return charsetRegex.test(str);
  4965. }
  4966. var validators$1 = {
  4967. 'cs-CZ': function csCZ(str) {
  4968. return /^(([ABCDEFHIJKLMNPRSTUVXYZ]|[0-9])-?){5,8}$/.test(str);
  4969. },
  4970. 'de-DE': function deDE(str) {
  4971. return /^((A|AA|AB|AC|AE|AH|AK|AM|AN|AÖ|AP|AS|AT|AU|AW|AZ|B|BA|BB|BC|BE|BF|BH|BI|BK|BL|BM|BN|BO|BÖ|BS|BT|BZ|C|CA|CB|CE|CO|CR|CW|D|DA|DD|DE|DH|DI|DL|DM|DN|DO|DU|DW|DZ|E|EA|EB|ED|EE|EF|EG|EH|EI|EL|EM|EN|ER|ES|EU|EW|F|FB|FD|FF|FG|FI|FL|FN|FO|FR|FS|FT|FÜ|FW|FZ|G|GA|GC|GD|GE|GF|GG|GI|GK|GL|GM|GN|GÖ|GP|GR|GS|GT|GÜ|GV|GW|GZ|H|HA|HB|HC|HD|HE|HF|HG|HH|HI|HK|HL|HM|HN|HO|HP|HR|HS|HU|HV|HX|HY|HZ|IK|IL|IN|IZ|J|JE|JL|K|KA|KB|KC|KE|KF|KG|KH|KI|KK|KL|KM|KN|KO|KR|KS|KT|KU|KW|KY|L|LA|LB|LC|LD|LF|LG|LH|LI|LL|LM|LN|LÖ|LP|LR|LU|M|MA|MB|MC|MD|ME|MG|MH|MI|MK|ML|MM|MN|MO|MQ|MR|MS|MÜ|MW|MY|MZ|N|NB|ND|NE|NF|NH|NI|NK|NM|NÖ|NP|NR|NT|NU|NW|NY|NZ|OA|OB|OC|OD|OE|OF|OG|OH|OK|OL|OP|OS|OZ|P|PA|PB|PE|PF|PI|PL|PM|PN|PR|PS|PW|PZ|R|RA|RC|RD|RE|RG|RH|RI|RL|RM|RN|RO|RP|RS|RT|RU|RV|RW|RZ|S|SB|SC|SE|SG|SI|SK|SL|SM|SN|SO|SP|SR|ST|SU|SW|SY|SZ|TE|TF|TG|TO|TP|TR|TS|TT|TÜ|ÜB|UE|UH|UL|UM|UN|V|VB|VG|VK|VR|VS|W|WA|WB|WE|WF|WI|WK|WL|WM|WN|WO|WR|WS|WT|WÜ|WW|WZ|Z|ZE|ZI|ZP|ZR|ZW|ZZ)[- ]?[A-Z]{1,2}[- ]?\d{1,4}|(ABG|ABI|AIB|AIC|ALF|ALZ|ANA|ANG|ANK|APD|ARN|ART|ASL|ASZ|AUR|AZE|BAD|BAR|BBG|BCH|BED|BER|BGD|BGL|BID|BIN|BIR|BIT|BIW|BKS|BLB|BLK|BNA|BOG|BOH|BOR|BOT|BRA|BRB|BRG|BRK|BRL|BRV|BSB|BSK|BTF|BÜD|BUL|BÜR|BÜS|BÜZ|CAS|CHA|CLP|CLZ|COC|COE|CUX|DAH|DAN|DAU|DBR|DEG|DEL|DGF|DIL|DIN|DIZ|DKB|DLG|DON|DUD|DÜW|EBE|EBN|EBS|ECK|EIC|EIL|EIN|EIS|EMD|EMS|ERB|ERH|ERK|ERZ|ESB|ESW|FDB|FDS|FEU|FFB|FKB|FLÖ|FOR|FRG|FRI|FRW|FTL|FÜS|GAN|GAP|GDB|GEL|GEO|GER|GHA|GHC|GLA|GMN|GNT|GOA|GOH|GRA|GRH|GRI|GRM|GRZ|GTH|GUB|GUN|GVM|HAB|HAL|HAM|HAS|HBN|HBS|HCH|HDH|HDL|HEB|HEF|HEI|HER|HET|HGN|HGW|HHM|HIG|HIP|HMÜ|HOG|HOH|HOL|HOM|HOR|HÖS|HOT|HRO|HSK|HST|HVL|HWI|IGB|ILL|JÜL|KEH|KEL|KEM|KIB|KLE|KLZ|KÖN|KÖT|KÖZ|KRU|KÜN|KUS|KYF|LAN|LAU|LBS|LBZ|LDK|LDS|LEO|LER|LEV|LIB|LIF|LIP|LÖB|LOS|LRO|LSZ|LÜN|LUP|LWL|MAB|MAI|MAK|MAL|MED|MEG|MEI|MEK|MEL|MER|MET|MGH|MGN|MHL|MIL|MKK|MOD|MOL|MON|MOS|MSE|MSH|MSP|MST|MTK|MTL|MÜB|MÜR|MYK|MZG|NAB|NAI|NAU|NDH|NEA|NEB|NEC|NEN|NES|NEW|NMB|NMS|NOH|NOL|NOM|NOR|NVP|NWM|OAL|OBB|OBG|OCH|OHA|ÖHR|OHV|OHZ|OPR|OSL|OVI|OVL|OVP|PAF|PAN|PAR|PCH|PEG|PIR|PLÖ|PRÜ|QFT|QLB|RDG|REG|REH|REI|RID|RIE|ROD|ROF|ROK|ROL|ROS|ROT|ROW|RSL|RÜD|RÜG|SAB|SAD|SAN|SAW|SBG|SBK|SCZ|SDH|SDL|SDT|SEB|SEE|SEF|SEL|SFB|SFT|SGH|SHA|SHG|SHK|SHL|SIG|SIM|SLE|SLF|SLK|SLN|SLS|SLÜ|SLZ|SMÜ|SOB|SOG|SOK|SÖM|SON|SPB|SPN|SRB|SRO|STA|STB|STD|STE|STL|SUL|SÜW|SWA|SZB|TBB|TDO|TET|TIR|TÖL|TUT|UEM|UER|UFF|USI|VAI|VEC|VER|VIB|VIE|VIT|VOH|WAF|WAK|WAN|WAR|WAT|WBS|WDA|WEL|WEN|WER|WES|WHV|WIL|WIS|WIT|WIZ|WLG|WMS|WND|WOB|WOH|WOL|WOR|WOS|WRN|WSF|WST|WSW|WTL|WTM|WUG|WÜM|WUN|WUR|WZL|ZEL|ZIG)[- ]?(([A-Z][- ]?\d{1,4})|([A-Z]{2}[- ]?\d{1,3})))[- ]?(E|H)?$/.test(str);
  4972. },
  4973. 'de-LI': function deLI(str) {
  4974. return /^FL[- ]?\d{1,5}[UZ]?$/.test(str);
  4975. },
  4976. 'en-IN': function enIN(str) {
  4977. return /^[A-Z]{2}[ -]?[0-9]{1,2}(?:[ -]?[A-Z])(?:[ -]?[A-Z]*)?[ -]?[0-9]{4}$/.test(str);
  4978. },
  4979. 'en-SG': function enSG(str) {
  4980. return /^[A-Z]{3}[ -]?[\d]{4}[ -]?[A-Z]{1}$/.test(str);
  4981. },
  4982. 'es-AR': function esAR(str) {
  4983. return /^(([A-Z]{2} ?[0-9]{3} ?[A-Z]{2})|([A-Z]{3} ?[0-9]{3}))$/.test(str);
  4984. },
  4985. 'fi-FI': function fiFI(str) {
  4986. return /^(?=.{4,7})(([A-Z]{1,3}|[0-9]{1,3})[\s-]?([A-Z]{1,3}|[0-9]{1,5}))$/.test(str);
  4987. },
  4988. 'hu-HU': function huHU(str) {
  4989. return /^((((?!AAA)(([A-NPRSTVZWXY]{1})([A-PR-Z]{1})([A-HJ-NPR-Z]))|(A[ABC]I)|A[ABC]O|A[A-W]Q|BPI|BPO|UCO|UDO|XAO)-(?!000)\d{3})|(M\d{6})|((CK|DT|CD|HC|H[ABEFIKLMNPRSTVX]|MA|OT|R[A-Z]) \d{2}-\d{2})|(CD \d{3}-\d{3})|(C-(C|X) \d{4})|(X-(A|B|C) \d{4})|(([EPVZ]-\d{5}))|(S A[A-Z]{2} \d{2})|(SP \d{2}-\d{2}))$/.test(str);
  4990. },
  4991. 'pt-BR': function ptBR(str) {
  4992. return /^[A-Z]{3}[ -]?[0-9][A-Z][0-9]{2}|[A-Z]{3}[ -]?[0-9]{4}$/.test(str);
  4993. },
  4994. 'pt-PT': function ptPT(str) {
  4995. return /^(([A-Z]{2}[ -·]?[0-9]{2}[ -·]?[0-9]{2})|([0-9]{2}[ -·]?[A-Z]{2}[ -·]?[0-9]{2})|([0-9]{2}[ -·]?[0-9]{2}[ -·]?[A-Z]{2})|([A-Z]{2}[ -·]?[0-9]{2}[ -·]?[A-Z]{2}))$/.test(str);
  4996. },
  4997. 'sq-AL': function sqAL(str) {
  4998. return /^[A-Z]{2}[- ]?((\d{3}[- ]?(([A-Z]{2})|T))|(R[- ]?\d{3}))$/.test(str);
  4999. },
  5000. 'sv-SE': function svSE(str) {
  5001. return /^[A-HJ-PR-UW-Z]{3} ?[\d]{2}[A-HJ-PR-UW-Z1-9]$|(^[A-ZÅÄÖ ]{2,7}$)/.test(str.trim());
  5002. },
  5003. 'en-PK': function enPK(str) {
  5004. return /(^[A-Z]{2}((\s|-){0,1})[0-9]{3,4}((\s|-)[0-9]{2}){0,1}$)|(^[A-Z]{3}((\s|-){0,1})[0-9]{3,4}((\s|-)[0-9]{2}){0,1}$)|(^[A-Z]{4}((\s|-){0,1})[0-9]{3,4}((\s|-)[0-9]{2}){0,1}$)|(^[A-Z]((\s|-){0,1})[0-9]{4}((\s|-)[0-9]{2}){0,1}$)/.test(str.trim());
  5005. }
  5006. };
  5007. function isLicensePlate(str, locale) {
  5008. assertString(str);
  5009. if (locale in validators$1) {
  5010. return validators$1[locale](str);
  5011. } else if (locale === 'any') {
  5012. for (var key in validators$1) {
  5013. /* eslint guard-for-in: 0 */
  5014. var validator = validators$1[key];
  5015. if (validator(str)) {
  5016. return true;
  5017. }
  5018. }
  5019. return false;
  5020. }
  5021. throw new Error("Invalid locale '".concat(locale, "'"));
  5022. }
  5023. var upperCaseRegex = /^[A-Z]$/;
  5024. var lowerCaseRegex = /^[a-z]$/;
  5025. var numberRegex = /^[0-9]$/;
  5026. var symbolRegex = /^[-#!$@£%^&*()_+|~=`{}\[\]:";'<>?,.\/\\ ]$/;
  5027. var defaultOptions$1 = {
  5028. minLength: 8,
  5029. minLowercase: 1,
  5030. minUppercase: 1,
  5031. minNumbers: 1,
  5032. minSymbols: 1,
  5033. returnScore: false,
  5034. pointsPerUnique: 1,
  5035. pointsPerRepeat: 0.5,
  5036. pointsForContainingLower: 10,
  5037. pointsForContainingUpper: 10,
  5038. pointsForContainingNumber: 10,
  5039. pointsForContainingSymbol: 10
  5040. };
  5041. /* Counts number of occurrences of each char in a string
  5042. * could be moved to util/ ?
  5043. */
  5044. function countChars(str) {
  5045. var result = {};
  5046. Array.from(str).forEach(function (_char) {
  5047. var curVal = result[_char];
  5048. if (curVal) {
  5049. result[_char] += 1;
  5050. } else {
  5051. result[_char] = 1;
  5052. }
  5053. });
  5054. return result;
  5055. }
  5056. /* Return information about a password */
  5057. function analyzePassword(password) {
  5058. var charMap = countChars(password);
  5059. var analysis = {
  5060. length: password.length,
  5061. uniqueChars: Object.keys(charMap).length,
  5062. uppercaseCount: 0,
  5063. lowercaseCount: 0,
  5064. numberCount: 0,
  5065. symbolCount: 0
  5066. };
  5067. Object.keys(charMap).forEach(function (_char2) {
  5068. /* istanbul ignore else */
  5069. if (upperCaseRegex.test(_char2)) {
  5070. analysis.uppercaseCount += charMap[_char2];
  5071. } else if (lowerCaseRegex.test(_char2)) {
  5072. analysis.lowercaseCount += charMap[_char2];
  5073. } else if (numberRegex.test(_char2)) {
  5074. analysis.numberCount += charMap[_char2];
  5075. } else if (symbolRegex.test(_char2)) {
  5076. analysis.symbolCount += charMap[_char2];
  5077. }
  5078. });
  5079. return analysis;
  5080. }
  5081. function scorePassword(analysis, scoringOptions) {
  5082. var points = 0;
  5083. points += analysis.uniqueChars * scoringOptions.pointsPerUnique;
  5084. points += (analysis.length - analysis.uniqueChars) * scoringOptions.pointsPerRepeat;
  5085. if (analysis.lowercaseCount > 0) {
  5086. points += scoringOptions.pointsForContainingLower;
  5087. }
  5088. if (analysis.uppercaseCount > 0) {
  5089. points += scoringOptions.pointsForContainingUpper;
  5090. }
  5091. if (analysis.numberCount > 0) {
  5092. points += scoringOptions.pointsForContainingNumber;
  5093. }
  5094. if (analysis.symbolCount > 0) {
  5095. points += scoringOptions.pointsForContainingSymbol;
  5096. }
  5097. return points;
  5098. }
  5099. function isStrongPassword(str) {
  5100. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5101. assertString(str);
  5102. var analysis = analyzePassword(str);
  5103. options = merge(options || {}, defaultOptions$1);
  5104. if (options.returnScore) {
  5105. return scorePassword(analysis, options);
  5106. }
  5107. return analysis.length >= options.minLength && analysis.lowercaseCount >= options.minLowercase && analysis.uppercaseCount >= options.minUppercase && analysis.numberCount >= options.minNumbers && analysis.symbolCount >= options.minSymbols;
  5108. }
  5109. var AU = function AU(str) {
  5110. var match = str.match(/^(AU)?(\d{11})$/);
  5111. if (!match) {
  5112. return false;
  5113. }
  5114. // @see {@link https://abr.business.gov.au/Help/AbnFormat}
  5115. var weights = [10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19];
  5116. str = str.replace(/^AU/, '');
  5117. var ABN = (parseInt(str.slice(0, 1), 10) - 1).toString() + str.slice(1);
  5118. var total = 0;
  5119. for (var i = 0; i < 11; i++) {
  5120. total += weights[i] * ABN.charAt(i);
  5121. }
  5122. return total !== 0 && total % 89 === 0;
  5123. };
  5124. var CH = function CH(str) {
  5125. // @see {@link https://www.ech.ch/de/ech/ech-0097/5.2.0}
  5126. var hasValidCheckNumber = function hasValidCheckNumber(digits) {
  5127. var lastDigit = digits.pop(); // used as check number
  5128. var weights = [5, 4, 3, 2, 7, 6, 5, 4];
  5129. var calculatedCheckNumber = (11 - digits.reduce(function (acc, el, idx) {
  5130. return acc + el * weights[idx];
  5131. }, 0) % 11) % 11;
  5132. return lastDigit === calculatedCheckNumber;
  5133. };
  5134. // @see {@link https://www.estv.admin.ch/estv/de/home/mehrwertsteuer/uid/mwst-uid-nummer.html}
  5135. return /^(CHE[- ]?)?(\d{9}|(\d{3}\.\d{3}\.\d{3})|(\d{3} \d{3} \d{3})) ?(TVA|MWST|IVA)?$/.test(str) && hasValidCheckNumber(str.match(/\d/g).map(function (el) {
  5136. return +el;
  5137. }));
  5138. };
  5139. var PT = function PT(str) {
  5140. var match = str.match(/^(PT)?(\d{9})$/);
  5141. if (!match) {
  5142. return false;
  5143. }
  5144. var tin = match[2];
  5145. var checksum = 11 - reverseMultiplyAndSum(tin.split('').slice(0, 8).map(function (a) {
  5146. return parseInt(a, 10);
  5147. }), 9) % 11;
  5148. if (checksum > 9) {
  5149. return parseInt(tin[8], 10) === 0;
  5150. }
  5151. return checksum === parseInt(tin[8], 10);
  5152. };
  5153. var vatMatchers = {
  5154. /**
  5155. * European Union VAT identification numbers
  5156. */
  5157. AT: function AT(str) {
  5158. return /^(AT)?U\d{8}$/.test(str);
  5159. },
  5160. BE: function BE(str) {
  5161. return /^(BE)?\d{10}$/.test(str);
  5162. },
  5163. BG: function BG(str) {
  5164. return /^(BG)?\d{9,10}$/.test(str);
  5165. },
  5166. HR: function HR(str) {
  5167. return /^(HR)?\d{11}$/.test(str);
  5168. },
  5169. CY: function CY(str) {
  5170. return /^(CY)?\w{9}$/.test(str);
  5171. },
  5172. CZ: function CZ(str) {
  5173. return /^(CZ)?\d{8,10}$/.test(str);
  5174. },
  5175. DK: function DK(str) {
  5176. return /^(DK)?\d{8}$/.test(str);
  5177. },
  5178. EE: function EE(str) {
  5179. return /^(EE)?\d{9}$/.test(str);
  5180. },
  5181. FI: function FI(str) {
  5182. return /^(FI)?\d{8}$/.test(str);
  5183. },
  5184. FR: function FR(str) {
  5185. return /^(FR)([A-Z0-9]{2}\d{9})$/.test(str);
  5186. },
  5187. DE: function DE(str) {
  5188. return /^(DE)?\d{9}$/.test(str);
  5189. },
  5190. EL: function EL(str) {
  5191. return /^(EL)?\d{9}$/.test(str);
  5192. },
  5193. HU: function HU(str) {
  5194. return /^(HU)?\d{8}$/.test(str);
  5195. },
  5196. IE: function IE(str) {
  5197. return /^(IE)?\d{7}\w{1}(W)?$/.test(str);
  5198. },
  5199. IT: function IT(str) {
  5200. return /^(IT)?\d{11}$/.test(str);
  5201. },
  5202. LV: function LV(str) {
  5203. return /^(LV)?\d{11}$/.test(str);
  5204. },
  5205. LT: function LT(str) {
  5206. return /^(LT)?\d{9,12}$/.test(str);
  5207. },
  5208. LU: function LU(str) {
  5209. return /^(LU)?\d{8}$/.test(str);
  5210. },
  5211. MT: function MT(str) {
  5212. return /^(MT)?\d{8}$/.test(str);
  5213. },
  5214. NL: function NL(str) {
  5215. return /^(NL)?\d{9}B\d{2}$/.test(str);
  5216. },
  5217. PL: function PL(str) {
  5218. return /^(PL)?(\d{10}|(\d{3}-\d{3}-\d{2}-\d{2})|(\d{3}-\d{2}-\d{2}-\d{3}))$/.test(str);
  5219. },
  5220. PT: PT,
  5221. RO: function RO(str) {
  5222. return /^(RO)?\d{2,10}$/.test(str);
  5223. },
  5224. SK: function SK(str) {
  5225. return /^(SK)?\d{10}$/.test(str);
  5226. },
  5227. SI: function SI(str) {
  5228. return /^(SI)?\d{8}$/.test(str);
  5229. },
  5230. ES: function ES(str) {
  5231. return /^(ES)?\w\d{7}[A-Z]$/.test(str);
  5232. },
  5233. SE: function SE(str) {
  5234. return /^(SE)?\d{12}$/.test(str);
  5235. },
  5236. /**
  5237. * VAT numbers of non-EU countries
  5238. */
  5239. AL: function AL(str) {
  5240. return /^(AL)?\w{9}[A-Z]$/.test(str);
  5241. },
  5242. MK: function MK(str) {
  5243. return /^(MK)?\d{13}$/.test(str);
  5244. },
  5245. AU: AU,
  5246. BY: function BY(str) {
  5247. return /^(УНП )?\d{9}$/.test(str);
  5248. },
  5249. CA: function CA(str) {
  5250. return /^(CA)?\d{9}$/.test(str);
  5251. },
  5252. IS: function IS(str) {
  5253. return /^(IS)?\d{5,6}$/.test(str);
  5254. },
  5255. IN: function IN(str) {
  5256. return /^(IN)?\d{15}$/.test(str);
  5257. },
  5258. ID: function ID(str) {
  5259. return /^(ID)?(\d{15}|(\d{2}.\d{3}.\d{3}.\d{1}-\d{3}.\d{3}))$/.test(str);
  5260. },
  5261. IL: function IL(str) {
  5262. return /^(IL)?\d{9}$/.test(str);
  5263. },
  5264. KZ: function KZ(str) {
  5265. return /^(KZ)?\d{12}$/.test(str);
  5266. },
  5267. NZ: function NZ(str) {
  5268. return /^(NZ)?\d{9}$/.test(str);
  5269. },
  5270. NG: function NG(str) {
  5271. return /^(NG)?(\d{12}|(\d{8}-\d{4}))$/.test(str);
  5272. },
  5273. NO: function NO(str) {
  5274. return /^(NO)?\d{9}MVA$/.test(str);
  5275. },
  5276. PH: function PH(str) {
  5277. return /^(PH)?(\d{12}|\d{3} \d{3} \d{3} \d{3})$/.test(str);
  5278. },
  5279. RU: function RU(str) {
  5280. return /^(RU)?(\d{10}|\d{12})$/.test(str);
  5281. },
  5282. SM: function SM(str) {
  5283. return /^(SM)?\d{5}$/.test(str);
  5284. },
  5285. SA: function SA(str) {
  5286. return /^(SA)?\d{15}$/.test(str);
  5287. },
  5288. RS: function RS(str) {
  5289. return /^(RS)?\d{9}$/.test(str);
  5290. },
  5291. CH: CH,
  5292. TR: function TR(str) {
  5293. return /^(TR)?\d{10}$/.test(str);
  5294. },
  5295. UA: function UA(str) {
  5296. return /^(UA)?\d{12}$/.test(str);
  5297. },
  5298. GB: function GB(str) {
  5299. return /^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}))$/.test(str);
  5300. },
  5301. UZ: function UZ(str) {
  5302. return /^(UZ)?\d{9}$/.test(str);
  5303. },
  5304. /**
  5305. * VAT numbers of Latin American countries
  5306. */
  5307. AR: function AR(str) {
  5308. return /^(AR)?\d{11}$/.test(str);
  5309. },
  5310. BO: function BO(str) {
  5311. return /^(BO)?\d{7}$/.test(str);
  5312. },
  5313. BR: function BR(str) {
  5314. return /^(BR)?((\d{2}.\d{3}.\d{3}\/\d{4}-\d{2})|(\d{3}.\d{3}.\d{3}-\d{2}))$/.test(str);
  5315. },
  5316. CL: function CL(str) {
  5317. return /^(CL)?\d{8}-\d{1}$/.test(str);
  5318. },
  5319. CO: function CO(str) {
  5320. return /^(CO)?\d{10}$/.test(str);
  5321. },
  5322. CR: function CR(str) {
  5323. return /^(CR)?\d{9,12}$/.test(str);
  5324. },
  5325. EC: function EC(str) {
  5326. return /^(EC)?\d{13}$/.test(str);
  5327. },
  5328. SV: function SV(str) {
  5329. return /^(SV)?\d{4}-\d{6}-\d{3}-\d{1}$/.test(str);
  5330. },
  5331. GT: function GT(str) {
  5332. return /^(GT)?\d{7}-\d{1}$/.test(str);
  5333. },
  5334. HN: function HN(str) {
  5335. return /^(HN)?$/.test(str);
  5336. },
  5337. MX: function MX(str) {
  5338. return /^(MX)?\w{3,4}\d{6}\w{3}$/.test(str);
  5339. },
  5340. NI: function NI(str) {
  5341. return /^(NI)?\d{3}-\d{6}-\d{4}\w{1}$/.test(str);
  5342. },
  5343. PA: function PA(str) {
  5344. return /^(PA)?$/.test(str);
  5345. },
  5346. PY: function PY(str) {
  5347. return /^(PY)?\d{6,8}-\d{1}$/.test(str);
  5348. },
  5349. PE: function PE(str) {
  5350. return /^(PE)?\d{11}$/.test(str);
  5351. },
  5352. DO: function DO(str) {
  5353. return /^(DO)?(\d{11}|(\d{3}-\d{7}-\d{1})|[1,4,5]{1}\d{8}|([1,4,5]{1})-\d{2}-\d{5}-\d{1})$/.test(str);
  5354. },
  5355. UY: function UY(str) {
  5356. return /^(UY)?\d{12}$/.test(str);
  5357. },
  5358. VE: function VE(str) {
  5359. return /^(VE)?[J,G,V,E]{1}-(\d{9}|(\d{8}-\d{1}))$/.test(str);
  5360. }
  5361. };
  5362. function isVAT(str, countryCode) {
  5363. assertString(str);
  5364. assertString(countryCode);
  5365. if (countryCode in vatMatchers) {
  5366. return vatMatchers[countryCode](str);
  5367. }
  5368. throw new Error("Invalid country code: '".concat(countryCode, "'"));
  5369. }
  5370. var version = '13.15.35';
  5371. var validator = {
  5372. version: version,
  5373. toDate: toDate,
  5374. toFloat: toFloat,
  5375. toInt: toInt,
  5376. toBoolean: toBoolean,
  5377. equals: equals,
  5378. contains: contains,
  5379. matches: matches,
  5380. isEmail: isEmail,
  5381. isURL: isURL,
  5382. isMACAddress: isMACAddress,
  5383. isIP: isIP,
  5384. isIPRange: isIPRange,
  5385. isFQDN: isFQDN,
  5386. isBoolean: isBoolean,
  5387. isIBAN: isIBAN,
  5388. isBIC: isBIC,
  5389. isAbaRouting: isAbaRouting,
  5390. isAlpha: isAlpha,
  5391. isAlphaLocales: locales$1,
  5392. isAlphanumeric: isAlphanumeric,
  5393. isAlphanumericLocales: locales$2,
  5394. isNumeric: isNumeric,
  5395. isPassportNumber: isPassportNumber,
  5396. passportNumberLocales: locales$3,
  5397. isPort: isPort,
  5398. isLowercase: isLowercase,
  5399. isUppercase: isUppercase,
  5400. isAscii: isAscii,
  5401. isFullWidth: isFullWidth,
  5402. isHalfWidth: isHalfWidth,
  5403. isVariableWidth: isVariableWidth,
  5404. isMultibyte: isMultibyte,
  5405. isSemVer: isSemVer,
  5406. isSurrogatePair: isSurrogatePair,
  5407. isInt: isInt,
  5408. isIMEI: isIMEI,
  5409. isFloat: isFloat,
  5410. isFloatLocales: locales,
  5411. isDecimal: isDecimal,
  5412. isHexadecimal: isHexadecimal,
  5413. isOctal: isOctal,
  5414. isDivisibleBy: isDivisibleBy,
  5415. isHexColor: isHexColor,
  5416. isRgbColor: isRgbColor,
  5417. isHSL: isHSL,
  5418. isISRC: isISRC,
  5419. isMD5: isMD5,
  5420. isHash: isHash,
  5421. isJWT: isJWT,
  5422. isJSON: isJSON,
  5423. isEmpty: isEmpty,
  5424. isLength: isLength,
  5425. isLocale: isLocale,
  5426. isByteLength: isByteLength,
  5427. isULID: isULID,
  5428. isUUID: isUUID,
  5429. isMongoId: isMongoId,
  5430. isAfter: isAfter,
  5431. isBefore: isBefore,
  5432. isIn: isIn,
  5433. isLuhnNumber: isLuhnNumber,
  5434. isCreditCard: isCreditCard,
  5435. isIdentityCard: isIdentityCard,
  5436. isEAN: isEAN,
  5437. isISIN: isISIN,
  5438. isISBN: isISBN,
  5439. isISSN: isISSN,
  5440. isMobilePhone: isMobilePhone,
  5441. isMobilePhoneLocales: locales$5,
  5442. isPostalCode: isPostalCode,
  5443. isPostalCodeLocales: locales$6,
  5444. isEthereumAddress: isEthereumAddress,
  5445. isCurrency: isCurrency,
  5446. isBtcAddress: isBtcAddress,
  5447. isISO6346: isISO6346,
  5448. isFreightContainerID: isFreightContainerID,
  5449. isISO6391: isISO6391,
  5450. isISO8601: isISO8601,
  5451. isISO15924: isISO15924,
  5452. isRFC3339: isRFC3339,
  5453. isISO31661Alpha2: isISO31661Alpha2,
  5454. isISO31661Alpha3: isISO31661Alpha3,
  5455. isISO31661Numeric: isISO31661Numeric,
  5456. isISO4217: isISO4217,
  5457. isBase32: isBase32,
  5458. isBase58: isBase58,
  5459. isBase64: isBase64,
  5460. isDataURI: isDataURI,
  5461. isMagnetURI: isMagnetURI,
  5462. isMailtoURI: isMailtoURI,
  5463. isMimeType: isMimeType,
  5464. isLatLong: isLatLong,
  5465. ltrim: ltrim,
  5466. rtrim: rtrim,
  5467. trim: trim,
  5468. escape: escape,
  5469. unescape: unescape,
  5470. stripLow: stripLow,
  5471. whitelist: whitelist,
  5472. blacklist: blacklist$1,
  5473. isWhitelisted: isWhitelisted,
  5474. normalizeEmail: normalizeEmail,
  5475. toString: toString,
  5476. isSlug: isSlug,
  5477. isStrongPassword: isStrongPassword,
  5478. isTaxID: isTaxID,
  5479. isDate: isDate,
  5480. isTime: isTime,
  5481. isLicensePlate: isLicensePlate,
  5482. isVAT: isVAT,
  5483. ibanLocales: locales$4
  5484. };
  5485. return validator;
  5486. })));