ZSchema-browser.js 401 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901
  1. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ZSchema = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  2. (function (global){(function (){
  3. /**
  4. * lodash (Custom Build) <https://lodash.com/>
  5. * Build: `lodash modularize exports="npm" -o ./`
  6. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  7. * Released under MIT license <https://lodash.com/license>
  8. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  9. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  10. */
  11. /** Used as the `TypeError` message for "Functions" methods. */
  12. var FUNC_ERROR_TEXT = 'Expected a function';
  13. /** Used to stand-in for `undefined` hash values. */
  14. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  15. /** Used as references for various `Number` constants. */
  16. var INFINITY = 1 / 0;
  17. /** `Object#toString` result references. */
  18. var funcTag = '[object Function]',
  19. genTag = '[object GeneratorFunction]',
  20. symbolTag = '[object Symbol]';
  21. /** Used to match property names within property paths. */
  22. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  23. reIsPlainProp = /^\w*$/,
  24. reLeadingDot = /^\./,
  25. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  26. /**
  27. * Used to match `RegExp`
  28. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  29. */
  30. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  31. /** Used to match backslashes in property paths. */
  32. var reEscapeChar = /\\(\\)?/g;
  33. /** Used to detect host constructors (Safari). */
  34. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  35. /** Detect free variable `global` from Node.js. */
  36. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  37. /** Detect free variable `self`. */
  38. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  39. /** Used as a reference to the global object. */
  40. var root = freeGlobal || freeSelf || Function('return this')();
  41. /**
  42. * Gets the value at `key` of `object`.
  43. *
  44. * @private
  45. * @param {Object} [object] The object to query.
  46. * @param {string} key The key of the property to get.
  47. * @returns {*} Returns the property value.
  48. */
  49. function getValue(object, key) {
  50. return object == null ? undefined : object[key];
  51. }
  52. /**
  53. * Checks if `value` is a host object in IE < 9.
  54. *
  55. * @private
  56. * @param {*} value The value to check.
  57. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  58. */
  59. function isHostObject(value) {
  60. // Many host objects are `Object` objects that can coerce to strings
  61. // despite having improperly defined `toString` methods.
  62. var result = false;
  63. if (value != null && typeof value.toString != 'function') {
  64. try {
  65. result = !!(value + '');
  66. } catch (e) {}
  67. }
  68. return result;
  69. }
  70. /** Used for built-in method references. */
  71. var arrayProto = Array.prototype,
  72. funcProto = Function.prototype,
  73. objectProto = Object.prototype;
  74. /** Used to detect overreaching core-js shims. */
  75. var coreJsData = root['__core-js_shared__'];
  76. /** Used to detect methods masquerading as native. */
  77. var maskSrcKey = (function() {
  78. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  79. return uid ? ('Symbol(src)_1.' + uid) : '';
  80. }());
  81. /** Used to resolve the decompiled source of functions. */
  82. var funcToString = funcProto.toString;
  83. /** Used to check objects for own properties. */
  84. var hasOwnProperty = objectProto.hasOwnProperty;
  85. /**
  86. * Used to resolve the
  87. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  88. * of values.
  89. */
  90. var objectToString = objectProto.toString;
  91. /** Used to detect if a method is native. */
  92. var reIsNative = RegExp('^' +
  93. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  94. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  95. );
  96. /** Built-in value references. */
  97. var Symbol = root.Symbol,
  98. splice = arrayProto.splice;
  99. /* Built-in method references that are verified to be native. */
  100. var Map = getNative(root, 'Map'),
  101. nativeCreate = getNative(Object, 'create');
  102. /** Used to convert symbols to primitives and strings. */
  103. var symbolProto = Symbol ? Symbol.prototype : undefined,
  104. symbolToString = symbolProto ? symbolProto.toString : undefined;
  105. /**
  106. * Creates a hash object.
  107. *
  108. * @private
  109. * @constructor
  110. * @param {Array} [entries] The key-value pairs to cache.
  111. */
  112. function Hash(entries) {
  113. var index = -1,
  114. length = entries ? entries.length : 0;
  115. this.clear();
  116. while (++index < length) {
  117. var entry = entries[index];
  118. this.set(entry[0], entry[1]);
  119. }
  120. }
  121. /**
  122. * Removes all key-value entries from the hash.
  123. *
  124. * @private
  125. * @name clear
  126. * @memberOf Hash
  127. */
  128. function hashClear() {
  129. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  130. }
  131. /**
  132. * Removes `key` and its value from the hash.
  133. *
  134. * @private
  135. * @name delete
  136. * @memberOf Hash
  137. * @param {Object} hash The hash to modify.
  138. * @param {string} key The key of the value to remove.
  139. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  140. */
  141. function hashDelete(key) {
  142. return this.has(key) && delete this.__data__[key];
  143. }
  144. /**
  145. * Gets the hash value for `key`.
  146. *
  147. * @private
  148. * @name get
  149. * @memberOf Hash
  150. * @param {string} key The key of the value to get.
  151. * @returns {*} Returns the entry value.
  152. */
  153. function hashGet(key) {
  154. var data = this.__data__;
  155. if (nativeCreate) {
  156. var result = data[key];
  157. return result === HASH_UNDEFINED ? undefined : result;
  158. }
  159. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  160. }
  161. /**
  162. * Checks if a hash value for `key` exists.
  163. *
  164. * @private
  165. * @name has
  166. * @memberOf Hash
  167. * @param {string} key The key of the entry to check.
  168. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  169. */
  170. function hashHas(key) {
  171. var data = this.__data__;
  172. return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
  173. }
  174. /**
  175. * Sets the hash `key` to `value`.
  176. *
  177. * @private
  178. * @name set
  179. * @memberOf Hash
  180. * @param {string} key The key of the value to set.
  181. * @param {*} value The value to set.
  182. * @returns {Object} Returns the hash instance.
  183. */
  184. function hashSet(key, value) {
  185. var data = this.__data__;
  186. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  187. return this;
  188. }
  189. // Add methods to `Hash`.
  190. Hash.prototype.clear = hashClear;
  191. Hash.prototype['delete'] = hashDelete;
  192. Hash.prototype.get = hashGet;
  193. Hash.prototype.has = hashHas;
  194. Hash.prototype.set = hashSet;
  195. /**
  196. * Creates an list cache object.
  197. *
  198. * @private
  199. * @constructor
  200. * @param {Array} [entries] The key-value pairs to cache.
  201. */
  202. function ListCache(entries) {
  203. var index = -1,
  204. length = entries ? entries.length : 0;
  205. this.clear();
  206. while (++index < length) {
  207. var entry = entries[index];
  208. this.set(entry[0], entry[1]);
  209. }
  210. }
  211. /**
  212. * Removes all key-value entries from the list cache.
  213. *
  214. * @private
  215. * @name clear
  216. * @memberOf ListCache
  217. */
  218. function listCacheClear() {
  219. this.__data__ = [];
  220. }
  221. /**
  222. * Removes `key` and its value from the list cache.
  223. *
  224. * @private
  225. * @name delete
  226. * @memberOf ListCache
  227. * @param {string} key The key of the value to remove.
  228. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  229. */
  230. function listCacheDelete(key) {
  231. var data = this.__data__,
  232. index = assocIndexOf(data, key);
  233. if (index < 0) {
  234. return false;
  235. }
  236. var lastIndex = data.length - 1;
  237. if (index == lastIndex) {
  238. data.pop();
  239. } else {
  240. splice.call(data, index, 1);
  241. }
  242. return true;
  243. }
  244. /**
  245. * Gets the list cache value for `key`.
  246. *
  247. * @private
  248. * @name get
  249. * @memberOf ListCache
  250. * @param {string} key The key of the value to get.
  251. * @returns {*} Returns the entry value.
  252. */
  253. function listCacheGet(key) {
  254. var data = this.__data__,
  255. index = assocIndexOf(data, key);
  256. return index < 0 ? undefined : data[index][1];
  257. }
  258. /**
  259. * Checks if a list cache value for `key` exists.
  260. *
  261. * @private
  262. * @name has
  263. * @memberOf ListCache
  264. * @param {string} key The key of the entry to check.
  265. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  266. */
  267. function listCacheHas(key) {
  268. return assocIndexOf(this.__data__, key) > -1;
  269. }
  270. /**
  271. * Sets the list cache `key` to `value`.
  272. *
  273. * @private
  274. * @name set
  275. * @memberOf ListCache
  276. * @param {string} key The key of the value to set.
  277. * @param {*} value The value to set.
  278. * @returns {Object} Returns the list cache instance.
  279. */
  280. function listCacheSet(key, value) {
  281. var data = this.__data__,
  282. index = assocIndexOf(data, key);
  283. if (index < 0) {
  284. data.push([key, value]);
  285. } else {
  286. data[index][1] = value;
  287. }
  288. return this;
  289. }
  290. // Add methods to `ListCache`.
  291. ListCache.prototype.clear = listCacheClear;
  292. ListCache.prototype['delete'] = listCacheDelete;
  293. ListCache.prototype.get = listCacheGet;
  294. ListCache.prototype.has = listCacheHas;
  295. ListCache.prototype.set = listCacheSet;
  296. /**
  297. * Creates a map cache object to store key-value pairs.
  298. *
  299. * @private
  300. * @constructor
  301. * @param {Array} [entries] The key-value pairs to cache.
  302. */
  303. function MapCache(entries) {
  304. var index = -1,
  305. length = entries ? entries.length : 0;
  306. this.clear();
  307. while (++index < length) {
  308. var entry = entries[index];
  309. this.set(entry[0], entry[1]);
  310. }
  311. }
  312. /**
  313. * Removes all key-value entries from the map.
  314. *
  315. * @private
  316. * @name clear
  317. * @memberOf MapCache
  318. */
  319. function mapCacheClear() {
  320. this.__data__ = {
  321. 'hash': new Hash,
  322. 'map': new (Map || ListCache),
  323. 'string': new Hash
  324. };
  325. }
  326. /**
  327. * Removes `key` and its value from the map.
  328. *
  329. * @private
  330. * @name delete
  331. * @memberOf MapCache
  332. * @param {string} key The key of the value to remove.
  333. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  334. */
  335. function mapCacheDelete(key) {
  336. return getMapData(this, key)['delete'](key);
  337. }
  338. /**
  339. * Gets the map value for `key`.
  340. *
  341. * @private
  342. * @name get
  343. * @memberOf MapCache
  344. * @param {string} key The key of the value to get.
  345. * @returns {*} Returns the entry value.
  346. */
  347. function mapCacheGet(key) {
  348. return getMapData(this, key).get(key);
  349. }
  350. /**
  351. * Checks if a map value for `key` exists.
  352. *
  353. * @private
  354. * @name has
  355. * @memberOf MapCache
  356. * @param {string} key The key of the entry to check.
  357. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  358. */
  359. function mapCacheHas(key) {
  360. return getMapData(this, key).has(key);
  361. }
  362. /**
  363. * Sets the map `key` to `value`.
  364. *
  365. * @private
  366. * @name set
  367. * @memberOf MapCache
  368. * @param {string} key The key of the value to set.
  369. * @param {*} value The value to set.
  370. * @returns {Object} Returns the map cache instance.
  371. */
  372. function mapCacheSet(key, value) {
  373. getMapData(this, key).set(key, value);
  374. return this;
  375. }
  376. // Add methods to `MapCache`.
  377. MapCache.prototype.clear = mapCacheClear;
  378. MapCache.prototype['delete'] = mapCacheDelete;
  379. MapCache.prototype.get = mapCacheGet;
  380. MapCache.prototype.has = mapCacheHas;
  381. MapCache.prototype.set = mapCacheSet;
  382. /**
  383. * Gets the index at which the `key` is found in `array` of key-value pairs.
  384. *
  385. * @private
  386. * @param {Array} array The array to inspect.
  387. * @param {*} key The key to search for.
  388. * @returns {number} Returns the index of the matched value, else `-1`.
  389. */
  390. function assocIndexOf(array, key) {
  391. var length = array.length;
  392. while (length--) {
  393. if (eq(array[length][0], key)) {
  394. return length;
  395. }
  396. }
  397. return -1;
  398. }
  399. /**
  400. * The base implementation of `_.get` without support for default values.
  401. *
  402. * @private
  403. * @param {Object} object The object to query.
  404. * @param {Array|string} path The path of the property to get.
  405. * @returns {*} Returns the resolved value.
  406. */
  407. function baseGet(object, path) {
  408. path = isKey(path, object) ? [path] : castPath(path);
  409. var index = 0,
  410. length = path.length;
  411. while (object != null && index < length) {
  412. object = object[toKey(path[index++])];
  413. }
  414. return (index && index == length) ? object : undefined;
  415. }
  416. /**
  417. * The base implementation of `_.isNative` without bad shim checks.
  418. *
  419. * @private
  420. * @param {*} value The value to check.
  421. * @returns {boolean} Returns `true` if `value` is a native function,
  422. * else `false`.
  423. */
  424. function baseIsNative(value) {
  425. if (!isObject(value) || isMasked(value)) {
  426. return false;
  427. }
  428. var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
  429. return pattern.test(toSource(value));
  430. }
  431. /**
  432. * The base implementation of `_.toString` which doesn't convert nullish
  433. * values to empty strings.
  434. *
  435. * @private
  436. * @param {*} value The value to process.
  437. * @returns {string} Returns the string.
  438. */
  439. function baseToString(value) {
  440. // Exit early for strings to avoid a performance hit in some environments.
  441. if (typeof value == 'string') {
  442. return value;
  443. }
  444. if (isSymbol(value)) {
  445. return symbolToString ? symbolToString.call(value) : '';
  446. }
  447. var result = (value + '');
  448. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  449. }
  450. /**
  451. * Casts `value` to a path array if it's not one.
  452. *
  453. * @private
  454. * @param {*} value The value to inspect.
  455. * @returns {Array} Returns the cast property path array.
  456. */
  457. function castPath(value) {
  458. return isArray(value) ? value : stringToPath(value);
  459. }
  460. /**
  461. * Gets the data for `map`.
  462. *
  463. * @private
  464. * @param {Object} map The map to query.
  465. * @param {string} key The reference key.
  466. * @returns {*} Returns the map data.
  467. */
  468. function getMapData(map, key) {
  469. var data = map.__data__;
  470. return isKeyable(key)
  471. ? data[typeof key == 'string' ? 'string' : 'hash']
  472. : data.map;
  473. }
  474. /**
  475. * Gets the native function at `key` of `object`.
  476. *
  477. * @private
  478. * @param {Object} object The object to query.
  479. * @param {string} key The key of the method to get.
  480. * @returns {*} Returns the function if it's native, else `undefined`.
  481. */
  482. function getNative(object, key) {
  483. var value = getValue(object, key);
  484. return baseIsNative(value) ? value : undefined;
  485. }
  486. /**
  487. * Checks if `value` is a property name and not a property path.
  488. *
  489. * @private
  490. * @param {*} value The value to check.
  491. * @param {Object} [object] The object to query keys on.
  492. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  493. */
  494. function isKey(value, object) {
  495. if (isArray(value)) {
  496. return false;
  497. }
  498. var type = typeof value;
  499. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  500. value == null || isSymbol(value)) {
  501. return true;
  502. }
  503. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  504. (object != null && value in Object(object));
  505. }
  506. /**
  507. * Checks if `value` is suitable for use as unique object key.
  508. *
  509. * @private
  510. * @param {*} value The value to check.
  511. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  512. */
  513. function isKeyable(value) {
  514. var type = typeof value;
  515. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  516. ? (value !== '__proto__')
  517. : (value === null);
  518. }
  519. /**
  520. * Checks if `func` has its source masked.
  521. *
  522. * @private
  523. * @param {Function} func The function to check.
  524. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  525. */
  526. function isMasked(func) {
  527. return !!maskSrcKey && (maskSrcKey in func);
  528. }
  529. /**
  530. * Converts `string` to a property path array.
  531. *
  532. * @private
  533. * @param {string} string The string to convert.
  534. * @returns {Array} Returns the property path array.
  535. */
  536. var stringToPath = memoize(function(string) {
  537. string = toString(string);
  538. var result = [];
  539. if (reLeadingDot.test(string)) {
  540. result.push('');
  541. }
  542. string.replace(rePropName, function(match, number, quote, string) {
  543. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  544. });
  545. return result;
  546. });
  547. /**
  548. * Converts `value` to a string key if it's not a string or symbol.
  549. *
  550. * @private
  551. * @param {*} value The value to inspect.
  552. * @returns {string|symbol} Returns the key.
  553. */
  554. function toKey(value) {
  555. if (typeof value == 'string' || isSymbol(value)) {
  556. return value;
  557. }
  558. var result = (value + '');
  559. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  560. }
  561. /**
  562. * Converts `func` to its source code.
  563. *
  564. * @private
  565. * @param {Function} func The function to process.
  566. * @returns {string} Returns the source code.
  567. */
  568. function toSource(func) {
  569. if (func != null) {
  570. try {
  571. return funcToString.call(func);
  572. } catch (e) {}
  573. try {
  574. return (func + '');
  575. } catch (e) {}
  576. }
  577. return '';
  578. }
  579. /**
  580. * Creates a function that memoizes the result of `func`. If `resolver` is
  581. * provided, it determines the cache key for storing the result based on the
  582. * arguments provided to the memoized function. By default, the first argument
  583. * provided to the memoized function is used as the map cache key. The `func`
  584. * is invoked with the `this` binding of the memoized function.
  585. *
  586. * **Note:** The cache is exposed as the `cache` property on the memoized
  587. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  588. * constructor with one whose instances implement the
  589. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  590. * method interface of `delete`, `get`, `has`, and `set`.
  591. *
  592. * @static
  593. * @memberOf _
  594. * @since 0.1.0
  595. * @category Function
  596. * @param {Function} func The function to have its output memoized.
  597. * @param {Function} [resolver] The function to resolve the cache key.
  598. * @returns {Function} Returns the new memoized function.
  599. * @example
  600. *
  601. * var object = { 'a': 1, 'b': 2 };
  602. * var other = { 'c': 3, 'd': 4 };
  603. *
  604. * var values = _.memoize(_.values);
  605. * values(object);
  606. * // => [1, 2]
  607. *
  608. * values(other);
  609. * // => [3, 4]
  610. *
  611. * object.a = 2;
  612. * values(object);
  613. * // => [1, 2]
  614. *
  615. * // Modify the result cache.
  616. * values.cache.set(object, ['a', 'b']);
  617. * values(object);
  618. * // => ['a', 'b']
  619. *
  620. * // Replace `_.memoize.Cache`.
  621. * _.memoize.Cache = WeakMap;
  622. */
  623. function memoize(func, resolver) {
  624. if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
  625. throw new TypeError(FUNC_ERROR_TEXT);
  626. }
  627. var memoized = function() {
  628. var args = arguments,
  629. key = resolver ? resolver.apply(this, args) : args[0],
  630. cache = memoized.cache;
  631. if (cache.has(key)) {
  632. return cache.get(key);
  633. }
  634. var result = func.apply(this, args);
  635. memoized.cache = cache.set(key, result);
  636. return result;
  637. };
  638. memoized.cache = new (memoize.Cache || MapCache);
  639. return memoized;
  640. }
  641. // Assign cache to `_.memoize`.
  642. memoize.Cache = MapCache;
  643. /**
  644. * Performs a
  645. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  646. * comparison between two values to determine if they are equivalent.
  647. *
  648. * @static
  649. * @memberOf _
  650. * @since 4.0.0
  651. * @category Lang
  652. * @param {*} value The value to compare.
  653. * @param {*} other The other value to compare.
  654. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  655. * @example
  656. *
  657. * var object = { 'a': 1 };
  658. * var other = { 'a': 1 };
  659. *
  660. * _.eq(object, object);
  661. * // => true
  662. *
  663. * _.eq(object, other);
  664. * // => false
  665. *
  666. * _.eq('a', 'a');
  667. * // => true
  668. *
  669. * _.eq('a', Object('a'));
  670. * // => false
  671. *
  672. * _.eq(NaN, NaN);
  673. * // => true
  674. */
  675. function eq(value, other) {
  676. return value === other || (value !== value && other !== other);
  677. }
  678. /**
  679. * Checks if `value` is classified as an `Array` object.
  680. *
  681. * @static
  682. * @memberOf _
  683. * @since 0.1.0
  684. * @category Lang
  685. * @param {*} value The value to check.
  686. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  687. * @example
  688. *
  689. * _.isArray([1, 2, 3]);
  690. * // => true
  691. *
  692. * _.isArray(document.body.children);
  693. * // => false
  694. *
  695. * _.isArray('abc');
  696. * // => false
  697. *
  698. * _.isArray(_.noop);
  699. * // => false
  700. */
  701. var isArray = Array.isArray;
  702. /**
  703. * Checks if `value` is classified as a `Function` object.
  704. *
  705. * @static
  706. * @memberOf _
  707. * @since 0.1.0
  708. * @category Lang
  709. * @param {*} value The value to check.
  710. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  711. * @example
  712. *
  713. * _.isFunction(_);
  714. * // => true
  715. *
  716. * _.isFunction(/abc/);
  717. * // => false
  718. */
  719. function isFunction(value) {
  720. // The use of `Object#toString` avoids issues with the `typeof` operator
  721. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  722. var tag = isObject(value) ? objectToString.call(value) : '';
  723. return tag == funcTag || tag == genTag;
  724. }
  725. /**
  726. * Checks if `value` is the
  727. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  728. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  729. *
  730. * @static
  731. * @memberOf _
  732. * @since 0.1.0
  733. * @category Lang
  734. * @param {*} value The value to check.
  735. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  736. * @example
  737. *
  738. * _.isObject({});
  739. * // => true
  740. *
  741. * _.isObject([1, 2, 3]);
  742. * // => true
  743. *
  744. * _.isObject(_.noop);
  745. * // => true
  746. *
  747. * _.isObject(null);
  748. * // => false
  749. */
  750. function isObject(value) {
  751. var type = typeof value;
  752. return !!value && (type == 'object' || type == 'function');
  753. }
  754. /**
  755. * Checks if `value` is object-like. A value is object-like if it's not `null`
  756. * and has a `typeof` result of "object".
  757. *
  758. * @static
  759. * @memberOf _
  760. * @since 4.0.0
  761. * @category Lang
  762. * @param {*} value The value to check.
  763. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  764. * @example
  765. *
  766. * _.isObjectLike({});
  767. * // => true
  768. *
  769. * _.isObjectLike([1, 2, 3]);
  770. * // => true
  771. *
  772. * _.isObjectLike(_.noop);
  773. * // => false
  774. *
  775. * _.isObjectLike(null);
  776. * // => false
  777. */
  778. function isObjectLike(value) {
  779. return !!value && typeof value == 'object';
  780. }
  781. /**
  782. * Checks if `value` is classified as a `Symbol` primitive or object.
  783. *
  784. * @static
  785. * @memberOf _
  786. * @since 4.0.0
  787. * @category Lang
  788. * @param {*} value The value to check.
  789. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  790. * @example
  791. *
  792. * _.isSymbol(Symbol.iterator);
  793. * // => true
  794. *
  795. * _.isSymbol('abc');
  796. * // => false
  797. */
  798. function isSymbol(value) {
  799. return typeof value == 'symbol' ||
  800. (isObjectLike(value) && objectToString.call(value) == symbolTag);
  801. }
  802. /**
  803. * Converts `value` to a string. An empty string is returned for `null`
  804. * and `undefined` values. The sign of `-0` is preserved.
  805. *
  806. * @static
  807. * @memberOf _
  808. * @since 4.0.0
  809. * @category Lang
  810. * @param {*} value The value to process.
  811. * @returns {string} Returns the string.
  812. * @example
  813. *
  814. * _.toString(null);
  815. * // => ''
  816. *
  817. * _.toString(-0);
  818. * // => '-0'
  819. *
  820. * _.toString([1, 2, 3]);
  821. * // => '1,2,3'
  822. */
  823. function toString(value) {
  824. return value == null ? '' : baseToString(value);
  825. }
  826. /**
  827. * Gets the value at `path` of `object`. If the resolved value is
  828. * `undefined`, the `defaultValue` is returned in its place.
  829. *
  830. * @static
  831. * @memberOf _
  832. * @since 3.7.0
  833. * @category Object
  834. * @param {Object} object The object to query.
  835. * @param {Array|string} path The path of the property to get.
  836. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  837. * @returns {*} Returns the resolved value.
  838. * @example
  839. *
  840. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  841. *
  842. * _.get(object, 'a[0].b.c');
  843. * // => 3
  844. *
  845. * _.get(object, ['a', '0', 'b', 'c']);
  846. * // => 3
  847. *
  848. * _.get(object, 'a.b.c', 'default');
  849. * // => 'default'
  850. */
  851. function get(object, path, defaultValue) {
  852. var result = object == null ? undefined : baseGet(object, path);
  853. return result === undefined ? defaultValue : result;
  854. }
  855. module.exports = get;
  856. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  857. },{}],2:[function(require,module,exports){
  858. (function (global){(function (){
  859. /**
  860. * Lodash (Custom Build) <https://lodash.com/>
  861. * Build: `lodash modularize exports="npm" -o ./`
  862. * Copyright JS Foundation and other contributors <https://js.foundation/>
  863. * Released under MIT license <https://lodash.com/license>
  864. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  865. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  866. */
  867. /** Used as the size to enable large array optimizations. */
  868. var LARGE_ARRAY_SIZE = 200;
  869. /** Used to stand-in for `undefined` hash values. */
  870. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  871. /** Used to compose bitmasks for value comparisons. */
  872. var COMPARE_PARTIAL_FLAG = 1,
  873. COMPARE_UNORDERED_FLAG = 2;
  874. /** Used as references for various `Number` constants. */
  875. var MAX_SAFE_INTEGER = 9007199254740991;
  876. /** `Object#toString` result references. */
  877. var argsTag = '[object Arguments]',
  878. arrayTag = '[object Array]',
  879. asyncTag = '[object AsyncFunction]',
  880. boolTag = '[object Boolean]',
  881. dateTag = '[object Date]',
  882. errorTag = '[object Error]',
  883. funcTag = '[object Function]',
  884. genTag = '[object GeneratorFunction]',
  885. mapTag = '[object Map]',
  886. numberTag = '[object Number]',
  887. nullTag = '[object Null]',
  888. objectTag = '[object Object]',
  889. promiseTag = '[object Promise]',
  890. proxyTag = '[object Proxy]',
  891. regexpTag = '[object RegExp]',
  892. setTag = '[object Set]',
  893. stringTag = '[object String]',
  894. symbolTag = '[object Symbol]',
  895. undefinedTag = '[object Undefined]',
  896. weakMapTag = '[object WeakMap]';
  897. var arrayBufferTag = '[object ArrayBuffer]',
  898. dataViewTag = '[object DataView]',
  899. float32Tag = '[object Float32Array]',
  900. float64Tag = '[object Float64Array]',
  901. int8Tag = '[object Int8Array]',
  902. int16Tag = '[object Int16Array]',
  903. int32Tag = '[object Int32Array]',
  904. uint8Tag = '[object Uint8Array]',
  905. uint8ClampedTag = '[object Uint8ClampedArray]',
  906. uint16Tag = '[object Uint16Array]',
  907. uint32Tag = '[object Uint32Array]';
  908. /**
  909. * Used to match `RegExp`
  910. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  911. */
  912. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  913. /** Used to detect host constructors (Safari). */
  914. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  915. /** Used to detect unsigned integer values. */
  916. var reIsUint = /^(?:0|[1-9]\d*)$/;
  917. /** Used to identify `toStringTag` values of typed arrays. */
  918. var typedArrayTags = {};
  919. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  920. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  921. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  922. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  923. typedArrayTags[uint32Tag] = true;
  924. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  925. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  926. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  927. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  928. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  929. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  930. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  931. typedArrayTags[weakMapTag] = false;
  932. /** Detect free variable `global` from Node.js. */
  933. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  934. /** Detect free variable `self`. */
  935. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  936. /** Used as a reference to the global object. */
  937. var root = freeGlobal || freeSelf || Function('return this')();
  938. /** Detect free variable `exports`. */
  939. var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  940. /** Detect free variable `module`. */
  941. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  942. /** Detect the popular CommonJS extension `module.exports`. */
  943. var moduleExports = freeModule && freeModule.exports === freeExports;
  944. /** Detect free variable `process` from Node.js. */
  945. var freeProcess = moduleExports && freeGlobal.process;
  946. /** Used to access faster Node.js helpers. */
  947. var nodeUtil = (function() {
  948. try {
  949. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  950. } catch (e) {}
  951. }());
  952. /* Node.js helper references. */
  953. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  954. /**
  955. * A specialized version of `_.filter` for arrays without support for
  956. * iteratee shorthands.
  957. *
  958. * @private
  959. * @param {Array} [array] The array to iterate over.
  960. * @param {Function} predicate The function invoked per iteration.
  961. * @returns {Array} Returns the new filtered array.
  962. */
  963. function arrayFilter(array, predicate) {
  964. var index = -1,
  965. length = array == null ? 0 : array.length,
  966. resIndex = 0,
  967. result = [];
  968. while (++index < length) {
  969. var value = array[index];
  970. if (predicate(value, index, array)) {
  971. result[resIndex++] = value;
  972. }
  973. }
  974. return result;
  975. }
  976. /**
  977. * Appends the elements of `values` to `array`.
  978. *
  979. * @private
  980. * @param {Array} array The array to modify.
  981. * @param {Array} values The values to append.
  982. * @returns {Array} Returns `array`.
  983. */
  984. function arrayPush(array, values) {
  985. var index = -1,
  986. length = values.length,
  987. offset = array.length;
  988. while (++index < length) {
  989. array[offset + index] = values[index];
  990. }
  991. return array;
  992. }
  993. /**
  994. * A specialized version of `_.some` for arrays without support for iteratee
  995. * shorthands.
  996. *
  997. * @private
  998. * @param {Array} [array] The array to iterate over.
  999. * @param {Function} predicate The function invoked per iteration.
  1000. * @returns {boolean} Returns `true` if any element passes the predicate check,
  1001. * else `false`.
  1002. */
  1003. function arraySome(array, predicate) {
  1004. var index = -1,
  1005. length = array == null ? 0 : array.length;
  1006. while (++index < length) {
  1007. if (predicate(array[index], index, array)) {
  1008. return true;
  1009. }
  1010. }
  1011. return false;
  1012. }
  1013. /**
  1014. * The base implementation of `_.times` without support for iteratee shorthands
  1015. * or max array length checks.
  1016. *
  1017. * @private
  1018. * @param {number} n The number of times to invoke `iteratee`.
  1019. * @param {Function} iteratee The function invoked per iteration.
  1020. * @returns {Array} Returns the array of results.
  1021. */
  1022. function baseTimes(n, iteratee) {
  1023. var index = -1,
  1024. result = Array(n);
  1025. while (++index < n) {
  1026. result[index] = iteratee(index);
  1027. }
  1028. return result;
  1029. }
  1030. /**
  1031. * The base implementation of `_.unary` without support for storing metadata.
  1032. *
  1033. * @private
  1034. * @param {Function} func The function to cap arguments for.
  1035. * @returns {Function} Returns the new capped function.
  1036. */
  1037. function baseUnary(func) {
  1038. return function(value) {
  1039. return func(value);
  1040. };
  1041. }
  1042. /**
  1043. * Checks if a `cache` value for `key` exists.
  1044. *
  1045. * @private
  1046. * @param {Object} cache The cache to query.
  1047. * @param {string} key The key of the entry to check.
  1048. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1049. */
  1050. function cacheHas(cache, key) {
  1051. return cache.has(key);
  1052. }
  1053. /**
  1054. * Gets the value at `key` of `object`.
  1055. *
  1056. * @private
  1057. * @param {Object} [object] The object to query.
  1058. * @param {string} key The key of the property to get.
  1059. * @returns {*} Returns the property value.
  1060. */
  1061. function getValue(object, key) {
  1062. return object == null ? undefined : object[key];
  1063. }
  1064. /**
  1065. * Converts `map` to its key-value pairs.
  1066. *
  1067. * @private
  1068. * @param {Object} map The map to convert.
  1069. * @returns {Array} Returns the key-value pairs.
  1070. */
  1071. function mapToArray(map) {
  1072. var index = -1,
  1073. result = Array(map.size);
  1074. map.forEach(function(value, key) {
  1075. result[++index] = [key, value];
  1076. });
  1077. return result;
  1078. }
  1079. /**
  1080. * Creates a unary function that invokes `func` with its argument transformed.
  1081. *
  1082. * @private
  1083. * @param {Function} func The function to wrap.
  1084. * @param {Function} transform The argument transform.
  1085. * @returns {Function} Returns the new function.
  1086. */
  1087. function overArg(func, transform) {
  1088. return function(arg) {
  1089. return func(transform(arg));
  1090. };
  1091. }
  1092. /**
  1093. * Converts `set` to an array of its values.
  1094. *
  1095. * @private
  1096. * @param {Object} set The set to convert.
  1097. * @returns {Array} Returns the values.
  1098. */
  1099. function setToArray(set) {
  1100. var index = -1,
  1101. result = Array(set.size);
  1102. set.forEach(function(value) {
  1103. result[++index] = value;
  1104. });
  1105. return result;
  1106. }
  1107. /** Used for built-in method references. */
  1108. var arrayProto = Array.prototype,
  1109. funcProto = Function.prototype,
  1110. objectProto = Object.prototype;
  1111. /** Used to detect overreaching core-js shims. */
  1112. var coreJsData = root['__core-js_shared__'];
  1113. /** Used to resolve the decompiled source of functions. */
  1114. var funcToString = funcProto.toString;
  1115. /** Used to check objects for own properties. */
  1116. var hasOwnProperty = objectProto.hasOwnProperty;
  1117. /** Used to detect methods masquerading as native. */
  1118. var maskSrcKey = (function() {
  1119. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  1120. return uid ? ('Symbol(src)_1.' + uid) : '';
  1121. }());
  1122. /**
  1123. * Used to resolve the
  1124. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  1125. * of values.
  1126. */
  1127. var nativeObjectToString = objectProto.toString;
  1128. /** Used to detect if a method is native. */
  1129. var reIsNative = RegExp('^' +
  1130. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  1131. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  1132. );
  1133. /** Built-in value references. */
  1134. var Buffer = moduleExports ? root.Buffer : undefined,
  1135. Symbol = root.Symbol,
  1136. Uint8Array = root.Uint8Array,
  1137. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  1138. splice = arrayProto.splice,
  1139. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  1140. /* Built-in method references for those with the same name as other `lodash` methods. */
  1141. var nativeGetSymbols = Object.getOwnPropertySymbols,
  1142. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  1143. nativeKeys = overArg(Object.keys, Object);
  1144. /* Built-in method references that are verified to be native. */
  1145. var DataView = getNative(root, 'DataView'),
  1146. Map = getNative(root, 'Map'),
  1147. Promise = getNative(root, 'Promise'),
  1148. Set = getNative(root, 'Set'),
  1149. WeakMap = getNative(root, 'WeakMap'),
  1150. nativeCreate = getNative(Object, 'create');
  1151. /** Used to detect maps, sets, and weakmaps. */
  1152. var dataViewCtorString = toSource(DataView),
  1153. mapCtorString = toSource(Map),
  1154. promiseCtorString = toSource(Promise),
  1155. setCtorString = toSource(Set),
  1156. weakMapCtorString = toSource(WeakMap);
  1157. /** Used to convert symbols to primitives and strings. */
  1158. var symbolProto = Symbol ? Symbol.prototype : undefined,
  1159. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
  1160. /**
  1161. * Creates a hash object.
  1162. *
  1163. * @private
  1164. * @constructor
  1165. * @param {Array} [entries] The key-value pairs to cache.
  1166. */
  1167. function Hash(entries) {
  1168. var index = -1,
  1169. length = entries == null ? 0 : entries.length;
  1170. this.clear();
  1171. while (++index < length) {
  1172. var entry = entries[index];
  1173. this.set(entry[0], entry[1]);
  1174. }
  1175. }
  1176. /**
  1177. * Removes all key-value entries from the hash.
  1178. *
  1179. * @private
  1180. * @name clear
  1181. * @memberOf Hash
  1182. */
  1183. function hashClear() {
  1184. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  1185. this.size = 0;
  1186. }
  1187. /**
  1188. * Removes `key` and its value from the hash.
  1189. *
  1190. * @private
  1191. * @name delete
  1192. * @memberOf Hash
  1193. * @param {Object} hash The hash to modify.
  1194. * @param {string} key The key of the value to remove.
  1195. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  1196. */
  1197. function hashDelete(key) {
  1198. var result = this.has(key) && delete this.__data__[key];
  1199. this.size -= result ? 1 : 0;
  1200. return result;
  1201. }
  1202. /**
  1203. * Gets the hash value for `key`.
  1204. *
  1205. * @private
  1206. * @name get
  1207. * @memberOf Hash
  1208. * @param {string} key The key of the value to get.
  1209. * @returns {*} Returns the entry value.
  1210. */
  1211. function hashGet(key) {
  1212. var data = this.__data__;
  1213. if (nativeCreate) {
  1214. var result = data[key];
  1215. return result === HASH_UNDEFINED ? undefined : result;
  1216. }
  1217. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  1218. }
  1219. /**
  1220. * Checks if a hash value for `key` exists.
  1221. *
  1222. * @private
  1223. * @name has
  1224. * @memberOf Hash
  1225. * @param {string} key The key of the entry to check.
  1226. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1227. */
  1228. function hashHas(key) {
  1229. var data = this.__data__;
  1230. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  1231. }
  1232. /**
  1233. * Sets the hash `key` to `value`.
  1234. *
  1235. * @private
  1236. * @name set
  1237. * @memberOf Hash
  1238. * @param {string} key The key of the value to set.
  1239. * @param {*} value The value to set.
  1240. * @returns {Object} Returns the hash instance.
  1241. */
  1242. function hashSet(key, value) {
  1243. var data = this.__data__;
  1244. this.size += this.has(key) ? 0 : 1;
  1245. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  1246. return this;
  1247. }
  1248. // Add methods to `Hash`.
  1249. Hash.prototype.clear = hashClear;
  1250. Hash.prototype['delete'] = hashDelete;
  1251. Hash.prototype.get = hashGet;
  1252. Hash.prototype.has = hashHas;
  1253. Hash.prototype.set = hashSet;
  1254. /**
  1255. * Creates an list cache object.
  1256. *
  1257. * @private
  1258. * @constructor
  1259. * @param {Array} [entries] The key-value pairs to cache.
  1260. */
  1261. function ListCache(entries) {
  1262. var index = -1,
  1263. length = entries == null ? 0 : entries.length;
  1264. this.clear();
  1265. while (++index < length) {
  1266. var entry = entries[index];
  1267. this.set(entry[0], entry[1]);
  1268. }
  1269. }
  1270. /**
  1271. * Removes all key-value entries from the list cache.
  1272. *
  1273. * @private
  1274. * @name clear
  1275. * @memberOf ListCache
  1276. */
  1277. function listCacheClear() {
  1278. this.__data__ = [];
  1279. this.size = 0;
  1280. }
  1281. /**
  1282. * Removes `key` and its value from the list cache.
  1283. *
  1284. * @private
  1285. * @name delete
  1286. * @memberOf ListCache
  1287. * @param {string} key The key of the value to remove.
  1288. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  1289. */
  1290. function listCacheDelete(key) {
  1291. var data = this.__data__,
  1292. index = assocIndexOf(data, key);
  1293. if (index < 0) {
  1294. return false;
  1295. }
  1296. var lastIndex = data.length - 1;
  1297. if (index == lastIndex) {
  1298. data.pop();
  1299. } else {
  1300. splice.call(data, index, 1);
  1301. }
  1302. --this.size;
  1303. return true;
  1304. }
  1305. /**
  1306. * Gets the list cache value for `key`.
  1307. *
  1308. * @private
  1309. * @name get
  1310. * @memberOf ListCache
  1311. * @param {string} key The key of the value to get.
  1312. * @returns {*} Returns the entry value.
  1313. */
  1314. function listCacheGet(key) {
  1315. var data = this.__data__,
  1316. index = assocIndexOf(data, key);
  1317. return index < 0 ? undefined : data[index][1];
  1318. }
  1319. /**
  1320. * Checks if a list cache value for `key` exists.
  1321. *
  1322. * @private
  1323. * @name has
  1324. * @memberOf ListCache
  1325. * @param {string} key The key of the entry to check.
  1326. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1327. */
  1328. function listCacheHas(key) {
  1329. return assocIndexOf(this.__data__, key) > -1;
  1330. }
  1331. /**
  1332. * Sets the list cache `key` to `value`.
  1333. *
  1334. * @private
  1335. * @name set
  1336. * @memberOf ListCache
  1337. * @param {string} key The key of the value to set.
  1338. * @param {*} value The value to set.
  1339. * @returns {Object} Returns the list cache instance.
  1340. */
  1341. function listCacheSet(key, value) {
  1342. var data = this.__data__,
  1343. index = assocIndexOf(data, key);
  1344. if (index < 0) {
  1345. ++this.size;
  1346. data.push([key, value]);
  1347. } else {
  1348. data[index][1] = value;
  1349. }
  1350. return this;
  1351. }
  1352. // Add methods to `ListCache`.
  1353. ListCache.prototype.clear = listCacheClear;
  1354. ListCache.prototype['delete'] = listCacheDelete;
  1355. ListCache.prototype.get = listCacheGet;
  1356. ListCache.prototype.has = listCacheHas;
  1357. ListCache.prototype.set = listCacheSet;
  1358. /**
  1359. * Creates a map cache object to store key-value pairs.
  1360. *
  1361. * @private
  1362. * @constructor
  1363. * @param {Array} [entries] The key-value pairs to cache.
  1364. */
  1365. function MapCache(entries) {
  1366. var index = -1,
  1367. length = entries == null ? 0 : entries.length;
  1368. this.clear();
  1369. while (++index < length) {
  1370. var entry = entries[index];
  1371. this.set(entry[0], entry[1]);
  1372. }
  1373. }
  1374. /**
  1375. * Removes all key-value entries from the map.
  1376. *
  1377. * @private
  1378. * @name clear
  1379. * @memberOf MapCache
  1380. */
  1381. function mapCacheClear() {
  1382. this.size = 0;
  1383. this.__data__ = {
  1384. 'hash': new Hash,
  1385. 'map': new (Map || ListCache),
  1386. 'string': new Hash
  1387. };
  1388. }
  1389. /**
  1390. * Removes `key` and its value from the map.
  1391. *
  1392. * @private
  1393. * @name delete
  1394. * @memberOf MapCache
  1395. * @param {string} key The key of the value to remove.
  1396. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  1397. */
  1398. function mapCacheDelete(key) {
  1399. var result = getMapData(this, key)['delete'](key);
  1400. this.size -= result ? 1 : 0;
  1401. return result;
  1402. }
  1403. /**
  1404. * Gets the map value for `key`.
  1405. *
  1406. * @private
  1407. * @name get
  1408. * @memberOf MapCache
  1409. * @param {string} key The key of the value to get.
  1410. * @returns {*} Returns the entry value.
  1411. */
  1412. function mapCacheGet(key) {
  1413. return getMapData(this, key).get(key);
  1414. }
  1415. /**
  1416. * Checks if a map value for `key` exists.
  1417. *
  1418. * @private
  1419. * @name has
  1420. * @memberOf MapCache
  1421. * @param {string} key The key of the entry to check.
  1422. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1423. */
  1424. function mapCacheHas(key) {
  1425. return getMapData(this, key).has(key);
  1426. }
  1427. /**
  1428. * Sets the map `key` to `value`.
  1429. *
  1430. * @private
  1431. * @name set
  1432. * @memberOf MapCache
  1433. * @param {string} key The key of the value to set.
  1434. * @param {*} value The value to set.
  1435. * @returns {Object} Returns the map cache instance.
  1436. */
  1437. function mapCacheSet(key, value) {
  1438. var data = getMapData(this, key),
  1439. size = data.size;
  1440. data.set(key, value);
  1441. this.size += data.size == size ? 0 : 1;
  1442. return this;
  1443. }
  1444. // Add methods to `MapCache`.
  1445. MapCache.prototype.clear = mapCacheClear;
  1446. MapCache.prototype['delete'] = mapCacheDelete;
  1447. MapCache.prototype.get = mapCacheGet;
  1448. MapCache.prototype.has = mapCacheHas;
  1449. MapCache.prototype.set = mapCacheSet;
  1450. /**
  1451. *
  1452. * Creates an array cache object to store unique values.
  1453. *
  1454. * @private
  1455. * @constructor
  1456. * @param {Array} [values] The values to cache.
  1457. */
  1458. function SetCache(values) {
  1459. var index = -1,
  1460. length = values == null ? 0 : values.length;
  1461. this.__data__ = new MapCache;
  1462. while (++index < length) {
  1463. this.add(values[index]);
  1464. }
  1465. }
  1466. /**
  1467. * Adds `value` to the array cache.
  1468. *
  1469. * @private
  1470. * @name add
  1471. * @memberOf SetCache
  1472. * @alias push
  1473. * @param {*} value The value to cache.
  1474. * @returns {Object} Returns the cache instance.
  1475. */
  1476. function setCacheAdd(value) {
  1477. this.__data__.set(value, HASH_UNDEFINED);
  1478. return this;
  1479. }
  1480. /**
  1481. * Checks if `value` is in the array cache.
  1482. *
  1483. * @private
  1484. * @name has
  1485. * @memberOf SetCache
  1486. * @param {*} value The value to search for.
  1487. * @returns {number} Returns `true` if `value` is found, else `false`.
  1488. */
  1489. function setCacheHas(value) {
  1490. return this.__data__.has(value);
  1491. }
  1492. // Add methods to `SetCache`.
  1493. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  1494. SetCache.prototype.has = setCacheHas;
  1495. /**
  1496. * Creates a stack cache object to store key-value pairs.
  1497. *
  1498. * @private
  1499. * @constructor
  1500. * @param {Array} [entries] The key-value pairs to cache.
  1501. */
  1502. function Stack(entries) {
  1503. var data = this.__data__ = new ListCache(entries);
  1504. this.size = data.size;
  1505. }
  1506. /**
  1507. * Removes all key-value entries from the stack.
  1508. *
  1509. * @private
  1510. * @name clear
  1511. * @memberOf Stack
  1512. */
  1513. function stackClear() {
  1514. this.__data__ = new ListCache;
  1515. this.size = 0;
  1516. }
  1517. /**
  1518. * Removes `key` and its value from the stack.
  1519. *
  1520. * @private
  1521. * @name delete
  1522. * @memberOf Stack
  1523. * @param {string} key The key of the value to remove.
  1524. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  1525. */
  1526. function stackDelete(key) {
  1527. var data = this.__data__,
  1528. result = data['delete'](key);
  1529. this.size = data.size;
  1530. return result;
  1531. }
  1532. /**
  1533. * Gets the stack value for `key`.
  1534. *
  1535. * @private
  1536. * @name get
  1537. * @memberOf Stack
  1538. * @param {string} key The key of the value to get.
  1539. * @returns {*} Returns the entry value.
  1540. */
  1541. function stackGet(key) {
  1542. return this.__data__.get(key);
  1543. }
  1544. /**
  1545. * Checks if a stack value for `key` exists.
  1546. *
  1547. * @private
  1548. * @name has
  1549. * @memberOf Stack
  1550. * @param {string} key The key of the entry to check.
  1551. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1552. */
  1553. function stackHas(key) {
  1554. return this.__data__.has(key);
  1555. }
  1556. /**
  1557. * Sets the stack `key` to `value`.
  1558. *
  1559. * @private
  1560. * @name set
  1561. * @memberOf Stack
  1562. * @param {string} key The key of the value to set.
  1563. * @param {*} value The value to set.
  1564. * @returns {Object} Returns the stack cache instance.
  1565. */
  1566. function stackSet(key, value) {
  1567. var data = this.__data__;
  1568. if (data instanceof ListCache) {
  1569. var pairs = data.__data__;
  1570. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  1571. pairs.push([key, value]);
  1572. this.size = ++data.size;
  1573. return this;
  1574. }
  1575. data = this.__data__ = new MapCache(pairs);
  1576. }
  1577. data.set(key, value);
  1578. this.size = data.size;
  1579. return this;
  1580. }
  1581. // Add methods to `Stack`.
  1582. Stack.prototype.clear = stackClear;
  1583. Stack.prototype['delete'] = stackDelete;
  1584. Stack.prototype.get = stackGet;
  1585. Stack.prototype.has = stackHas;
  1586. Stack.prototype.set = stackSet;
  1587. /**
  1588. * Creates an array of the enumerable property names of the array-like `value`.
  1589. *
  1590. * @private
  1591. * @param {*} value The value to query.
  1592. * @param {boolean} inherited Specify returning inherited property names.
  1593. * @returns {Array} Returns the array of property names.
  1594. */
  1595. function arrayLikeKeys(value, inherited) {
  1596. var isArr = isArray(value),
  1597. isArg = !isArr && isArguments(value),
  1598. isBuff = !isArr && !isArg && isBuffer(value),
  1599. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  1600. skipIndexes = isArr || isArg || isBuff || isType,
  1601. result = skipIndexes ? baseTimes(value.length, String) : [],
  1602. length = result.length;
  1603. for (var key in value) {
  1604. if ((inherited || hasOwnProperty.call(value, key)) &&
  1605. !(skipIndexes && (
  1606. // Safari 9 has enumerable `arguments.length` in strict mode.
  1607. key == 'length' ||
  1608. // Node.js 0.10 has enumerable non-index properties on buffers.
  1609. (isBuff && (key == 'offset' || key == 'parent')) ||
  1610. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  1611. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  1612. // Skip index properties.
  1613. isIndex(key, length)
  1614. ))) {
  1615. result.push(key);
  1616. }
  1617. }
  1618. return result;
  1619. }
  1620. /**
  1621. * Gets the index at which the `key` is found in `array` of key-value pairs.
  1622. *
  1623. * @private
  1624. * @param {Array} array The array to inspect.
  1625. * @param {*} key The key to search for.
  1626. * @returns {number} Returns the index of the matched value, else `-1`.
  1627. */
  1628. function assocIndexOf(array, key) {
  1629. var length = array.length;
  1630. while (length--) {
  1631. if (eq(array[length][0], key)) {
  1632. return length;
  1633. }
  1634. }
  1635. return -1;
  1636. }
  1637. /**
  1638. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  1639. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  1640. * symbols of `object`.
  1641. *
  1642. * @private
  1643. * @param {Object} object The object to query.
  1644. * @param {Function} keysFunc The function to get the keys of `object`.
  1645. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  1646. * @returns {Array} Returns the array of property names and symbols.
  1647. */
  1648. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  1649. var result = keysFunc(object);
  1650. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  1651. }
  1652. /**
  1653. * The base implementation of `getTag` without fallbacks for buggy environments.
  1654. *
  1655. * @private
  1656. * @param {*} value The value to query.
  1657. * @returns {string} Returns the `toStringTag`.
  1658. */
  1659. function baseGetTag(value) {
  1660. if (value == null) {
  1661. return value === undefined ? undefinedTag : nullTag;
  1662. }
  1663. return (symToStringTag && symToStringTag in Object(value))
  1664. ? getRawTag(value)
  1665. : objectToString(value);
  1666. }
  1667. /**
  1668. * The base implementation of `_.isArguments`.
  1669. *
  1670. * @private
  1671. * @param {*} value The value to check.
  1672. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  1673. */
  1674. function baseIsArguments(value) {
  1675. return isObjectLike(value) && baseGetTag(value) == argsTag;
  1676. }
  1677. /**
  1678. * The base implementation of `_.isEqual` which supports partial comparisons
  1679. * and tracks traversed objects.
  1680. *
  1681. * @private
  1682. * @param {*} value The value to compare.
  1683. * @param {*} other The other value to compare.
  1684. * @param {boolean} bitmask The bitmask flags.
  1685. * 1 - Unordered comparison
  1686. * 2 - Partial comparison
  1687. * @param {Function} [customizer] The function to customize comparisons.
  1688. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  1689. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  1690. */
  1691. function baseIsEqual(value, other, bitmask, customizer, stack) {
  1692. if (value === other) {
  1693. return true;
  1694. }
  1695. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  1696. return value !== value && other !== other;
  1697. }
  1698. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  1699. }
  1700. /**
  1701. * A specialized version of `baseIsEqual` for arrays and objects which performs
  1702. * deep comparisons and tracks traversed objects enabling objects with circular
  1703. * references to be compared.
  1704. *
  1705. * @private
  1706. * @param {Object} object The object to compare.
  1707. * @param {Object} other The other object to compare.
  1708. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  1709. * @param {Function} customizer The function to customize comparisons.
  1710. * @param {Function} equalFunc The function to determine equivalents of values.
  1711. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  1712. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  1713. */
  1714. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  1715. var objIsArr = isArray(object),
  1716. othIsArr = isArray(other),
  1717. objTag = objIsArr ? arrayTag : getTag(object),
  1718. othTag = othIsArr ? arrayTag : getTag(other);
  1719. objTag = objTag == argsTag ? objectTag : objTag;
  1720. othTag = othTag == argsTag ? objectTag : othTag;
  1721. var objIsObj = objTag == objectTag,
  1722. othIsObj = othTag == objectTag,
  1723. isSameTag = objTag == othTag;
  1724. if (isSameTag && isBuffer(object)) {
  1725. if (!isBuffer(other)) {
  1726. return false;
  1727. }
  1728. objIsArr = true;
  1729. objIsObj = false;
  1730. }
  1731. if (isSameTag && !objIsObj) {
  1732. stack || (stack = new Stack);
  1733. return (objIsArr || isTypedArray(object))
  1734. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  1735. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  1736. }
  1737. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  1738. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  1739. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  1740. if (objIsWrapped || othIsWrapped) {
  1741. var objUnwrapped = objIsWrapped ? object.value() : object,
  1742. othUnwrapped = othIsWrapped ? other.value() : other;
  1743. stack || (stack = new Stack);
  1744. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  1745. }
  1746. }
  1747. if (!isSameTag) {
  1748. return false;
  1749. }
  1750. stack || (stack = new Stack);
  1751. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  1752. }
  1753. /**
  1754. * The base implementation of `_.isNative` without bad shim checks.
  1755. *
  1756. * @private
  1757. * @param {*} value The value to check.
  1758. * @returns {boolean} Returns `true` if `value` is a native function,
  1759. * else `false`.
  1760. */
  1761. function baseIsNative(value) {
  1762. if (!isObject(value) || isMasked(value)) {
  1763. return false;
  1764. }
  1765. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  1766. return pattern.test(toSource(value));
  1767. }
  1768. /**
  1769. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  1770. *
  1771. * @private
  1772. * @param {*} value The value to check.
  1773. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  1774. */
  1775. function baseIsTypedArray(value) {
  1776. return isObjectLike(value) &&
  1777. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  1778. }
  1779. /**
  1780. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  1781. *
  1782. * @private
  1783. * @param {Object} object The object to query.
  1784. * @returns {Array} Returns the array of property names.
  1785. */
  1786. function baseKeys(object) {
  1787. if (!isPrototype(object)) {
  1788. return nativeKeys(object);
  1789. }
  1790. var result = [];
  1791. for (var key in Object(object)) {
  1792. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  1793. result.push(key);
  1794. }
  1795. }
  1796. return result;
  1797. }
  1798. /**
  1799. * A specialized version of `baseIsEqualDeep` for arrays with support for
  1800. * partial deep comparisons.
  1801. *
  1802. * @private
  1803. * @param {Array} array The array to compare.
  1804. * @param {Array} other The other array to compare.
  1805. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  1806. * @param {Function} customizer The function to customize comparisons.
  1807. * @param {Function} equalFunc The function to determine equivalents of values.
  1808. * @param {Object} stack Tracks traversed `array` and `other` objects.
  1809. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  1810. */
  1811. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  1812. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  1813. arrLength = array.length,
  1814. othLength = other.length;
  1815. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  1816. return false;
  1817. }
  1818. // Assume cyclic values are equal.
  1819. var stacked = stack.get(array);
  1820. if (stacked && stack.get(other)) {
  1821. return stacked == other;
  1822. }
  1823. var index = -1,
  1824. result = true,
  1825. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  1826. stack.set(array, other);
  1827. stack.set(other, array);
  1828. // Ignore non-index properties.
  1829. while (++index < arrLength) {
  1830. var arrValue = array[index],
  1831. othValue = other[index];
  1832. if (customizer) {
  1833. var compared = isPartial
  1834. ? customizer(othValue, arrValue, index, other, array, stack)
  1835. : customizer(arrValue, othValue, index, array, other, stack);
  1836. }
  1837. if (compared !== undefined) {
  1838. if (compared) {
  1839. continue;
  1840. }
  1841. result = false;
  1842. break;
  1843. }
  1844. // Recursively compare arrays (susceptible to call stack limits).
  1845. if (seen) {
  1846. if (!arraySome(other, function(othValue, othIndex) {
  1847. if (!cacheHas(seen, othIndex) &&
  1848. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  1849. return seen.push(othIndex);
  1850. }
  1851. })) {
  1852. result = false;
  1853. break;
  1854. }
  1855. } else if (!(
  1856. arrValue === othValue ||
  1857. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  1858. )) {
  1859. result = false;
  1860. break;
  1861. }
  1862. }
  1863. stack['delete'](array);
  1864. stack['delete'](other);
  1865. return result;
  1866. }
  1867. /**
  1868. * A specialized version of `baseIsEqualDeep` for comparing objects of
  1869. * the same `toStringTag`.
  1870. *
  1871. * **Note:** This function only supports comparing values with tags of
  1872. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  1873. *
  1874. * @private
  1875. * @param {Object} object The object to compare.
  1876. * @param {Object} other The other object to compare.
  1877. * @param {string} tag The `toStringTag` of the objects to compare.
  1878. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  1879. * @param {Function} customizer The function to customize comparisons.
  1880. * @param {Function} equalFunc The function to determine equivalents of values.
  1881. * @param {Object} stack Tracks traversed `object` and `other` objects.
  1882. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  1883. */
  1884. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  1885. switch (tag) {
  1886. case dataViewTag:
  1887. if ((object.byteLength != other.byteLength) ||
  1888. (object.byteOffset != other.byteOffset)) {
  1889. return false;
  1890. }
  1891. object = object.buffer;
  1892. other = other.buffer;
  1893. case arrayBufferTag:
  1894. if ((object.byteLength != other.byteLength) ||
  1895. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  1896. return false;
  1897. }
  1898. return true;
  1899. case boolTag:
  1900. case dateTag:
  1901. case numberTag:
  1902. // Coerce booleans to `1` or `0` and dates to milliseconds.
  1903. // Invalid dates are coerced to `NaN`.
  1904. return eq(+object, +other);
  1905. case errorTag:
  1906. return object.name == other.name && object.message == other.message;
  1907. case regexpTag:
  1908. case stringTag:
  1909. // Coerce regexes to strings and treat strings, primitives and objects,
  1910. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  1911. // for more details.
  1912. return object == (other + '');
  1913. case mapTag:
  1914. var convert = mapToArray;
  1915. case setTag:
  1916. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  1917. convert || (convert = setToArray);
  1918. if (object.size != other.size && !isPartial) {
  1919. return false;
  1920. }
  1921. // Assume cyclic values are equal.
  1922. var stacked = stack.get(object);
  1923. if (stacked) {
  1924. return stacked == other;
  1925. }
  1926. bitmask |= COMPARE_UNORDERED_FLAG;
  1927. // Recursively compare objects (susceptible to call stack limits).
  1928. stack.set(object, other);
  1929. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  1930. stack['delete'](object);
  1931. return result;
  1932. case symbolTag:
  1933. if (symbolValueOf) {
  1934. return symbolValueOf.call(object) == symbolValueOf.call(other);
  1935. }
  1936. }
  1937. return false;
  1938. }
  1939. /**
  1940. * A specialized version of `baseIsEqualDeep` for objects with support for
  1941. * partial deep comparisons.
  1942. *
  1943. * @private
  1944. * @param {Object} object The object to compare.
  1945. * @param {Object} other The other object to compare.
  1946. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  1947. * @param {Function} customizer The function to customize comparisons.
  1948. * @param {Function} equalFunc The function to determine equivalents of values.
  1949. * @param {Object} stack Tracks traversed `object` and `other` objects.
  1950. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  1951. */
  1952. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  1953. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  1954. objProps = getAllKeys(object),
  1955. objLength = objProps.length,
  1956. othProps = getAllKeys(other),
  1957. othLength = othProps.length;
  1958. if (objLength != othLength && !isPartial) {
  1959. return false;
  1960. }
  1961. var index = objLength;
  1962. while (index--) {
  1963. var key = objProps[index];
  1964. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  1965. return false;
  1966. }
  1967. }
  1968. // Assume cyclic values are equal.
  1969. var stacked = stack.get(object);
  1970. if (stacked && stack.get(other)) {
  1971. return stacked == other;
  1972. }
  1973. var result = true;
  1974. stack.set(object, other);
  1975. stack.set(other, object);
  1976. var skipCtor = isPartial;
  1977. while (++index < objLength) {
  1978. key = objProps[index];
  1979. var objValue = object[key],
  1980. othValue = other[key];
  1981. if (customizer) {
  1982. var compared = isPartial
  1983. ? customizer(othValue, objValue, key, other, object, stack)
  1984. : customizer(objValue, othValue, key, object, other, stack);
  1985. }
  1986. // Recursively compare objects (susceptible to call stack limits).
  1987. if (!(compared === undefined
  1988. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  1989. : compared
  1990. )) {
  1991. result = false;
  1992. break;
  1993. }
  1994. skipCtor || (skipCtor = key == 'constructor');
  1995. }
  1996. if (result && !skipCtor) {
  1997. var objCtor = object.constructor,
  1998. othCtor = other.constructor;
  1999. // Non `Object` object instances with different constructors are not equal.
  2000. if (objCtor != othCtor &&
  2001. ('constructor' in object && 'constructor' in other) &&
  2002. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  2003. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  2004. result = false;
  2005. }
  2006. }
  2007. stack['delete'](object);
  2008. stack['delete'](other);
  2009. return result;
  2010. }
  2011. /**
  2012. * Creates an array of own enumerable property names and symbols of `object`.
  2013. *
  2014. * @private
  2015. * @param {Object} object The object to query.
  2016. * @returns {Array} Returns the array of property names and symbols.
  2017. */
  2018. function getAllKeys(object) {
  2019. return baseGetAllKeys(object, keys, getSymbols);
  2020. }
  2021. /**
  2022. * Gets the data for `map`.
  2023. *
  2024. * @private
  2025. * @param {Object} map The map to query.
  2026. * @param {string} key The reference key.
  2027. * @returns {*} Returns the map data.
  2028. */
  2029. function getMapData(map, key) {
  2030. var data = map.__data__;
  2031. return isKeyable(key)
  2032. ? data[typeof key == 'string' ? 'string' : 'hash']
  2033. : data.map;
  2034. }
  2035. /**
  2036. * Gets the native function at `key` of `object`.
  2037. *
  2038. * @private
  2039. * @param {Object} object The object to query.
  2040. * @param {string} key The key of the method to get.
  2041. * @returns {*} Returns the function if it's native, else `undefined`.
  2042. */
  2043. function getNative(object, key) {
  2044. var value = getValue(object, key);
  2045. return baseIsNative(value) ? value : undefined;
  2046. }
  2047. /**
  2048. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  2049. *
  2050. * @private
  2051. * @param {*} value The value to query.
  2052. * @returns {string} Returns the raw `toStringTag`.
  2053. */
  2054. function getRawTag(value) {
  2055. var isOwn = hasOwnProperty.call(value, symToStringTag),
  2056. tag = value[symToStringTag];
  2057. try {
  2058. value[symToStringTag] = undefined;
  2059. var unmasked = true;
  2060. } catch (e) {}
  2061. var result = nativeObjectToString.call(value);
  2062. if (unmasked) {
  2063. if (isOwn) {
  2064. value[symToStringTag] = tag;
  2065. } else {
  2066. delete value[symToStringTag];
  2067. }
  2068. }
  2069. return result;
  2070. }
  2071. /**
  2072. * Creates an array of the own enumerable symbols of `object`.
  2073. *
  2074. * @private
  2075. * @param {Object} object The object to query.
  2076. * @returns {Array} Returns the array of symbols.
  2077. */
  2078. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  2079. if (object == null) {
  2080. return [];
  2081. }
  2082. object = Object(object);
  2083. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  2084. return propertyIsEnumerable.call(object, symbol);
  2085. });
  2086. };
  2087. /**
  2088. * Gets the `toStringTag` of `value`.
  2089. *
  2090. * @private
  2091. * @param {*} value The value to query.
  2092. * @returns {string} Returns the `toStringTag`.
  2093. */
  2094. var getTag = baseGetTag;
  2095. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  2096. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  2097. (Map && getTag(new Map) != mapTag) ||
  2098. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  2099. (Set && getTag(new Set) != setTag) ||
  2100. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  2101. getTag = function(value) {
  2102. var result = baseGetTag(value),
  2103. Ctor = result == objectTag ? value.constructor : undefined,
  2104. ctorString = Ctor ? toSource(Ctor) : '';
  2105. if (ctorString) {
  2106. switch (ctorString) {
  2107. case dataViewCtorString: return dataViewTag;
  2108. case mapCtorString: return mapTag;
  2109. case promiseCtorString: return promiseTag;
  2110. case setCtorString: return setTag;
  2111. case weakMapCtorString: return weakMapTag;
  2112. }
  2113. }
  2114. return result;
  2115. };
  2116. }
  2117. /**
  2118. * Checks if `value` is a valid array-like index.
  2119. *
  2120. * @private
  2121. * @param {*} value The value to check.
  2122. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  2123. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  2124. */
  2125. function isIndex(value, length) {
  2126. length = length == null ? MAX_SAFE_INTEGER : length;
  2127. return !!length &&
  2128. (typeof value == 'number' || reIsUint.test(value)) &&
  2129. (value > -1 && value % 1 == 0 && value < length);
  2130. }
  2131. /**
  2132. * Checks if `value` is suitable for use as unique object key.
  2133. *
  2134. * @private
  2135. * @param {*} value The value to check.
  2136. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  2137. */
  2138. function isKeyable(value) {
  2139. var type = typeof value;
  2140. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  2141. ? (value !== '__proto__')
  2142. : (value === null);
  2143. }
  2144. /**
  2145. * Checks if `func` has its source masked.
  2146. *
  2147. * @private
  2148. * @param {Function} func The function to check.
  2149. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  2150. */
  2151. function isMasked(func) {
  2152. return !!maskSrcKey && (maskSrcKey in func);
  2153. }
  2154. /**
  2155. * Checks if `value` is likely a prototype object.
  2156. *
  2157. * @private
  2158. * @param {*} value The value to check.
  2159. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  2160. */
  2161. function isPrototype(value) {
  2162. var Ctor = value && value.constructor,
  2163. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  2164. return value === proto;
  2165. }
  2166. /**
  2167. * Converts `value` to a string using `Object.prototype.toString`.
  2168. *
  2169. * @private
  2170. * @param {*} value The value to convert.
  2171. * @returns {string} Returns the converted string.
  2172. */
  2173. function objectToString(value) {
  2174. return nativeObjectToString.call(value);
  2175. }
  2176. /**
  2177. * Converts `func` to its source code.
  2178. *
  2179. * @private
  2180. * @param {Function} func The function to convert.
  2181. * @returns {string} Returns the source code.
  2182. */
  2183. function toSource(func) {
  2184. if (func != null) {
  2185. try {
  2186. return funcToString.call(func);
  2187. } catch (e) {}
  2188. try {
  2189. return (func + '');
  2190. } catch (e) {}
  2191. }
  2192. return '';
  2193. }
  2194. /**
  2195. * Performs a
  2196. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  2197. * comparison between two values to determine if they are equivalent.
  2198. *
  2199. * @static
  2200. * @memberOf _
  2201. * @since 4.0.0
  2202. * @category Lang
  2203. * @param {*} value The value to compare.
  2204. * @param {*} other The other value to compare.
  2205. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  2206. * @example
  2207. *
  2208. * var object = { 'a': 1 };
  2209. * var other = { 'a': 1 };
  2210. *
  2211. * _.eq(object, object);
  2212. * // => true
  2213. *
  2214. * _.eq(object, other);
  2215. * // => false
  2216. *
  2217. * _.eq('a', 'a');
  2218. * // => true
  2219. *
  2220. * _.eq('a', Object('a'));
  2221. * // => false
  2222. *
  2223. * _.eq(NaN, NaN);
  2224. * // => true
  2225. */
  2226. function eq(value, other) {
  2227. return value === other || (value !== value && other !== other);
  2228. }
  2229. /**
  2230. * Checks if `value` is likely an `arguments` object.
  2231. *
  2232. * @static
  2233. * @memberOf _
  2234. * @since 0.1.0
  2235. * @category Lang
  2236. * @param {*} value The value to check.
  2237. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  2238. * else `false`.
  2239. * @example
  2240. *
  2241. * _.isArguments(function() { return arguments; }());
  2242. * // => true
  2243. *
  2244. * _.isArguments([1, 2, 3]);
  2245. * // => false
  2246. */
  2247. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  2248. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  2249. !propertyIsEnumerable.call(value, 'callee');
  2250. };
  2251. /**
  2252. * Checks if `value` is classified as an `Array` object.
  2253. *
  2254. * @static
  2255. * @memberOf _
  2256. * @since 0.1.0
  2257. * @category Lang
  2258. * @param {*} value The value to check.
  2259. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  2260. * @example
  2261. *
  2262. * _.isArray([1, 2, 3]);
  2263. * // => true
  2264. *
  2265. * _.isArray(document.body.children);
  2266. * // => false
  2267. *
  2268. * _.isArray('abc');
  2269. * // => false
  2270. *
  2271. * _.isArray(_.noop);
  2272. * // => false
  2273. */
  2274. var isArray = Array.isArray;
  2275. /**
  2276. * Checks if `value` is array-like. A value is considered array-like if it's
  2277. * not a function and has a `value.length` that's an integer greater than or
  2278. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  2279. *
  2280. * @static
  2281. * @memberOf _
  2282. * @since 4.0.0
  2283. * @category Lang
  2284. * @param {*} value The value to check.
  2285. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  2286. * @example
  2287. *
  2288. * _.isArrayLike([1, 2, 3]);
  2289. * // => true
  2290. *
  2291. * _.isArrayLike(document.body.children);
  2292. * // => true
  2293. *
  2294. * _.isArrayLike('abc');
  2295. * // => true
  2296. *
  2297. * _.isArrayLike(_.noop);
  2298. * // => false
  2299. */
  2300. function isArrayLike(value) {
  2301. return value != null && isLength(value.length) && !isFunction(value);
  2302. }
  2303. /**
  2304. * Checks if `value` is a buffer.
  2305. *
  2306. * @static
  2307. * @memberOf _
  2308. * @since 4.3.0
  2309. * @category Lang
  2310. * @param {*} value The value to check.
  2311. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  2312. * @example
  2313. *
  2314. * _.isBuffer(new Buffer(2));
  2315. * // => true
  2316. *
  2317. * _.isBuffer(new Uint8Array(2));
  2318. * // => false
  2319. */
  2320. var isBuffer = nativeIsBuffer || stubFalse;
  2321. /**
  2322. * Performs a deep comparison between two values to determine if they are
  2323. * equivalent.
  2324. *
  2325. * **Note:** This method supports comparing arrays, array buffers, booleans,
  2326. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  2327. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  2328. * by their own, not inherited, enumerable properties. Functions and DOM
  2329. * nodes are compared by strict equality, i.e. `===`.
  2330. *
  2331. * @static
  2332. * @memberOf _
  2333. * @since 0.1.0
  2334. * @category Lang
  2335. * @param {*} value The value to compare.
  2336. * @param {*} other The other value to compare.
  2337. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  2338. * @example
  2339. *
  2340. * var object = { 'a': 1 };
  2341. * var other = { 'a': 1 };
  2342. *
  2343. * _.isEqual(object, other);
  2344. * // => true
  2345. *
  2346. * object === other;
  2347. * // => false
  2348. */
  2349. function isEqual(value, other) {
  2350. return baseIsEqual(value, other);
  2351. }
  2352. /**
  2353. * Checks if `value` is classified as a `Function` object.
  2354. *
  2355. * @static
  2356. * @memberOf _
  2357. * @since 0.1.0
  2358. * @category Lang
  2359. * @param {*} value The value to check.
  2360. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  2361. * @example
  2362. *
  2363. * _.isFunction(_);
  2364. * // => true
  2365. *
  2366. * _.isFunction(/abc/);
  2367. * // => false
  2368. */
  2369. function isFunction(value) {
  2370. if (!isObject(value)) {
  2371. return false;
  2372. }
  2373. // The use of `Object#toString` avoids issues with the `typeof` operator
  2374. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  2375. var tag = baseGetTag(value);
  2376. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  2377. }
  2378. /**
  2379. * Checks if `value` is a valid array-like length.
  2380. *
  2381. * **Note:** This method is loosely based on
  2382. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  2383. *
  2384. * @static
  2385. * @memberOf _
  2386. * @since 4.0.0
  2387. * @category Lang
  2388. * @param {*} value The value to check.
  2389. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  2390. * @example
  2391. *
  2392. * _.isLength(3);
  2393. * // => true
  2394. *
  2395. * _.isLength(Number.MIN_VALUE);
  2396. * // => false
  2397. *
  2398. * _.isLength(Infinity);
  2399. * // => false
  2400. *
  2401. * _.isLength('3');
  2402. * // => false
  2403. */
  2404. function isLength(value) {
  2405. return typeof value == 'number' &&
  2406. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  2407. }
  2408. /**
  2409. * Checks if `value` is the
  2410. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  2411. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  2412. *
  2413. * @static
  2414. * @memberOf _
  2415. * @since 0.1.0
  2416. * @category Lang
  2417. * @param {*} value The value to check.
  2418. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  2419. * @example
  2420. *
  2421. * _.isObject({});
  2422. * // => true
  2423. *
  2424. * _.isObject([1, 2, 3]);
  2425. * // => true
  2426. *
  2427. * _.isObject(_.noop);
  2428. * // => true
  2429. *
  2430. * _.isObject(null);
  2431. * // => false
  2432. */
  2433. function isObject(value) {
  2434. var type = typeof value;
  2435. return value != null && (type == 'object' || type == 'function');
  2436. }
  2437. /**
  2438. * Checks if `value` is object-like. A value is object-like if it's not `null`
  2439. * and has a `typeof` result of "object".
  2440. *
  2441. * @static
  2442. * @memberOf _
  2443. * @since 4.0.0
  2444. * @category Lang
  2445. * @param {*} value The value to check.
  2446. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  2447. * @example
  2448. *
  2449. * _.isObjectLike({});
  2450. * // => true
  2451. *
  2452. * _.isObjectLike([1, 2, 3]);
  2453. * // => true
  2454. *
  2455. * _.isObjectLike(_.noop);
  2456. * // => false
  2457. *
  2458. * _.isObjectLike(null);
  2459. * // => false
  2460. */
  2461. function isObjectLike(value) {
  2462. return value != null && typeof value == 'object';
  2463. }
  2464. /**
  2465. * Checks if `value` is classified as a typed array.
  2466. *
  2467. * @static
  2468. * @memberOf _
  2469. * @since 3.0.0
  2470. * @category Lang
  2471. * @param {*} value The value to check.
  2472. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  2473. * @example
  2474. *
  2475. * _.isTypedArray(new Uint8Array);
  2476. * // => true
  2477. *
  2478. * _.isTypedArray([]);
  2479. * // => false
  2480. */
  2481. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  2482. /**
  2483. * Creates an array of the own enumerable property names of `object`.
  2484. *
  2485. * **Note:** Non-object values are coerced to objects. See the
  2486. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  2487. * for more details.
  2488. *
  2489. * @static
  2490. * @since 0.1.0
  2491. * @memberOf _
  2492. * @category Object
  2493. * @param {Object} object The object to query.
  2494. * @returns {Array} Returns the array of property names.
  2495. * @example
  2496. *
  2497. * function Foo() {
  2498. * this.a = 1;
  2499. * this.b = 2;
  2500. * }
  2501. *
  2502. * Foo.prototype.c = 3;
  2503. *
  2504. * _.keys(new Foo);
  2505. * // => ['a', 'b'] (iteration order is not guaranteed)
  2506. *
  2507. * _.keys('hi');
  2508. * // => ['0', '1']
  2509. */
  2510. function keys(object) {
  2511. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  2512. }
  2513. /**
  2514. * This method returns a new empty array.
  2515. *
  2516. * @static
  2517. * @memberOf _
  2518. * @since 4.13.0
  2519. * @category Util
  2520. * @returns {Array} Returns the new empty array.
  2521. * @example
  2522. *
  2523. * var arrays = _.times(2, _.stubArray);
  2524. *
  2525. * console.log(arrays);
  2526. * // => [[], []]
  2527. *
  2528. * console.log(arrays[0] === arrays[1]);
  2529. * // => false
  2530. */
  2531. function stubArray() {
  2532. return [];
  2533. }
  2534. /**
  2535. * This method returns `false`.
  2536. *
  2537. * @static
  2538. * @memberOf _
  2539. * @since 4.13.0
  2540. * @category Util
  2541. * @returns {boolean} Returns `false`.
  2542. * @example
  2543. *
  2544. * _.times(2, _.stubFalse);
  2545. * // => [false, false]
  2546. */
  2547. function stubFalse() {
  2548. return false;
  2549. }
  2550. module.exports = isEqual;
  2551. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  2552. },{}],3:[function(require,module,exports){
  2553. // shim for using process in browser
  2554. var process = module.exports = {};
  2555. // cached from whatever global is present so that test runners that stub it
  2556. // don't break things. But we need to wrap it in a try catch in case it is
  2557. // wrapped in strict mode code which doesn't define any globals. It's inside a
  2558. // function because try/catches deoptimize in certain engines.
  2559. var cachedSetTimeout;
  2560. var cachedClearTimeout;
  2561. function defaultSetTimout() {
  2562. throw new Error('setTimeout has not been defined');
  2563. }
  2564. function defaultClearTimeout () {
  2565. throw new Error('clearTimeout has not been defined');
  2566. }
  2567. (function () {
  2568. try {
  2569. if (typeof setTimeout === 'function') {
  2570. cachedSetTimeout = setTimeout;
  2571. } else {
  2572. cachedSetTimeout = defaultSetTimout;
  2573. }
  2574. } catch (e) {
  2575. cachedSetTimeout = defaultSetTimout;
  2576. }
  2577. try {
  2578. if (typeof clearTimeout === 'function') {
  2579. cachedClearTimeout = clearTimeout;
  2580. } else {
  2581. cachedClearTimeout = defaultClearTimeout;
  2582. }
  2583. } catch (e) {
  2584. cachedClearTimeout = defaultClearTimeout;
  2585. }
  2586. } ())
  2587. function runTimeout(fun) {
  2588. if (cachedSetTimeout === setTimeout) {
  2589. //normal enviroments in sane situations
  2590. return setTimeout(fun, 0);
  2591. }
  2592. // if setTimeout wasn't available but was latter defined
  2593. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  2594. cachedSetTimeout = setTimeout;
  2595. return setTimeout(fun, 0);
  2596. }
  2597. try {
  2598. // when when somebody has screwed with setTimeout but no I.E. maddness
  2599. return cachedSetTimeout(fun, 0);
  2600. } catch(e){
  2601. try {
  2602. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  2603. return cachedSetTimeout.call(null, fun, 0);
  2604. } catch(e){
  2605. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  2606. return cachedSetTimeout.call(this, fun, 0);
  2607. }
  2608. }
  2609. }
  2610. function runClearTimeout(marker) {
  2611. if (cachedClearTimeout === clearTimeout) {
  2612. //normal enviroments in sane situations
  2613. return clearTimeout(marker);
  2614. }
  2615. // if clearTimeout wasn't available but was latter defined
  2616. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  2617. cachedClearTimeout = clearTimeout;
  2618. return clearTimeout(marker);
  2619. }
  2620. try {
  2621. // when when somebody has screwed with setTimeout but no I.E. maddness
  2622. return cachedClearTimeout(marker);
  2623. } catch (e){
  2624. try {
  2625. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  2626. return cachedClearTimeout.call(null, marker);
  2627. } catch (e){
  2628. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  2629. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  2630. return cachedClearTimeout.call(this, marker);
  2631. }
  2632. }
  2633. }
  2634. var queue = [];
  2635. var draining = false;
  2636. var currentQueue;
  2637. var queueIndex = -1;
  2638. function cleanUpNextTick() {
  2639. if (!draining || !currentQueue) {
  2640. return;
  2641. }
  2642. draining = false;
  2643. if (currentQueue.length) {
  2644. queue = currentQueue.concat(queue);
  2645. } else {
  2646. queueIndex = -1;
  2647. }
  2648. if (queue.length) {
  2649. drainQueue();
  2650. }
  2651. }
  2652. function drainQueue() {
  2653. if (draining) {
  2654. return;
  2655. }
  2656. var timeout = runTimeout(cleanUpNextTick);
  2657. draining = true;
  2658. var len = queue.length;
  2659. while(len) {
  2660. currentQueue = queue;
  2661. queue = [];
  2662. while (++queueIndex < len) {
  2663. if (currentQueue) {
  2664. currentQueue[queueIndex].run();
  2665. }
  2666. }
  2667. queueIndex = -1;
  2668. len = queue.length;
  2669. }
  2670. currentQueue = null;
  2671. draining = false;
  2672. runClearTimeout(timeout);
  2673. }
  2674. process.nextTick = function (fun) {
  2675. var args = new Array(arguments.length - 1);
  2676. if (arguments.length > 1) {
  2677. for (var i = 1; i < arguments.length; i++) {
  2678. args[i - 1] = arguments[i];
  2679. }
  2680. }
  2681. queue.push(new Item(fun, args));
  2682. if (queue.length === 1 && !draining) {
  2683. runTimeout(drainQueue);
  2684. }
  2685. };
  2686. // v8 likes predictible objects
  2687. function Item(fun, array) {
  2688. this.fun = fun;
  2689. this.array = array;
  2690. }
  2691. Item.prototype.run = function () {
  2692. this.fun.apply(null, this.array);
  2693. };
  2694. process.title = 'browser';
  2695. process.browser = true;
  2696. process.env = {};
  2697. process.argv = [];
  2698. process.version = ''; // empty string to avoid regexp issues
  2699. process.versions = {};
  2700. function noop() {}
  2701. process.on = noop;
  2702. process.addListener = noop;
  2703. process.once = noop;
  2704. process.off = noop;
  2705. process.removeListener = noop;
  2706. process.removeAllListeners = noop;
  2707. process.emit = noop;
  2708. process.prependListener = noop;
  2709. process.prependOnceListener = noop;
  2710. process.listeners = function (name) { return [] }
  2711. process.binding = function (name) {
  2712. throw new Error('process.binding is not supported');
  2713. };
  2714. process.cwd = function () { return '/' };
  2715. process.chdir = function (dir) {
  2716. throw new Error('process.chdir is not supported');
  2717. };
  2718. process.umask = function() { return 0; };
  2719. },{}],4:[function(require,module,exports){
  2720. "use strict";
  2721. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2722. Object.defineProperty(exports, "__esModule", {
  2723. value: true
  2724. });
  2725. exports.default = void 0;
  2726. var _toDate = _interopRequireDefault(require("./lib/toDate"));
  2727. var _toFloat = _interopRequireDefault(require("./lib/toFloat"));
  2728. var _toInt = _interopRequireDefault(require("./lib/toInt"));
  2729. var _toBoolean = _interopRequireDefault(require("./lib/toBoolean"));
  2730. var _equals = _interopRequireDefault(require("./lib/equals"));
  2731. var _contains = _interopRequireDefault(require("./lib/contains"));
  2732. var _matches = _interopRequireDefault(require("./lib/matches"));
  2733. var _isEmail = _interopRequireDefault(require("./lib/isEmail"));
  2734. var _isURL = _interopRequireDefault(require("./lib/isURL"));
  2735. var _isMACAddress = _interopRequireDefault(require("./lib/isMACAddress"));
  2736. var _isIP = _interopRequireDefault(require("./lib/isIP"));
  2737. var _isIPRange = _interopRequireDefault(require("./lib/isIPRange"));
  2738. var _isFQDN = _interopRequireDefault(require("./lib/isFQDN"));
  2739. var _isDate = _interopRequireDefault(require("./lib/isDate"));
  2740. var _isBoolean = _interopRequireDefault(require("./lib/isBoolean"));
  2741. var _isLocale = _interopRequireDefault(require("./lib/isLocale"));
  2742. var _isAlpha = _interopRequireWildcard(require("./lib/isAlpha"));
  2743. var _isAlphanumeric = _interopRequireWildcard(require("./lib/isAlphanumeric"));
  2744. var _isNumeric = _interopRequireDefault(require("./lib/isNumeric"));
  2745. var _isPassportNumber = _interopRequireDefault(require("./lib/isPassportNumber"));
  2746. var _isPort = _interopRequireDefault(require("./lib/isPort"));
  2747. var _isLowercase = _interopRequireDefault(require("./lib/isLowercase"));
  2748. var _isUppercase = _interopRequireDefault(require("./lib/isUppercase"));
  2749. var _isIMEI = _interopRequireDefault(require("./lib/isIMEI"));
  2750. var _isAscii = _interopRequireDefault(require("./lib/isAscii"));
  2751. var _isFullWidth = _interopRequireDefault(require("./lib/isFullWidth"));
  2752. var _isHalfWidth = _interopRequireDefault(require("./lib/isHalfWidth"));
  2753. var _isVariableWidth = _interopRequireDefault(require("./lib/isVariableWidth"));
  2754. var _isMultibyte = _interopRequireDefault(require("./lib/isMultibyte"));
  2755. var _isSemVer = _interopRequireDefault(require("./lib/isSemVer"));
  2756. var _isSurrogatePair = _interopRequireDefault(require("./lib/isSurrogatePair"));
  2757. var _isInt = _interopRequireDefault(require("./lib/isInt"));
  2758. var _isFloat = _interopRequireWildcard(require("./lib/isFloat"));
  2759. var _isDecimal = _interopRequireDefault(require("./lib/isDecimal"));
  2760. var _isHexadecimal = _interopRequireDefault(require("./lib/isHexadecimal"));
  2761. var _isOctal = _interopRequireDefault(require("./lib/isOctal"));
  2762. var _isDivisibleBy = _interopRequireDefault(require("./lib/isDivisibleBy"));
  2763. var _isHexColor = _interopRequireDefault(require("./lib/isHexColor"));
  2764. var _isRgbColor = _interopRequireDefault(require("./lib/isRgbColor"));
  2765. var _isHSL = _interopRequireDefault(require("./lib/isHSL"));
  2766. var _isISRC = _interopRequireDefault(require("./lib/isISRC"));
  2767. var _isIBAN = _interopRequireWildcard(require("./lib/isIBAN"));
  2768. var _isBIC = _interopRequireDefault(require("./lib/isBIC"));
  2769. var _isMD = _interopRequireDefault(require("./lib/isMD5"));
  2770. var _isHash = _interopRequireDefault(require("./lib/isHash"));
  2771. var _isJWT = _interopRequireDefault(require("./lib/isJWT"));
  2772. var _isJSON = _interopRequireDefault(require("./lib/isJSON"));
  2773. var _isEmpty = _interopRequireDefault(require("./lib/isEmpty"));
  2774. var _isLength = _interopRequireDefault(require("./lib/isLength"));
  2775. var _isByteLength = _interopRequireDefault(require("./lib/isByteLength"));
  2776. var _isUUID = _interopRequireDefault(require("./lib/isUUID"));
  2777. var _isMongoId = _interopRequireDefault(require("./lib/isMongoId"));
  2778. var _isAfter = _interopRequireDefault(require("./lib/isAfter"));
  2779. var _isBefore = _interopRequireDefault(require("./lib/isBefore"));
  2780. var _isIn = _interopRequireDefault(require("./lib/isIn"));
  2781. var _isCreditCard = _interopRequireDefault(require("./lib/isCreditCard"));
  2782. var _isIdentityCard = _interopRequireDefault(require("./lib/isIdentityCard"));
  2783. var _isEAN = _interopRequireDefault(require("./lib/isEAN"));
  2784. var _isISIN = _interopRequireDefault(require("./lib/isISIN"));
  2785. var _isISBN = _interopRequireDefault(require("./lib/isISBN"));
  2786. var _isISSN = _interopRequireDefault(require("./lib/isISSN"));
  2787. var _isTaxID = _interopRequireDefault(require("./lib/isTaxID"));
  2788. var _isMobilePhone = _interopRequireWildcard(require("./lib/isMobilePhone"));
  2789. var _isEthereumAddress = _interopRequireDefault(require("./lib/isEthereumAddress"));
  2790. var _isCurrency = _interopRequireDefault(require("./lib/isCurrency"));
  2791. var _isBtcAddress = _interopRequireDefault(require("./lib/isBtcAddress"));
  2792. var _isISO = _interopRequireDefault(require("./lib/isISO8601"));
  2793. var _isRFC = _interopRequireDefault(require("./lib/isRFC3339"));
  2794. var _isISO31661Alpha = _interopRequireDefault(require("./lib/isISO31661Alpha2"));
  2795. var _isISO31661Alpha2 = _interopRequireDefault(require("./lib/isISO31661Alpha3"));
  2796. var _isISO2 = _interopRequireDefault(require("./lib/isISO4217"));
  2797. var _isBase = _interopRequireDefault(require("./lib/isBase32"));
  2798. var _isBase2 = _interopRequireDefault(require("./lib/isBase58"));
  2799. var _isBase3 = _interopRequireDefault(require("./lib/isBase64"));
  2800. var _isDataURI = _interopRequireDefault(require("./lib/isDataURI"));
  2801. var _isMagnetURI = _interopRequireDefault(require("./lib/isMagnetURI"));
  2802. var _isMimeType = _interopRequireDefault(require("./lib/isMimeType"));
  2803. var _isLatLong = _interopRequireDefault(require("./lib/isLatLong"));
  2804. var _isPostalCode = _interopRequireWildcard(require("./lib/isPostalCode"));
  2805. var _ltrim = _interopRequireDefault(require("./lib/ltrim"));
  2806. var _rtrim = _interopRequireDefault(require("./lib/rtrim"));
  2807. var _trim = _interopRequireDefault(require("./lib/trim"));
  2808. var _escape = _interopRequireDefault(require("./lib/escape"));
  2809. var _unescape = _interopRequireDefault(require("./lib/unescape"));
  2810. var _stripLow = _interopRequireDefault(require("./lib/stripLow"));
  2811. var _whitelist = _interopRequireDefault(require("./lib/whitelist"));
  2812. var _blacklist = _interopRequireDefault(require("./lib/blacklist"));
  2813. var _isWhitelisted = _interopRequireDefault(require("./lib/isWhitelisted"));
  2814. var _normalizeEmail = _interopRequireDefault(require("./lib/normalizeEmail"));
  2815. var _isSlug = _interopRequireDefault(require("./lib/isSlug"));
  2816. var _isLicensePlate = _interopRequireDefault(require("./lib/isLicensePlate"));
  2817. var _isStrongPassword = _interopRequireDefault(require("./lib/isStrongPassword"));
  2818. var _isVAT = _interopRequireDefault(require("./lib/isVAT"));
  2819. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  2820. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  2821. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2822. var version = '13.7.0';
  2823. var validator = {
  2824. version: version,
  2825. toDate: _toDate.default,
  2826. toFloat: _toFloat.default,
  2827. toInt: _toInt.default,
  2828. toBoolean: _toBoolean.default,
  2829. equals: _equals.default,
  2830. contains: _contains.default,
  2831. matches: _matches.default,
  2832. isEmail: _isEmail.default,
  2833. isURL: _isURL.default,
  2834. isMACAddress: _isMACAddress.default,
  2835. isIP: _isIP.default,
  2836. isIPRange: _isIPRange.default,
  2837. isFQDN: _isFQDN.default,
  2838. isBoolean: _isBoolean.default,
  2839. isIBAN: _isIBAN.default,
  2840. isBIC: _isBIC.default,
  2841. isAlpha: _isAlpha.default,
  2842. isAlphaLocales: _isAlpha.locales,
  2843. isAlphanumeric: _isAlphanumeric.default,
  2844. isAlphanumericLocales: _isAlphanumeric.locales,
  2845. isNumeric: _isNumeric.default,
  2846. isPassportNumber: _isPassportNumber.default,
  2847. isPort: _isPort.default,
  2848. isLowercase: _isLowercase.default,
  2849. isUppercase: _isUppercase.default,
  2850. isAscii: _isAscii.default,
  2851. isFullWidth: _isFullWidth.default,
  2852. isHalfWidth: _isHalfWidth.default,
  2853. isVariableWidth: _isVariableWidth.default,
  2854. isMultibyte: _isMultibyte.default,
  2855. isSemVer: _isSemVer.default,
  2856. isSurrogatePair: _isSurrogatePair.default,
  2857. isInt: _isInt.default,
  2858. isIMEI: _isIMEI.default,
  2859. isFloat: _isFloat.default,
  2860. isFloatLocales: _isFloat.locales,
  2861. isDecimal: _isDecimal.default,
  2862. isHexadecimal: _isHexadecimal.default,
  2863. isOctal: _isOctal.default,
  2864. isDivisibleBy: _isDivisibleBy.default,
  2865. isHexColor: _isHexColor.default,
  2866. isRgbColor: _isRgbColor.default,
  2867. isHSL: _isHSL.default,
  2868. isISRC: _isISRC.default,
  2869. isMD5: _isMD.default,
  2870. isHash: _isHash.default,
  2871. isJWT: _isJWT.default,
  2872. isJSON: _isJSON.default,
  2873. isEmpty: _isEmpty.default,
  2874. isLength: _isLength.default,
  2875. isLocale: _isLocale.default,
  2876. isByteLength: _isByteLength.default,
  2877. isUUID: _isUUID.default,
  2878. isMongoId: _isMongoId.default,
  2879. isAfter: _isAfter.default,
  2880. isBefore: _isBefore.default,
  2881. isIn: _isIn.default,
  2882. isCreditCard: _isCreditCard.default,
  2883. isIdentityCard: _isIdentityCard.default,
  2884. isEAN: _isEAN.default,
  2885. isISIN: _isISIN.default,
  2886. isISBN: _isISBN.default,
  2887. isISSN: _isISSN.default,
  2888. isMobilePhone: _isMobilePhone.default,
  2889. isMobilePhoneLocales: _isMobilePhone.locales,
  2890. isPostalCode: _isPostalCode.default,
  2891. isPostalCodeLocales: _isPostalCode.locales,
  2892. isEthereumAddress: _isEthereumAddress.default,
  2893. isCurrency: _isCurrency.default,
  2894. isBtcAddress: _isBtcAddress.default,
  2895. isISO8601: _isISO.default,
  2896. isRFC3339: _isRFC.default,
  2897. isISO31661Alpha2: _isISO31661Alpha.default,
  2898. isISO31661Alpha3: _isISO31661Alpha2.default,
  2899. isISO4217: _isISO2.default,
  2900. isBase32: _isBase.default,
  2901. isBase58: _isBase2.default,
  2902. isBase64: _isBase3.default,
  2903. isDataURI: _isDataURI.default,
  2904. isMagnetURI: _isMagnetURI.default,
  2905. isMimeType: _isMimeType.default,
  2906. isLatLong: _isLatLong.default,
  2907. ltrim: _ltrim.default,
  2908. rtrim: _rtrim.default,
  2909. trim: _trim.default,
  2910. escape: _escape.default,
  2911. unescape: _unescape.default,
  2912. stripLow: _stripLow.default,
  2913. whitelist: _whitelist.default,
  2914. blacklist: _blacklist.default,
  2915. isWhitelisted: _isWhitelisted.default,
  2916. normalizeEmail: _normalizeEmail.default,
  2917. toString: toString,
  2918. isSlug: _isSlug.default,
  2919. isStrongPassword: _isStrongPassword.default,
  2920. isTaxID: _isTaxID.default,
  2921. isDate: _isDate.default,
  2922. isLicensePlate: _isLicensePlate.default,
  2923. isVAT: _isVAT.default,
  2924. ibanLocales: _isIBAN.locales
  2925. };
  2926. var _default = validator;
  2927. exports.default = _default;
  2928. module.exports = exports.default;
  2929. module.exports.default = exports.default;
  2930. },{"./lib/blacklist":6,"./lib/contains":7,"./lib/equals":8,"./lib/escape":9,"./lib/isAfter":10,"./lib/isAlpha":11,"./lib/isAlphanumeric":12,"./lib/isAscii":13,"./lib/isBIC":14,"./lib/isBase32":15,"./lib/isBase58":16,"./lib/isBase64":17,"./lib/isBefore":18,"./lib/isBoolean":19,"./lib/isBtcAddress":20,"./lib/isByteLength":21,"./lib/isCreditCard":22,"./lib/isCurrency":23,"./lib/isDataURI":24,"./lib/isDate":25,"./lib/isDecimal":26,"./lib/isDivisibleBy":27,"./lib/isEAN":28,"./lib/isEmail":29,"./lib/isEmpty":30,"./lib/isEthereumAddress":31,"./lib/isFQDN":32,"./lib/isFloat":33,"./lib/isFullWidth":34,"./lib/isHSL":35,"./lib/isHalfWidth":36,"./lib/isHash":37,"./lib/isHexColor":38,"./lib/isHexadecimal":39,"./lib/isIBAN":40,"./lib/isIMEI":41,"./lib/isIP":42,"./lib/isIPRange":43,"./lib/isISBN":44,"./lib/isISIN":45,"./lib/isISO31661Alpha2":46,"./lib/isISO31661Alpha3":47,"./lib/isISO4217":48,"./lib/isISO8601":49,"./lib/isISRC":50,"./lib/isISSN":51,"./lib/isIdentityCard":52,"./lib/isIn":53,"./lib/isInt":54,"./lib/isJSON":55,"./lib/isJWT":56,"./lib/isLatLong":57,"./lib/isLength":58,"./lib/isLicensePlate":59,"./lib/isLocale":60,"./lib/isLowercase":61,"./lib/isMACAddress":62,"./lib/isMD5":63,"./lib/isMagnetURI":64,"./lib/isMimeType":65,"./lib/isMobilePhone":66,"./lib/isMongoId":67,"./lib/isMultibyte":68,"./lib/isNumeric":69,"./lib/isOctal":70,"./lib/isPassportNumber":71,"./lib/isPort":72,"./lib/isPostalCode":73,"./lib/isRFC3339":74,"./lib/isRgbColor":75,"./lib/isSemVer":76,"./lib/isSlug":77,"./lib/isStrongPassword":78,"./lib/isSurrogatePair":79,"./lib/isTaxID":80,"./lib/isURL":81,"./lib/isUUID":82,"./lib/isUppercase":83,"./lib/isVAT":84,"./lib/isVariableWidth":85,"./lib/isWhitelisted":86,"./lib/ltrim":87,"./lib/matches":88,"./lib/normalizeEmail":89,"./lib/rtrim":90,"./lib/stripLow":91,"./lib/toBoolean":92,"./lib/toDate":93,"./lib/toFloat":94,"./lib/toInt":95,"./lib/trim":96,"./lib/unescape":97,"./lib/whitelist":104}],5:[function(require,module,exports){
  2931. "use strict";
  2932. Object.defineProperty(exports, "__esModule", {
  2933. value: true
  2934. });
  2935. exports.commaDecimal = exports.dotDecimal = exports.farsiLocales = exports.arabicLocales = exports.englishLocales = exports.decimal = exports.alphanumeric = exports.alpha = void 0;
  2936. var alpha = {
  2937. 'en-US': /^[A-Z]+$/i,
  2938. 'az-AZ': /^[A-VXYZÇƏĞİıÖŞÜ]+$/i,
  2939. 'bg-BG': /^[А-Я]+$/i,
  2940. 'cs-CZ': /^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,
  2941. 'da-DK': /^[A-ZÆØÅ]+$/i,
  2942. 'de-DE': /^[A-ZÄÖÜß]+$/i,
  2943. 'el-GR': /^[Α-ώ]+$/i,
  2944. 'es-ES': /^[A-ZÁÉÍÑÓÚÜ]+$/i,
  2945. 'fa-IR': /^[ابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی]+$/i,
  2946. 'fi-FI': /^[A-ZÅÄÖ]+$/i,
  2947. 'fr-FR': /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
  2948. 'it-IT': /^[A-ZÀÉÈÌÎÓÒÙ]+$/i,
  2949. 'nb-NO': /^[A-ZÆØÅ]+$/i,
  2950. 'nl-NL': /^[A-ZÁÉËÏÓÖÜÚ]+$/i,
  2951. 'nn-NO': /^[A-ZÆØÅ]+$/i,
  2952. 'hu-HU': /^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i,
  2953. 'pl-PL': /^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,
  2954. 'pt-PT': /^[A-ZÃÁÀÂÄÇÉÊËÍÏÕÓÔÖÚÜ]+$/i,
  2955. 'ru-RU': /^[А-ЯЁ]+$/i,
  2956. 'sl-SI': /^[A-ZČĆĐŠŽ]+$/i,
  2957. 'sk-SK': /^[A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,
  2958. 'sr-RS@latin': /^[A-ZČĆŽŠĐ]+$/i,
  2959. 'sr-RS': /^[А-ЯЂЈЉЊЋЏ]+$/i,
  2960. 'sv-SE': /^[A-ZÅÄÖ]+$/i,
  2961. 'th-TH': /^[ก-๐\s]+$/i,
  2962. 'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i,
  2963. 'uk-UA': /^[А-ЩЬЮЯЄIЇҐі]+$/i,
  2964. 'vi-VN': /^[A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$/i,
  2965. 'ku-IQ': /^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
  2966. ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
  2967. he: /^[א-ת]+$/,
  2968. fa: /^['آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی']+$/i,
  2969. 'hi-IN': /^[\u0900-\u0961]+[\u0972-\u097F]*$/i
  2970. };
  2971. exports.alpha = alpha;
  2972. var alphanumeric = {
  2973. 'en-US': /^[0-9A-Z]+$/i,
  2974. 'az-AZ': /^[0-9A-VXYZÇƏĞİıÖŞÜ]+$/i,
  2975. 'bg-BG': /^[0-9А-Я]+$/i,
  2976. 'cs-CZ': /^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,
  2977. 'da-DK': /^[0-9A-ZÆØÅ]+$/i,
  2978. 'de-DE': /^[0-9A-ZÄÖÜß]+$/i,
  2979. 'el-GR': /^[0-9Α-ω]+$/i,
  2980. 'es-ES': /^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,
  2981. 'fi-FI': /^[0-9A-ZÅÄÖ]+$/i,
  2982. 'fr-FR': /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
  2983. 'it-IT': /^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i,
  2984. 'hu-HU': /^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i,
  2985. 'nb-NO': /^[0-9A-ZÆØÅ]+$/i,
  2986. 'nl-NL': /^[0-9A-ZÁÉËÏÓÖÜÚ]+$/i,
  2987. 'nn-NO': /^[0-9A-ZÆØÅ]+$/i,
  2988. 'pl-PL': /^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i,
  2989. 'pt-PT': /^[0-9A-ZÃÁÀÂÄÇÉÊËÍÏÕÓÔÖÚÜ]+$/i,
  2990. 'ru-RU': /^[0-9А-ЯЁ]+$/i,
  2991. 'sl-SI': /^[0-9A-ZČĆĐŠŽ]+$/i,
  2992. 'sk-SK': /^[0-9A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,
  2993. 'sr-RS@latin': /^[0-9A-ZČĆŽŠĐ]+$/i,
  2994. 'sr-RS': /^[0-9А-ЯЂЈЉЊЋЏ]+$/i,
  2995. 'sv-SE': /^[0-9A-ZÅÄÖ]+$/i,
  2996. 'th-TH': /^[ก-๙\s]+$/i,
  2997. 'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i,
  2998. 'uk-UA': /^[0-9А-ЩЬЮЯЄIЇҐі]+$/i,
  2999. 'ku-IQ': /^[٠١٢٣٤٥٦٧٨٩0-9ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
  3000. 'vi-VN': /^[0-9A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$/i,
  3001. ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
  3002. he: /^[0-9א-ת]+$/,
  3003. fa: /^['0-9آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی۱۲۳۴۵۶۷۸۹۰']+$/i,
  3004. 'hi-IN': /^[\u0900-\u0963]+[\u0966-\u097F]*$/i
  3005. };
  3006. exports.alphanumeric = alphanumeric;
  3007. var decimal = {
  3008. 'en-US': '.',
  3009. ar: '٫'
  3010. };
  3011. exports.decimal = decimal;
  3012. var englishLocales = ['AU', 'GB', 'HK', 'IN', 'NZ', 'ZA', 'ZM'];
  3013. exports.englishLocales = englishLocales;
  3014. for (var locale, i = 0; i < englishLocales.length; i++) {
  3015. locale = "en-".concat(englishLocales[i]);
  3016. alpha[locale] = alpha['en-US'];
  3017. alphanumeric[locale] = alphanumeric['en-US'];
  3018. decimal[locale] = decimal['en-US'];
  3019. } // Source: http://www.localeplanet.com/java/
  3020. var arabicLocales = ['AE', 'BH', 'DZ', 'EG', 'IQ', 'JO', 'KW', 'LB', 'LY', 'MA', 'QM', 'QA', 'SA', 'SD', 'SY', 'TN', 'YE'];
  3021. exports.arabicLocales = arabicLocales;
  3022. for (var _locale, _i = 0; _i < arabicLocales.length; _i++) {
  3023. _locale = "ar-".concat(arabicLocales[_i]);
  3024. alpha[_locale] = alpha.ar;
  3025. alphanumeric[_locale] = alphanumeric.ar;
  3026. decimal[_locale] = decimal.ar;
  3027. }
  3028. var farsiLocales = ['IR', 'AF'];
  3029. exports.farsiLocales = farsiLocales;
  3030. for (var _locale2, _i2 = 0; _i2 < farsiLocales.length; _i2++) {
  3031. _locale2 = "fa-".concat(farsiLocales[_i2]);
  3032. alphanumeric[_locale2] = alphanumeric.fa;
  3033. decimal[_locale2] = decimal.ar;
  3034. } // Source: https://en.wikipedia.org/wiki/Decimal_mark
  3035. var dotDecimal = ['ar-EG', 'ar-LB', 'ar-LY'];
  3036. exports.dotDecimal = dotDecimal;
  3037. var commaDecimal = ['bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-ZM', 'es-ES', 'fr-CA', 'fr-FR', 'id-ID', 'it-IT', 'ku-IQ', 'hi-IN', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-PL', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA', 'vi-VN'];
  3038. exports.commaDecimal = commaDecimal;
  3039. for (var _i3 = 0; _i3 < dotDecimal.length; _i3++) {
  3040. decimal[dotDecimal[_i3]] = decimal['en-US'];
  3041. }
  3042. for (var _i4 = 0; _i4 < commaDecimal.length; _i4++) {
  3043. decimal[commaDecimal[_i4]] = ',';
  3044. }
  3045. alpha['fr-CA'] = alpha['fr-FR'];
  3046. alphanumeric['fr-CA'] = alphanumeric['fr-FR'];
  3047. alpha['pt-BR'] = alpha['pt-PT'];
  3048. alphanumeric['pt-BR'] = alphanumeric['pt-PT'];
  3049. decimal['pt-BR'] = decimal['pt-PT']; // see #862
  3050. alpha['pl-Pl'] = alpha['pl-PL'];
  3051. alphanumeric['pl-Pl'] = alphanumeric['pl-PL'];
  3052. decimal['pl-Pl'] = decimal['pl-PL']; // see #1455
  3053. alpha['fa-AF'] = alpha.fa;
  3054. },{}],6:[function(require,module,exports){
  3055. "use strict";
  3056. Object.defineProperty(exports, "__esModule", {
  3057. value: true
  3058. });
  3059. exports.default = blacklist;
  3060. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3061. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3062. function blacklist(str, chars) {
  3063. (0, _assertString.default)(str);
  3064. return str.replace(new RegExp("[".concat(chars, "]+"), 'g'), '');
  3065. }
  3066. module.exports = exports.default;
  3067. module.exports.default = exports.default;
  3068. },{"./util/assertString":99}],7:[function(require,module,exports){
  3069. "use strict";
  3070. Object.defineProperty(exports, "__esModule", {
  3071. value: true
  3072. });
  3073. exports.default = contains;
  3074. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3075. var _toString = _interopRequireDefault(require("./util/toString"));
  3076. var _merge = _interopRequireDefault(require("./util/merge"));
  3077. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3078. var defaulContainsOptions = {
  3079. ignoreCase: false,
  3080. minOccurrences: 1
  3081. };
  3082. function contains(str, elem, options) {
  3083. (0, _assertString.default)(str);
  3084. options = (0, _merge.default)(options, defaulContainsOptions);
  3085. if (options.ignoreCase) {
  3086. return str.toLowerCase().split((0, _toString.default)(elem).toLowerCase()).length > options.minOccurrences;
  3087. }
  3088. return str.split((0, _toString.default)(elem)).length > options.minOccurrences;
  3089. }
  3090. module.exports = exports.default;
  3091. module.exports.default = exports.default;
  3092. },{"./util/assertString":99,"./util/merge":101,"./util/toString":103}],8:[function(require,module,exports){
  3093. "use strict";
  3094. Object.defineProperty(exports, "__esModule", {
  3095. value: true
  3096. });
  3097. exports.default = equals;
  3098. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3099. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3100. function equals(str, comparison) {
  3101. (0, _assertString.default)(str);
  3102. return str === comparison;
  3103. }
  3104. module.exports = exports.default;
  3105. module.exports.default = exports.default;
  3106. },{"./util/assertString":99}],9:[function(require,module,exports){
  3107. "use strict";
  3108. Object.defineProperty(exports, "__esModule", {
  3109. value: true
  3110. });
  3111. exports.default = escape;
  3112. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3113. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3114. function escape(str) {
  3115. (0, _assertString.default)(str);
  3116. 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;');
  3117. }
  3118. module.exports = exports.default;
  3119. module.exports.default = exports.default;
  3120. },{"./util/assertString":99}],10:[function(require,module,exports){
  3121. "use strict";
  3122. Object.defineProperty(exports, "__esModule", {
  3123. value: true
  3124. });
  3125. exports.default = isAfter;
  3126. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3127. var _toDate = _interopRequireDefault(require("./toDate"));
  3128. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3129. function isAfter(str) {
  3130. var date = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : String(new Date());
  3131. (0, _assertString.default)(str);
  3132. var comparison = (0, _toDate.default)(date);
  3133. var original = (0, _toDate.default)(str);
  3134. return !!(original && comparison && original > comparison);
  3135. }
  3136. module.exports = exports.default;
  3137. module.exports.default = exports.default;
  3138. },{"./toDate":93,"./util/assertString":99}],11:[function(require,module,exports){
  3139. "use strict";
  3140. Object.defineProperty(exports, "__esModule", {
  3141. value: true
  3142. });
  3143. exports.default = isAlpha;
  3144. exports.locales = void 0;
  3145. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3146. var _alpha = require("./alpha");
  3147. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3148. function isAlpha(_str) {
  3149. var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US';
  3150. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  3151. (0, _assertString.default)(_str);
  3152. var str = _str;
  3153. var ignore = options.ignore;
  3154. if (ignore) {
  3155. if (ignore instanceof RegExp) {
  3156. str = str.replace(ignore, '');
  3157. } else if (typeof ignore === 'string') {
  3158. str = str.replace(new RegExp("[".concat(ignore.replace(/[-[\]{}()*+?.,\\^$|#\\s]/g, '\\$&'), "]"), 'g'), ''); // escape regex for ignore
  3159. } else {
  3160. throw new Error('ignore should be instance of a String or RegExp');
  3161. }
  3162. }
  3163. if (locale in _alpha.alpha) {
  3164. return _alpha.alpha[locale].test(str);
  3165. }
  3166. throw new Error("Invalid locale '".concat(locale, "'"));
  3167. }
  3168. var locales = Object.keys(_alpha.alpha);
  3169. exports.locales = locales;
  3170. },{"./alpha":5,"./util/assertString":99}],12:[function(require,module,exports){
  3171. "use strict";
  3172. Object.defineProperty(exports, "__esModule", {
  3173. value: true
  3174. });
  3175. exports.default = isAlphanumeric;
  3176. exports.locales = void 0;
  3177. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3178. var _alpha = require("./alpha");
  3179. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3180. function isAlphanumeric(_str) {
  3181. var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US';
  3182. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  3183. (0, _assertString.default)(_str);
  3184. var str = _str;
  3185. var ignore = options.ignore;
  3186. if (ignore) {
  3187. if (ignore instanceof RegExp) {
  3188. str = str.replace(ignore, '');
  3189. } else if (typeof ignore === 'string') {
  3190. str = str.replace(new RegExp("[".concat(ignore.replace(/[-[\]{}()*+?.,\\^$|#\\s]/g, '\\$&'), "]"), 'g'), ''); // escape regex for ignore
  3191. } else {
  3192. throw new Error('ignore should be instance of a String or RegExp');
  3193. }
  3194. }
  3195. if (locale in _alpha.alphanumeric) {
  3196. return _alpha.alphanumeric[locale].test(str);
  3197. }
  3198. throw new Error("Invalid locale '".concat(locale, "'"));
  3199. }
  3200. var locales = Object.keys(_alpha.alphanumeric);
  3201. exports.locales = locales;
  3202. },{"./alpha":5,"./util/assertString":99}],13:[function(require,module,exports){
  3203. "use strict";
  3204. Object.defineProperty(exports, "__esModule", {
  3205. value: true
  3206. });
  3207. exports.default = isAscii;
  3208. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3209. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3210. /* eslint-disable no-control-regex */
  3211. var ascii = /^[\x00-\x7F]+$/;
  3212. /* eslint-enable no-control-regex */
  3213. function isAscii(str) {
  3214. (0, _assertString.default)(str);
  3215. return ascii.test(str);
  3216. }
  3217. module.exports = exports.default;
  3218. module.exports.default = exports.default;
  3219. },{"./util/assertString":99}],14:[function(require,module,exports){
  3220. "use strict";
  3221. Object.defineProperty(exports, "__esModule", {
  3222. value: true
  3223. });
  3224. exports.default = isBIC;
  3225. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3226. var _isISO31661Alpha = require("./isISO31661Alpha2");
  3227. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3228. // https://en.wikipedia.org/wiki/ISO_9362
  3229. var isBICReg = /^[A-Za-z]{6}[A-Za-z0-9]{2}([A-Za-z0-9]{3})?$/;
  3230. function isBIC(str) {
  3231. (0, _assertString.default)(str); // toUpperCase() should be removed when a new major version goes out that changes
  3232. // the regex to [A-Z] (per the spec).
  3233. if (!_isISO31661Alpha.CountryCodes.has(str.slice(4, 6).toUpperCase())) {
  3234. return false;
  3235. }
  3236. return isBICReg.test(str);
  3237. }
  3238. module.exports = exports.default;
  3239. module.exports.default = exports.default;
  3240. },{"./isISO31661Alpha2":46,"./util/assertString":99}],15:[function(require,module,exports){
  3241. "use strict";
  3242. Object.defineProperty(exports, "__esModule", {
  3243. value: true
  3244. });
  3245. exports.default = isBase32;
  3246. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3247. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3248. var base32 = /^[A-Z2-7]+=*$/;
  3249. function isBase32(str) {
  3250. (0, _assertString.default)(str);
  3251. var len = str.length;
  3252. if (len % 8 === 0 && base32.test(str)) {
  3253. return true;
  3254. }
  3255. return false;
  3256. }
  3257. module.exports = exports.default;
  3258. module.exports.default = exports.default;
  3259. },{"./util/assertString":99}],16:[function(require,module,exports){
  3260. "use strict";
  3261. Object.defineProperty(exports, "__esModule", {
  3262. value: true
  3263. });
  3264. exports.default = isBase58;
  3265. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3266. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3267. // Accepted chars - 123456789ABCDEFGH JKLMN PQRSTUVWXYZabcdefghijk mnopqrstuvwxyz
  3268. var base58Reg = /^[A-HJ-NP-Za-km-z1-9]*$/;
  3269. function isBase58(str) {
  3270. (0, _assertString.default)(str);
  3271. if (base58Reg.test(str)) {
  3272. return true;
  3273. }
  3274. return false;
  3275. }
  3276. module.exports = exports.default;
  3277. module.exports.default = exports.default;
  3278. },{"./util/assertString":99}],17:[function(require,module,exports){
  3279. "use strict";
  3280. Object.defineProperty(exports, "__esModule", {
  3281. value: true
  3282. });
  3283. exports.default = isBase64;
  3284. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3285. var _merge = _interopRequireDefault(require("./util/merge"));
  3286. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3287. var notBase64 = /[^A-Z0-9+\/=]/i;
  3288. var urlSafeBase64 = /^[A-Z0-9_\-]*$/i;
  3289. var defaultBase64Options = {
  3290. urlSafe: false
  3291. };
  3292. function isBase64(str, options) {
  3293. (0, _assertString.default)(str);
  3294. options = (0, _merge.default)(options, defaultBase64Options);
  3295. var len = str.length;
  3296. if (options.urlSafe) {
  3297. return urlSafeBase64.test(str);
  3298. }
  3299. if (len % 4 !== 0 || notBase64.test(str)) {
  3300. return false;
  3301. }
  3302. var firstPaddingChar = str.indexOf('=');
  3303. return firstPaddingChar === -1 || firstPaddingChar === len - 1 || firstPaddingChar === len - 2 && str[len - 1] === '=';
  3304. }
  3305. module.exports = exports.default;
  3306. module.exports.default = exports.default;
  3307. },{"./util/assertString":99,"./util/merge":101}],18:[function(require,module,exports){
  3308. "use strict";
  3309. Object.defineProperty(exports, "__esModule", {
  3310. value: true
  3311. });
  3312. exports.default = isBefore;
  3313. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3314. var _toDate = _interopRequireDefault(require("./toDate"));
  3315. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3316. function isBefore(str) {
  3317. var date = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : String(new Date());
  3318. (0, _assertString.default)(str);
  3319. var comparison = (0, _toDate.default)(date);
  3320. var original = (0, _toDate.default)(str);
  3321. return !!(original && comparison && original < comparison);
  3322. }
  3323. module.exports = exports.default;
  3324. module.exports.default = exports.default;
  3325. },{"./toDate":93,"./util/assertString":99}],19:[function(require,module,exports){
  3326. "use strict";
  3327. Object.defineProperty(exports, "__esModule", {
  3328. value: true
  3329. });
  3330. exports.default = isBoolean;
  3331. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3332. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3333. var defaultOptions = {
  3334. loose: false
  3335. };
  3336. var strictBooleans = ['true', 'false', '1', '0'];
  3337. var looseBooleans = [].concat(strictBooleans, ['yes', 'no']);
  3338. function isBoolean(str) {
  3339. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
  3340. (0, _assertString.default)(str);
  3341. if (options.loose) {
  3342. return looseBooleans.includes(str.toLowerCase());
  3343. }
  3344. return strictBooleans.includes(str);
  3345. }
  3346. module.exports = exports.default;
  3347. module.exports.default = exports.default;
  3348. },{"./util/assertString":99}],20:[function(require,module,exports){
  3349. "use strict";
  3350. Object.defineProperty(exports, "__esModule", {
  3351. value: true
  3352. });
  3353. exports.default = isBtcAddress;
  3354. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3355. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3356. // supports Bech32 addresses
  3357. var bech32 = /^(bc1)[a-z0-9]{25,39}$/;
  3358. var base58 = /^(1|3)[A-HJ-NP-Za-km-z1-9]{25,39}$/;
  3359. function isBtcAddress(str) {
  3360. (0, _assertString.default)(str); // check for bech32
  3361. if (str.startsWith('bc1')) {
  3362. return bech32.test(str);
  3363. }
  3364. return base58.test(str);
  3365. }
  3366. module.exports = exports.default;
  3367. module.exports.default = exports.default;
  3368. },{"./util/assertString":99}],21:[function(require,module,exports){
  3369. "use strict";
  3370. Object.defineProperty(exports, "__esModule", {
  3371. value: true
  3372. });
  3373. exports.default = isByteLength;
  3374. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3375. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3376. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3377. /* eslint-disable prefer-rest-params */
  3378. function isByteLength(str, options) {
  3379. (0, _assertString.default)(str);
  3380. var min;
  3381. var max;
  3382. if (_typeof(options) === 'object') {
  3383. min = options.min || 0;
  3384. max = options.max;
  3385. } else {
  3386. // backwards compatibility: isByteLength(str, min [, max])
  3387. min = arguments[1];
  3388. max = arguments[2];
  3389. }
  3390. var len = encodeURI(str).split(/%..|./).length - 1;
  3391. return len >= min && (typeof max === 'undefined' || len <= max);
  3392. }
  3393. module.exports = exports.default;
  3394. module.exports.default = exports.default;
  3395. },{"./util/assertString":99}],22:[function(require,module,exports){
  3396. "use strict";
  3397. Object.defineProperty(exports, "__esModule", {
  3398. value: true
  3399. });
  3400. exports.default = isCreditCard;
  3401. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3402. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3403. /* eslint-disable max-len */
  3404. var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/;
  3405. /* eslint-enable max-len */
  3406. function isCreditCard(str) {
  3407. (0, _assertString.default)(str);
  3408. var sanitized = str.replace(/[- ]+/g, '');
  3409. if (!creditCard.test(sanitized)) {
  3410. return false;
  3411. }
  3412. var sum = 0;
  3413. var digit;
  3414. var tmpNum;
  3415. var shouldDouble;
  3416. for (var i = sanitized.length - 1; i >= 0; i--) {
  3417. digit = sanitized.substring(i, i + 1);
  3418. tmpNum = parseInt(digit, 10);
  3419. if (shouldDouble) {
  3420. tmpNum *= 2;
  3421. if (tmpNum >= 10) {
  3422. sum += tmpNum % 10 + 1;
  3423. } else {
  3424. sum += tmpNum;
  3425. }
  3426. } else {
  3427. sum += tmpNum;
  3428. }
  3429. shouldDouble = !shouldDouble;
  3430. }
  3431. return !!(sum % 10 === 0 ? sanitized : false);
  3432. }
  3433. module.exports = exports.default;
  3434. module.exports.default = exports.default;
  3435. },{"./util/assertString":99}],23:[function(require,module,exports){
  3436. "use strict";
  3437. Object.defineProperty(exports, "__esModule", {
  3438. value: true
  3439. });
  3440. exports.default = isCurrency;
  3441. var _merge = _interopRequireDefault(require("./util/merge"));
  3442. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3443. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3444. function currencyRegex(options) {
  3445. var decimal_digits = "\\d{".concat(options.digits_after_decimal[0], "}");
  3446. options.digits_after_decimal.forEach(function (digit, index) {
  3447. if (index !== 0) decimal_digits = "".concat(decimal_digits, "|\\d{").concat(digit, "}");
  3448. });
  3449. var symbol = "(".concat(options.symbol.replace(/\W/, function (m) {
  3450. return "\\".concat(m);
  3451. }), ")").concat(options.require_symbol ? '' : '?'),
  3452. negative = '-?',
  3453. whole_dollar_amount_without_sep = '[1-9]\\d*',
  3454. whole_dollar_amount_with_sep = "[1-9]\\d{0,2}(\\".concat(options.thousands_separator, "\\d{3})*"),
  3455. valid_whole_dollar_amounts = ['0', whole_dollar_amount_without_sep, whole_dollar_amount_with_sep],
  3456. whole_dollar_amount = "(".concat(valid_whole_dollar_amounts.join('|'), ")?"),
  3457. decimal_amount = "(\\".concat(options.decimal_separator, "(").concat(decimal_digits, "))").concat(options.require_decimal ? '' : '?');
  3458. var pattern = whole_dollar_amount + (options.allow_decimal || options.require_decimal ? decimal_amount : ''); // default is negative sign before symbol, but there are two other options (besides parens)
  3459. if (options.allow_negatives && !options.parens_for_negatives) {
  3460. if (options.negative_sign_after_digits) {
  3461. pattern += negative;
  3462. } else if (options.negative_sign_before_digits) {
  3463. pattern = negative + pattern;
  3464. }
  3465. } // South African Rand, for example, uses R 123 (space) and R-123 (no space)
  3466. if (options.allow_negative_sign_placeholder) {
  3467. pattern = "( (?!\\-))?".concat(pattern);
  3468. } else if (options.allow_space_after_symbol) {
  3469. pattern = " ?".concat(pattern);
  3470. } else if (options.allow_space_after_digits) {
  3471. pattern += '( (?!$))?';
  3472. }
  3473. if (options.symbol_after_digits) {
  3474. pattern += symbol;
  3475. } else {
  3476. pattern = symbol + pattern;
  3477. }
  3478. if (options.allow_negatives) {
  3479. if (options.parens_for_negatives) {
  3480. pattern = "(\\(".concat(pattern, "\\)|").concat(pattern, ")");
  3481. } else if (!(options.negative_sign_before_digits || options.negative_sign_after_digits)) {
  3482. pattern = negative + pattern;
  3483. }
  3484. } // ensure there's a dollar and/or decimal amount, and that
  3485. // it doesn't start with a space or a negative sign followed by a space
  3486. return new RegExp("^(?!-? )(?=.*\\d)".concat(pattern, "$"));
  3487. }
  3488. var default_currency_options = {
  3489. symbol: '$',
  3490. require_symbol: false,
  3491. allow_space_after_symbol: false,
  3492. symbol_after_digits: false,
  3493. allow_negatives: true,
  3494. parens_for_negatives: false,
  3495. negative_sign_before_digits: false,
  3496. negative_sign_after_digits: false,
  3497. allow_negative_sign_placeholder: false,
  3498. thousands_separator: ',',
  3499. decimal_separator: '.',
  3500. allow_decimal: true,
  3501. require_decimal: false,
  3502. digits_after_decimal: [2],
  3503. allow_space_after_digits: false
  3504. };
  3505. function isCurrency(str, options) {
  3506. (0, _assertString.default)(str);
  3507. options = (0, _merge.default)(options, default_currency_options);
  3508. return currencyRegex(options).test(str);
  3509. }
  3510. module.exports = exports.default;
  3511. module.exports.default = exports.default;
  3512. },{"./util/assertString":99,"./util/merge":101}],24:[function(require,module,exports){
  3513. "use strict";
  3514. Object.defineProperty(exports, "__esModule", {
  3515. value: true
  3516. });
  3517. exports.default = isDataURI;
  3518. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3519. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3520. var validMediaType = /^[a-z]+\/[a-z0-9\-\+]+$/i;
  3521. var validAttribute = /^[a-z\-]+=[a-z0-9\-]+$/i;
  3522. var validData = /^[a-z0-9!\$&'\(\)\*\+,;=\-\._~:@\/\?%\s]*$/i;
  3523. function isDataURI(str) {
  3524. (0, _assertString.default)(str);
  3525. var data = str.split(',');
  3526. if (data.length < 2) {
  3527. return false;
  3528. }
  3529. var attributes = data.shift().trim().split(';');
  3530. var schemeAndMediaType = attributes.shift();
  3531. if (schemeAndMediaType.substr(0, 5) !== 'data:') {
  3532. return false;
  3533. }
  3534. var mediaType = schemeAndMediaType.substr(5);
  3535. if (mediaType !== '' && !validMediaType.test(mediaType)) {
  3536. return false;
  3537. }
  3538. for (var i = 0; i < attributes.length; i++) {
  3539. if (!(i === attributes.length - 1 && attributes[i].toLowerCase() === 'base64') && !validAttribute.test(attributes[i])) {
  3540. return false;
  3541. }
  3542. }
  3543. for (var _i = 0; _i < data.length; _i++) {
  3544. if (!validData.test(data[_i])) {
  3545. return false;
  3546. }
  3547. }
  3548. return true;
  3549. }
  3550. module.exports = exports.default;
  3551. module.exports.default = exports.default;
  3552. },{"./util/assertString":99}],25:[function(require,module,exports){
  3553. "use strict";
  3554. Object.defineProperty(exports, "__esModule", {
  3555. value: true
  3556. });
  3557. exports.default = isDate;
  3558. var _merge = _interopRequireDefault(require("./util/merge"));
  3559. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3560. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  3561. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  3562. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  3563. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  3564. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
  3565. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  3566. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  3567. var default_date_options = {
  3568. format: 'YYYY/MM/DD',
  3569. delimiters: ['/', '-'],
  3570. strictMode: false
  3571. };
  3572. function isValidFormat(format) {
  3573. 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);
  3574. }
  3575. function zip(date, format) {
  3576. var zippedArr = [],
  3577. len = Math.min(date.length, format.length);
  3578. for (var i = 0; i < len; i++) {
  3579. zippedArr.push([date[i], format[i]]);
  3580. }
  3581. return zippedArr;
  3582. }
  3583. function isDate(input, options) {
  3584. if (typeof options === 'string') {
  3585. // Allow backward compatbility for old format isDate(input [, format])
  3586. options = (0, _merge.default)({
  3587. format: options
  3588. }, default_date_options);
  3589. } else {
  3590. options = (0, _merge.default)(options, default_date_options);
  3591. }
  3592. if (typeof input === 'string' && isValidFormat(options.format)) {
  3593. var formatDelimiter = options.delimiters.find(function (delimiter) {
  3594. return options.format.indexOf(delimiter) !== -1;
  3595. });
  3596. var dateDelimiter = options.strictMode ? formatDelimiter : options.delimiters.find(function (delimiter) {
  3597. return input.indexOf(delimiter) !== -1;
  3598. });
  3599. var dateAndFormat = zip(input.split(dateDelimiter), options.format.toLowerCase().split(formatDelimiter));
  3600. var dateObj = {};
  3601. var _iterator = _createForOfIteratorHelper(dateAndFormat),
  3602. _step;
  3603. try {
  3604. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  3605. var _step$value = _slicedToArray(_step.value, 2),
  3606. dateWord = _step$value[0],
  3607. formatWord = _step$value[1];
  3608. if (dateWord.length !== formatWord.length) {
  3609. return false;
  3610. }
  3611. dateObj[formatWord.charAt(0)] = dateWord;
  3612. }
  3613. } catch (err) {
  3614. _iterator.e(err);
  3615. } finally {
  3616. _iterator.f();
  3617. }
  3618. return new Date("".concat(dateObj.m, "/").concat(dateObj.d, "/").concat(dateObj.y)).getDate() === +dateObj.d;
  3619. }
  3620. if (!options.strictMode) {
  3621. return Object.prototype.toString.call(input) === '[object Date]' && isFinite(input);
  3622. }
  3623. return false;
  3624. }
  3625. module.exports = exports.default;
  3626. module.exports.default = exports.default;
  3627. },{"./util/merge":101}],26:[function(require,module,exports){
  3628. "use strict";
  3629. Object.defineProperty(exports, "__esModule", {
  3630. value: true
  3631. });
  3632. exports.default = isDecimal;
  3633. var _merge = _interopRequireDefault(require("./util/merge"));
  3634. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3635. var _includes = _interopRequireDefault(require("./util/includes"));
  3636. var _alpha = require("./alpha");
  3637. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3638. function decimalRegExp(options) {
  3639. var regExp = new RegExp("^[-+]?([0-9]+)?(\\".concat(_alpha.decimal[options.locale], "[0-9]{").concat(options.decimal_digits, "})").concat(options.force_decimal ? '' : '?', "$"));
  3640. return regExp;
  3641. }
  3642. var default_decimal_options = {
  3643. force_decimal: false,
  3644. decimal_digits: '1,',
  3645. locale: 'en-US'
  3646. };
  3647. var blacklist = ['', '-', '+'];
  3648. function isDecimal(str, options) {
  3649. (0, _assertString.default)(str);
  3650. options = (0, _merge.default)(options, default_decimal_options);
  3651. if (options.locale in _alpha.decimal) {
  3652. return !(0, _includes.default)(blacklist, str.replace(/ /g, '')) && decimalRegExp(options).test(str);
  3653. }
  3654. throw new Error("Invalid locale '".concat(options.locale, "'"));
  3655. }
  3656. module.exports = exports.default;
  3657. module.exports.default = exports.default;
  3658. },{"./alpha":5,"./util/assertString":99,"./util/includes":100,"./util/merge":101}],27:[function(require,module,exports){
  3659. "use strict";
  3660. Object.defineProperty(exports, "__esModule", {
  3661. value: true
  3662. });
  3663. exports.default = isDivisibleBy;
  3664. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3665. var _toFloat = _interopRequireDefault(require("./toFloat"));
  3666. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3667. function isDivisibleBy(str, num) {
  3668. (0, _assertString.default)(str);
  3669. return (0, _toFloat.default)(str) % parseInt(num, 10) === 0;
  3670. }
  3671. module.exports = exports.default;
  3672. module.exports.default = exports.default;
  3673. },{"./toFloat":94,"./util/assertString":99}],28:[function(require,module,exports){
  3674. "use strict";
  3675. Object.defineProperty(exports, "__esModule", {
  3676. value: true
  3677. });
  3678. exports.default = isEAN;
  3679. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3680. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3681. /**
  3682. * The most commonly used EAN standard is
  3683. * the thirteen-digit EAN-13, while the
  3684. * less commonly used 8-digit EAN-8 barcode was
  3685. * introduced for use on small packages.
  3686. * Also EAN/UCC-14 is used for Grouping of individual
  3687. * trade items above unit level(Intermediate, Carton or Pallet).
  3688. * For more info about EAN-14 checkout: https://www.gtin.info/itf-14-barcodes/
  3689. * EAN consists of:
  3690. * GS1 prefix, manufacturer code, product code and check digit
  3691. * Reference: https://en.wikipedia.org/wiki/International_Article_Number
  3692. * Reference: https://www.gtin.info/
  3693. */
  3694. /**
  3695. * Define EAN Lenghts; 8 for EAN-8; 13 for EAN-13; 14 for EAN-14
  3696. * and Regular Expression for valid EANs (EAN-8, EAN-13, EAN-14),
  3697. * with exact numberic matching of 8 or 13 or 14 digits [0-9]
  3698. */
  3699. var LENGTH_EAN_8 = 8;
  3700. var LENGTH_EAN_14 = 14;
  3701. var validEanRegex = /^(\d{8}|\d{13}|\d{14})$/;
  3702. /**
  3703. * Get position weight given:
  3704. * EAN length and digit index/position
  3705. *
  3706. * @param {number} length
  3707. * @param {number} index
  3708. * @return {number}
  3709. */
  3710. function getPositionWeightThroughLengthAndIndex(length, index) {
  3711. if (length === LENGTH_EAN_8 || length === LENGTH_EAN_14) {
  3712. return index % 2 === 0 ? 3 : 1;
  3713. }
  3714. return index % 2 === 0 ? 1 : 3;
  3715. }
  3716. /**
  3717. * Calculate EAN Check Digit
  3718. * Reference: https://en.wikipedia.org/wiki/International_Article_Number#Calculation_of_checksum_digit
  3719. *
  3720. * @param {string} ean
  3721. * @return {number}
  3722. */
  3723. function calculateCheckDigit(ean) {
  3724. var checksum = ean.slice(0, -1).split('').map(function (char, index) {
  3725. return Number(char) * getPositionWeightThroughLengthAndIndex(ean.length, index);
  3726. }).reduce(function (acc, partialSum) {
  3727. return acc + partialSum;
  3728. }, 0);
  3729. var remainder = 10 - checksum % 10;
  3730. return remainder < 10 ? remainder : 0;
  3731. }
  3732. /**
  3733. * Check if string is valid EAN:
  3734. * Matches EAN-8/EAN-13/EAN-14 regex
  3735. * Has valid check digit.
  3736. *
  3737. * @param {string} str
  3738. * @return {boolean}
  3739. */
  3740. function isEAN(str) {
  3741. (0, _assertString.default)(str);
  3742. var actualCheckDigit = Number(str.slice(-1));
  3743. return validEanRegex.test(str) && actualCheckDigit === calculateCheckDigit(str);
  3744. }
  3745. module.exports = exports.default;
  3746. module.exports.default = exports.default;
  3747. },{"./util/assertString":99}],29:[function(require,module,exports){
  3748. "use strict";
  3749. Object.defineProperty(exports, "__esModule", {
  3750. value: true
  3751. });
  3752. exports.default = isEmail;
  3753. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3754. var _merge = _interopRequireDefault(require("./util/merge"));
  3755. var _isByteLength = _interopRequireDefault(require("./isByteLength"));
  3756. var _isFQDN = _interopRequireDefault(require("./isFQDN"));
  3757. var _isIP = _interopRequireDefault(require("./isIP"));
  3758. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3759. var default_email_options = {
  3760. allow_display_name: false,
  3761. require_display_name: false,
  3762. allow_utf8_local_part: true,
  3763. require_tld: true,
  3764. blacklisted_chars: '',
  3765. ignore_max_length: false,
  3766. host_blacklist: []
  3767. };
  3768. /* eslint-disable max-len */
  3769. /* eslint-disable no-control-regex */
  3770. var splitNameAddress = /^([^\x00-\x1F\x7F-\x9F\cX]+)</i;
  3771. var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i;
  3772. var gmailUserPart = /^[a-z\d]+$/;
  3773. var quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i;
  3774. var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i;
  3775. 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;
  3776. var defaultMaxEmailLength = 254;
  3777. /* eslint-enable max-len */
  3778. /* eslint-enable no-control-regex */
  3779. /**
  3780. * Validate display name according to the RFC2822: https://tools.ietf.org/html/rfc2822#appendix-A.1.2
  3781. * @param {String} display_name
  3782. */
  3783. function validateDisplayName(display_name) {
  3784. var display_name_without_quotes = display_name.replace(/^"(.+)"$/, '$1'); // display name with only spaces is not valid
  3785. if (!display_name_without_quotes.trim()) {
  3786. return false;
  3787. } // check whether display name contains illegal character
  3788. var contains_illegal = /[\.";<>]/.test(display_name_without_quotes);
  3789. if (contains_illegal) {
  3790. // if contains illegal characters,
  3791. // must to be enclosed in double-quotes, otherwise it's not a valid display name
  3792. if (display_name_without_quotes === display_name) {
  3793. return false;
  3794. } // the quotes in display name must start with character symbol \
  3795. var all_start_with_back_slash = display_name_without_quotes.split('"').length === display_name_without_quotes.split('\\"').length;
  3796. if (!all_start_with_back_slash) {
  3797. return false;
  3798. }
  3799. }
  3800. return true;
  3801. }
  3802. function isEmail(str, options) {
  3803. (0, _assertString.default)(str);
  3804. options = (0, _merge.default)(options, default_email_options);
  3805. if (options.require_display_name || options.allow_display_name) {
  3806. var display_email = str.match(splitNameAddress);
  3807. if (display_email) {
  3808. var display_name = display_email[1]; // Remove display name and angle brackets to get email address
  3809. // Can be done in the regex but will introduce a ReDOS (See #1597 for more info)
  3810. str = str.replace(display_name, '').replace(/(^<|>$)/g, ''); // sometimes need to trim the last space to get the display name
  3811. // because there may be a space between display name and email address
  3812. // eg. myname <address@gmail.com>
  3813. // the display name is `myname` instead of `myname `, so need to trim the last space
  3814. if (display_name.endsWith(' ')) {
  3815. display_name = display_name.substr(0, display_name.length - 1);
  3816. }
  3817. if (!validateDisplayName(display_name)) {
  3818. return false;
  3819. }
  3820. } else if (options.require_display_name) {
  3821. return false;
  3822. }
  3823. }
  3824. if (!options.ignore_max_length && str.length > defaultMaxEmailLength) {
  3825. return false;
  3826. }
  3827. var parts = str.split('@');
  3828. var domain = parts.pop();
  3829. var lower_domain = domain.toLowerCase();
  3830. if (options.host_blacklist.includes(lower_domain)) {
  3831. return false;
  3832. }
  3833. var user = parts.join('@');
  3834. if (options.domain_specific_validation && (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com')) {
  3835. /*
  3836. Previously we removed dots for gmail addresses before validating.
  3837. This was removed because it allows `multiple..dots@gmail.com`
  3838. to be reported as valid, but it is not.
  3839. Gmail only normalizes single dots, removing them from here is pointless,
  3840. should be done in normalizeEmail
  3841. */
  3842. user = user.toLowerCase(); // Removing sub-address from username before gmail validation
  3843. var username = user.split('+')[0]; // Dots are not included in gmail length restriction
  3844. if (!(0, _isByteLength.default)(username.replace(/\./g, ''), {
  3845. min: 6,
  3846. max: 30
  3847. })) {
  3848. return false;
  3849. }
  3850. var _user_parts = username.split('.');
  3851. for (var i = 0; i < _user_parts.length; i++) {
  3852. if (!gmailUserPart.test(_user_parts[i])) {
  3853. return false;
  3854. }
  3855. }
  3856. }
  3857. if (options.ignore_max_length === false && (!(0, _isByteLength.default)(user, {
  3858. max: 64
  3859. }) || !(0, _isByteLength.default)(domain, {
  3860. max: 254
  3861. }))) {
  3862. return false;
  3863. }
  3864. if (!(0, _isFQDN.default)(domain, {
  3865. require_tld: options.require_tld
  3866. })) {
  3867. if (!options.allow_ip_domain) {
  3868. return false;
  3869. }
  3870. if (!(0, _isIP.default)(domain)) {
  3871. if (!domain.startsWith('[') || !domain.endsWith(']')) {
  3872. return false;
  3873. }
  3874. var noBracketdomain = domain.substr(1, domain.length - 2);
  3875. if (noBracketdomain.length === 0 || !(0, _isIP.default)(noBracketdomain)) {
  3876. return false;
  3877. }
  3878. }
  3879. }
  3880. if (user[0] === '"') {
  3881. user = user.slice(1, user.length - 1);
  3882. return options.allow_utf8_local_part ? quotedEmailUserUtf8.test(user) : quotedEmailUser.test(user);
  3883. }
  3884. var pattern = options.allow_utf8_local_part ? emailUserUtf8Part : emailUserPart;
  3885. var user_parts = user.split('.');
  3886. for (var _i = 0; _i < user_parts.length; _i++) {
  3887. if (!pattern.test(user_parts[_i])) {
  3888. return false;
  3889. }
  3890. }
  3891. if (options.blacklisted_chars) {
  3892. if (user.search(new RegExp("[".concat(options.blacklisted_chars, "]+"), 'g')) !== -1) return false;
  3893. }
  3894. return true;
  3895. }
  3896. module.exports = exports.default;
  3897. module.exports.default = exports.default;
  3898. },{"./isByteLength":21,"./isFQDN":32,"./isIP":42,"./util/assertString":99,"./util/merge":101}],30:[function(require,module,exports){
  3899. "use strict";
  3900. Object.defineProperty(exports, "__esModule", {
  3901. value: true
  3902. });
  3903. exports.default = isEmpty;
  3904. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3905. var _merge = _interopRequireDefault(require("./util/merge"));
  3906. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3907. var default_is_empty_options = {
  3908. ignore_whitespace: false
  3909. };
  3910. function isEmpty(str, options) {
  3911. (0, _assertString.default)(str);
  3912. options = (0, _merge.default)(options, default_is_empty_options);
  3913. return (options.ignore_whitespace ? str.trim().length : str.length) === 0;
  3914. }
  3915. module.exports = exports.default;
  3916. module.exports.default = exports.default;
  3917. },{"./util/assertString":99,"./util/merge":101}],31:[function(require,module,exports){
  3918. "use strict";
  3919. Object.defineProperty(exports, "__esModule", {
  3920. value: true
  3921. });
  3922. exports.default = isEthereumAddress;
  3923. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3924. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3925. var eth = /^(0x)[0-9a-f]{40}$/i;
  3926. function isEthereumAddress(str) {
  3927. (0, _assertString.default)(str);
  3928. return eth.test(str);
  3929. }
  3930. module.exports = exports.default;
  3931. module.exports.default = exports.default;
  3932. },{"./util/assertString":99}],32:[function(require,module,exports){
  3933. "use strict";
  3934. Object.defineProperty(exports, "__esModule", {
  3935. value: true
  3936. });
  3937. exports.default = isFQDN;
  3938. var _assertString = _interopRequireDefault(require("./util/assertString"));
  3939. var _merge = _interopRequireDefault(require("./util/merge"));
  3940. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3941. var default_fqdn_options = {
  3942. require_tld: true,
  3943. allow_underscores: false,
  3944. allow_trailing_dot: false,
  3945. allow_numeric_tld: false,
  3946. allow_wildcard: false
  3947. };
  3948. function isFQDN(str, options) {
  3949. (0, _assertString.default)(str);
  3950. options = (0, _merge.default)(options, default_fqdn_options);
  3951. /* Remove the optional trailing dot before checking validity */
  3952. if (options.allow_trailing_dot && str[str.length - 1] === '.') {
  3953. str = str.substring(0, str.length - 1);
  3954. }
  3955. /* Remove the optional wildcard before checking validity */
  3956. if (options.allow_wildcard === true && str.indexOf('*.') === 0) {
  3957. str = str.substring(2);
  3958. }
  3959. var parts = str.split('.');
  3960. var tld = parts[parts.length - 1];
  3961. if (options.require_tld) {
  3962. // disallow fqdns without tld
  3963. if (parts.length < 2) {
  3964. return false;
  3965. }
  3966. if (!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
  3967. return false;
  3968. } // disallow spaces
  3969. if (/\s/.test(tld)) {
  3970. return false;
  3971. }
  3972. } // reject numeric TLDs
  3973. if (!options.allow_numeric_tld && /^\d+$/.test(tld)) {
  3974. return false;
  3975. }
  3976. return parts.every(function (part) {
  3977. if (part.length > 63) {
  3978. return false;
  3979. }
  3980. if (!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(part)) {
  3981. return false;
  3982. } // disallow full-width chars
  3983. if (/[\uff01-\uff5e]/.test(part)) {
  3984. return false;
  3985. } // disallow parts starting or ending with hyphen
  3986. if (/^-|-$/.test(part)) {
  3987. return false;
  3988. }
  3989. if (!options.allow_underscores && /_/.test(part)) {
  3990. return false;
  3991. }
  3992. return true;
  3993. });
  3994. }
  3995. module.exports = exports.default;
  3996. module.exports.default = exports.default;
  3997. },{"./util/assertString":99,"./util/merge":101}],33:[function(require,module,exports){
  3998. "use strict";
  3999. Object.defineProperty(exports, "__esModule", {
  4000. value: true
  4001. });
  4002. exports.default = isFloat;
  4003. exports.locales = void 0;
  4004. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4005. var _alpha = require("./alpha");
  4006. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4007. function isFloat(str, options) {
  4008. (0, _assertString.default)(str);
  4009. options = options || {};
  4010. var float = new RegExp("^(?:[-+])?(?:[0-9]+)?(?:\\".concat(options.locale ? _alpha.decimal[options.locale] : '.', "[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$"));
  4011. if (str === '' || str === '.' || str === '-' || str === '+') {
  4012. return false;
  4013. }
  4014. var value = parseFloat(str.replace(',', '.'));
  4015. return float.test(str) && (!options.hasOwnProperty('min') || value >= options.min) && (!options.hasOwnProperty('max') || value <= options.max) && (!options.hasOwnProperty('lt') || value < options.lt) && (!options.hasOwnProperty('gt') || value > options.gt);
  4016. }
  4017. var locales = Object.keys(_alpha.decimal);
  4018. exports.locales = locales;
  4019. },{"./alpha":5,"./util/assertString":99}],34:[function(require,module,exports){
  4020. "use strict";
  4021. Object.defineProperty(exports, "__esModule", {
  4022. value: true
  4023. });
  4024. exports.default = isFullWidth;
  4025. exports.fullWidth = void 0;
  4026. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4027. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4028. var fullWidth = /[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;
  4029. exports.fullWidth = fullWidth;
  4030. function isFullWidth(str) {
  4031. (0, _assertString.default)(str);
  4032. return fullWidth.test(str);
  4033. }
  4034. },{"./util/assertString":99}],35:[function(require,module,exports){
  4035. "use strict";
  4036. Object.defineProperty(exports, "__esModule", {
  4037. value: true
  4038. });
  4039. exports.default = isHSL;
  4040. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4041. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4042. 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;
  4043. 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;
  4044. function isHSL(str) {
  4045. (0, _assertString.default)(str); // Strip duplicate spaces before calling the validation regex (See #1598 for more info)
  4046. var strippedStr = str.replace(/\s+/g, ' ').replace(/\s?(hsla?\(|\)|,)\s?/ig, '$1');
  4047. if (strippedStr.indexOf(',') !== -1) {
  4048. return hslComma.test(strippedStr);
  4049. }
  4050. return hslSpace.test(strippedStr);
  4051. }
  4052. module.exports = exports.default;
  4053. module.exports.default = exports.default;
  4054. },{"./util/assertString":99}],36:[function(require,module,exports){
  4055. "use strict";
  4056. Object.defineProperty(exports, "__esModule", {
  4057. value: true
  4058. });
  4059. exports.default = isHalfWidth;
  4060. exports.halfWidth = void 0;
  4061. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4062. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4063. var halfWidth = /[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;
  4064. exports.halfWidth = halfWidth;
  4065. function isHalfWidth(str) {
  4066. (0, _assertString.default)(str);
  4067. return halfWidth.test(str);
  4068. }
  4069. },{"./util/assertString":99}],37:[function(require,module,exports){
  4070. "use strict";
  4071. Object.defineProperty(exports, "__esModule", {
  4072. value: true
  4073. });
  4074. exports.default = isHash;
  4075. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4076. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4077. var lengths = {
  4078. md5: 32,
  4079. md4: 32,
  4080. sha1: 40,
  4081. sha256: 64,
  4082. sha384: 96,
  4083. sha512: 128,
  4084. ripemd128: 32,
  4085. ripemd160: 40,
  4086. tiger128: 32,
  4087. tiger160: 40,
  4088. tiger192: 48,
  4089. crc32: 8,
  4090. crc32b: 8
  4091. };
  4092. function isHash(str, algorithm) {
  4093. (0, _assertString.default)(str);
  4094. var hash = new RegExp("^[a-fA-F0-9]{".concat(lengths[algorithm], "}$"));
  4095. return hash.test(str);
  4096. }
  4097. module.exports = exports.default;
  4098. module.exports.default = exports.default;
  4099. },{"./util/assertString":99}],38:[function(require,module,exports){
  4100. "use strict";
  4101. Object.defineProperty(exports, "__esModule", {
  4102. value: true
  4103. });
  4104. exports.default = isHexColor;
  4105. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4106. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4107. var hexcolor = /^#?([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$/i;
  4108. function isHexColor(str) {
  4109. (0, _assertString.default)(str);
  4110. return hexcolor.test(str);
  4111. }
  4112. module.exports = exports.default;
  4113. module.exports.default = exports.default;
  4114. },{"./util/assertString":99}],39:[function(require,module,exports){
  4115. "use strict";
  4116. Object.defineProperty(exports, "__esModule", {
  4117. value: true
  4118. });
  4119. exports.default = isHexadecimal;
  4120. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4121. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4122. var hexadecimal = /^(0x|0h)?[0-9A-F]+$/i;
  4123. function isHexadecimal(str) {
  4124. (0, _assertString.default)(str);
  4125. return hexadecimal.test(str);
  4126. }
  4127. module.exports = exports.default;
  4128. module.exports.default = exports.default;
  4129. },{"./util/assertString":99}],40:[function(require,module,exports){
  4130. "use strict";
  4131. Object.defineProperty(exports, "__esModule", {
  4132. value: true
  4133. });
  4134. exports.default = isIBAN;
  4135. exports.locales = void 0;
  4136. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4137. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4138. /**
  4139. * List of country codes with
  4140. * corresponding IBAN regular expression
  4141. * Reference: https://en.wikipedia.org/wiki/International_Bank_Account_Number
  4142. */
  4143. var ibanRegexThroughCountryCode = {
  4144. AD: /^(AD[0-9]{2})\d{8}[A-Z0-9]{12}$/,
  4145. AE: /^(AE[0-9]{2})\d{3}\d{16}$/,
  4146. AL: /^(AL[0-9]{2})\d{8}[A-Z0-9]{16}$/,
  4147. AT: /^(AT[0-9]{2})\d{16}$/,
  4148. AZ: /^(AZ[0-9]{2})[A-Z0-9]{4}\d{20}$/,
  4149. BA: /^(BA[0-9]{2})\d{16}$/,
  4150. BE: /^(BE[0-9]{2})\d{12}$/,
  4151. BG: /^(BG[0-9]{2})[A-Z]{4}\d{6}[A-Z0-9]{8}$/,
  4152. BH: /^(BH[0-9]{2})[A-Z]{4}[A-Z0-9]{14}$/,
  4153. BR: /^(BR[0-9]{2})\d{23}[A-Z]{1}[A-Z0-9]{1}$/,
  4154. BY: /^(BY[0-9]{2})[A-Z0-9]{4}\d{20}$/,
  4155. CH: /^(CH[0-9]{2})\d{5}[A-Z0-9]{12}$/,
  4156. CR: /^(CR[0-9]{2})\d{18}$/,
  4157. CY: /^(CY[0-9]{2})\d{8}[A-Z0-9]{16}$/,
  4158. CZ: /^(CZ[0-9]{2})\d{20}$/,
  4159. DE: /^(DE[0-9]{2})\d{18}$/,
  4160. DK: /^(DK[0-9]{2})\d{14}$/,
  4161. DO: /^(DO[0-9]{2})[A-Z]{4}\d{20}$/,
  4162. EE: /^(EE[0-9]{2})\d{16}$/,
  4163. EG: /^(EG[0-9]{2})\d{25}$/,
  4164. ES: /^(ES[0-9]{2})\d{20}$/,
  4165. FI: /^(FI[0-9]{2})\d{14}$/,
  4166. FO: /^(FO[0-9]{2})\d{14}$/,
  4167. FR: /^(FR[0-9]{2})\d{10}[A-Z0-9]{11}\d{2}$/,
  4168. GB: /^(GB[0-9]{2})[A-Z]{4}\d{14}$/,
  4169. GE: /^(GE[0-9]{2})[A-Z0-9]{2}\d{16}$/,
  4170. GI: /^(GI[0-9]{2})[A-Z]{4}[A-Z0-9]{15}$/,
  4171. GL: /^(GL[0-9]{2})\d{14}$/,
  4172. GR: /^(GR[0-9]{2})\d{7}[A-Z0-9]{16}$/,
  4173. GT: /^(GT[0-9]{2})[A-Z0-9]{4}[A-Z0-9]{20}$/,
  4174. HR: /^(HR[0-9]{2})\d{17}$/,
  4175. HU: /^(HU[0-9]{2})\d{24}$/,
  4176. IE: /^(IE[0-9]{2})[A-Z0-9]{4}\d{14}$/,
  4177. IL: /^(IL[0-9]{2})\d{19}$/,
  4178. IQ: /^(IQ[0-9]{2})[A-Z]{4}\d{15}$/,
  4179. IR: /^(IR[0-9]{2})0\d{2}0\d{18}$/,
  4180. IS: /^(IS[0-9]{2})\d{22}$/,
  4181. IT: /^(IT[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/,
  4182. JO: /^(JO[0-9]{2})[A-Z]{4}\d{22}$/,
  4183. KW: /^(KW[0-9]{2})[A-Z]{4}[A-Z0-9]{22}$/,
  4184. KZ: /^(KZ[0-9]{2})\d{3}[A-Z0-9]{13}$/,
  4185. LB: /^(LB[0-9]{2})\d{4}[A-Z0-9]{20}$/,
  4186. LC: /^(LC[0-9]{2})[A-Z]{4}[A-Z0-9]{24}$/,
  4187. LI: /^(LI[0-9]{2})\d{5}[A-Z0-9]{12}$/,
  4188. LT: /^(LT[0-9]{2})\d{16}$/,
  4189. LU: /^(LU[0-9]{2})\d{3}[A-Z0-9]{13}$/,
  4190. LV: /^(LV[0-9]{2})[A-Z]{4}[A-Z0-9]{13}$/,
  4191. MC: /^(MC[0-9]{2})\d{10}[A-Z0-9]{11}\d{2}$/,
  4192. MD: /^(MD[0-9]{2})[A-Z0-9]{20}$/,
  4193. ME: /^(ME[0-9]{2})\d{18}$/,
  4194. MK: /^(MK[0-9]{2})\d{3}[A-Z0-9]{10}\d{2}$/,
  4195. MR: /^(MR[0-9]{2})\d{23}$/,
  4196. MT: /^(MT[0-9]{2})[A-Z]{4}\d{5}[A-Z0-9]{18}$/,
  4197. MU: /^(MU[0-9]{2})[A-Z]{4}\d{19}[A-Z]{3}$/,
  4198. MZ: /^(MZ[0-9]{2})\d{21}$/,
  4199. NL: /^(NL[0-9]{2})[A-Z]{4}\d{10}$/,
  4200. NO: /^(NO[0-9]{2})\d{11}$/,
  4201. PK: /^(PK[0-9]{2})[A-Z0-9]{4}\d{16}$/,
  4202. PL: /^(PL[0-9]{2})\d{24}$/,
  4203. PS: /^(PS[0-9]{2})[A-Z0-9]{4}\d{21}$/,
  4204. PT: /^(PT[0-9]{2})\d{21}$/,
  4205. QA: /^(QA[0-9]{2})[A-Z]{4}[A-Z0-9]{21}$/,
  4206. RO: /^(RO[0-9]{2})[A-Z]{4}[A-Z0-9]{16}$/,
  4207. RS: /^(RS[0-9]{2})\d{18}$/,
  4208. SA: /^(SA[0-9]{2})\d{2}[A-Z0-9]{18}$/,
  4209. SC: /^(SC[0-9]{2})[A-Z]{4}\d{20}[A-Z]{3}$/,
  4210. SE: /^(SE[0-9]{2})\d{20}$/,
  4211. SI: /^(SI[0-9]{2})\d{15}$/,
  4212. SK: /^(SK[0-9]{2})\d{20}$/,
  4213. SM: /^(SM[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/,
  4214. SV: /^(SV[0-9]{2})[A-Z0-9]{4}\d{20}$/,
  4215. TL: /^(TL[0-9]{2})\d{19}$/,
  4216. TN: /^(TN[0-9]{2})\d{20}$/,
  4217. TR: /^(TR[0-9]{2})\d{5}[A-Z0-9]{17}$/,
  4218. UA: /^(UA[0-9]{2})\d{6}[A-Z0-9]{19}$/,
  4219. VA: /^(VA[0-9]{2})\d{18}$/,
  4220. VG: /^(VG[0-9]{2})[A-Z0-9]{4}\d{16}$/,
  4221. XK: /^(XK[0-9]{2})\d{16}$/
  4222. };
  4223. /**
  4224. * Check whether string has correct universal IBAN format
  4225. * The IBAN consists of up to 34 alphanumeric characters, as follows:
  4226. * Country Code using ISO 3166-1 alpha-2, two letters
  4227. * check digits, two digits and
  4228. * Basic Bank Account Number (BBAN), up to 30 alphanumeric characters.
  4229. * NOTE: Permitted IBAN characters are: digits [0-9] and the 26 latin alphabetic [A-Z]
  4230. *
  4231. * @param {string} str - string under validation
  4232. * @return {boolean}
  4233. */
  4234. function hasValidIbanFormat(str) {
  4235. // Strip white spaces and hyphens
  4236. var strippedStr = str.replace(/[\s\-]+/gi, '').toUpperCase();
  4237. var isoCountryCode = strippedStr.slice(0, 2).toUpperCase();
  4238. return isoCountryCode in ibanRegexThroughCountryCode && ibanRegexThroughCountryCode[isoCountryCode].test(strippedStr);
  4239. }
  4240. /**
  4241. * Check whether string has valid IBAN Checksum
  4242. * by performing basic mod-97 operation and
  4243. * the remainder should equal 1
  4244. * -- Start by rearranging the IBAN by moving the four initial characters to the end of the string
  4245. * -- Replace each letter in the string with two digits, A -> 10, B = 11, Z = 35
  4246. * -- Interpret the string as a decimal integer and
  4247. * -- compute the remainder on division by 97 (mod 97)
  4248. * Reference: https://en.wikipedia.org/wiki/International_Bank_Account_Number
  4249. *
  4250. * @param {string} str
  4251. * @return {boolean}
  4252. */
  4253. function hasValidIbanChecksum(str) {
  4254. var strippedStr = str.replace(/[^A-Z0-9]+/gi, '').toUpperCase(); // Keep only digits and A-Z latin alphabetic
  4255. var rearranged = strippedStr.slice(4) + strippedStr.slice(0, 4);
  4256. var alphaCapsReplacedWithDigits = rearranged.replace(/[A-Z]/g, function (char) {
  4257. return char.charCodeAt(0) - 55;
  4258. });
  4259. var remainder = alphaCapsReplacedWithDigits.match(/\d{1,7}/g).reduce(function (acc, value) {
  4260. return Number(acc + value) % 97;
  4261. }, '');
  4262. return remainder === 1;
  4263. }
  4264. function isIBAN(str) {
  4265. (0, _assertString.default)(str);
  4266. return hasValidIbanFormat(str) && hasValidIbanChecksum(str);
  4267. }
  4268. var locales = Object.keys(ibanRegexThroughCountryCode);
  4269. exports.locales = locales;
  4270. },{"./util/assertString":99}],41:[function(require,module,exports){
  4271. "use strict";
  4272. Object.defineProperty(exports, "__esModule", {
  4273. value: true
  4274. });
  4275. exports.default = isIMEI;
  4276. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4277. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4278. var imeiRegexWithoutHypens = /^[0-9]{15}$/;
  4279. var imeiRegexWithHypens = /^\d{2}-\d{6}-\d{6}-\d{1}$/;
  4280. function isIMEI(str, options) {
  4281. (0, _assertString.default)(str);
  4282. options = options || {}; // default regex for checking imei is the one without hyphens
  4283. var imeiRegex = imeiRegexWithoutHypens;
  4284. if (options.allow_hyphens) {
  4285. imeiRegex = imeiRegexWithHypens;
  4286. }
  4287. if (!imeiRegex.test(str)) {
  4288. return false;
  4289. }
  4290. str = str.replace(/-/g, '');
  4291. var sum = 0,
  4292. mul = 2,
  4293. l = 14;
  4294. for (var i = 0; i < l; i++) {
  4295. var digit = str.substring(l - i - 1, l - i);
  4296. var tp = parseInt(digit, 10) * mul;
  4297. if (tp >= 10) {
  4298. sum += tp % 10 + 1;
  4299. } else {
  4300. sum += tp;
  4301. }
  4302. if (mul === 1) {
  4303. mul += 1;
  4304. } else {
  4305. mul -= 1;
  4306. }
  4307. }
  4308. var chk = (10 - sum % 10) % 10;
  4309. if (chk !== parseInt(str.substring(14, 15), 10)) {
  4310. return false;
  4311. }
  4312. return true;
  4313. }
  4314. module.exports = exports.default;
  4315. module.exports.default = exports.default;
  4316. },{"./util/assertString":99}],42:[function(require,module,exports){
  4317. "use strict";
  4318. Object.defineProperty(exports, "__esModule", {
  4319. value: true
  4320. });
  4321. exports.default = isIP;
  4322. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4323. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4324. /**
  4325. 11.3. Examples
  4326. The following addresses
  4327. fe80::1234 (on the 1st link of the node)
  4328. ff02::5678 (on the 5th link of the node)
  4329. ff08::9abc (on the 10th organization of the node)
  4330. would be represented as follows:
  4331. fe80::1234%1
  4332. ff02::5678%5
  4333. ff08::9abc%10
  4334. (Here we assume a natural translation from a zone index to the
  4335. <zone_id> part, where the Nth zone of any scope is translated into
  4336. "N".)
  4337. If we use interface names as <zone_id>, those addresses could also be
  4338. represented as follows:
  4339. fe80::1234%ne0
  4340. ff02::5678%pvc1.3
  4341. ff08::9abc%interface10
  4342. where the interface "ne0" belongs to the 1st link, "pvc1.3" belongs
  4343. to the 5th link, and "interface10" belongs to the 10th organization.
  4344. * * */
  4345. var IPv4SegmentFormat = '(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
  4346. var IPv4AddressFormat = "(".concat(IPv4SegmentFormat, "[.]){3}").concat(IPv4SegmentFormat);
  4347. var IPv4AddressRegExp = new RegExp("^".concat(IPv4AddressFormat, "$"));
  4348. var IPv6SegmentFormat = '(?:[0-9a-fA-F]{1,4})';
  4349. 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,})?$');
  4350. function isIP(str) {
  4351. var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  4352. (0, _assertString.default)(str);
  4353. version = String(version);
  4354. if (!version) {
  4355. return isIP(str, 4) || isIP(str, 6);
  4356. }
  4357. if (version === '4') {
  4358. if (!IPv4AddressRegExp.test(str)) {
  4359. return false;
  4360. }
  4361. var parts = str.split('.').sort(function (a, b) {
  4362. return a - b;
  4363. });
  4364. return parts[3] <= 255;
  4365. }
  4366. if (version === '6') {
  4367. return !!IPv6AddressRegExp.test(str);
  4368. }
  4369. return false;
  4370. }
  4371. module.exports = exports.default;
  4372. module.exports.default = exports.default;
  4373. },{"./util/assertString":99}],43:[function(require,module,exports){
  4374. "use strict";
  4375. Object.defineProperty(exports, "__esModule", {
  4376. value: true
  4377. });
  4378. exports.default = isIPRange;
  4379. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4380. var _isIP = _interopRequireDefault(require("./isIP"));
  4381. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4382. var subnetMaybe = /^\d{1,3}$/;
  4383. var v4Subnet = 32;
  4384. var v6Subnet = 128;
  4385. function isIPRange(str) {
  4386. var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  4387. (0, _assertString.default)(str);
  4388. var parts = str.split('/'); // parts[0] -> ip, parts[1] -> subnet
  4389. if (parts.length !== 2) {
  4390. return false;
  4391. }
  4392. if (!subnetMaybe.test(parts[1])) {
  4393. return false;
  4394. } // Disallow preceding 0 i.e. 01, 02, ...
  4395. if (parts[1].length > 1 && parts[1].startsWith('0')) {
  4396. return false;
  4397. }
  4398. var isValidIP = (0, _isIP.default)(parts[0], version);
  4399. if (!isValidIP) {
  4400. return false;
  4401. } // Define valid subnet according to IP's version
  4402. var expectedSubnet = null;
  4403. switch (String(version)) {
  4404. case '4':
  4405. expectedSubnet = v4Subnet;
  4406. break;
  4407. case '6':
  4408. expectedSubnet = v6Subnet;
  4409. break;
  4410. default:
  4411. expectedSubnet = (0, _isIP.default)(parts[0], '6') ? v6Subnet : v4Subnet;
  4412. }
  4413. return parts[1] <= expectedSubnet && parts[1] >= 0;
  4414. }
  4415. module.exports = exports.default;
  4416. module.exports.default = exports.default;
  4417. },{"./isIP":42,"./util/assertString":99}],44:[function(require,module,exports){
  4418. "use strict";
  4419. Object.defineProperty(exports, "__esModule", {
  4420. value: true
  4421. });
  4422. exports.default = isISBN;
  4423. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4424. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4425. var isbn10Maybe = /^(?:[0-9]{9}X|[0-9]{10})$/;
  4426. var isbn13Maybe = /^(?:[0-9]{13})$/;
  4427. var factor = [1, 3];
  4428. function isISBN(str) {
  4429. var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  4430. (0, _assertString.default)(str);
  4431. version = String(version);
  4432. if (!version) {
  4433. return isISBN(str, 10) || isISBN(str, 13);
  4434. }
  4435. var sanitized = str.replace(/[\s-]+/g, '');
  4436. var checksum = 0;
  4437. var i;
  4438. if (version === '10') {
  4439. if (!isbn10Maybe.test(sanitized)) {
  4440. return false;
  4441. }
  4442. for (i = 0; i < 9; i++) {
  4443. checksum += (i + 1) * sanitized.charAt(i);
  4444. }
  4445. if (sanitized.charAt(9) === 'X') {
  4446. checksum += 10 * 10;
  4447. } else {
  4448. checksum += 10 * sanitized.charAt(9);
  4449. }
  4450. if (checksum % 11 === 0) {
  4451. return !!sanitized;
  4452. }
  4453. } else if (version === '13') {
  4454. if (!isbn13Maybe.test(sanitized)) {
  4455. return false;
  4456. }
  4457. for (i = 0; i < 12; i++) {
  4458. checksum += factor[i % 2] * sanitized.charAt(i);
  4459. }
  4460. if (sanitized.charAt(12) - (10 - checksum % 10) % 10 === 0) {
  4461. return !!sanitized;
  4462. }
  4463. }
  4464. return false;
  4465. }
  4466. module.exports = exports.default;
  4467. module.exports.default = exports.default;
  4468. },{"./util/assertString":99}],45:[function(require,module,exports){
  4469. "use strict";
  4470. Object.defineProperty(exports, "__esModule", {
  4471. value: true
  4472. });
  4473. exports.default = isISIN;
  4474. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4475. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4476. var isin = /^[A-Z]{2}[0-9A-Z]{9}[0-9]$/; // this link details how the check digit is calculated:
  4477. // https://www.isin.org/isin-format/. it is a little bit
  4478. // odd in that it works with digits, not numbers. in order
  4479. // to make only one pass through the ISIN characters, the
  4480. // each alpha character is handled as 2 characters within
  4481. // the loop.
  4482. function isISIN(str) {
  4483. (0, _assertString.default)(str);
  4484. if (!isin.test(str)) {
  4485. return false;
  4486. }
  4487. var double = true;
  4488. var sum = 0; // convert values
  4489. for (var i = str.length - 2; i >= 0; i--) {
  4490. if (str[i] >= 'A' && str[i] <= 'Z') {
  4491. var value = str[i].charCodeAt(0) - 55;
  4492. var lo = value % 10;
  4493. var hi = Math.trunc(value / 10); // letters have two digits, so handle the low order
  4494. // and high order digits separately.
  4495. for (var _i = 0, _arr = [lo, hi]; _i < _arr.length; _i++) {
  4496. var digit = _arr[_i];
  4497. if (double) {
  4498. if (digit >= 5) {
  4499. sum += 1 + (digit - 5) * 2;
  4500. } else {
  4501. sum += digit * 2;
  4502. }
  4503. } else {
  4504. sum += digit;
  4505. }
  4506. double = !double;
  4507. }
  4508. } else {
  4509. var _digit = str[i].charCodeAt(0) - '0'.charCodeAt(0);
  4510. if (double) {
  4511. if (_digit >= 5) {
  4512. sum += 1 + (_digit - 5) * 2;
  4513. } else {
  4514. sum += _digit * 2;
  4515. }
  4516. } else {
  4517. sum += _digit;
  4518. }
  4519. double = !double;
  4520. }
  4521. }
  4522. var check = Math.trunc((sum + 9) / 10) * 10 - sum;
  4523. return +str[str.length - 1] === check;
  4524. }
  4525. module.exports = exports.default;
  4526. module.exports.default = exports.default;
  4527. },{"./util/assertString":99}],46:[function(require,module,exports){
  4528. "use strict";
  4529. Object.defineProperty(exports, "__esModule", {
  4530. value: true
  4531. });
  4532. exports.default = isISO31661Alpha2;
  4533. exports.CountryCodes = void 0;
  4534. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4535. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4536. // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
  4537. 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']);
  4538. function isISO31661Alpha2(str) {
  4539. (0, _assertString.default)(str);
  4540. return validISO31661Alpha2CountriesCodes.has(str.toUpperCase());
  4541. }
  4542. var CountryCodes = validISO31661Alpha2CountriesCodes;
  4543. exports.CountryCodes = CountryCodes;
  4544. },{"./util/assertString":99}],47:[function(require,module,exports){
  4545. "use strict";
  4546. Object.defineProperty(exports, "__esModule", {
  4547. value: true
  4548. });
  4549. exports.default = isISO31661Alpha3;
  4550. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4551. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4552. // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
  4553. 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']);
  4554. function isISO31661Alpha3(str) {
  4555. (0, _assertString.default)(str);
  4556. return validISO31661Alpha3CountriesCodes.has(str.toUpperCase());
  4557. }
  4558. module.exports = exports.default;
  4559. module.exports.default = exports.default;
  4560. },{"./util/assertString":99}],48:[function(require,module,exports){
  4561. "use strict";
  4562. Object.defineProperty(exports, "__esModule", {
  4563. value: true
  4564. });
  4565. exports.default = isISO4217;
  4566. exports.CurrencyCodes = void 0;
  4567. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4568. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4569. // from https://en.wikipedia.org/wiki/ISO_4217
  4570. var validISO4217CurrencyCodes = new Set(['AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', 'AWG', 'AZN', 'BAM', 'BBD', 'BDT', 'BGN', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BOV', 'BRL', 'BSD', 'BTN', 'BWP', 'BYN', 'BZD', 'CAD', 'CDF', 'CHE', 'CHF', 'CHW', 'CLF', 'CLP', 'CNY', 'COP', 'COU', 'CRC', 'CUC', 'CUP', 'CVE', 'CZK', 'DJF', 'DKK', 'DOP', 'DZD', 'EGP', 'ERN', 'ETB', 'EUR', 'FJD', 'FKP', 'GBP', 'GEL', 'GHS', 'GIP', 'GMD', 'GNF', 'GTQ', 'GYD', 'HKD', 'HNL', 'HRK', 'HTG', 'HUF', 'IDR', 'ILS', 'INR', 'IQD', 'IRR', 'ISK', 'JMD', 'JOD', 'JPY', 'KES', 'KGS', 'KHR', 'KMF', 'KPW', 'KRW', 'KWD', 'KYD', 'KZT', 'LAK', 'LBP', 'LKR', 'LRD', 'LSL', 'LYD', 'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRU', 'MUR', 'MVR', 'MWK', 'MXN', 'MXV', 'MYR', 'MZN', 'NAD', 'NGN', 'NIO', 'NOK', 'NPR', 'NZD', 'OMR', 'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN', 'PYG', 'QAR', 'RON', 'RSD', 'RUB', 'RWF', 'SAR', 'SBD', 'SCR', 'SDG', 'SEK', 'SGD', 'SHP', 'SLL', 'SOS', 'SRD', 'SSP', 'STN', 'SVC', 'SYP', 'SZL', 'THB', 'TJS', 'TMT', 'TND', 'TOP', 'TRY', 'TTD', 'TWD', 'TZS', 'UAH', 'UGX', 'USD', 'USN', 'UYI', 'UYU', 'UYW', 'UZS', 'VES', 'VND', 'VUV', 'WST', 'XAF', 'XAG', 'XAU', 'XBA', 'XBB', 'XBC', 'XBD', 'XCD', 'XDR', 'XOF', 'XPD', 'XPF', 'XPT', 'XSU', 'XTS', 'XUA', 'XXX', 'YER', 'ZAR', 'ZMW', 'ZWL']);
  4571. function isISO4217(str) {
  4572. (0, _assertString.default)(str);
  4573. return validISO4217CurrencyCodes.has(str.toUpperCase());
  4574. }
  4575. var CurrencyCodes = validISO4217CurrencyCodes;
  4576. exports.CurrencyCodes = CurrencyCodes;
  4577. },{"./util/assertString":99}],49:[function(require,module,exports){
  4578. "use strict";
  4579. Object.defineProperty(exports, "__esModule", {
  4580. value: true
  4581. });
  4582. exports.default = isISO8601;
  4583. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4584. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4585. /* eslint-disable max-len */
  4586. // from http://goo.gl/0ejHHW
  4587. var iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; // same as above, except with a strict 'T' separator between date and time
  4588. 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)?)?)?)?$/;
  4589. /* eslint-enable max-len */
  4590. var isValidDate = function isValidDate(str) {
  4591. // str must have passed the ISO8601 check
  4592. // this check is meant to catch invalid dates
  4593. // like 2009-02-31
  4594. // first check for ordinal dates
  4595. var ordinalMatch = str.match(/^(\d{4})-?(\d{3})([ T]{1}\.*|$)/);
  4596. if (ordinalMatch) {
  4597. var oYear = Number(ordinalMatch[1]);
  4598. var oDay = Number(ordinalMatch[2]); // if is leap year
  4599. if (oYear % 4 === 0 && oYear % 100 !== 0 || oYear % 400 === 0) return oDay <= 366;
  4600. return oDay <= 365;
  4601. }
  4602. var match = str.match(/(\d{4})-?(\d{0,2})-?(\d*)/).map(Number);
  4603. var year = match[1];
  4604. var month = match[2];
  4605. var day = match[3];
  4606. var monthString = month ? "0".concat(month).slice(-2) : month;
  4607. var dayString = day ? "0".concat(day).slice(-2) : day; // create a date object and compare
  4608. var d = new Date("".concat(year, "-").concat(monthString || '01', "-").concat(dayString || '01'));
  4609. if (month && day) {
  4610. return d.getUTCFullYear() === year && d.getUTCMonth() + 1 === month && d.getUTCDate() === day;
  4611. }
  4612. return true;
  4613. };
  4614. function isISO8601(str) {
  4615. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  4616. (0, _assertString.default)(str);
  4617. var check = options.strictSeparator ? iso8601StrictSeparator.test(str) : iso8601.test(str);
  4618. if (check && options.strict) return isValidDate(str);
  4619. return check;
  4620. }
  4621. module.exports = exports.default;
  4622. module.exports.default = exports.default;
  4623. },{"./util/assertString":99}],50:[function(require,module,exports){
  4624. "use strict";
  4625. Object.defineProperty(exports, "__esModule", {
  4626. value: true
  4627. });
  4628. exports.default = isISRC;
  4629. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4630. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4631. // see http://isrc.ifpi.org/en/isrc-standard/code-syntax
  4632. var isrc = /^[A-Z]{2}[0-9A-Z]{3}\d{2}\d{5}$/;
  4633. function isISRC(str) {
  4634. (0, _assertString.default)(str);
  4635. return isrc.test(str);
  4636. }
  4637. module.exports = exports.default;
  4638. module.exports.default = exports.default;
  4639. },{"./util/assertString":99}],51:[function(require,module,exports){
  4640. "use strict";
  4641. Object.defineProperty(exports, "__esModule", {
  4642. value: true
  4643. });
  4644. exports.default = isISSN;
  4645. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4646. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4647. var issn = '^\\d{4}-?\\d{3}[\\dX]$';
  4648. function isISSN(str) {
  4649. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  4650. (0, _assertString.default)(str);
  4651. var testIssn = issn;
  4652. testIssn = options.require_hyphen ? testIssn.replace('?', '') : testIssn;
  4653. testIssn = options.case_sensitive ? new RegExp(testIssn) : new RegExp(testIssn, 'i');
  4654. if (!testIssn.test(str)) {
  4655. return false;
  4656. }
  4657. var digits = str.replace('-', '').toUpperCase();
  4658. var checksum = 0;
  4659. for (var i = 0; i < digits.length; i++) {
  4660. var digit = digits[i];
  4661. checksum += (digit === 'X' ? 10 : +digit) * (8 - i);
  4662. }
  4663. return checksum % 11 === 0;
  4664. }
  4665. module.exports = exports.default;
  4666. module.exports.default = exports.default;
  4667. },{"./util/assertString":99}],52:[function(require,module,exports){
  4668. "use strict";
  4669. Object.defineProperty(exports, "__esModule", {
  4670. value: true
  4671. });
  4672. exports.default = isIdentityCard;
  4673. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4674. var _isInt = _interopRequireDefault(require("./isInt"));
  4675. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4676. var validators = {
  4677. PL: function PL(str) {
  4678. (0, _assertString.default)(str);
  4679. var weightOfDigits = {
  4680. 1: 1,
  4681. 2: 3,
  4682. 3: 7,
  4683. 4: 9,
  4684. 5: 1,
  4685. 6: 3,
  4686. 7: 7,
  4687. 8: 9,
  4688. 9: 1,
  4689. 10: 3,
  4690. 11: 0
  4691. };
  4692. if (str != null && str.length === 11 && (0, _isInt.default)(str, {
  4693. allow_leading_zeroes: true
  4694. })) {
  4695. var digits = str.split('').slice(0, -1);
  4696. var sum = digits.reduce(function (acc, digit, index) {
  4697. return acc + Number(digit) * weightOfDigits[index + 1];
  4698. }, 0);
  4699. var modulo = sum % 10;
  4700. var lastDigit = Number(str.charAt(str.length - 1));
  4701. if (modulo === 0 && lastDigit === 0 || lastDigit === 10 - modulo) {
  4702. return true;
  4703. }
  4704. }
  4705. return false;
  4706. },
  4707. ES: function ES(str) {
  4708. (0, _assertString.default)(str);
  4709. var DNI = /^[0-9X-Z][0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKE]$/;
  4710. var charsValue = {
  4711. X: 0,
  4712. Y: 1,
  4713. Z: 2
  4714. };
  4715. var controlDigits = ['T', 'R', 'W', 'A', 'G', 'M', 'Y', 'F', 'P', 'D', 'X', 'B', 'N', 'J', 'Z', 'S', 'Q', 'V', 'H', 'L', 'C', 'K', 'E']; // sanitize user input
  4716. var sanitized = str.trim().toUpperCase(); // validate the data structure
  4717. if (!DNI.test(sanitized)) {
  4718. return false;
  4719. } // validate the control digit
  4720. var number = sanitized.slice(0, -1).replace(/[X,Y,Z]/g, function (char) {
  4721. return charsValue[char];
  4722. });
  4723. return sanitized.endsWith(controlDigits[number % 23]);
  4724. },
  4725. FI: function FI(str) {
  4726. // https://dvv.fi/en/personal-identity-code#:~:text=control%20character%20for%20a-,personal,-identity%20code%20calculated
  4727. (0, _assertString.default)(str);
  4728. if (str.length !== 11) {
  4729. return false;
  4730. }
  4731. if (!str.match(/^\d{6}[\-A\+]\d{3}[0-9ABCDEFHJKLMNPRSTUVWXY]{1}$/)) {
  4732. return false;
  4733. }
  4734. var checkDigits = '0123456789ABCDEFHJKLMNPRSTUVWXY';
  4735. var idAsNumber = parseInt(str.slice(0, 6), 10) * 1000 + parseInt(str.slice(7, 10), 10);
  4736. var remainder = idAsNumber % 31;
  4737. var checkDigit = checkDigits[remainder];
  4738. return checkDigit === str.slice(10, 11);
  4739. },
  4740. IN: function IN(str) {
  4741. var DNI = /^[1-9]\d{3}\s?\d{4}\s?\d{4}$/; // multiplication table
  4742. var d = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 0, 6, 7, 8, 9, 5], [2, 3, 4, 0, 1, 7, 8, 9, 5, 6], [3, 4, 0, 1, 2, 8, 9, 5, 6, 7], [4, 0, 1, 2, 3, 9, 5, 6, 7, 8], [5, 9, 8, 7, 6, 0, 4, 3, 2, 1], [6, 5, 9, 8, 7, 1, 0, 4, 3, 2], [7, 6, 5, 9, 8, 2, 1, 0, 4, 3], [8, 7, 6, 5, 9, 3, 2, 1, 0, 4], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]; // permutation table
  4743. var p = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 5, 7, 6, 2, 8, 3, 0, 9, 4], [5, 8, 0, 3, 7, 9, 6, 1, 4, 2], [8, 9, 1, 6, 0, 4, 3, 5, 2, 7], [9, 4, 5, 3, 1, 2, 6, 8, 7, 0], [4, 2, 8, 6, 5, 7, 3, 9, 0, 1], [2, 7, 9, 3, 8, 0, 6, 4, 1, 5], [7, 0, 4, 6, 9, 1, 3, 2, 5, 8]]; // sanitize user input
  4744. var sanitized = str.trim(); // validate the data structure
  4745. if (!DNI.test(sanitized)) {
  4746. return false;
  4747. }
  4748. var c = 0;
  4749. var invertedArray = sanitized.replace(/\s/g, '').split('').map(Number).reverse();
  4750. invertedArray.forEach(function (val, i) {
  4751. c = d[c][p[i % 8][val]];
  4752. });
  4753. return c === 0;
  4754. },
  4755. IR: function IR(str) {
  4756. if (!str.match(/^\d{10}$/)) return false;
  4757. str = "0000".concat(str).substr(str.length - 6);
  4758. if (parseInt(str.substr(3, 6), 10) === 0) return false;
  4759. var lastNumber = parseInt(str.substr(9, 1), 10);
  4760. var sum = 0;
  4761. for (var i = 0; i < 9; i++) {
  4762. sum += parseInt(str.substr(i, 1), 10) * (10 - i);
  4763. }
  4764. sum %= 11;
  4765. return sum < 2 && lastNumber === sum || sum >= 2 && lastNumber === 11 - sum;
  4766. },
  4767. IT: function IT(str) {
  4768. if (str.length !== 9) return false;
  4769. if (str === 'CA00000AA') return false; // https://it.wikipedia.org/wiki/Carta_d%27identit%C3%A0_elettronica_italiana
  4770. return str.search(/C[A-Z][0-9]{5}[A-Z]{2}/i) > -1;
  4771. },
  4772. NO: function NO(str) {
  4773. var sanitized = str.trim();
  4774. if (isNaN(Number(sanitized))) return false;
  4775. if (sanitized.length !== 11) return false;
  4776. if (sanitized === '00000000000') return false; // https://no.wikipedia.org/wiki/F%C3%B8dselsnummer
  4777. var f = sanitized.split('').map(Number);
  4778. 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;
  4779. 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;
  4780. if (k1 !== f[9] || k2 !== f[10]) return false;
  4781. return true;
  4782. },
  4783. TH: function TH(str) {
  4784. if (!str.match(/^[1-8]\d{12}$/)) return false; // validate check digit
  4785. var sum = 0;
  4786. for (var i = 0; i < 12; i++) {
  4787. sum += parseInt(str[i], 10) * (13 - i);
  4788. }
  4789. return str[12] === ((11 - sum % 11) % 10).toString();
  4790. },
  4791. LK: function LK(str) {
  4792. var old_nic = /^[1-9]\d{8}[vx]$/i;
  4793. var new_nic = /^[1-9]\d{11}$/i;
  4794. if (str.length === 10 && old_nic.test(str)) return true;else if (str.length === 12 && new_nic.test(str)) return true;
  4795. return false;
  4796. },
  4797. 'he-IL': function heIL(str) {
  4798. var DNI = /^\d{9}$/; // sanitize user input
  4799. var sanitized = str.trim(); // validate the data structure
  4800. if (!DNI.test(sanitized)) {
  4801. return false;
  4802. }
  4803. var id = sanitized;
  4804. var sum = 0,
  4805. incNum;
  4806. for (var i = 0; i < id.length; i++) {
  4807. incNum = Number(id[i]) * (i % 2 + 1); // Multiply number by 1 or 2
  4808. sum += incNum > 9 ? incNum - 9 : incNum; // Sum the digits up and add to total
  4809. }
  4810. return sum % 10 === 0;
  4811. },
  4812. 'ar-LY': function arLY(str) {
  4813. // Libya National Identity Number NIN is 12 digits, the first digit is either 1 or 2
  4814. var NIN = /^(1|2)\d{11}$/; // sanitize user input
  4815. var sanitized = str.trim(); // validate the data structure
  4816. if (!NIN.test(sanitized)) {
  4817. return false;
  4818. }
  4819. return true;
  4820. },
  4821. 'ar-TN': function arTN(str) {
  4822. var DNI = /^\d{8}$/; // sanitize user input
  4823. var sanitized = str.trim(); // validate the data structure
  4824. if (!DNI.test(sanitized)) {
  4825. return false;
  4826. }
  4827. return true;
  4828. },
  4829. 'zh-CN': function zhCN(str) {
  4830. var provincesAndCities = ['11', // 北京
  4831. '12', // 天津
  4832. '13', // 河北
  4833. '14', // 山西
  4834. '15', // 内蒙古
  4835. '21', // 辽宁
  4836. '22', // 吉林
  4837. '23', // 黑龙江
  4838. '31', // 上海
  4839. '32', // 江苏
  4840. '33', // 浙江
  4841. '34', // 安徽
  4842. '35', // 福建
  4843. '36', // 江西
  4844. '37', // 山东
  4845. '41', // 河南
  4846. '42', // 湖北
  4847. '43', // 湖南
  4848. '44', // 广东
  4849. '45', // 广西
  4850. '46', // 海南
  4851. '50', // 重庆
  4852. '51', // 四川
  4853. '52', // 贵州
  4854. '53', // 云南
  4855. '54', // 西藏
  4856. '61', // 陕西
  4857. '62', // 甘肃
  4858. '63', // 青海
  4859. '64', // 宁夏
  4860. '65', // 新疆
  4861. '71', // 台湾
  4862. '81', // 香港
  4863. '82', // 澳门
  4864. '91' // 国外
  4865. ];
  4866. var powers = ['7', '9', '10', '5', '8', '4', '2', '1', '6', '3', '7', '9', '10', '5', '8', '4', '2'];
  4867. var parityBit = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
  4868. var checkAddressCode = function checkAddressCode(addressCode) {
  4869. return provincesAndCities.includes(addressCode);
  4870. };
  4871. var checkBirthDayCode = function checkBirthDayCode(birDayCode) {
  4872. var yyyy = parseInt(birDayCode.substring(0, 4), 10);
  4873. var mm = parseInt(birDayCode.substring(4, 6), 10);
  4874. var dd = parseInt(birDayCode.substring(6), 10);
  4875. var xdata = new Date(yyyy, mm - 1, dd);
  4876. if (xdata > new Date()) {
  4877. return false; // eslint-disable-next-line max-len
  4878. } else if (xdata.getFullYear() === yyyy && xdata.getMonth() === mm - 1 && xdata.getDate() === dd) {
  4879. return true;
  4880. }
  4881. return false;
  4882. };
  4883. var getParityBit = function getParityBit(idCardNo) {
  4884. var id17 = idCardNo.substring(0, 17);
  4885. var power = 0;
  4886. for (var i = 0; i < 17; i++) {
  4887. power += parseInt(id17.charAt(i), 10) * parseInt(powers[i], 10);
  4888. }
  4889. var mod = power % 11;
  4890. return parityBit[mod];
  4891. };
  4892. var checkParityBit = function checkParityBit(idCardNo) {
  4893. return getParityBit(idCardNo) === idCardNo.charAt(17).toUpperCase();
  4894. };
  4895. var check15IdCardNo = function check15IdCardNo(idCardNo) {
  4896. 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);
  4897. if (!check) return false;
  4898. var addressCode = idCardNo.substring(0, 2);
  4899. check = checkAddressCode(addressCode);
  4900. if (!check) return false;
  4901. var birDayCode = "19".concat(idCardNo.substring(6, 12));
  4902. check = checkBirthDayCode(birDayCode);
  4903. if (!check) return false;
  4904. return true;
  4905. };
  4906. var check18IdCardNo = function check18IdCardNo(idCardNo) {
  4907. 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);
  4908. if (!check) return false;
  4909. var addressCode = idCardNo.substring(0, 2);
  4910. check = checkAddressCode(addressCode);
  4911. if (!check) return false;
  4912. var birDayCode = idCardNo.substring(6, 14);
  4913. check = checkBirthDayCode(birDayCode);
  4914. if (!check) return false;
  4915. return checkParityBit(idCardNo);
  4916. };
  4917. var checkIdCardNo = function checkIdCardNo(idCardNo) {
  4918. var check = /^\d{15}|(\d{17}(\d|x|X))$/.test(idCardNo);
  4919. if (!check) return false;
  4920. if (idCardNo.length === 15) {
  4921. return check15IdCardNo(idCardNo);
  4922. }
  4923. return check18IdCardNo(idCardNo);
  4924. };
  4925. return checkIdCardNo(str);
  4926. },
  4927. 'zh-TW': function zhTW(str) {
  4928. var ALPHABET_CODES = {
  4929. A: 10,
  4930. B: 11,
  4931. C: 12,
  4932. D: 13,
  4933. E: 14,
  4934. F: 15,
  4935. G: 16,
  4936. H: 17,
  4937. I: 34,
  4938. J: 18,
  4939. K: 19,
  4940. L: 20,
  4941. M: 21,
  4942. N: 22,
  4943. O: 35,
  4944. P: 23,
  4945. Q: 24,
  4946. R: 25,
  4947. S: 26,
  4948. T: 27,
  4949. U: 28,
  4950. V: 29,
  4951. W: 32,
  4952. X: 30,
  4953. Y: 31,
  4954. Z: 33
  4955. };
  4956. var sanitized = str.trim().toUpperCase();
  4957. if (!/^[A-Z][0-9]{9}$/.test(sanitized)) return false;
  4958. return Array.from(sanitized).reduce(function (sum, number, index) {
  4959. if (index === 0) {
  4960. var code = ALPHABET_CODES[number];
  4961. return code % 10 * 9 + Math.floor(code / 10);
  4962. }
  4963. if (index === 9) {
  4964. return (10 - sum % 10 - Number(number)) % 10 === 0;
  4965. }
  4966. return sum + Number(number) * (9 - index);
  4967. }, 0);
  4968. }
  4969. };
  4970. function isIdentityCard(str, locale) {
  4971. (0, _assertString.default)(str);
  4972. if (locale in validators) {
  4973. return validators[locale](str);
  4974. } else if (locale === 'any') {
  4975. for (var key in validators) {
  4976. // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
  4977. // istanbul ignore else
  4978. if (validators.hasOwnProperty(key)) {
  4979. var validator = validators[key];
  4980. if (validator(str)) {
  4981. return true;
  4982. }
  4983. }
  4984. }
  4985. return false;
  4986. }
  4987. throw new Error("Invalid locale '".concat(locale, "'"));
  4988. }
  4989. module.exports = exports.default;
  4990. module.exports.default = exports.default;
  4991. },{"./isInt":54,"./util/assertString":99}],53:[function(require,module,exports){
  4992. "use strict";
  4993. Object.defineProperty(exports, "__esModule", {
  4994. value: true
  4995. });
  4996. exports.default = isIn;
  4997. var _assertString = _interopRequireDefault(require("./util/assertString"));
  4998. var _toString = _interopRequireDefault(require("./util/toString"));
  4999. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5000. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  5001. function isIn(str, options) {
  5002. (0, _assertString.default)(str);
  5003. var i;
  5004. if (Object.prototype.toString.call(options) === '[object Array]') {
  5005. var array = [];
  5006. for (i in options) {
  5007. // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
  5008. // istanbul ignore else
  5009. if ({}.hasOwnProperty.call(options, i)) {
  5010. array[i] = (0, _toString.default)(options[i]);
  5011. }
  5012. }
  5013. return array.indexOf(str) >= 0;
  5014. } else if (_typeof(options) === 'object') {
  5015. return options.hasOwnProperty(str);
  5016. } else if (options && typeof options.indexOf === 'function') {
  5017. return options.indexOf(str) >= 0;
  5018. }
  5019. return false;
  5020. }
  5021. module.exports = exports.default;
  5022. module.exports.default = exports.default;
  5023. },{"./util/assertString":99,"./util/toString":103}],54:[function(require,module,exports){
  5024. "use strict";
  5025. Object.defineProperty(exports, "__esModule", {
  5026. value: true
  5027. });
  5028. exports.default = isInt;
  5029. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5030. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5031. var int = /^(?:[-+]?(?:0|[1-9][0-9]*))$/;
  5032. var intLeadingZeroes = /^[-+]?[0-9]+$/;
  5033. function isInt(str, options) {
  5034. (0, _assertString.default)(str);
  5035. options = options || {}; // Get the regex to use for testing, based on whether
  5036. // leading zeroes are allowed or not.
  5037. var regex = options.hasOwnProperty('allow_leading_zeroes') && !options.allow_leading_zeroes ? int : intLeadingZeroes; // Check min/max/lt/gt
  5038. var minCheckPassed = !options.hasOwnProperty('min') || str >= options.min;
  5039. var maxCheckPassed = !options.hasOwnProperty('max') || str <= options.max;
  5040. var ltCheckPassed = !options.hasOwnProperty('lt') || str < options.lt;
  5041. var gtCheckPassed = !options.hasOwnProperty('gt') || str > options.gt;
  5042. return regex.test(str) && minCheckPassed && maxCheckPassed && ltCheckPassed && gtCheckPassed;
  5043. }
  5044. module.exports = exports.default;
  5045. module.exports.default = exports.default;
  5046. },{"./util/assertString":99}],55:[function(require,module,exports){
  5047. "use strict";
  5048. Object.defineProperty(exports, "__esModule", {
  5049. value: true
  5050. });
  5051. exports.default = isJSON;
  5052. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5053. var _merge = _interopRequireDefault(require("./util/merge"));
  5054. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5055. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  5056. var default_json_options = {
  5057. allow_primitives: false
  5058. };
  5059. function isJSON(str, options) {
  5060. (0, _assertString.default)(str);
  5061. try {
  5062. options = (0, _merge.default)(options, default_json_options);
  5063. var primitives = [];
  5064. if (options.allow_primitives) {
  5065. primitives = [null, false, true];
  5066. }
  5067. var obj = JSON.parse(str);
  5068. return primitives.includes(obj) || !!obj && _typeof(obj) === 'object';
  5069. } catch (e) {
  5070. /* ignore */
  5071. }
  5072. return false;
  5073. }
  5074. module.exports = exports.default;
  5075. module.exports.default = exports.default;
  5076. },{"./util/assertString":99,"./util/merge":101}],56:[function(require,module,exports){
  5077. "use strict";
  5078. Object.defineProperty(exports, "__esModule", {
  5079. value: true
  5080. });
  5081. exports.default = isJWT;
  5082. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5083. var _isBase = _interopRequireDefault(require("./isBase64"));
  5084. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5085. function isJWT(str) {
  5086. (0, _assertString.default)(str);
  5087. var dotSplit = str.split('.');
  5088. var len = dotSplit.length;
  5089. if (len > 3 || len < 2) {
  5090. return false;
  5091. }
  5092. return dotSplit.reduce(function (acc, currElem) {
  5093. return acc && (0, _isBase.default)(currElem, {
  5094. urlSafe: true
  5095. });
  5096. }, true);
  5097. }
  5098. module.exports = exports.default;
  5099. module.exports.default = exports.default;
  5100. },{"./isBase64":17,"./util/assertString":99}],57:[function(require,module,exports){
  5101. "use strict";
  5102. Object.defineProperty(exports, "__esModule", {
  5103. value: true
  5104. });
  5105. exports.default = isLatLong;
  5106. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5107. var _merge = _interopRequireDefault(require("./util/merge"));
  5108. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5109. var lat = /^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/;
  5110. var long = /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/;
  5111. var latDMS = /^(([1-8]?\d)\D+([1-5]?\d|60)\D+([1-5]?\d|60)(\.\d+)?|90\D+0\D+0)\D+[NSns]?$/i;
  5112. 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;
  5113. var defaultLatLongOptions = {
  5114. checkDMS: false
  5115. };
  5116. function isLatLong(str, options) {
  5117. (0, _assertString.default)(str);
  5118. options = (0, _merge.default)(options, defaultLatLongOptions);
  5119. if (!str.includes(',')) return false;
  5120. var pair = str.split(',');
  5121. if (pair[0].startsWith('(') && !pair[1].endsWith(')') || pair[1].endsWith(')') && !pair[0].startsWith('(')) return false;
  5122. if (options.checkDMS) {
  5123. return latDMS.test(pair[0]) && longDMS.test(pair[1]);
  5124. }
  5125. return lat.test(pair[0]) && long.test(pair[1]);
  5126. }
  5127. module.exports = exports.default;
  5128. module.exports.default = exports.default;
  5129. },{"./util/assertString":99,"./util/merge":101}],58:[function(require,module,exports){
  5130. "use strict";
  5131. Object.defineProperty(exports, "__esModule", {
  5132. value: true
  5133. });
  5134. exports.default = isLength;
  5135. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5136. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5137. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  5138. /* eslint-disable prefer-rest-params */
  5139. function isLength(str, options) {
  5140. (0, _assertString.default)(str);
  5141. var min;
  5142. var max;
  5143. if (_typeof(options) === 'object') {
  5144. min = options.min || 0;
  5145. max = options.max;
  5146. } else {
  5147. // backwards compatibility: isLength(str, min [, max])
  5148. min = arguments[1] || 0;
  5149. max = arguments[2];
  5150. }
  5151. var surrogatePairs = str.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g) || [];
  5152. var len = str.length - surrogatePairs.length;
  5153. return len >= min && (typeof max === 'undefined' || len <= max);
  5154. }
  5155. module.exports = exports.default;
  5156. module.exports.default = exports.default;
  5157. },{"./util/assertString":99}],59:[function(require,module,exports){
  5158. "use strict";
  5159. Object.defineProperty(exports, "__esModule", {
  5160. value: true
  5161. });
  5162. exports.default = isLicensePlate;
  5163. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5164. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5165. var validators = {
  5166. 'cs-CZ': function csCZ(str) {
  5167. return /^(([ABCDEFHKIJKLMNPRSTUVXYZ]|[0-9])-?){5,8}$/.test(str);
  5168. },
  5169. 'de-DE': function deDE(str) {
  5170. return /^((AW|UL|AK|GA|AÖ|LF|AZ|AM|AS|ZE|AN|AB|A|KG|KH|BA|EW|BZ|HY|KM|BT|HP|B|BC|BI|BO|FN|TT|ÜB|BN|AH|BS|FR|HB|ZZ|BB|BK|BÖ|OC|OK|CW|CE|C|CO|LH|CB|KW|LC|LN|DA|DI|DE|DH|SY|NÖ|DO|DD|DU|DN|D|EI|EA|EE|FI|EM|EL|EN|PF|ED|EF|ER|AU|ZP|E|ES|NT|EU|FL|FO|FT|FF|F|FS|FD|FÜ|GE|G|GI|GF|GS|ZR|GG|GP|GR|NY|ZI|GÖ|GZ|GT|HA|HH|HM|HU|WL|HZ|WR|RN|HK|HD|HN|HS|GK|HE|HF|RZ|HI|HG|HO|HX|IK|IL|IN|J|JL|KL|KA|KS|KF|KE|KI|KT|KO|KN|KR|KC|KU|K|LD|LL|LA|L|OP|LM|LI|LB|LU|LÖ|HL|LG|MD|GN|MZ|MA|ML|MR|MY|AT|DM|MC|NZ|RM|RG|MM|ME|MB|MI|FG|DL|HC|MW|RL|MK|MG|MÜ|WS|MH|M|MS|NU|NB|ND|NM|NK|NW|NR|NI|NF|DZ|EB|OZ|TG|TO|N|OA|GM|OB|CA|EH|FW|OF|OL|OE|OG|BH|LR|OS|AA|GD|OH|KY|NP|WK|PB|PA|PE|PI|PS|P|PM|PR|RA|RV|RE|R|H|SB|WN|RS|RD|RT|BM|NE|GV|RP|SU|GL|RO|GÜ|RH|EG|RW|PN|SK|MQ|RU|SZ|RI|SL|SM|SC|HR|FZ|VS|SW|SN|CR|SE|SI|SO|LP|SG|NH|SP|IZ|ST|BF|TE|HV|OD|SR|S|AC|DW|ZW|TF|TS|TR|TÜ|UM|PZ|TP|UE|UN|UH|MN|KK|VB|V|AE|PL|RC|VG|GW|PW|VR|VK|KB|WA|WT|BE|WM|WE|AP|MO|WW|FB|WZ|WI|WB|JE|WF|WO|W|WÜ|BL|Z|GC)[- ]?[A-Z]{1,2}[- ]?\d{1,4}|(AIC|FDB|ABG|SLN|SAW|KLZ|BUL|ESB|NAB|SUL|WST|ABI|AZE|BTF|KÖT|DKB|FEU|ROT|ALZ|SMÜ|WER|AUR|NOR|DÜW|BRK|HAB|TÖL|WOR|BAD|BAR|BER|BIW|EBS|KEM|MÜB|PEG|BGL|BGD|REI|WIL|BKS|BIR|WAT|BOR|BOH|BOT|BRB|BLK|HHM|NEB|NMB|WSF|LEO|HDL|WMS|WZL|BÜS|CHA|KÖZ|ROD|WÜM|CLP|NEC|COC|ZEL|COE|CUX|DAH|LDS|DEG|DEL|RSL|DLG|DGF|LAN|HEI|MED|DON|KIB|ROK|JÜL|MON|SLE|EBE|EIC|HIG|WBS|BIT|PRÜ|LIB|EMD|WIT|ERH|HÖS|ERZ|ANA|ASZ|MAB|MEK|STL|SZB|FDS|HCH|HOR|WOL|FRG|GRA|WOS|FRI|FFB|GAP|GER|BRL|CLZ|GTH|NOH|HGW|GRZ|LÖB|NOL|WSW|DUD|HMÜ|OHA|KRU|HAL|HAM|HBS|QLB|HVL|NAU|HAS|EBN|GEO|HOH|HDH|ERK|HER|WAN|HEF|ROF|HBN|ALF|HSK|USI|NAI|REH|SAN|KÜN|ÖHR|HOL|WAR|ARN|BRG|GNT|HOG|WOH|KEH|MAI|PAR|RID|ROL|KLE|GEL|KUS|KYF|ART|SDH|LDK|DIL|MAL|VIB|LER|BNA|GHA|GRM|MTL|WUR|LEV|LIF|STE|WEL|LIP|VAI|LUP|HGN|LBZ|LWL|PCH|STB|DAN|MKK|SLÜ|MSP|TBB|MGH|MTK|BIN|MSH|EIL|HET|SGH|BID|MYK|MSE|MST|MÜR|WRN|MEI|GRH|RIE|MZG|MIL|OBB|BED|FLÖ|MOL|FRW|SEE|SRB|AIB|MOS|BCH|ILL|SOB|NMS|NEA|SEF|UFF|NEW|VOH|NDH|TDO|NWM|GDB|GVM|WIS|NOM|EIN|GAN|LAU|HEB|OHV|OSL|SFB|ERB|LOS|BSK|KEL|BSB|MEL|WTL|OAL|FÜS|MOD|OHZ|OPR|BÜR|PAF|PLÖ|CAS|GLA|REG|VIT|ECK|SIM|GOA|EMS|DIZ|GOH|RÜD|SWA|NES|KÖN|MET|LRO|BÜZ|DBR|ROS|TET|HRO|ROW|BRV|HIP|PAN|GRI|SHK|EIS|SRO|SOK|LBS|SCZ|MER|QFT|SLF|SLS|HOM|SLK|ASL|BBG|SBK|SFT|SHG|MGN|MEG|ZIG|SAD|NEN|OVI|SHA|BLB|SIG|SON|SPN|FOR|GUB|SPB|IGB|WND|STD|STA|SDL|OBG|HST|BOG|SHL|PIR|FTL|SEB|SÖM|SÜW|TIR|SAB|TUT|ANG|SDT|LÜN|LSZ|MHL|VEC|VER|VIE|OVL|ANK|OVP|SBG|UEM|UER|WLG|GMN|NVP|RDG|RÜG|DAU|FKB|WAF|WAK|SLZ|WEN|SOG|APD|WUG|GUN|ESW|WIZ|WES|DIN|BRA|BÜD|WHV|HWI|GHC|WTM|WOB|WUN|MAK|SEL|OCH|HOT|WDA)[- ]?(([A-Z][- ]?\d{1,4})|([A-Z]{2}[- ]?\d{1,3})))[- ]?(E|H)?$/.test(str);
  5171. },
  5172. 'de-LI': function deLI(str) {
  5173. return /^FL[- ]?\d{1,5}[UZ]?$/.test(str);
  5174. },
  5175. 'fi-FI': function fiFI(str) {
  5176. return /^(?=.{4,7})(([A-Z]{1,3}|[0-9]{1,3})[\s-]?([A-Z]{1,3}|[0-9]{1,5}))$/.test(str);
  5177. },
  5178. 'pt-PT': function ptPT(str) {
  5179. return /^([A-Z]{2}|[0-9]{2})[ -·]?([A-Z]{2}|[0-9]{2})[ -·]?([A-Z]{2}|[0-9]{2})$/.test(str);
  5180. },
  5181. 'sq-AL': function sqAL(str) {
  5182. return /^[A-Z]{2}[- ]?((\d{3}[- ]?(([A-Z]{2})|T))|(R[- ]?\d{3}))$/.test(str);
  5183. },
  5184. 'pt-BR': function ptBR(str) {
  5185. return /^[A-Z]{3}[ -]?[0-9][A-Z][0-9]{2}|[A-Z]{3}[ -]?[0-9]{4}$/.test(str);
  5186. }
  5187. };
  5188. function isLicensePlate(str, locale) {
  5189. (0, _assertString.default)(str);
  5190. if (locale in validators) {
  5191. return validators[locale](str);
  5192. } else if (locale === 'any') {
  5193. for (var key in validators) {
  5194. /* eslint guard-for-in: 0 */
  5195. var validator = validators[key];
  5196. if (validator(str)) {
  5197. return true;
  5198. }
  5199. }
  5200. return false;
  5201. }
  5202. throw new Error("Invalid locale '".concat(locale, "'"));
  5203. }
  5204. module.exports = exports.default;
  5205. module.exports.default = exports.default;
  5206. },{"./util/assertString":99}],60:[function(require,module,exports){
  5207. "use strict";
  5208. Object.defineProperty(exports, "__esModule", {
  5209. value: true
  5210. });
  5211. exports.default = isLocale;
  5212. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5213. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5214. var localeReg = /^[A-Za-z]{2,4}([_-]([A-Za-z]{4}|[\d]{3}))?([_-]([A-Za-z]{2}|[\d]{3}))?$/;
  5215. function isLocale(str) {
  5216. (0, _assertString.default)(str);
  5217. if (str === 'en_US_POSIX' || str === 'ca_ES_VALENCIA') {
  5218. return true;
  5219. }
  5220. return localeReg.test(str);
  5221. }
  5222. module.exports = exports.default;
  5223. module.exports.default = exports.default;
  5224. },{"./util/assertString":99}],61:[function(require,module,exports){
  5225. "use strict";
  5226. Object.defineProperty(exports, "__esModule", {
  5227. value: true
  5228. });
  5229. exports.default = isLowercase;
  5230. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5231. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5232. function isLowercase(str) {
  5233. (0, _assertString.default)(str);
  5234. return str === str.toLowerCase();
  5235. }
  5236. module.exports = exports.default;
  5237. module.exports.default = exports.default;
  5238. },{"./util/assertString":99}],62:[function(require,module,exports){
  5239. "use strict";
  5240. Object.defineProperty(exports, "__esModule", {
  5241. value: true
  5242. });
  5243. exports.default = isMACAddress;
  5244. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5245. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5246. var macAddress = /^(?:[0-9a-fA-F]{2}([-:\s]))([0-9a-fA-F]{2}\1){4}([0-9a-fA-F]{2})$/;
  5247. var macAddressNoSeparators = /^([0-9a-fA-F]){12}$/;
  5248. var macAddressWithDots = /^([0-9a-fA-F]{4}\.){2}([0-9a-fA-F]{4})$/;
  5249. function isMACAddress(str, options) {
  5250. (0, _assertString.default)(str);
  5251. /**
  5252. * @deprecated `no_colons` TODO: remove it in the next major
  5253. */
  5254. if (options && (options.no_colons || options.no_separators)) {
  5255. return macAddressNoSeparators.test(str);
  5256. }
  5257. return macAddress.test(str) || macAddressWithDots.test(str);
  5258. }
  5259. module.exports = exports.default;
  5260. module.exports.default = exports.default;
  5261. },{"./util/assertString":99}],63:[function(require,module,exports){
  5262. "use strict";
  5263. Object.defineProperty(exports, "__esModule", {
  5264. value: true
  5265. });
  5266. exports.default = isMD5;
  5267. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5268. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5269. var md5 = /^[a-f0-9]{32}$/;
  5270. function isMD5(str) {
  5271. (0, _assertString.default)(str);
  5272. return md5.test(str);
  5273. }
  5274. module.exports = exports.default;
  5275. module.exports.default = exports.default;
  5276. },{"./util/assertString":99}],64:[function(require,module,exports){
  5277. "use strict";
  5278. Object.defineProperty(exports, "__esModule", {
  5279. value: true
  5280. });
  5281. exports.default = isMagnetURI;
  5282. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5283. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5284. var magnetURI = /^magnet:\?xt(?:\.1)?=urn:(?:aich|bitprint|btih|ed2k|ed2khash|kzhash|md5|sha1|tree:tiger):[a-z0-9]{32}(?:[a-z0-9]{8})?($|&)/i;
  5285. function isMagnetURI(url) {
  5286. (0, _assertString.default)(url);
  5287. return magnetURI.test(url.trim());
  5288. }
  5289. module.exports = exports.default;
  5290. module.exports.default = exports.default;
  5291. },{"./util/assertString":99}],65:[function(require,module,exports){
  5292. "use strict";
  5293. Object.defineProperty(exports, "__esModule", {
  5294. value: true
  5295. });
  5296. exports.default = isMimeType;
  5297. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5298. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5299. /*
  5300. Checks if the provided string matches to a correct Media type format (MIME type)
  5301. This function only checks is the string format follows the
  5302. etablished rules by the according RFC specifications.
  5303. This function supports 'charset' in textual media types
  5304. (https://tools.ietf.org/html/rfc6657).
  5305. This function does not check against all the media types listed
  5306. by the IANA (https://www.iana.org/assignments/media-types/media-types.xhtml)
  5307. because of lightness purposes : it would require to include
  5308. all these MIME types in this librairy, which would weigh it
  5309. significantly. This kind of effort maybe is not worth for the use that
  5310. this function has in this entire librairy.
  5311. More informations in the RFC specifications :
  5312. - https://tools.ietf.org/html/rfc2045
  5313. - https://tools.ietf.org/html/rfc2046
  5314. - https://tools.ietf.org/html/rfc7231#section-3.1.1.1
  5315. - https://tools.ietf.org/html/rfc7231#section-3.1.1.5
  5316. */
  5317. // Match simple MIME types
  5318. // NB :
  5319. // Subtype length must not exceed 100 characters.
  5320. // This rule does not comply to the RFC specs (what is the max length ?).
  5321. var mimeTypeSimple = /^(application|audio|font|image|message|model|multipart|text|video)\/[a-zA-Z0-9\.\-\+]{1,100}$/i; // eslint-disable-line max-len
  5322. // Handle "charset" in "text/*"
  5323. 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
  5324. // Handle "boundary" in "multipart/*"
  5325. 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
  5326. function isMimeType(str) {
  5327. (0, _assertString.default)(str);
  5328. return mimeTypeSimple.test(str) || mimeTypeText.test(str) || mimeTypeMultipart.test(str);
  5329. }
  5330. module.exports = exports.default;
  5331. module.exports.default = exports.default;
  5332. },{"./util/assertString":99}],66:[function(require,module,exports){
  5333. "use strict";
  5334. Object.defineProperty(exports, "__esModule", {
  5335. value: true
  5336. });
  5337. exports.default = isMobilePhone;
  5338. exports.locales = void 0;
  5339. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5340. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5341. /* eslint-disable max-len */
  5342. var phones = {
  5343. 'am-AM': /^(\+?374|0)((10|[9|7][0-9])\d{6}$|[2-4]\d{7}$)/,
  5344. 'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/,
  5345. 'ar-BH': /^(\+?973)?(3|6)\d{7}$/,
  5346. 'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/,
  5347. 'ar-LB': /^(\+?961)?((3|81)\d{6}|7\d{7})$/,
  5348. 'ar-EG': /^((\+?20)|0)?1[0125]\d{8}$/,
  5349. 'ar-IQ': /^(\+?964|0)?7[0-9]\d{8}$/,
  5350. 'ar-JO': /^(\+?962|0)?7[789]\d{7}$/,
  5351. 'ar-KW': /^(\+?965)[569]\d{7}$/,
  5352. 'ar-LY': /^((\+?218)|0)?(9[1-6]\d{7}|[1-8]\d{7,9})$/,
  5353. 'ar-MA': /^(?:(?:\+|00)212|0)[5-7]\d{8}$/,
  5354. 'ar-OM': /^((\+|00)968)?(9[1-9])\d{6}$/,
  5355. 'ar-PS': /^(\+?970|0)5[6|9](\d{7})$/,
  5356. 'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/,
  5357. 'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/,
  5358. 'ar-TN': /^(\+?216)?[2459]\d{7}$/,
  5359. 'az-AZ': /^(\+994|0)(5[015]|7[07]|99)\d{7}$/,
  5360. 'bs-BA': /^((((\+|00)3876)|06))((([0-3]|[5-6])\d{6})|(4\d{7}))$/,
  5361. 'be-BY': /^(\+?375)?(24|25|29|33|44)\d{7}$/,
  5362. 'bg-BG': /^(\+?359|0)?8[789]\d{7}$/,
  5363. 'bn-BD': /^(\+?880|0)1[13456789][0-9]{8}$/,
  5364. 'ca-AD': /^(\+376)?[346]\d{5}$/,
  5365. 'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
  5366. 'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,
  5367. 'de-DE': /^((\+49|0)[1|3])([0|5][0-45-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7,9}$/,
  5368. 'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/,
  5369. 'de-CH': /^(\+41|0)([1-9])\d{1,9}$/,
  5370. 'de-LU': /^(\+352)?((6\d1)\d{6})$/,
  5371. 'dv-MV': /^(\+?960)?(7[2-9]|91|9[3-9])\d{7}$/,
  5372. 'el-GR': /^(\+?30|0)?(69\d{8})$/,
  5373. 'en-AU': /^(\+?61|0)4\d{8}$/,
  5374. 'en-BM': /^(\+?1)?441(((3|7)\d{6}$)|(5[0-3][0-9]\d{4}$)|(59\d{5}))/,
  5375. 'en-GB': /^(\+?44|0)7\d{9}$/,
  5376. 'en-GG': /^(\+?44|0)1481\d{6}$/,
  5377. 'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28|55|59)\d{7}$/,
  5378. 'en-GY': /^(\+592|0)6\d{6}$/,
  5379. 'en-HK': /^(\+?852[-\s]?)?[456789]\d{3}[-\s]?\d{4}$/,
  5380. 'en-MO': /^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/,
  5381. 'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
  5382. 'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
  5383. 'en-KE': /^(\+?254|0)(7|1)\d{8}$/,
  5384. 'en-KI': /^((\+686|686)?)?( )?((6|7)(2|3|8)[0-9]{6})$/,
  5385. 'en-MT': /^(\+?356|0)?(99|79|77|21|27|22|25)[0-9]{6}$/,
  5386. 'en-MU': /^(\+?230|0)?\d{8}$/,
  5387. 'en-NA': /^(\+?264|0)(6|8)\d{7}$/,
  5388. 'en-NG': /^(\+?234|0)?[789]\d{9}$/,
  5389. 'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
  5390. 'en-PK': /^((00|\+)?92|0)3[0-6]\d{8}$/,
  5391. 'en-PH': /^(09|\+639)\d{9}$/,
  5392. 'en-RW': /^(\+?250|0)?[7]\d{8}$/,
  5393. 'en-SG': /^(\+65)?[3689]\d{7}$/,
  5394. 'en-SL': /^(\+?232|0)\d{8}$/,
  5395. 'en-TZ': /^(\+?255|0)?[67]\d{8}$/,
  5396. 'en-UG': /^(\+?256|0)?[7]\d{8}$/,
  5397. 'en-US': /^((\+1|1)?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/,
  5398. 'en-ZA': /^(\+?27|0)\d{9}$/,
  5399. 'en-ZM': /^(\+?26)?09[567]\d{7}$/,
  5400. 'en-ZW': /^(\+263)[0-9]{9}$/,
  5401. 'en-BW': /^(\+?267)?(7[1-8]{1})\d{6}$/,
  5402. 'es-AR': /^\+?549(11|[2368]\d)\d{8}$/,
  5403. 'es-BO': /^(\+?591)?(6|7)\d{7}$/,
  5404. 'es-CO': /^(\+?57)?3(0(0|1|2|4|5)|1\d|2[0-4]|5(0|1))\d{7}$/,
  5405. 'es-CL': /^(\+?56|0)[2-9]\d{1}\d{7}$/,
  5406. 'es-CR': /^(\+506)?[2-8]\d{7}$/,
  5407. 'es-CU': /^(\+53|0053)?5\d{7}/,
  5408. 'es-DO': /^(\+?1)?8[024]9\d{7}$/,
  5409. 'es-HN': /^(\+?504)?[9|8]\d{7}$/,
  5410. 'es-EC': /^(\+?593|0)([2-7]|9[2-9])\d{7}$/,
  5411. 'es-ES': /^(\+?34)?[6|7]\d{8}$/,
  5412. 'es-PE': /^(\+?51)?9\d{8}$/,
  5413. 'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
  5414. 'es-PA': /^(\+?507)\d{7,8}$/,
  5415. 'es-PY': /^(\+?595|0)9[9876]\d{7}$/,
  5416. 'es-SV': /^(\+?503)?[67]\d{7}$/,
  5417. 'es-UY': /^(\+598|0)9[1-9][\d]{6}$/,
  5418. 'es-VE': /^(\+?58)?(2|4)\d{9}$/,
  5419. 'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/,
  5420. 'fa-IR': /^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/,
  5421. 'fi-FI': /^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/,
  5422. 'fj-FJ': /^(\+?679)?\s?\d{3}\s?\d{4}$/,
  5423. 'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
  5424. 'fr-BF': /^(\+226|0)[67]\d{7}$/,
  5425. 'fr-CM': /^(\+?237)6[0-9]{8}$/,
  5426. 'fr-FR': /^(\+?33|0)[67]\d{8}$/,
  5427. 'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/,
  5428. 'fr-GP': /^(\+?590|0|00590)[67]\d{8}$/,
  5429. 'fr-MQ': /^(\+?596|0|00596)[67]\d{8}$/,
  5430. 'fr-PF': /^(\+?689)?8[789]\d{6}$/,
  5431. 'fr-RE': /^(\+?262|0|00262)[67]\d{8}$/,
  5432. 'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/,
  5433. 'hu-HU': /^(\+?36|06)(20|30|31|50|70)\d{7}$/,
  5434. 'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/,
  5435. 'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/,
  5436. 'it-SM': /^((\+378)|(0549)|(\+390549)|(\+3780549))?6\d{5,9}$/,
  5437. 'ja-JP': /^(\+81[ \-]?(\(0\))?|0)[6789]0[ \-]?\d{4}[ \-]?\d{4}$/,
  5438. 'ka-GE': /^(\+?995)?(5|79)\d{7}$/,
  5439. 'kk-KZ': /^(\+?7|8)?7\d{9}$/,
  5440. 'kl-GL': /^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
  5441. 'ko-KR': /^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,
  5442. 'lt-LT': /^(\+370|8)\d{8}$/,
  5443. 'lv-LV': /^(\+?371)2\d{7}$/,
  5444. 'ms-MY': /^(\+?6?01){1}(([0145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/,
  5445. 'mz-MZ': /^(\+?258)?8[234567]\d{7}$/,
  5446. 'nb-NO': /^(\+?47)?[49]\d{7}$/,
  5447. 'ne-NP': /^(\+?977)?9[78]\d{8}$/,
  5448. 'nl-BE': /^(\+?32|0)4\d{8}$/,
  5449. 'nl-NL': /^(((\+|00)?31\(0\))|((\+|00)?31)|0)6{1}\d{8}$/,
  5450. 'nn-NO': /^(\+?47)?[49]\d{7}$/,
  5451. 'pl-PL': /^(\+?48)? ?[5-8]\d ?\d{3} ?\d{2} ?\d{2}$/,
  5452. 'pt-BR': /^((\+?55\ ?[1-9]{2}\ ?)|(\+?55\ ?\([1-9]{2}\)\ ?)|(0[1-9]{2}\ ?)|(\([1-9]{2}\)\ ?)|([1-9]{2}\ ?))((\d{4}\-?\d{4})|(9[2-9]{1}\d{3}\-?\d{4}))$/,
  5453. 'pt-PT': /^(\+?351)?9[1236]\d{7}$/,
  5454. 'pt-AO': /^(\+244)\d{9}$/,
  5455. 'ro-RO': /^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/,
  5456. 'ru-RU': /^(\+?7|8)?9\d{9}$/,
  5457. 'si-LK': /^(?:0|94|\+94)?(7(0|1|2|4|5|6|7|8)( |-)?)\d{7}$/,
  5458. 'sl-SI': /^(\+386\s?|0)(\d{1}\s?\d{3}\s?\d{2}\s?\d{2}|\d{2}\s?\d{3}\s?\d{3})$/,
  5459. 'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
  5460. 'sq-AL': /^(\+355|0)6[789]\d{6}$/,
  5461. 'sr-RS': /^(\+3816|06)[- \d]{5,9}$/,
  5462. 'sv-SE': /^(\+?46|0)[\s\-]?7[\s\-]?[02369]([\s\-]?\d){7}$/,
  5463. 'tg-TJ': /^(\+?992)?[5][5]\d{7}$/,
  5464. 'th-TH': /^(\+66|66|0)\d{9}$/,
  5465. 'tr-TR': /^(\+?90|0)?5\d{9}$/,
  5466. 'tk-TM': /^(\+993|993|8)\d{8}$/,
  5467. 'uk-UA': /^(\+?38|8)?0\d{9}$/,
  5468. 'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/,
  5469. 'vi-VN': /^((\+?84)|0)((3([2-9]))|(5([25689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/,
  5470. 'zh-CN': /^((\+|00)86)?(1[3-9]|9[28])\d{9}$/,
  5471. 'zh-TW': /^(\+?886\-?|0)?9\d{8}$/,
  5472. 'dz-BT': /^(\+?975|0)?(17|16|77|02)\d{6}$/
  5473. };
  5474. /* eslint-enable max-len */
  5475. // aliases
  5476. phones['en-CA'] = phones['en-US'];
  5477. phones['fr-CA'] = phones['en-CA'];
  5478. phones['fr-BE'] = phones['nl-BE'];
  5479. phones['zh-HK'] = phones['en-HK'];
  5480. phones['zh-MO'] = phones['en-MO'];
  5481. phones['ga-IE'] = phones['en-IE'];
  5482. phones['fr-CH'] = phones['de-CH'];
  5483. phones['it-CH'] = phones['fr-CH'];
  5484. function isMobilePhone(str, locale, options) {
  5485. (0, _assertString.default)(str);
  5486. if (options && options.strictMode && !str.startsWith('+')) {
  5487. return false;
  5488. }
  5489. if (Array.isArray(locale)) {
  5490. return locale.some(function (key) {
  5491. // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
  5492. // istanbul ignore else
  5493. if (phones.hasOwnProperty(key)) {
  5494. var phone = phones[key];
  5495. if (phone.test(str)) {
  5496. return true;
  5497. }
  5498. }
  5499. return false;
  5500. });
  5501. } else if (locale in phones) {
  5502. return phones[locale].test(str); // alias falsey locale as 'any'
  5503. } else if (!locale || locale === 'any') {
  5504. for (var key in phones) {
  5505. // istanbul ignore else
  5506. if (phones.hasOwnProperty(key)) {
  5507. var phone = phones[key];
  5508. if (phone.test(str)) {
  5509. return true;
  5510. }
  5511. }
  5512. }
  5513. return false;
  5514. }
  5515. throw new Error("Invalid locale '".concat(locale, "'"));
  5516. }
  5517. var locales = Object.keys(phones);
  5518. exports.locales = locales;
  5519. },{"./util/assertString":99}],67:[function(require,module,exports){
  5520. "use strict";
  5521. Object.defineProperty(exports, "__esModule", {
  5522. value: true
  5523. });
  5524. exports.default = isMongoId;
  5525. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5526. var _isHexadecimal = _interopRequireDefault(require("./isHexadecimal"));
  5527. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5528. function isMongoId(str) {
  5529. (0, _assertString.default)(str);
  5530. return (0, _isHexadecimal.default)(str) && str.length === 24;
  5531. }
  5532. module.exports = exports.default;
  5533. module.exports.default = exports.default;
  5534. },{"./isHexadecimal":39,"./util/assertString":99}],68:[function(require,module,exports){
  5535. "use strict";
  5536. Object.defineProperty(exports, "__esModule", {
  5537. value: true
  5538. });
  5539. exports.default = isMultibyte;
  5540. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5541. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5542. /* eslint-disable no-control-regex */
  5543. var multibyte = /[^\x00-\x7F]/;
  5544. /* eslint-enable no-control-regex */
  5545. function isMultibyte(str) {
  5546. (0, _assertString.default)(str);
  5547. return multibyte.test(str);
  5548. }
  5549. module.exports = exports.default;
  5550. module.exports.default = exports.default;
  5551. },{"./util/assertString":99}],69:[function(require,module,exports){
  5552. "use strict";
  5553. Object.defineProperty(exports, "__esModule", {
  5554. value: true
  5555. });
  5556. exports.default = isNumeric;
  5557. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5558. var _alpha = require("./alpha");
  5559. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5560. var numericNoSymbols = /^[0-9]+$/;
  5561. function isNumeric(str, options) {
  5562. (0, _assertString.default)(str);
  5563. if (options && options.no_symbols) {
  5564. return numericNoSymbols.test(str);
  5565. }
  5566. return new RegExp("^[+-]?([0-9]*[".concat((options || {}).locale ? _alpha.decimal[options.locale] : '.', "])?[0-9]+$")).test(str);
  5567. }
  5568. module.exports = exports.default;
  5569. module.exports.default = exports.default;
  5570. },{"./alpha":5,"./util/assertString":99}],70:[function(require,module,exports){
  5571. "use strict";
  5572. Object.defineProperty(exports, "__esModule", {
  5573. value: true
  5574. });
  5575. exports.default = isOctal;
  5576. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5577. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5578. var octal = /^(0o)?[0-7]+$/i;
  5579. function isOctal(str) {
  5580. (0, _assertString.default)(str);
  5581. return octal.test(str);
  5582. }
  5583. module.exports = exports.default;
  5584. module.exports.default = exports.default;
  5585. },{"./util/assertString":99}],71:[function(require,module,exports){
  5586. "use strict";
  5587. Object.defineProperty(exports, "__esModule", {
  5588. value: true
  5589. });
  5590. exports.default = isPassportNumber;
  5591. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5592. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5593. /**
  5594. * Reference:
  5595. * https://en.wikipedia.org/ -- Wikipedia
  5596. * https://docs.microsoft.com/en-us/microsoft-365/compliance/eu-passport-number -- EU Passport Number
  5597. * https://countrycode.org/ -- Country Codes
  5598. */
  5599. var passportRegexByCountryCode = {
  5600. AM: /^[A-Z]{2}\d{7}$/,
  5601. // ARMENIA
  5602. AR: /^[A-Z]{3}\d{6}$/,
  5603. // ARGENTINA
  5604. AT: /^[A-Z]\d{7}$/,
  5605. // AUSTRIA
  5606. AU: /^[A-Z]\d{7}$/,
  5607. // AUSTRALIA
  5608. BE: /^[A-Z]{2}\d{6}$/,
  5609. // BELGIUM
  5610. BG: /^\d{9}$/,
  5611. // BULGARIA
  5612. BR: /^[A-Z]{2}\d{6}$/,
  5613. // BRAZIL
  5614. BY: /^[A-Z]{2}\d{7}$/,
  5615. // BELARUS
  5616. CA: /^[A-Z]{2}\d{6}$/,
  5617. // CANADA
  5618. CH: /^[A-Z]\d{7}$/,
  5619. // SWITZERLAND
  5620. CN: /^G\d{8}$|^E(?![IO])[A-Z0-9]\d{7}$/,
  5621. // CHINA [G=Ordinary, E=Electronic] followed by 8-digits, or E followed by any UPPERCASE letter (except I and O) followed by 7 digits
  5622. CY: /^[A-Z](\d{6}|\d{8})$/,
  5623. // CYPRUS
  5624. CZ: /^\d{8}$/,
  5625. // CZECH REPUBLIC
  5626. DE: /^[CFGHJKLMNPRTVWXYZ0-9]{9}$/,
  5627. // GERMANY
  5628. DK: /^\d{9}$/,
  5629. // DENMARK
  5630. DZ: /^\d{9}$/,
  5631. // ALGERIA
  5632. EE: /^([A-Z]\d{7}|[A-Z]{2}\d{7})$/,
  5633. // ESTONIA (K followed by 7-digits), e-passports have 2 UPPERCASE followed by 7 digits
  5634. ES: /^[A-Z0-9]{2}([A-Z0-9]?)\d{6}$/,
  5635. // SPAIN
  5636. FI: /^[A-Z]{2}\d{7}$/,
  5637. // FINLAND
  5638. FR: /^\d{2}[A-Z]{2}\d{5}$/,
  5639. // FRANCE
  5640. GB: /^\d{9}$/,
  5641. // UNITED KINGDOM
  5642. GR: /^[A-Z]{2}\d{7}$/,
  5643. // GREECE
  5644. HR: /^\d{9}$/,
  5645. // CROATIA
  5646. HU: /^[A-Z]{2}(\d{6}|\d{7})$/,
  5647. // HUNGARY
  5648. IE: /^[A-Z0-9]{2}\d{7}$/,
  5649. // IRELAND
  5650. IN: /^[A-Z]{1}-?\d{7}$/,
  5651. // INDIA
  5652. ID: /^[A-C]\d{7}$/,
  5653. // INDONESIA
  5654. IR: /^[A-Z]\d{8}$/,
  5655. // IRAN
  5656. IS: /^(A)\d{7}$/,
  5657. // ICELAND
  5658. IT: /^[A-Z0-9]{2}\d{7}$/,
  5659. // ITALY
  5660. JP: /^[A-Z]{2}\d{7}$/,
  5661. // JAPAN
  5662. KR: /^[MS]\d{8}$/,
  5663. // SOUTH KOREA, REPUBLIC OF KOREA, [S=PS Passports, M=PM Passports]
  5664. LT: /^[A-Z0-9]{8}$/,
  5665. // LITHUANIA
  5666. LU: /^[A-Z0-9]{8}$/,
  5667. // LUXEMBURG
  5668. LV: /^[A-Z0-9]{2}\d{7}$/,
  5669. // LATVIA
  5670. LY: /^[A-Z0-9]{8}$/,
  5671. // LIBYA
  5672. MT: /^\d{7}$/,
  5673. // MALTA
  5674. MZ: /^([A-Z]{2}\d{7})|(\d{2}[A-Z]{2}\d{5})$/,
  5675. // MOZAMBIQUE
  5676. MY: /^[AHK]\d{8}$/,
  5677. // MALAYSIA
  5678. NL: /^[A-Z]{2}[A-Z0-9]{6}\d$/,
  5679. // NETHERLANDS
  5680. PL: /^[A-Z]{2}\d{7}$/,
  5681. // POLAND
  5682. PT: /^[A-Z]\d{6}$/,
  5683. // PORTUGAL
  5684. RO: /^\d{8,9}$/,
  5685. // ROMANIA
  5686. RU: /^\d{9}$/,
  5687. // RUSSIAN FEDERATION
  5688. SE: /^\d{8}$/,
  5689. // SWEDEN
  5690. SL: /^(P)[A-Z]\d{7}$/,
  5691. // SLOVANIA
  5692. SK: /^[0-9A-Z]\d{7}$/,
  5693. // SLOVAKIA
  5694. TR: /^[A-Z]\d{8}$/,
  5695. // TURKEY
  5696. UA: /^[A-Z]{2}\d{6}$/,
  5697. // UKRAINE
  5698. US: /^\d{9}$/ // UNITED STATES
  5699. };
  5700. /**
  5701. * Check if str is a valid passport number
  5702. * relative to provided ISO Country Code.
  5703. *
  5704. * @param {string} str
  5705. * @param {string} countryCode
  5706. * @return {boolean}
  5707. */
  5708. function isPassportNumber(str, countryCode) {
  5709. (0, _assertString.default)(str);
  5710. /** Remove All Whitespaces, Convert to UPPERCASE */
  5711. var normalizedStr = str.replace(/\s/g, '').toUpperCase();
  5712. return countryCode.toUpperCase() in passportRegexByCountryCode && passportRegexByCountryCode[countryCode].test(normalizedStr);
  5713. }
  5714. module.exports = exports.default;
  5715. module.exports.default = exports.default;
  5716. },{"./util/assertString":99}],72:[function(require,module,exports){
  5717. "use strict";
  5718. Object.defineProperty(exports, "__esModule", {
  5719. value: true
  5720. });
  5721. exports.default = isPort;
  5722. var _isInt = _interopRequireDefault(require("./isInt"));
  5723. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5724. function isPort(str) {
  5725. return (0, _isInt.default)(str, {
  5726. min: 0,
  5727. max: 65535
  5728. });
  5729. }
  5730. module.exports = exports.default;
  5731. module.exports.default = exports.default;
  5732. },{"./isInt":54}],73:[function(require,module,exports){
  5733. "use strict";
  5734. Object.defineProperty(exports, "__esModule", {
  5735. value: true
  5736. });
  5737. exports.default = isPostalCode;
  5738. exports.locales = void 0;
  5739. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5740. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5741. // common patterns
  5742. var threeDigit = /^\d{3}$/;
  5743. var fourDigit = /^\d{4}$/;
  5744. var fiveDigit = /^\d{5}$/;
  5745. var sixDigit = /^\d{6}$/;
  5746. var patterns = {
  5747. AD: /^AD\d{3}$/,
  5748. AT: fourDigit,
  5749. AU: fourDigit,
  5750. AZ: /^AZ\d{4}$/,
  5751. BE: fourDigit,
  5752. BG: fourDigit,
  5753. BR: /^\d{5}-\d{3}$/,
  5754. BY: /2[1-4]{1}\d{4}$/,
  5755. CA: /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,
  5756. CH: fourDigit,
  5757. 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}$/,
  5758. CZ: /^\d{3}\s?\d{2}$/,
  5759. DE: fiveDigit,
  5760. DK: fourDigit,
  5761. DO: fiveDigit,
  5762. DZ: fiveDigit,
  5763. EE: fiveDigit,
  5764. ES: /^(5[0-2]{1}|[0-4]{1}\d{1})\d{3}$/,
  5765. FI: fiveDigit,
  5766. FR: /^\d{2}\s?\d{3}$/,
  5767. GB: /^(gir\s?0aa|[a-z]{1,2}\d[\da-z]?\s?(\d[a-z]{2})?)$/i,
  5768. GR: /^\d{3}\s?\d{2}$/,
  5769. HR: /^([1-5]\d{4}$)/,
  5770. HT: /^HT\d{4}$/,
  5771. HU: fourDigit,
  5772. ID: fiveDigit,
  5773. IE: /^(?!.*(?:o))[A-Za-z]\d[\dw]\s\w{4}$/i,
  5774. IL: /^(\d{5}|\d{7})$/,
  5775. IN: /^((?!10|29|35|54|55|65|66|86|87|88|89)[1-9][0-9]{5})$/,
  5776. IR: /\b(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}\b/,
  5777. IS: threeDigit,
  5778. IT: fiveDigit,
  5779. JP: /^\d{3}\-\d{4}$/,
  5780. KE: fiveDigit,
  5781. KR: /^(\d{5}|\d{6})$/,
  5782. LI: /^(948[5-9]|949[0-7])$/,
  5783. LT: /^LT\-\d{5}$/,
  5784. LU: fourDigit,
  5785. LV: /^LV\-\d{4}$/,
  5786. LK: fiveDigit,
  5787. MX: fiveDigit,
  5788. MT: /^[A-Za-z]{3}\s{0,1}\d{4}$/,
  5789. MY: fiveDigit,
  5790. NL: /^\d{4}\s?[a-z]{2}$/i,
  5791. NO: fourDigit,
  5792. NP: /^(10|21|22|32|33|34|44|45|56|57)\d{3}$|^(977)$/i,
  5793. NZ: fourDigit,
  5794. PL: /^\d{2}\-\d{3}$/,
  5795. PR: /^00[679]\d{2}([ -]\d{4})?$/,
  5796. PT: /^\d{4}\-\d{3}?$/,
  5797. RO: sixDigit,
  5798. RU: sixDigit,
  5799. SA: fiveDigit,
  5800. SE: /^[1-9]\d{2}\s?\d{2}$/,
  5801. SG: sixDigit,
  5802. SI: fourDigit,
  5803. SK: /^\d{3}\s?\d{2}$/,
  5804. TH: fiveDigit,
  5805. TN: fourDigit,
  5806. TW: /^\d{3}(\d{2})?$/,
  5807. UA: fiveDigit,
  5808. US: /^\d{5}(-\d{4})?$/,
  5809. ZA: fourDigit,
  5810. ZM: fiveDigit
  5811. };
  5812. var locales = Object.keys(patterns);
  5813. exports.locales = locales;
  5814. function isPostalCode(str, locale) {
  5815. (0, _assertString.default)(str);
  5816. if (locale in patterns) {
  5817. return patterns[locale].test(str);
  5818. } else if (locale === 'any') {
  5819. for (var key in patterns) {
  5820. // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
  5821. // istanbul ignore else
  5822. if (patterns.hasOwnProperty(key)) {
  5823. var pattern = patterns[key];
  5824. if (pattern.test(str)) {
  5825. return true;
  5826. }
  5827. }
  5828. }
  5829. return false;
  5830. }
  5831. throw new Error("Invalid locale '".concat(locale, "'"));
  5832. }
  5833. },{"./util/assertString":99}],74:[function(require,module,exports){
  5834. "use strict";
  5835. Object.defineProperty(exports, "__esModule", {
  5836. value: true
  5837. });
  5838. exports.default = isRFC3339;
  5839. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5840. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5841. /* Based on https://tools.ietf.org/html/rfc3339#section-5.6 */
  5842. var dateFullYear = /[0-9]{4}/;
  5843. var dateMonth = /(0[1-9]|1[0-2])/;
  5844. var dateMDay = /([12]\d|0[1-9]|3[01])/;
  5845. var timeHour = /([01][0-9]|2[0-3])/;
  5846. var timeMinute = /[0-5][0-9]/;
  5847. var timeSecond = /([0-5][0-9]|60)/;
  5848. var timeSecFrac = /(\.[0-9]+)?/;
  5849. var timeNumOffset = new RegExp("[-+]".concat(timeHour.source, ":").concat(timeMinute.source));
  5850. var timeOffset = new RegExp("([zZ]|".concat(timeNumOffset.source, ")"));
  5851. var partialTime = new RegExp("".concat(timeHour.source, ":").concat(timeMinute.source, ":").concat(timeSecond.source).concat(timeSecFrac.source));
  5852. var fullDate = new RegExp("".concat(dateFullYear.source, "-").concat(dateMonth.source, "-").concat(dateMDay.source));
  5853. var fullTime = new RegExp("".concat(partialTime.source).concat(timeOffset.source));
  5854. var rfc3339 = new RegExp("^".concat(fullDate.source, "[ tT]").concat(fullTime.source, "$"));
  5855. function isRFC3339(str) {
  5856. (0, _assertString.default)(str);
  5857. return rfc3339.test(str);
  5858. }
  5859. module.exports = exports.default;
  5860. module.exports.default = exports.default;
  5861. },{"./util/assertString":99}],75:[function(require,module,exports){
  5862. "use strict";
  5863. Object.defineProperty(exports, "__esModule", {
  5864. value: true
  5865. });
  5866. exports.default = isRgbColor;
  5867. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5868. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5869. 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])\)$/;
  5870. var rgbaColor = /^rgba\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)$/;
  5871. var rgbColorPercent = /^rgb\((([0-9]%|[1-9][0-9]%|100%),){2}([0-9]%|[1-9][0-9]%|100%)\)/;
  5872. var rgbaColorPercent = /^rgba\((([0-9]%|[1-9][0-9]%|100%),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)/;
  5873. function isRgbColor(str) {
  5874. var includePercentValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5875. (0, _assertString.default)(str);
  5876. if (!includePercentValues) {
  5877. return rgbColor.test(str) || rgbaColor.test(str);
  5878. }
  5879. return rgbColor.test(str) || rgbaColor.test(str) || rgbColorPercent.test(str) || rgbaColorPercent.test(str);
  5880. }
  5881. module.exports = exports.default;
  5882. module.exports.default = exports.default;
  5883. },{"./util/assertString":99}],76:[function(require,module,exports){
  5884. "use strict";
  5885. Object.defineProperty(exports, "__esModule", {
  5886. value: true
  5887. });
  5888. exports.default = isSemVer;
  5889. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5890. var _multilineRegex = _interopRequireDefault(require("./util/multilineRegex"));
  5891. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5892. /**
  5893. * Regular Expression to match
  5894. * semantic versioning (SemVer)
  5895. * built from multi-line, multi-parts regexp
  5896. * Reference: https://semver.org/
  5897. */
  5898. var semanticVersioningRegex = (0, _multilineRegex.default)(['^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)', '(?:-((?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*))*))', '?(?:\\+([0-9a-z-]+(?:\\.[0-9a-z-]+)*))?$'], 'i');
  5899. function isSemVer(str) {
  5900. (0, _assertString.default)(str);
  5901. return semanticVersioningRegex.test(str);
  5902. }
  5903. module.exports = exports.default;
  5904. module.exports.default = exports.default;
  5905. },{"./util/assertString":99,"./util/multilineRegex":102}],77:[function(require,module,exports){
  5906. "use strict";
  5907. Object.defineProperty(exports, "__esModule", {
  5908. value: true
  5909. });
  5910. exports.default = isSlug;
  5911. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5912. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5913. var charsetRegex = /^[^\s-_](?!.*?[-_]{2,})[a-z0-9-\\][^\s]*[^-_\s]$/;
  5914. function isSlug(str) {
  5915. (0, _assertString.default)(str);
  5916. return charsetRegex.test(str);
  5917. }
  5918. module.exports = exports.default;
  5919. module.exports.default = exports.default;
  5920. },{"./util/assertString":99}],78:[function(require,module,exports){
  5921. "use strict";
  5922. Object.defineProperty(exports, "__esModule", {
  5923. value: true
  5924. });
  5925. exports.default = isStrongPassword;
  5926. var _merge = _interopRequireDefault(require("./util/merge"));
  5927. var _assertString = _interopRequireDefault(require("./util/assertString"));
  5928. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5929. var upperCaseRegex = /^[A-Z]$/;
  5930. var lowerCaseRegex = /^[a-z]$/;
  5931. var numberRegex = /^[0-9]$/;
  5932. var symbolRegex = /^[-#!$@%^&*()_+|~=`{}\[\]:";'<>?,.\/ ]$/;
  5933. var defaultOptions = {
  5934. minLength: 8,
  5935. minLowercase: 1,
  5936. minUppercase: 1,
  5937. minNumbers: 1,
  5938. minSymbols: 1,
  5939. returnScore: false,
  5940. pointsPerUnique: 1,
  5941. pointsPerRepeat: 0.5,
  5942. pointsForContainingLower: 10,
  5943. pointsForContainingUpper: 10,
  5944. pointsForContainingNumber: 10,
  5945. pointsForContainingSymbol: 10
  5946. };
  5947. /* Counts number of occurrences of each char in a string
  5948. * could be moved to util/ ?
  5949. */
  5950. function countChars(str) {
  5951. var result = {};
  5952. Array.from(str).forEach(function (char) {
  5953. var curVal = result[char];
  5954. if (curVal) {
  5955. result[char] += 1;
  5956. } else {
  5957. result[char] = 1;
  5958. }
  5959. });
  5960. return result;
  5961. }
  5962. /* Return information about a password */
  5963. function analyzePassword(password) {
  5964. var charMap = countChars(password);
  5965. var analysis = {
  5966. length: password.length,
  5967. uniqueChars: Object.keys(charMap).length,
  5968. uppercaseCount: 0,
  5969. lowercaseCount: 0,
  5970. numberCount: 0,
  5971. symbolCount: 0
  5972. };
  5973. Object.keys(charMap).forEach(function (char) {
  5974. /* istanbul ignore else */
  5975. if (upperCaseRegex.test(char)) {
  5976. analysis.uppercaseCount += charMap[char];
  5977. } else if (lowerCaseRegex.test(char)) {
  5978. analysis.lowercaseCount += charMap[char];
  5979. } else if (numberRegex.test(char)) {
  5980. analysis.numberCount += charMap[char];
  5981. } else if (symbolRegex.test(char)) {
  5982. analysis.symbolCount += charMap[char];
  5983. }
  5984. });
  5985. return analysis;
  5986. }
  5987. function scorePassword(analysis, scoringOptions) {
  5988. var points = 0;
  5989. points += analysis.uniqueChars * scoringOptions.pointsPerUnique;
  5990. points += (analysis.length - analysis.uniqueChars) * scoringOptions.pointsPerRepeat;
  5991. if (analysis.lowercaseCount > 0) {
  5992. points += scoringOptions.pointsForContainingLower;
  5993. }
  5994. if (analysis.uppercaseCount > 0) {
  5995. points += scoringOptions.pointsForContainingUpper;
  5996. }
  5997. if (analysis.numberCount > 0) {
  5998. points += scoringOptions.pointsForContainingNumber;
  5999. }
  6000. if (analysis.symbolCount > 0) {
  6001. points += scoringOptions.pointsForContainingSymbol;
  6002. }
  6003. return points;
  6004. }
  6005. function isStrongPassword(str) {
  6006. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6007. (0, _assertString.default)(str);
  6008. var analysis = analyzePassword(str);
  6009. options = (0, _merge.default)(options || {}, defaultOptions);
  6010. if (options.returnScore) {
  6011. return scorePassword(analysis, options);
  6012. }
  6013. return analysis.length >= options.minLength && analysis.lowercaseCount >= options.minLowercase && analysis.uppercaseCount >= options.minUppercase && analysis.numberCount >= options.minNumbers && analysis.symbolCount >= options.minSymbols;
  6014. }
  6015. module.exports = exports.default;
  6016. module.exports.default = exports.default;
  6017. },{"./util/assertString":99,"./util/merge":101}],79:[function(require,module,exports){
  6018. "use strict";
  6019. Object.defineProperty(exports, "__esModule", {
  6020. value: true
  6021. });
  6022. exports.default = isSurrogatePair;
  6023. var _assertString = _interopRequireDefault(require("./util/assertString"));
  6024. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6025. var surrogatePair = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
  6026. function isSurrogatePair(str) {
  6027. (0, _assertString.default)(str);
  6028. return surrogatePair.test(str);
  6029. }
  6030. module.exports = exports.default;
  6031. module.exports.default = exports.default;
  6032. },{"./util/assertString":99}],80:[function(require,module,exports){
  6033. "use strict";
  6034. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  6035. Object.defineProperty(exports, "__esModule", {
  6036. value: true
  6037. });
  6038. exports.default = isTaxID;
  6039. var _assertString = _interopRequireDefault(require("./util/assertString"));
  6040. var algorithms = _interopRequireWildcard(require("./util/algorithms"));
  6041. var _isDate = _interopRequireDefault(require("./isDate"));
  6042. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  6043. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  6044. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6045. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  6046. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  6047. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  6048. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
  6049. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  6050. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  6051. /**
  6052. * TIN Validation
  6053. * Validates Tax Identification Numbers (TINs) from the US, EU member states and the United Kingdom.
  6054. *
  6055. * EU-UK:
  6056. * National TIN validity is calculated using public algorithms as made available by DG TAXUD.
  6057. *
  6058. * See `https://ec.europa.eu/taxation_customs/tin/specs/FS-TIN%20Algorithms-Public.docx` for more information.
  6059. *
  6060. * US:
  6061. * An Employer Identification Number (EIN), also known as a Federal Tax Identification Number,
  6062. * is used to identify a business entity.
  6063. *
  6064. * NOTES:
  6065. * - Prefix 47 is being reserved for future use
  6066. * - Prefixes 26, 27, 45, 46 and 47 were previously assigned by the Philadelphia campus.
  6067. *
  6068. * See `http://www.irs.gov/Businesses/Small-Businesses-&-Self-Employed/How-EINs-are-Assigned-and-Valid-EIN-Prefixes`
  6069. * for more information.
  6070. */
  6071. // Locale functions
  6072. /*
  6073. * bg-BG validation function
  6074. * (Edinen graždanski nomer (EGN/ЕГН), persons only)
  6075. * Checks if birth date (first six digits) is valid and calculates check (last) digit
  6076. */
  6077. function bgBgCheck(tin) {
  6078. // Extract full year, normalize month and check birth date validity
  6079. var century_year = tin.slice(0, 2);
  6080. var month = parseInt(tin.slice(2, 4), 10);
  6081. if (month > 40) {
  6082. month -= 40;
  6083. century_year = "20".concat(century_year);
  6084. } else if (month > 20) {
  6085. month -= 20;
  6086. century_year = "18".concat(century_year);
  6087. } else {
  6088. century_year = "19".concat(century_year);
  6089. }
  6090. if (month < 10) {
  6091. month = "0".concat(month);
  6092. }
  6093. var date = "".concat(century_year, "/").concat(month, "/").concat(tin.slice(4, 6));
  6094. if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  6095. return false;
  6096. } // split digits into an array for further processing
  6097. var digits = tin.split('').map(function (a) {
  6098. return parseInt(a, 10);
  6099. }); // Calculate checksum by multiplying digits with fixed values
  6100. var multip_lookup = [2, 4, 8, 5, 10, 9, 7, 3, 6];
  6101. var checksum = 0;
  6102. for (var i = 0; i < multip_lookup.length; i++) {
  6103. checksum += digits[i] * multip_lookup[i];
  6104. }
  6105. checksum = checksum % 11 === 10 ? 0 : checksum % 11;
  6106. return checksum === digits[9];
  6107. }
  6108. /*
  6109. * cs-CZ validation function
  6110. * (Rodné číslo (RČ), persons only)
  6111. * Checks if birth date (first six digits) is valid and divisibility by 11
  6112. * Material not in DG TAXUD document sourced from:
  6113. * -`https://lorenc.info/3MA381/overeni-spravnosti-rodneho-cisla.htm`
  6114. * -`https://www.mvcr.cz/clanek/rady-a-sluzby-dokumenty-rodne-cislo.aspx`
  6115. */
  6116. function csCzCheck(tin) {
  6117. tin = tin.replace(/\W/, ''); // Extract full year from TIN length
  6118. var full_year = parseInt(tin.slice(0, 2), 10);
  6119. if (tin.length === 10) {
  6120. if (full_year < 54) {
  6121. full_year = "20".concat(full_year);
  6122. } else {
  6123. full_year = "19".concat(full_year);
  6124. }
  6125. } else {
  6126. if (tin.slice(6) === '000') {
  6127. return false;
  6128. } // Three-zero serial not assigned before 1954
  6129. if (full_year < 54) {
  6130. full_year = "19".concat(full_year);
  6131. } else {
  6132. return false; // No 18XX years seen in any of the resources
  6133. }
  6134. } // Add missing zero if needed
  6135. if (full_year.length === 3) {
  6136. full_year = [full_year.slice(0, 2), '0', full_year.slice(2)].join('');
  6137. } // Extract month from TIN and normalize
  6138. var month = parseInt(tin.slice(2, 4), 10);
  6139. if (month > 50) {
  6140. month -= 50;
  6141. }
  6142. if (month > 20) {
  6143. // Month-plus-twenty was only introduced in 2004
  6144. if (parseInt(full_year, 10) < 2004) {
  6145. return false;
  6146. }
  6147. month -= 20;
  6148. }
  6149. if (month < 10) {
  6150. month = "0".concat(month);
  6151. } // Check date validity
  6152. var date = "".concat(full_year, "/").concat(month, "/").concat(tin.slice(4, 6));
  6153. if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  6154. return false;
  6155. } // Verify divisibility by 11
  6156. if (tin.length === 10) {
  6157. if (parseInt(tin, 10) % 11 !== 0) {
  6158. // Some numbers up to and including 1985 are still valid if
  6159. // check (last) digit equals 0 and modulo of first 9 digits equals 10
  6160. var checkdigit = parseInt(tin.slice(0, 9), 10) % 11;
  6161. if (parseInt(full_year, 10) < 1986 && checkdigit === 10) {
  6162. if (parseInt(tin.slice(9), 10) !== 0) {
  6163. return false;
  6164. }
  6165. } else {
  6166. return false;
  6167. }
  6168. }
  6169. }
  6170. return true;
  6171. }
  6172. /*
  6173. * de-AT validation function
  6174. * (Abgabenkontonummer, persons/entities)
  6175. * Verify TIN validity by calling luhnCheck()
  6176. */
  6177. function deAtCheck(tin) {
  6178. return algorithms.luhnCheck(tin);
  6179. }
  6180. /*
  6181. * de-DE validation function
  6182. * (Steueridentifikationsnummer (Steuer-IdNr.), persons only)
  6183. * Tests for single duplicate/triplicate value, then calculates ISO 7064 check (last) digit
  6184. * Partial implementation of spec (same result with both algorithms always)
  6185. */
  6186. function deDeCheck(tin) {
  6187. // Split digits into an array for further processing
  6188. var digits = tin.split('').map(function (a) {
  6189. return parseInt(a, 10);
  6190. }); // Fill array with strings of number positions
  6191. var occurences = [];
  6192. for (var i = 0; i < digits.length - 1; i++) {
  6193. occurences.push('');
  6194. for (var j = 0; j < digits.length - 1; j++) {
  6195. if (digits[i] === digits[j]) {
  6196. occurences[i] += j;
  6197. }
  6198. }
  6199. } // Remove digits with one occurence and test for only one duplicate/triplicate
  6200. occurences = occurences.filter(function (a) {
  6201. return a.length > 1;
  6202. });
  6203. if (occurences.length !== 2 && occurences.length !== 3) {
  6204. return false;
  6205. } // In case of triplicate value only two digits are allowed next to each other
  6206. if (occurences[0].length === 3) {
  6207. var trip_locations = occurences[0].split('').map(function (a) {
  6208. return parseInt(a, 10);
  6209. });
  6210. var recurrent = 0; // Amount of neighbour occurences
  6211. for (var _i = 0; _i < trip_locations.length - 1; _i++) {
  6212. if (trip_locations[_i] + 1 === trip_locations[_i + 1]) {
  6213. recurrent += 1;
  6214. }
  6215. }
  6216. if (recurrent === 2) {
  6217. return false;
  6218. }
  6219. }
  6220. return algorithms.iso7064Check(tin);
  6221. }
  6222. /*
  6223. * dk-DK validation function
  6224. * (CPR-nummer (personnummer), persons only)
  6225. * Checks if birth date (first six digits) is valid and assigned to century (seventh) digit,
  6226. * and calculates check (last) digit
  6227. */
  6228. function dkDkCheck(tin) {
  6229. tin = tin.replace(/\W/, ''); // Extract year, check if valid for given century digit and add century
  6230. var year = parseInt(tin.slice(4, 6), 10);
  6231. var century_digit = tin.slice(6, 7);
  6232. switch (century_digit) {
  6233. case '0':
  6234. case '1':
  6235. case '2':
  6236. case '3':
  6237. year = "19".concat(year);
  6238. break;
  6239. case '4':
  6240. case '9':
  6241. if (year < 37) {
  6242. year = "20".concat(year);
  6243. } else {
  6244. year = "19".concat(year);
  6245. }
  6246. break;
  6247. default:
  6248. if (year < 37) {
  6249. year = "20".concat(year);
  6250. } else if (year > 58) {
  6251. year = "18".concat(year);
  6252. } else {
  6253. return false;
  6254. }
  6255. break;
  6256. } // Add missing zero if needed
  6257. if (year.length === 3) {
  6258. year = [year.slice(0, 2), '0', year.slice(2)].join('');
  6259. } // Check date validity
  6260. var date = "".concat(year, "/").concat(tin.slice(2, 4), "/").concat(tin.slice(0, 2));
  6261. if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  6262. return false;
  6263. } // Split digits into an array for further processing
  6264. var digits = tin.split('').map(function (a) {
  6265. return parseInt(a, 10);
  6266. });
  6267. var checksum = 0;
  6268. var weight = 4; // Multiply by weight and add to checksum
  6269. for (var i = 0; i < 9; i++) {
  6270. checksum += digits[i] * weight;
  6271. weight -= 1;
  6272. if (weight === 1) {
  6273. weight = 7;
  6274. }
  6275. }
  6276. checksum %= 11;
  6277. if (checksum === 1) {
  6278. return false;
  6279. }
  6280. return checksum === 0 ? digits[9] === 0 : digits[9] === 11 - checksum;
  6281. }
  6282. /*
  6283. * el-CY validation function
  6284. * (Arithmos Forologikou Mitroou (AFM/ΑΦΜ), persons only)
  6285. * Verify TIN validity by calculating ASCII value of check (last) character
  6286. */
  6287. function elCyCheck(tin) {
  6288. // split digits into an array for further processing
  6289. var digits = tin.slice(0, 8).split('').map(function (a) {
  6290. return parseInt(a, 10);
  6291. });
  6292. var checksum = 0; // add digits in even places
  6293. for (var i = 1; i < digits.length; i += 2) {
  6294. checksum += digits[i];
  6295. } // add digits in odd places
  6296. for (var _i2 = 0; _i2 < digits.length; _i2 += 2) {
  6297. if (digits[_i2] < 2) {
  6298. checksum += 1 - digits[_i2];
  6299. } else {
  6300. checksum += 2 * (digits[_i2] - 2) + 5;
  6301. if (digits[_i2] > 4) {
  6302. checksum += 2;
  6303. }
  6304. }
  6305. }
  6306. return String.fromCharCode(checksum % 26 + 65) === tin.charAt(8);
  6307. }
  6308. /*
  6309. * el-GR validation function
  6310. * (Arithmos Forologikou Mitroou (AFM/ΑΦΜ), persons/entities)
  6311. * Verify TIN validity by calculating check (last) digit
  6312. * Algorithm not in DG TAXUD document- sourced from:
  6313. * - `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`
  6314. */
  6315. function elGrCheck(tin) {
  6316. // split digits into an array for further processing
  6317. var digits = tin.split('').map(function (a) {
  6318. return parseInt(a, 10);
  6319. });
  6320. var checksum = 0;
  6321. for (var i = 0; i < 8; i++) {
  6322. checksum += digits[i] * Math.pow(2, 8 - i);
  6323. }
  6324. return checksum % 11 % 10 === digits[8];
  6325. }
  6326. /*
  6327. * en-GB validation function (should go here if needed)
  6328. * (National Insurance Number (NINO) or Unique Taxpayer Reference (UTR),
  6329. * persons/entities respectively)
  6330. */
  6331. /*
  6332. * en-IE validation function
  6333. * (Personal Public Service Number (PPS No), persons only)
  6334. * Verify TIN validity by calculating check (second to last) character
  6335. */
  6336. function enIeCheck(tin) {
  6337. var checksum = algorithms.reverseMultiplyAndSum(tin.split('').slice(0, 7).map(function (a) {
  6338. return parseInt(a, 10);
  6339. }), 8);
  6340. if (tin.length === 9 && tin[8] !== 'W') {
  6341. checksum += (tin[8].charCodeAt(0) - 64) * 9;
  6342. }
  6343. checksum %= 23;
  6344. if (checksum === 0) {
  6345. return tin[7].toUpperCase() === 'W';
  6346. }
  6347. return tin[7].toUpperCase() === String.fromCharCode(64 + checksum);
  6348. } // Valid US IRS campus prefixes
  6349. var enUsCampusPrefix = {
  6350. andover: ['10', '12'],
  6351. atlanta: ['60', '67'],
  6352. austin: ['50', '53'],
  6353. 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'],
  6354. cincinnati: ['30', '32', '35', '36', '37', '38', '61'],
  6355. fresno: ['15', '24'],
  6356. internet: ['20', '26', '27', '45', '46', '47'],
  6357. kansas: ['40', '44'],
  6358. memphis: ['94', '95'],
  6359. ogden: ['80', '90'],
  6360. 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'],
  6361. sba: ['31']
  6362. }; // Return an array of all US IRS campus prefixes
  6363. function enUsGetPrefixes() {
  6364. var prefixes = [];
  6365. for (var location in enUsCampusPrefix) {
  6366. // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
  6367. // istanbul ignore else
  6368. if (enUsCampusPrefix.hasOwnProperty(location)) {
  6369. prefixes.push.apply(prefixes, _toConsumableArray(enUsCampusPrefix[location]));
  6370. }
  6371. }
  6372. return prefixes;
  6373. }
  6374. /*
  6375. * en-US validation function
  6376. * Verify that the TIN starts with a valid IRS campus prefix
  6377. */
  6378. function enUsCheck(tin) {
  6379. return enUsGetPrefixes().indexOf(tin.substr(0, 2)) !== -1;
  6380. }
  6381. /*
  6382. * es-ES validation function
  6383. * (Documento Nacional de Identidad (DNI)
  6384. * or Número de Identificación de Extranjero (NIE), persons only)
  6385. * Verify TIN validity by calculating check (last) character
  6386. */
  6387. function esEsCheck(tin) {
  6388. // Split characters into an array for further processing
  6389. var chars = tin.toUpperCase().split(''); // Replace initial letter if needed
  6390. if (isNaN(parseInt(chars[0], 10)) && chars.length > 1) {
  6391. var lead_replace = 0;
  6392. switch (chars[0]) {
  6393. case 'Y':
  6394. lead_replace = 1;
  6395. break;
  6396. case 'Z':
  6397. lead_replace = 2;
  6398. break;
  6399. default:
  6400. }
  6401. chars.splice(0, 1, lead_replace); // Fill with zeros if smaller than proper
  6402. } else {
  6403. while (chars.length < 9) {
  6404. chars.unshift(0);
  6405. }
  6406. } // Calculate checksum and check according to lookup
  6407. 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'];
  6408. chars = chars.join('');
  6409. var checksum = parseInt(chars.slice(0, 8), 10) % 23;
  6410. return chars[8] === lookup[checksum];
  6411. }
  6412. /*
  6413. * et-EE validation function
  6414. * (Isikukood (IK), persons only)
  6415. * Checks if birth date (century digit and six following) is valid and calculates check (last) digit
  6416. * Material not in DG TAXUD document sourced from:
  6417. * - `https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/Estonia-TIN.pdf`
  6418. */
  6419. function etEeCheck(tin) {
  6420. // Extract year and add century
  6421. var full_year = tin.slice(1, 3);
  6422. var century_digit = tin.slice(0, 1);
  6423. switch (century_digit) {
  6424. case '1':
  6425. case '2':
  6426. full_year = "18".concat(full_year);
  6427. break;
  6428. case '3':
  6429. case '4':
  6430. full_year = "19".concat(full_year);
  6431. break;
  6432. default:
  6433. full_year = "20".concat(full_year);
  6434. break;
  6435. } // Check date validity
  6436. var date = "".concat(full_year, "/").concat(tin.slice(3, 5), "/").concat(tin.slice(5, 7));
  6437. if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  6438. return false;
  6439. } // Split digits into an array for further processing
  6440. var digits = tin.split('').map(function (a) {
  6441. return parseInt(a, 10);
  6442. });
  6443. var checksum = 0;
  6444. var weight = 1; // Multiply by weight and add to checksum
  6445. for (var i = 0; i < 10; i++) {
  6446. checksum += digits[i] * weight;
  6447. weight += 1;
  6448. if (weight === 10) {
  6449. weight = 1;
  6450. }
  6451. } // Do again if modulo 11 of checksum is 10
  6452. if (checksum % 11 === 10) {
  6453. checksum = 0;
  6454. weight = 3;
  6455. for (var _i3 = 0; _i3 < 10; _i3++) {
  6456. checksum += digits[_i3] * weight;
  6457. weight += 1;
  6458. if (weight === 10) {
  6459. weight = 1;
  6460. }
  6461. }
  6462. if (checksum % 11 === 10) {
  6463. return digits[10] === 0;
  6464. }
  6465. }
  6466. return checksum % 11 === digits[10];
  6467. }
  6468. /*
  6469. * fi-FI validation function
  6470. * (Henkilötunnus (HETU), persons only)
  6471. * Checks if birth date (first six digits plus century symbol) is valid
  6472. * and calculates check (last) digit
  6473. */
  6474. function fiFiCheck(tin) {
  6475. // Extract year and add century
  6476. var full_year = tin.slice(4, 6);
  6477. var century_symbol = tin.slice(6, 7);
  6478. switch (century_symbol) {
  6479. case '+':
  6480. full_year = "18".concat(full_year);
  6481. break;
  6482. case '-':
  6483. full_year = "19".concat(full_year);
  6484. break;
  6485. default:
  6486. full_year = "20".concat(full_year);
  6487. break;
  6488. } // Check date validity
  6489. var date = "".concat(full_year, "/").concat(tin.slice(2, 4), "/").concat(tin.slice(0, 2));
  6490. if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  6491. return false;
  6492. } // Calculate check character
  6493. var checksum = parseInt(tin.slice(0, 6) + tin.slice(7, 10), 10) % 31;
  6494. if (checksum < 10) {
  6495. return checksum === parseInt(tin.slice(10), 10);
  6496. }
  6497. checksum -= 10;
  6498. var letters_lookup = ['A', 'B', 'C', 'D', 'E', 'F', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y'];
  6499. return letters_lookup[checksum] === tin.slice(10);
  6500. }
  6501. /*
  6502. * fr/nl-BE validation function
  6503. * (Numéro national (N.N.), persons only)
  6504. * Checks if birth date (first six digits) is valid and calculates check (last two) digits
  6505. */
  6506. function frBeCheck(tin) {
  6507. // Zero month/day value is acceptable
  6508. if (tin.slice(2, 4) !== '00' || tin.slice(4, 6) !== '00') {
  6509. // Extract date from first six digits of TIN
  6510. var date = "".concat(tin.slice(0, 2), "/").concat(tin.slice(2, 4), "/").concat(tin.slice(4, 6));
  6511. if (!(0, _isDate.default)(date, 'YY/MM/DD')) {
  6512. return false;
  6513. }
  6514. }
  6515. var checksum = 97 - parseInt(tin.slice(0, 9), 10) % 97;
  6516. var checkdigits = parseInt(tin.slice(9, 11), 10);
  6517. if (checksum !== checkdigits) {
  6518. checksum = 97 - parseInt("2".concat(tin.slice(0, 9)), 10) % 97;
  6519. if (checksum !== checkdigits) {
  6520. return false;
  6521. }
  6522. }
  6523. return true;
  6524. }
  6525. /*
  6526. * fr-FR validation function
  6527. * (Numéro fiscal de référence (numéro SPI), persons only)
  6528. * Verify TIN validity by calculating check (last three) digits
  6529. */
  6530. function frFrCheck(tin) {
  6531. tin = tin.replace(/\s/g, '');
  6532. var checksum = parseInt(tin.slice(0, 10), 10) % 511;
  6533. var checkdigits = parseInt(tin.slice(10, 13), 10);
  6534. return checksum === checkdigits;
  6535. }
  6536. /*
  6537. * fr/lb-LU validation function
  6538. * (numéro d’identification personnelle, persons only)
  6539. * Verify birth date validity and run Luhn and Verhoeff checks
  6540. */
  6541. function frLuCheck(tin) {
  6542. // Extract date and check validity
  6543. var date = "".concat(tin.slice(0, 4), "/").concat(tin.slice(4, 6), "/").concat(tin.slice(6, 8));
  6544. if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  6545. return false;
  6546. } // Run Luhn check
  6547. if (!algorithms.luhnCheck(tin.slice(0, 12))) {
  6548. return false;
  6549. } // Remove Luhn check digit and run Verhoeff check
  6550. return algorithms.verhoeffCheck("".concat(tin.slice(0, 11)).concat(tin[12]));
  6551. }
  6552. /*
  6553. * hr-HR validation function
  6554. * (Osobni identifikacijski broj (OIB), persons/entities)
  6555. * Verify TIN validity by calling iso7064Check(digits)
  6556. */
  6557. function hrHrCheck(tin) {
  6558. return algorithms.iso7064Check(tin);
  6559. }
  6560. /*
  6561. * hu-HU validation function
  6562. * (Adóazonosító jel, persons only)
  6563. * Verify TIN validity by calculating check (last) digit
  6564. */
  6565. function huHuCheck(tin) {
  6566. // split digits into an array for further processing
  6567. var digits = tin.split('').map(function (a) {
  6568. return parseInt(a, 10);
  6569. });
  6570. var checksum = 8;
  6571. for (var i = 1; i < 9; i++) {
  6572. checksum += digits[i] * (i + 1);
  6573. }
  6574. return checksum % 11 === digits[9];
  6575. }
  6576. /*
  6577. * lt-LT validation function (should go here if needed)
  6578. * (Asmens kodas, persons/entities respectively)
  6579. * Current validation check is alias of etEeCheck- same format applies
  6580. */
  6581. /*
  6582. * it-IT first/last name validity check
  6583. * Accepts it-IT TIN-encoded names as a three-element character array and checks their validity
  6584. * Due to lack of clarity between resources ("Are only Italian consonants used?
  6585. * What happens if a person has X in their name?" etc.) only two test conditions
  6586. * have been implemented:
  6587. * Vowels may only be followed by other vowels or an X character
  6588. * and X characters after vowels may only be followed by other X characters.
  6589. */
  6590. function itItNameCheck(name) {
  6591. // true at the first occurence of a vowel
  6592. var vowelflag = false; // true at the first occurence of an X AFTER vowel
  6593. // (to properly handle last names with X as consonant)
  6594. var xflag = false;
  6595. for (var i = 0; i < 3; i++) {
  6596. if (!vowelflag && /[AEIOU]/.test(name[i])) {
  6597. vowelflag = true;
  6598. } else if (!xflag && vowelflag && name[i] === 'X') {
  6599. xflag = true;
  6600. } else if (i > 0) {
  6601. if (vowelflag && !xflag) {
  6602. if (!/[AEIOU]/.test(name[i])) {
  6603. return false;
  6604. }
  6605. }
  6606. if (xflag) {
  6607. if (!/X/.test(name[i])) {
  6608. return false;
  6609. }
  6610. }
  6611. }
  6612. }
  6613. return true;
  6614. }
  6615. /*
  6616. * it-IT validation function
  6617. * (Codice fiscale (TIN-IT), persons only)
  6618. * Verify name, birth date and codice catastale validity
  6619. * and calculate check character.
  6620. * Material not in DG-TAXUD document sourced from:
  6621. * `https://en.wikipedia.org/wiki/Italian_fiscal_code`
  6622. */
  6623. function itItCheck(tin) {
  6624. // Capitalize and split characters into an array for further processing
  6625. var chars = tin.toUpperCase().split(''); // Check first and last name validity calling itItNameCheck()
  6626. if (!itItNameCheck(chars.slice(0, 3))) {
  6627. return false;
  6628. }
  6629. if (!itItNameCheck(chars.slice(3, 6))) {
  6630. return false;
  6631. } // Convert letters in number spaces back to numbers if any
  6632. var number_locations = [6, 7, 9, 10, 12, 13, 14];
  6633. var number_replace = {
  6634. L: '0',
  6635. M: '1',
  6636. N: '2',
  6637. P: '3',
  6638. Q: '4',
  6639. R: '5',
  6640. S: '6',
  6641. T: '7',
  6642. U: '8',
  6643. V: '9'
  6644. };
  6645. for (var _i4 = 0, _number_locations = number_locations; _i4 < _number_locations.length; _i4++) {
  6646. var i = _number_locations[_i4];
  6647. if (chars[i] in number_replace) {
  6648. chars.splice(i, 1, number_replace[chars[i]]);
  6649. }
  6650. } // Extract month and day, and check date validity
  6651. var month_replace = {
  6652. A: '01',
  6653. B: '02',
  6654. C: '03',
  6655. D: '04',
  6656. E: '05',
  6657. H: '06',
  6658. L: '07',
  6659. M: '08',
  6660. P: '09',
  6661. R: '10',
  6662. S: '11',
  6663. T: '12'
  6664. };
  6665. var month = month_replace[chars[8]];
  6666. var day = parseInt(chars[9] + chars[10], 10);
  6667. if (day > 40) {
  6668. day -= 40;
  6669. }
  6670. if (day < 10) {
  6671. day = "0".concat(day);
  6672. }
  6673. var date = "".concat(chars[6]).concat(chars[7], "/").concat(month, "/").concat(day);
  6674. if (!(0, _isDate.default)(date, 'YY/MM/DD')) {
  6675. return false;
  6676. } // Calculate check character by adding up even and odd characters as numbers
  6677. var checksum = 0;
  6678. for (var _i5 = 1; _i5 < chars.length - 1; _i5 += 2) {
  6679. var char_to_int = parseInt(chars[_i5], 10);
  6680. if (isNaN(char_to_int)) {
  6681. char_to_int = chars[_i5].charCodeAt(0) - 65;
  6682. }
  6683. checksum += char_to_int;
  6684. }
  6685. var odd_convert = {
  6686. // Maps of characters at odd places
  6687. A: 1,
  6688. B: 0,
  6689. C: 5,
  6690. D: 7,
  6691. E: 9,
  6692. F: 13,
  6693. G: 15,
  6694. H: 17,
  6695. I: 19,
  6696. J: 21,
  6697. K: 2,
  6698. L: 4,
  6699. M: 18,
  6700. N: 20,
  6701. O: 11,
  6702. P: 3,
  6703. Q: 6,
  6704. R: 8,
  6705. S: 12,
  6706. T: 14,
  6707. U: 16,
  6708. V: 10,
  6709. W: 22,
  6710. X: 25,
  6711. Y: 24,
  6712. Z: 23,
  6713. 0: 1,
  6714. 1: 0
  6715. };
  6716. for (var _i6 = 0; _i6 < chars.length - 1; _i6 += 2) {
  6717. var _char_to_int = 0;
  6718. if (chars[_i6] in odd_convert) {
  6719. _char_to_int = odd_convert[chars[_i6]];
  6720. } else {
  6721. var multiplier = parseInt(chars[_i6], 10);
  6722. _char_to_int = 2 * multiplier + 1;
  6723. if (multiplier > 4) {
  6724. _char_to_int += 2;
  6725. }
  6726. }
  6727. checksum += _char_to_int;
  6728. }
  6729. if (String.fromCharCode(65 + checksum % 26) !== chars[15]) {
  6730. return false;
  6731. }
  6732. return true;
  6733. }
  6734. /*
  6735. * lv-LV validation function
  6736. * (Personas kods (PK), persons only)
  6737. * Check validity of birth date and calculate check (last) digit
  6738. * Support only for old format numbers (not starting with '32', issued before 2017/07/01)
  6739. * Material not in DG TAXUD document sourced from:
  6740. * `https://boot.ritakafija.lv/forums/index.php?/topic/88314-personas-koda-algoritms-%C4%8Deksumma/`
  6741. */
  6742. function lvLvCheck(tin) {
  6743. tin = tin.replace(/\W/, ''); // Extract date from TIN
  6744. var day = tin.slice(0, 2);
  6745. if (day !== '32') {
  6746. // No date/checksum check if new format
  6747. var month = tin.slice(2, 4);
  6748. if (month !== '00') {
  6749. // No date check if unknown month
  6750. var full_year = tin.slice(4, 6);
  6751. switch (tin[6]) {
  6752. case '0':
  6753. full_year = "18".concat(full_year);
  6754. break;
  6755. case '1':
  6756. full_year = "19".concat(full_year);
  6757. break;
  6758. default:
  6759. full_year = "20".concat(full_year);
  6760. break;
  6761. } // Check date validity
  6762. var date = "".concat(full_year, "/").concat(tin.slice(2, 4), "/").concat(day);
  6763. if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  6764. return false;
  6765. }
  6766. } // Calculate check digit
  6767. var checksum = 1101;
  6768. var multip_lookup = [1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
  6769. for (var i = 0; i < tin.length - 1; i++) {
  6770. checksum -= parseInt(tin[i], 10) * multip_lookup[i];
  6771. }
  6772. return parseInt(tin[10], 10) === checksum % 11;
  6773. }
  6774. return true;
  6775. }
  6776. /*
  6777. * mt-MT validation function
  6778. * (Identity Card Number or Unique Taxpayer Reference, persons/entities)
  6779. * Verify Identity Card Number structure (no other tests found)
  6780. */
  6781. function mtMtCheck(tin) {
  6782. if (tin.length !== 9) {
  6783. // No tests for UTR
  6784. var chars = tin.toUpperCase().split(''); // Fill with zeros if smaller than proper
  6785. while (chars.length < 8) {
  6786. chars.unshift(0);
  6787. } // Validate format according to last character
  6788. switch (tin[7]) {
  6789. case 'A':
  6790. case 'P':
  6791. if (parseInt(chars[6], 10) === 0) {
  6792. return false;
  6793. }
  6794. break;
  6795. default:
  6796. {
  6797. var first_part = parseInt(chars.join('').slice(0, 5), 10);
  6798. if (first_part > 32000) {
  6799. return false;
  6800. }
  6801. var second_part = parseInt(chars.join('').slice(5, 7), 10);
  6802. if (first_part === second_part) {
  6803. return false;
  6804. }
  6805. }
  6806. }
  6807. }
  6808. return true;
  6809. }
  6810. /*
  6811. * nl-NL validation function
  6812. * (Burgerservicenummer (BSN) or Rechtspersonen Samenwerkingsverbanden Informatie Nummer (RSIN),
  6813. * persons/entities respectively)
  6814. * Verify TIN validity by calculating check (last) digit (variant of MOD 11)
  6815. */
  6816. function nlNlCheck(tin) {
  6817. return algorithms.reverseMultiplyAndSum(tin.split('').slice(0, 8).map(function (a) {
  6818. return parseInt(a, 10);
  6819. }), 9) % 11 === parseInt(tin[8], 10);
  6820. }
  6821. /*
  6822. * pl-PL validation function
  6823. * (Powszechny Elektroniczny System Ewidencji Ludności (PESEL)
  6824. * or Numer identyfikacji podatkowej (NIP), persons/entities)
  6825. * Verify TIN validity by validating birth date (PESEL) and calculating check (last) digit
  6826. */
  6827. function plPlCheck(tin) {
  6828. // NIP
  6829. if (tin.length === 10) {
  6830. // Calculate last digit by multiplying with lookup
  6831. var lookup = [6, 5, 7, 2, 3, 4, 5, 6, 7];
  6832. var _checksum = 0;
  6833. for (var i = 0; i < lookup.length; i++) {
  6834. _checksum += parseInt(tin[i], 10) * lookup[i];
  6835. }
  6836. _checksum %= 11;
  6837. if (_checksum === 10) {
  6838. return false;
  6839. }
  6840. return _checksum === parseInt(tin[9], 10);
  6841. } // PESEL
  6842. // Extract full year using month
  6843. var full_year = tin.slice(0, 2);
  6844. var month = parseInt(tin.slice(2, 4), 10);
  6845. if (month > 80) {
  6846. full_year = "18".concat(full_year);
  6847. month -= 80;
  6848. } else if (month > 60) {
  6849. full_year = "22".concat(full_year);
  6850. month -= 60;
  6851. } else if (month > 40) {
  6852. full_year = "21".concat(full_year);
  6853. month -= 40;
  6854. } else if (month > 20) {
  6855. full_year = "20".concat(full_year);
  6856. month -= 20;
  6857. } else {
  6858. full_year = "19".concat(full_year);
  6859. } // Add leading zero to month if needed
  6860. if (month < 10) {
  6861. month = "0".concat(month);
  6862. } // Check date validity
  6863. var date = "".concat(full_year, "/").concat(month, "/").concat(tin.slice(4, 6));
  6864. if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  6865. return false;
  6866. } // Calculate last digit by mulitplying with odd one-digit numbers except 5
  6867. var checksum = 0;
  6868. var multiplier = 1;
  6869. for (var _i7 = 0; _i7 < tin.length - 1; _i7++) {
  6870. checksum += parseInt(tin[_i7], 10) * multiplier % 10;
  6871. multiplier += 2;
  6872. if (multiplier > 10) {
  6873. multiplier = 1;
  6874. } else if (multiplier === 5) {
  6875. multiplier += 2;
  6876. }
  6877. }
  6878. checksum = 10 - checksum % 10;
  6879. return checksum === parseInt(tin[10], 10);
  6880. }
  6881. /*
  6882. * pt-BR validation function
  6883. * (Cadastro de Pessoas Físicas (CPF, persons)
  6884. * Cadastro Nacional de Pessoas Jurídicas (CNPJ, entities)
  6885. * Both inputs will be validated
  6886. */
  6887. function ptBrCheck(tin) {
  6888. if (tin.length === 11) {
  6889. var _sum;
  6890. var remainder;
  6891. _sum = 0;
  6892. if ( // Reject known invalid CPFs
  6893. tin === '11111111111' || tin === '22222222222' || tin === '33333333333' || tin === '44444444444' || tin === '55555555555' || tin === '66666666666' || tin === '77777777777' || tin === '88888888888' || tin === '99999999999' || tin === '00000000000') return false;
  6894. for (var i = 1; i <= 9; i++) {
  6895. _sum += parseInt(tin.substring(i - 1, i), 10) * (11 - i);
  6896. }
  6897. remainder = _sum * 10 % 11;
  6898. if (remainder === 10) remainder = 0;
  6899. if (remainder !== parseInt(tin.substring(9, 10), 10)) return false;
  6900. _sum = 0;
  6901. for (var _i8 = 1; _i8 <= 10; _i8++) {
  6902. _sum += parseInt(tin.substring(_i8 - 1, _i8), 10) * (12 - _i8);
  6903. }
  6904. remainder = _sum * 10 % 11;
  6905. if (remainder === 10) remainder = 0;
  6906. if (remainder !== parseInt(tin.substring(10, 11), 10)) return false;
  6907. return true;
  6908. }
  6909. if ( // Reject know invalid CNPJs
  6910. tin === '00000000000000' || tin === '11111111111111' || tin === '22222222222222' || tin === '33333333333333' || tin === '44444444444444' || tin === '55555555555555' || tin === '66666666666666' || tin === '77777777777777' || tin === '88888888888888' || tin === '99999999999999') {
  6911. return false;
  6912. }
  6913. var length = tin.length - 2;
  6914. var identifiers = tin.substring(0, length);
  6915. var verificators = tin.substring(length);
  6916. var sum = 0;
  6917. var pos = length - 7;
  6918. for (var _i9 = length; _i9 >= 1; _i9--) {
  6919. sum += identifiers.charAt(length - _i9) * pos;
  6920. pos -= 1;
  6921. if (pos < 2) {
  6922. pos = 9;
  6923. }
  6924. }
  6925. var result = sum % 11 < 2 ? 0 : 11 - sum % 11;
  6926. if (result !== parseInt(verificators.charAt(0), 10)) {
  6927. return false;
  6928. }
  6929. length += 1;
  6930. identifiers = tin.substring(0, length);
  6931. sum = 0;
  6932. pos = length - 7;
  6933. for (var _i10 = length; _i10 >= 1; _i10--) {
  6934. sum += identifiers.charAt(length - _i10) * pos;
  6935. pos -= 1;
  6936. if (pos < 2) {
  6937. pos = 9;
  6938. }
  6939. }
  6940. result = sum % 11 < 2 ? 0 : 11 - sum % 11;
  6941. if (result !== parseInt(verificators.charAt(1), 10)) {
  6942. return false;
  6943. }
  6944. return true;
  6945. }
  6946. /*
  6947. * pt-PT validation function
  6948. * (Número de identificação fiscal (NIF), persons/entities)
  6949. * Verify TIN validity by calculating check (last) digit (variant of MOD 11)
  6950. */
  6951. function ptPtCheck(tin) {
  6952. var checksum = 11 - algorithms.reverseMultiplyAndSum(tin.split('').slice(0, 8).map(function (a) {
  6953. return parseInt(a, 10);
  6954. }), 9) % 11;
  6955. if (checksum > 9) {
  6956. return parseInt(tin[8], 10) === 0;
  6957. }
  6958. return checksum === parseInt(tin[8], 10);
  6959. }
  6960. /*
  6961. * ro-RO validation function
  6962. * (Cod Numeric Personal (CNP) or Cod de înregistrare fiscală (CIF),
  6963. * persons only)
  6964. * Verify CNP validity by calculating check (last) digit (test not found for CIF)
  6965. * Material not in DG TAXUD document sourced from:
  6966. * `https://en.wikipedia.org/wiki/National_identification_number#Romania`
  6967. */
  6968. function roRoCheck(tin) {
  6969. if (tin.slice(0, 4) !== '9000') {
  6970. // No test found for this format
  6971. // Extract full year using century digit if possible
  6972. var full_year = tin.slice(1, 3);
  6973. switch (tin[0]) {
  6974. case '1':
  6975. case '2':
  6976. full_year = "19".concat(full_year);
  6977. break;
  6978. case '3':
  6979. case '4':
  6980. full_year = "18".concat(full_year);
  6981. break;
  6982. case '5':
  6983. case '6':
  6984. full_year = "20".concat(full_year);
  6985. break;
  6986. default:
  6987. } // Check date validity
  6988. var date = "".concat(full_year, "/").concat(tin.slice(3, 5), "/").concat(tin.slice(5, 7));
  6989. if (date.length === 8) {
  6990. if (!(0, _isDate.default)(date, 'YY/MM/DD')) {
  6991. return false;
  6992. }
  6993. } else if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  6994. return false;
  6995. } // Calculate check digit
  6996. var digits = tin.split('').map(function (a) {
  6997. return parseInt(a, 10);
  6998. });
  6999. var multipliers = [2, 7, 9, 1, 4, 6, 3, 5, 8, 2, 7, 9];
  7000. var checksum = 0;
  7001. for (var i = 0; i < multipliers.length; i++) {
  7002. checksum += digits[i] * multipliers[i];
  7003. }
  7004. if (checksum % 11 === 10) {
  7005. return digits[12] === 1;
  7006. }
  7007. return digits[12] === checksum % 11;
  7008. }
  7009. return true;
  7010. }
  7011. /*
  7012. * sk-SK validation function
  7013. * (Rodné číslo (RČ) or bezvýznamové identifikačné číslo (BIČ), persons only)
  7014. * Checks validity of pre-1954 birth numbers (rodné číslo) only
  7015. * Due to the introduction of the pseudo-random BIČ it is not possible to test
  7016. * post-1954 birth numbers without knowing whether they are BIČ or RČ beforehand
  7017. */
  7018. function skSkCheck(tin) {
  7019. if (tin.length === 9) {
  7020. tin = tin.replace(/\W/, '');
  7021. if (tin.slice(6) === '000') {
  7022. return false;
  7023. } // Three-zero serial not assigned before 1954
  7024. // Extract full year from TIN length
  7025. var full_year = parseInt(tin.slice(0, 2), 10);
  7026. if (full_year > 53) {
  7027. return false;
  7028. }
  7029. if (full_year < 10) {
  7030. full_year = "190".concat(full_year);
  7031. } else {
  7032. full_year = "19".concat(full_year);
  7033. } // Extract month from TIN and normalize
  7034. var month = parseInt(tin.slice(2, 4), 10);
  7035. if (month > 50) {
  7036. month -= 50;
  7037. }
  7038. if (month < 10) {
  7039. month = "0".concat(month);
  7040. } // Check date validity
  7041. var date = "".concat(full_year, "/").concat(month, "/").concat(tin.slice(4, 6));
  7042. if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  7043. return false;
  7044. }
  7045. }
  7046. return true;
  7047. }
  7048. /*
  7049. * sl-SI validation function
  7050. * (Davčna številka, persons/entities)
  7051. * Verify TIN validity by calculating check (last) digit (variant of MOD 11)
  7052. */
  7053. function slSiCheck(tin) {
  7054. var checksum = 11 - algorithms.reverseMultiplyAndSum(tin.split('').slice(0, 7).map(function (a) {
  7055. return parseInt(a, 10);
  7056. }), 8) % 11;
  7057. if (checksum === 10) {
  7058. return parseInt(tin[7], 10) === 0;
  7059. }
  7060. return checksum === parseInt(tin[7], 10);
  7061. }
  7062. /*
  7063. * sv-SE validation function
  7064. * (Personnummer or samordningsnummer, persons only)
  7065. * Checks validity of birth date and calls luhnCheck() to validate check (last) digit
  7066. */
  7067. function svSeCheck(tin) {
  7068. // Make copy of TIN and normalize to two-digit year form
  7069. var tin_copy = tin.slice(0);
  7070. if (tin.length > 11) {
  7071. tin_copy = tin_copy.slice(2);
  7072. } // Extract date of birth
  7073. var full_year = '';
  7074. var month = tin_copy.slice(2, 4);
  7075. var day = parseInt(tin_copy.slice(4, 6), 10);
  7076. if (tin.length > 11) {
  7077. full_year = tin.slice(0, 4);
  7078. } else {
  7079. full_year = tin.slice(0, 2);
  7080. if (tin.length === 11 && day < 60) {
  7081. // Extract full year from centenarian symbol
  7082. // Should work just fine until year 10000 or so
  7083. var current_year = new Date().getFullYear().toString();
  7084. var current_century = parseInt(current_year.slice(0, 2), 10);
  7085. current_year = parseInt(current_year, 10);
  7086. if (tin[6] === '-') {
  7087. if (parseInt("".concat(current_century).concat(full_year), 10) > current_year) {
  7088. full_year = "".concat(current_century - 1).concat(full_year);
  7089. } else {
  7090. full_year = "".concat(current_century).concat(full_year);
  7091. }
  7092. } else {
  7093. full_year = "".concat(current_century - 1).concat(full_year);
  7094. if (current_year - parseInt(full_year, 10) < 100) {
  7095. return false;
  7096. }
  7097. }
  7098. }
  7099. } // Normalize day and check date validity
  7100. if (day > 60) {
  7101. day -= 60;
  7102. }
  7103. if (day < 10) {
  7104. day = "0".concat(day);
  7105. }
  7106. var date = "".concat(full_year, "/").concat(month, "/").concat(day);
  7107. if (date.length === 8) {
  7108. if (!(0, _isDate.default)(date, 'YY/MM/DD')) {
  7109. return false;
  7110. }
  7111. } else if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) {
  7112. return false;
  7113. }
  7114. return algorithms.luhnCheck(tin.replace(/\W/, ''));
  7115. } // Locale lookup objects
  7116. /*
  7117. * Tax id regex formats for various locales
  7118. *
  7119. * Where not explicitly specified in DG-TAXUD document both
  7120. * uppercase and lowercase letters are acceptable.
  7121. */
  7122. var taxIdFormat = {
  7123. 'bg-BG': /^\d{10}$/,
  7124. 'cs-CZ': /^\d{6}\/{0,1}\d{3,4}$/,
  7125. 'de-AT': /^\d{9}$/,
  7126. 'de-DE': /^[1-9]\d{10}$/,
  7127. 'dk-DK': /^\d{6}-{0,1}\d{4}$/,
  7128. 'el-CY': /^[09]\d{7}[A-Z]$/,
  7129. 'el-GR': /^([0-4]|[7-9])\d{8}$/,
  7130. 'en-GB': /^\d{10}$|^(?!GB|NK|TN|ZZ)(?![DFIQUV])[A-Z](?![DFIQUVO])[A-Z]\d{6}[ABCD ]$/i,
  7131. 'en-IE': /^\d{7}[A-W][A-IW]{0,1}$/i,
  7132. 'en-US': /^\d{2}[- ]{0,1}\d{7}$/,
  7133. 'es-ES': /^(\d{0,8}|[XYZKLM]\d{7})[A-HJ-NP-TV-Z]$/i,
  7134. 'et-EE': /^[1-6]\d{6}(00[1-9]|0[1-9][0-9]|[1-6][0-9]{2}|70[0-9]|710)\d$/,
  7135. 'fi-FI': /^\d{6}[-+A]\d{3}[0-9A-FHJ-NPR-Y]$/i,
  7136. 'fr-BE': /^\d{11}$/,
  7137. 'fr-FR': /^[0-3]\d{12}$|^[0-3]\d\s\d{2}(\s\d{3}){3}$/,
  7138. // Conforms both to official spec and provided example
  7139. 'fr-LU': /^\d{13}$/,
  7140. 'hr-HR': /^\d{11}$/,
  7141. 'hu-HU': /^8\d{9}$/,
  7142. '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,
  7143. 'lv-LV': /^\d{6}-{0,1}\d{5}$/,
  7144. // Conforms both to DG TAXUD spec and original research
  7145. 'mt-MT': /^\d{3,7}[APMGLHBZ]$|^([1-8])\1\d{7}$/i,
  7146. 'nl-NL': /^\d{9}$/,
  7147. 'pl-PL': /^\d{10,11}$/,
  7148. 'pt-BR': /(?:^\d{11}$)|(?:^\d{14}$)/,
  7149. 'pt-PT': /^\d{9}$/,
  7150. 'ro-RO': /^\d{13}$/,
  7151. 'sk-SK': /^\d{6}\/{0,1}\d{3,4}$/,
  7152. 'sl-SI': /^[1-9]\d{7}$/,
  7153. 'sv-SE': /^(\d{6}[-+]{0,1}\d{4}|(18|19|20)\d{6}[-+]{0,1}\d{4})$/
  7154. }; // taxIdFormat locale aliases
  7155. taxIdFormat['lb-LU'] = taxIdFormat['fr-LU'];
  7156. taxIdFormat['lt-LT'] = taxIdFormat['et-EE'];
  7157. taxIdFormat['nl-BE'] = taxIdFormat['fr-BE']; // Algorithmic tax id check functions for various locales
  7158. var taxIdCheck = {
  7159. 'bg-BG': bgBgCheck,
  7160. 'cs-CZ': csCzCheck,
  7161. 'de-AT': deAtCheck,
  7162. 'de-DE': deDeCheck,
  7163. 'dk-DK': dkDkCheck,
  7164. 'el-CY': elCyCheck,
  7165. 'el-GR': elGrCheck,
  7166. 'en-IE': enIeCheck,
  7167. 'en-US': enUsCheck,
  7168. 'es-ES': esEsCheck,
  7169. 'et-EE': etEeCheck,
  7170. 'fi-FI': fiFiCheck,
  7171. 'fr-BE': frBeCheck,
  7172. 'fr-FR': frFrCheck,
  7173. 'fr-LU': frLuCheck,
  7174. 'hr-HR': hrHrCheck,
  7175. 'hu-HU': huHuCheck,
  7176. 'it-IT': itItCheck,
  7177. 'lv-LV': lvLvCheck,
  7178. 'mt-MT': mtMtCheck,
  7179. 'nl-NL': nlNlCheck,
  7180. 'pl-PL': plPlCheck,
  7181. 'pt-BR': ptBrCheck,
  7182. 'pt-PT': ptPtCheck,
  7183. 'ro-RO': roRoCheck,
  7184. 'sk-SK': skSkCheck,
  7185. 'sl-SI': slSiCheck,
  7186. 'sv-SE': svSeCheck
  7187. }; // taxIdCheck locale aliases
  7188. taxIdCheck['lb-LU'] = taxIdCheck['fr-LU'];
  7189. taxIdCheck['lt-LT'] = taxIdCheck['et-EE'];
  7190. taxIdCheck['nl-BE'] = taxIdCheck['fr-BE']; // Regexes for locales where characters should be omitted before checking format
  7191. var allsymbols = /[-\\\/!@#$%\^&\*\(\)\+\=\[\]]+/g;
  7192. var sanitizeRegexes = {
  7193. 'de-AT': allsymbols,
  7194. 'de-DE': /[\/\\]/g,
  7195. 'fr-BE': allsymbols
  7196. }; // sanitizeRegexes locale aliases
  7197. sanitizeRegexes['nl-BE'] = sanitizeRegexes['fr-BE'];
  7198. /*
  7199. * Validator function
  7200. * Return true if the passed string is a valid tax identification number
  7201. * for the specified locale.
  7202. * Throw an error exception if the locale is not supported.
  7203. */
  7204. function isTaxID(str) {
  7205. var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US';
  7206. (0, _assertString.default)(str); // Copy TIN to avoid replacement if sanitized
  7207. var strcopy = str.slice(0);
  7208. if (locale in taxIdFormat) {
  7209. if (locale in sanitizeRegexes) {
  7210. strcopy = strcopy.replace(sanitizeRegexes[locale], '');
  7211. }
  7212. if (!taxIdFormat[locale].test(strcopy)) {
  7213. return false;
  7214. }
  7215. if (locale in taxIdCheck) {
  7216. return taxIdCheck[locale](strcopy);
  7217. } // Fallthrough; not all locales have algorithmic checks
  7218. return true;
  7219. }
  7220. throw new Error("Invalid locale '".concat(locale, "'"));
  7221. }
  7222. module.exports = exports.default;
  7223. module.exports.default = exports.default;
  7224. },{"./isDate":25,"./util/algorithms":98,"./util/assertString":99}],81:[function(require,module,exports){
  7225. "use strict";
  7226. Object.defineProperty(exports, "__esModule", {
  7227. value: true
  7228. });
  7229. exports.default = isURL;
  7230. var _assertString = _interopRequireDefault(require("./util/assertString"));
  7231. var _isFQDN = _interopRequireDefault(require("./isFQDN"));
  7232. var _isIP = _interopRequireDefault(require("./isIP"));
  7233. var _merge = _interopRequireDefault(require("./util/merge"));
  7234. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7235. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  7236. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  7237. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  7238. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  7239. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  7240. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  7241. /*
  7242. options for isURL method
  7243. require_protocol - if set as true isURL will return false if protocol is not present in the URL
  7244. require_valid_protocol - isURL will check if the URL's protocol is present in the protocols option
  7245. protocols - valid protocols can be modified with this option
  7246. require_host - if set as false isURL will not check if host is present in the URL
  7247. require_port - if set as true isURL will check if port is present in the URL
  7248. allow_protocol_relative_urls - if set as true protocol relative URLs will be allowed
  7249. validate_length - if set as false isURL will skip string length validation (IE maximum is 2083)
  7250. */
  7251. var default_url_options = {
  7252. protocols: ['http', 'https', 'ftp'],
  7253. require_tld: true,
  7254. require_protocol: false,
  7255. require_host: true,
  7256. require_port: false,
  7257. require_valid_protocol: true,
  7258. allow_underscores: false,
  7259. allow_trailing_dot: false,
  7260. allow_protocol_relative_urls: false,
  7261. allow_fragments: true,
  7262. allow_query_components: true,
  7263. validate_length: true
  7264. };
  7265. var wrapped_ipv6 = /^\[([^\]]+)\](?::([0-9]+))?$/;
  7266. function isRegExp(obj) {
  7267. return Object.prototype.toString.call(obj) === '[object RegExp]';
  7268. }
  7269. function checkHost(host, matches) {
  7270. for (var i = 0; i < matches.length; i++) {
  7271. var match = matches[i];
  7272. if (host === match || isRegExp(match) && match.test(host)) {
  7273. return true;
  7274. }
  7275. }
  7276. return false;
  7277. }
  7278. function isURL(url, options) {
  7279. (0, _assertString.default)(url);
  7280. if (!url || /[\s<>]/.test(url)) {
  7281. return false;
  7282. }
  7283. if (url.indexOf('mailto:') === 0) {
  7284. return false;
  7285. }
  7286. options = (0, _merge.default)(options, default_url_options);
  7287. if (options.validate_length && url.length >= 2083) {
  7288. return false;
  7289. }
  7290. if (!options.allow_fragments && url.includes('#')) {
  7291. return false;
  7292. }
  7293. if (!options.allow_query_components && (url.includes('?') || url.includes('&'))) {
  7294. return false;
  7295. }
  7296. var protocol, auth, host, hostname, port, port_str, split, ipv6;
  7297. split = url.split('#');
  7298. url = split.shift();
  7299. split = url.split('?');
  7300. url = split.shift();
  7301. split = url.split('://');
  7302. if (split.length > 1) {
  7303. protocol = split.shift().toLowerCase();
  7304. if (options.require_valid_protocol && options.protocols.indexOf(protocol) === -1) {
  7305. return false;
  7306. }
  7307. } else if (options.require_protocol) {
  7308. return false;
  7309. } else if (url.substr(0, 2) === '//') {
  7310. if (!options.allow_protocol_relative_urls) {
  7311. return false;
  7312. }
  7313. split[0] = url.substr(2);
  7314. }
  7315. url = split.join('://');
  7316. if (url === '') {
  7317. return false;
  7318. }
  7319. split = url.split('/');
  7320. url = split.shift();
  7321. if (url === '' && !options.require_host) {
  7322. return true;
  7323. }
  7324. split = url.split('@');
  7325. if (split.length > 1) {
  7326. if (options.disallow_auth) {
  7327. return false;
  7328. }
  7329. if (split[0] === '') {
  7330. return false;
  7331. }
  7332. auth = split.shift();
  7333. if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) {
  7334. return false;
  7335. }
  7336. var _auth$split = auth.split(':'),
  7337. _auth$split2 = _slicedToArray(_auth$split, 2),
  7338. user = _auth$split2[0],
  7339. password = _auth$split2[1];
  7340. if (user === '' && password === '') {
  7341. return false;
  7342. }
  7343. }
  7344. hostname = split.join('@');
  7345. port_str = null;
  7346. ipv6 = null;
  7347. var ipv6_match = hostname.match(wrapped_ipv6);
  7348. if (ipv6_match) {
  7349. host = '';
  7350. ipv6 = ipv6_match[1];
  7351. port_str = ipv6_match[2] || null;
  7352. } else {
  7353. split = hostname.split(':');
  7354. host = split.shift();
  7355. if (split.length) {
  7356. port_str = split.join(':');
  7357. }
  7358. }
  7359. if (port_str !== null && port_str.length > 0) {
  7360. port = parseInt(port_str, 10);
  7361. if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) {
  7362. return false;
  7363. }
  7364. } else if (options.require_port) {
  7365. return false;
  7366. }
  7367. if (options.host_whitelist) {
  7368. return checkHost(host, options.host_whitelist);
  7369. }
  7370. if (!(0, _isIP.default)(host) && !(0, _isFQDN.default)(host, options) && (!ipv6 || !(0, _isIP.default)(ipv6, 6))) {
  7371. return false;
  7372. }
  7373. host = host || ipv6;
  7374. if (options.host_blacklist && checkHost(host, options.host_blacklist)) {
  7375. return false;
  7376. }
  7377. return true;
  7378. }
  7379. module.exports = exports.default;
  7380. module.exports.default = exports.default;
  7381. },{"./isFQDN":32,"./isIP":42,"./util/assertString":99,"./util/merge":101}],82:[function(require,module,exports){
  7382. "use strict";
  7383. Object.defineProperty(exports, "__esModule", {
  7384. value: true
  7385. });
  7386. exports.default = isUUID;
  7387. var _assertString = _interopRequireDefault(require("./util/assertString"));
  7388. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7389. var uuid = {
  7390. 1: /^[0-9A-F]{8}-[0-9A-F]{4}-1[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
  7391. 2: /^[0-9A-F]{8}-[0-9A-F]{4}-2[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
  7392. 3: /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
  7393. 4: /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
  7394. 5: /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
  7395. all: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i
  7396. };
  7397. function isUUID(str, version) {
  7398. (0, _assertString.default)(str);
  7399. var pattern = uuid[![undefined, null].includes(version) ? version : 'all'];
  7400. return !!pattern && pattern.test(str);
  7401. }
  7402. module.exports = exports.default;
  7403. module.exports.default = exports.default;
  7404. },{"./util/assertString":99}],83:[function(require,module,exports){
  7405. "use strict";
  7406. Object.defineProperty(exports, "__esModule", {
  7407. value: true
  7408. });
  7409. exports.default = isUppercase;
  7410. var _assertString = _interopRequireDefault(require("./util/assertString"));
  7411. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7412. function isUppercase(str) {
  7413. (0, _assertString.default)(str);
  7414. return str === str.toUpperCase();
  7415. }
  7416. module.exports = exports.default;
  7417. module.exports.default = exports.default;
  7418. },{"./util/assertString":99}],84:[function(require,module,exports){
  7419. "use strict";
  7420. Object.defineProperty(exports, "__esModule", {
  7421. value: true
  7422. });
  7423. exports.default = isVAT;
  7424. exports.vatMatchers = void 0;
  7425. var _assertString = _interopRequireDefault(require("./util/assertString"));
  7426. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7427. var vatMatchers = {
  7428. GB: /^GB((\d{3} \d{4} ([0-8][0-9]|9[0-6]))|(\d{9} \d{3})|(((GD[0-4])|(HA[5-9]))[0-9]{2}))$/,
  7429. IT: /^(IT)?[0-9]{11}$/,
  7430. NL: /^(NL)?[0-9]{9}B[0-9]{2}$/
  7431. };
  7432. exports.vatMatchers = vatMatchers;
  7433. function isVAT(str, countryCode) {
  7434. (0, _assertString.default)(str);
  7435. (0, _assertString.default)(countryCode);
  7436. if (countryCode in vatMatchers) {
  7437. return vatMatchers[countryCode].test(str);
  7438. }
  7439. throw new Error("Invalid country code: '".concat(countryCode, "'"));
  7440. }
  7441. },{"./util/assertString":99}],85:[function(require,module,exports){
  7442. "use strict";
  7443. Object.defineProperty(exports, "__esModule", {
  7444. value: true
  7445. });
  7446. exports.default = isVariableWidth;
  7447. var _assertString = _interopRequireDefault(require("./util/assertString"));
  7448. var _isFullWidth = require("./isFullWidth");
  7449. var _isHalfWidth = require("./isHalfWidth");
  7450. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7451. function isVariableWidth(str) {
  7452. (0, _assertString.default)(str);
  7453. return _isFullWidth.fullWidth.test(str) && _isHalfWidth.halfWidth.test(str);
  7454. }
  7455. module.exports = exports.default;
  7456. module.exports.default = exports.default;
  7457. },{"./isFullWidth":34,"./isHalfWidth":36,"./util/assertString":99}],86:[function(require,module,exports){
  7458. "use strict";
  7459. Object.defineProperty(exports, "__esModule", {
  7460. value: true
  7461. });
  7462. exports.default = isWhitelisted;
  7463. var _assertString = _interopRequireDefault(require("./util/assertString"));
  7464. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7465. function isWhitelisted(str, chars) {
  7466. (0, _assertString.default)(str);
  7467. for (var i = str.length - 1; i >= 0; i--) {
  7468. if (chars.indexOf(str[i]) === -1) {
  7469. return false;
  7470. }
  7471. }
  7472. return true;
  7473. }
  7474. module.exports = exports.default;
  7475. module.exports.default = exports.default;
  7476. },{"./util/assertString":99}],87:[function(require,module,exports){
  7477. "use strict";
  7478. Object.defineProperty(exports, "__esModule", {
  7479. value: true
  7480. });
  7481. exports.default = ltrim;
  7482. var _assertString = _interopRequireDefault(require("./util/assertString"));
  7483. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7484. function ltrim(str, chars) {
  7485. (0, _assertString.default)(str); // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
  7486. var pattern = chars ? new RegExp("^[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+"), 'g') : /^\s+/g;
  7487. return str.replace(pattern, '');
  7488. }
  7489. module.exports = exports.default;
  7490. module.exports.default = exports.default;
  7491. },{"./util/assertString":99}],88:[function(require,module,exports){
  7492. "use strict";
  7493. Object.defineProperty(exports, "__esModule", {
  7494. value: true
  7495. });
  7496. exports.default = matches;
  7497. var _assertString = _interopRequireDefault(require("./util/assertString"));
  7498. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7499. function matches(str, pattern, modifiers) {
  7500. (0, _assertString.default)(str);
  7501. if (Object.prototype.toString.call(pattern) !== '[object RegExp]') {
  7502. pattern = new RegExp(pattern, modifiers);
  7503. }
  7504. return pattern.test(str);
  7505. }
  7506. module.exports = exports.default;
  7507. module.exports.default = exports.default;
  7508. },{"./util/assertString":99}],89:[function(require,module,exports){
  7509. "use strict";
  7510. Object.defineProperty(exports, "__esModule", {
  7511. value: true
  7512. });
  7513. exports.default = normalizeEmail;
  7514. var _merge = _interopRequireDefault(require("./util/merge"));
  7515. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7516. var default_normalize_email_options = {
  7517. // The following options apply to all email addresses
  7518. // Lowercases the local part of the email address.
  7519. // Please note this may violate RFC 5321 as per http://stackoverflow.com/a/9808332/192024).
  7520. // The domain is always lowercased, as per RFC 1035
  7521. all_lowercase: true,
  7522. // The following conversions are specific to GMail
  7523. // Lowercases the local part of the GMail address (known to be case-insensitive)
  7524. gmail_lowercase: true,
  7525. // Removes dots from the local part of the email address, as that's ignored by GMail
  7526. gmail_remove_dots: true,
  7527. // Removes the subaddress (e.g. "+foo") from the email address
  7528. gmail_remove_subaddress: true,
  7529. // Conversts the googlemail.com domain to gmail.com
  7530. gmail_convert_googlemaildotcom: true,
  7531. // The following conversions are specific to Outlook.com / Windows Live / Hotmail
  7532. // Lowercases the local part of the Outlook.com address (known to be case-insensitive)
  7533. outlookdotcom_lowercase: true,
  7534. // Removes the subaddress (e.g. "+foo") from the email address
  7535. outlookdotcom_remove_subaddress: true,
  7536. // The following conversions are specific to Yahoo
  7537. // Lowercases the local part of the Yahoo address (known to be case-insensitive)
  7538. yahoo_lowercase: true,
  7539. // Removes the subaddress (e.g. "-foo") from the email address
  7540. yahoo_remove_subaddress: true,
  7541. // The following conversions are specific to Yandex
  7542. // Lowercases the local part of the Yandex address (known to be case-insensitive)
  7543. yandex_lowercase: true,
  7544. // The following conversions are specific to iCloud
  7545. // Lowercases the local part of the iCloud address (known to be case-insensitive)
  7546. icloud_lowercase: true,
  7547. // Removes the subaddress (e.g. "+foo") from the email address
  7548. icloud_remove_subaddress: true
  7549. }; // List of domains used by iCloud
  7550. var icloud_domains = ['icloud.com', 'me.com']; // List of domains used by Outlook.com and its predecessors
  7551. // This list is likely incomplete.
  7552. // Partial reference:
  7553. // https://blogs.office.com/2013/04/17/outlook-com-gets-two-step-verification-sign-in-by-alias-and-new-international-domains/
  7554. var outlookdotcom_domains = ['hotmail.at', 'hotmail.be', 'hotmail.ca', 'hotmail.cl', 'hotmail.co.il', 'hotmail.co.nz', 'hotmail.co.th', 'hotmail.co.uk', 'hotmail.com', 'hotmail.com.ar', 'hotmail.com.au', 'hotmail.com.br', 'hotmail.com.gr', 'hotmail.com.mx', 'hotmail.com.pe', 'hotmail.com.tr', 'hotmail.com.vn', 'hotmail.cz', 'hotmail.de', 'hotmail.dk', 'hotmail.es', 'hotmail.fr', 'hotmail.hu', 'hotmail.id', 'hotmail.ie', 'hotmail.in', 'hotmail.it', 'hotmail.jp', 'hotmail.kr', 'hotmail.lv', 'hotmail.my', 'hotmail.ph', 'hotmail.pt', 'hotmail.sa', 'hotmail.sg', 'hotmail.sk', 'live.be', 'live.co.uk', 'live.com', 'live.com.ar', 'live.com.mx', 'live.de', 'live.es', 'live.eu', 'live.fr', 'live.it', 'live.nl', 'msn.com', 'outlook.at', 'outlook.be', 'outlook.cl', 'outlook.co.il', 'outlook.co.nz', 'outlook.co.th', 'outlook.com', 'outlook.com.ar', 'outlook.com.au', 'outlook.com.br', 'outlook.com.gr', 'outlook.com.pe', 'outlook.com.tr', 'outlook.com.vn', 'outlook.cz', 'outlook.de', 'outlook.dk', 'outlook.es', 'outlook.fr', 'outlook.hu', 'outlook.id', 'outlook.ie', 'outlook.in', 'outlook.it', 'outlook.jp', 'outlook.kr', 'outlook.lv', 'outlook.my', 'outlook.ph', 'outlook.pt', 'outlook.sa', 'outlook.sg', 'outlook.sk', 'passport.com']; // List of domains used by Yahoo Mail
  7555. // This list is likely incomplete
  7556. var yahoo_domains = ['rocketmail.com', 'yahoo.ca', 'yahoo.co.uk', 'yahoo.com', 'yahoo.de', 'yahoo.fr', 'yahoo.in', 'yahoo.it', 'ymail.com']; // List of domains used by yandex.ru
  7557. var yandex_domains = ['yandex.ru', 'yandex.ua', 'yandex.kz', 'yandex.com', 'yandex.by', 'ya.ru']; // replace single dots, but not multiple consecutive dots
  7558. function dotsReplacer(match) {
  7559. if (match.length > 1) {
  7560. return match;
  7561. }
  7562. return '';
  7563. }
  7564. function normalizeEmail(email, options) {
  7565. options = (0, _merge.default)(options, default_normalize_email_options);
  7566. var raw_parts = email.split('@');
  7567. var domain = raw_parts.pop();
  7568. var user = raw_parts.join('@');
  7569. var parts = [user, domain]; // The domain is always lowercased, as it's case-insensitive per RFC 1035
  7570. parts[1] = parts[1].toLowerCase();
  7571. if (parts[1] === 'gmail.com' || parts[1] === 'googlemail.com') {
  7572. // Address is GMail
  7573. if (options.gmail_remove_subaddress) {
  7574. parts[0] = parts[0].split('+')[0];
  7575. }
  7576. if (options.gmail_remove_dots) {
  7577. // this does not replace consecutive dots like example..email@gmail.com
  7578. parts[0] = parts[0].replace(/\.+/g, dotsReplacer);
  7579. }
  7580. if (!parts[0].length) {
  7581. return false;
  7582. }
  7583. if (options.all_lowercase || options.gmail_lowercase) {
  7584. parts[0] = parts[0].toLowerCase();
  7585. }
  7586. parts[1] = options.gmail_convert_googlemaildotcom ? 'gmail.com' : parts[1];
  7587. } else if (icloud_domains.indexOf(parts[1]) >= 0) {
  7588. // Address is iCloud
  7589. if (options.icloud_remove_subaddress) {
  7590. parts[0] = parts[0].split('+')[0];
  7591. }
  7592. if (!parts[0].length) {
  7593. return false;
  7594. }
  7595. if (options.all_lowercase || options.icloud_lowercase) {
  7596. parts[0] = parts[0].toLowerCase();
  7597. }
  7598. } else if (outlookdotcom_domains.indexOf(parts[1]) >= 0) {
  7599. // Address is Outlook.com
  7600. if (options.outlookdotcom_remove_subaddress) {
  7601. parts[0] = parts[0].split('+')[0];
  7602. }
  7603. if (!parts[0].length) {
  7604. return false;
  7605. }
  7606. if (options.all_lowercase || options.outlookdotcom_lowercase) {
  7607. parts[0] = parts[0].toLowerCase();
  7608. }
  7609. } else if (yahoo_domains.indexOf(parts[1]) >= 0) {
  7610. // Address is Yahoo
  7611. if (options.yahoo_remove_subaddress) {
  7612. var components = parts[0].split('-');
  7613. parts[0] = components.length > 1 ? components.slice(0, -1).join('-') : components[0];
  7614. }
  7615. if (!parts[0].length) {
  7616. return false;
  7617. }
  7618. if (options.all_lowercase || options.yahoo_lowercase) {
  7619. parts[0] = parts[0].toLowerCase();
  7620. }
  7621. } else if (yandex_domains.indexOf(parts[1]) >= 0) {
  7622. if (options.all_lowercase || options.yandex_lowercase) {
  7623. parts[0] = parts[0].toLowerCase();
  7624. }
  7625. parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preferred
  7626. } else if (options.all_lowercase) {
  7627. // Any other address
  7628. parts[0] = parts[0].toLowerCase();
  7629. }
  7630. return parts.join('@');
  7631. }
  7632. module.exports = exports.default;
  7633. module.exports.default = exports.default;
  7634. },{"./util/merge":101}],90:[function(require,module,exports){
  7635. "use strict";
  7636. Object.defineProperty(exports, "__esModule", {
  7637. value: true
  7638. });
  7639. exports.default = rtrim;
  7640. var _assertString = _interopRequireDefault(require("./util/assertString"));
  7641. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7642. function rtrim(str, chars) {
  7643. (0, _assertString.default)(str);
  7644. if (chars) {
  7645. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
  7646. var pattern = new RegExp("[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+$"), 'g');
  7647. return str.replace(pattern, '');
  7648. } // Use a faster and more safe than regex trim method https://blog.stevenlevithan.com/archives/faster-trim-javascript
  7649. var strIndex = str.length - 1;
  7650. while (/\s/.test(str.charAt(strIndex))) {
  7651. strIndex -= 1;
  7652. }
  7653. return str.slice(0, strIndex + 1);
  7654. }
  7655. module.exports = exports.default;
  7656. module.exports.default = exports.default;
  7657. },{"./util/assertString":99}],91:[function(require,module,exports){
  7658. "use strict";
  7659. Object.defineProperty(exports, "__esModule", {
  7660. value: true
  7661. });
  7662. exports.default = stripLow;
  7663. var _assertString = _interopRequireDefault(require("./util/assertString"));
  7664. var _blacklist = _interopRequireDefault(require("./blacklist"));
  7665. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7666. function stripLow(str, keep_new_lines) {
  7667. (0, _assertString.default)(str);
  7668. var chars = keep_new_lines ? '\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F' : '\\x00-\\x1F\\x7F';
  7669. return (0, _blacklist.default)(str, chars);
  7670. }
  7671. module.exports = exports.default;
  7672. module.exports.default = exports.default;
  7673. },{"./blacklist":6,"./util/assertString":99}],92:[function(require,module,exports){
  7674. "use strict";
  7675. Object.defineProperty(exports, "__esModule", {
  7676. value: true
  7677. });
  7678. exports.default = toBoolean;
  7679. var _assertString = _interopRequireDefault(require("./util/assertString"));
  7680. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7681. function toBoolean(str, strict) {
  7682. (0, _assertString.default)(str);
  7683. if (strict) {
  7684. return str === '1' || /^true$/i.test(str);
  7685. }
  7686. return str !== '0' && !/^false$/i.test(str) && str !== '';
  7687. }
  7688. module.exports = exports.default;
  7689. module.exports.default = exports.default;
  7690. },{"./util/assertString":99}],93:[function(require,module,exports){
  7691. "use strict";
  7692. Object.defineProperty(exports, "__esModule", {
  7693. value: true
  7694. });
  7695. exports.default = toDate;
  7696. var _assertString = _interopRequireDefault(require("./util/assertString"));
  7697. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7698. function toDate(date) {
  7699. (0, _assertString.default)(date);
  7700. date = Date.parse(date);
  7701. return !isNaN(date) ? new Date(date) : null;
  7702. }
  7703. module.exports = exports.default;
  7704. module.exports.default = exports.default;
  7705. },{"./util/assertString":99}],94:[function(require,module,exports){
  7706. "use strict";
  7707. Object.defineProperty(exports, "__esModule", {
  7708. value: true
  7709. });
  7710. exports.default = toFloat;
  7711. var _isFloat = _interopRequireDefault(require("./isFloat"));
  7712. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7713. function toFloat(str) {
  7714. if (!(0, _isFloat.default)(str)) return NaN;
  7715. return parseFloat(str);
  7716. }
  7717. module.exports = exports.default;
  7718. module.exports.default = exports.default;
  7719. },{"./isFloat":33}],95:[function(require,module,exports){
  7720. "use strict";
  7721. Object.defineProperty(exports, "__esModule", {
  7722. value: true
  7723. });
  7724. exports.default = toInt;
  7725. var _assertString = _interopRequireDefault(require("./util/assertString"));
  7726. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7727. function toInt(str, radix) {
  7728. (0, _assertString.default)(str);
  7729. return parseInt(str, radix || 10);
  7730. }
  7731. module.exports = exports.default;
  7732. module.exports.default = exports.default;
  7733. },{"./util/assertString":99}],96:[function(require,module,exports){
  7734. "use strict";
  7735. Object.defineProperty(exports, "__esModule", {
  7736. value: true
  7737. });
  7738. exports.default = trim;
  7739. var _rtrim = _interopRequireDefault(require("./rtrim"));
  7740. var _ltrim = _interopRequireDefault(require("./ltrim"));
  7741. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7742. function trim(str, chars) {
  7743. return (0, _rtrim.default)((0, _ltrim.default)(str, chars), chars);
  7744. }
  7745. module.exports = exports.default;
  7746. module.exports.default = exports.default;
  7747. },{"./ltrim":87,"./rtrim":90}],97:[function(require,module,exports){
  7748. "use strict";
  7749. Object.defineProperty(exports, "__esModule", {
  7750. value: true
  7751. });
  7752. exports.default = unescape;
  7753. var _assertString = _interopRequireDefault(require("./util/assertString"));
  7754. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7755. function unescape(str) {
  7756. (0, _assertString.default)(str);
  7757. return str.replace(/&quot;/g, '"').replace(/&#x27;/g, "'").replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&#x2F;/g, '/').replace(/&#x5C;/g, '\\').replace(/&#96;/g, '`').replace(/&amp;/g, '&'); // &amp; replacement has to be the last one to prevent
  7758. // bugs with intermediate strings containing escape sequences
  7759. // See: https://github.com/validatorjs/validator.js/issues/1827
  7760. }
  7761. module.exports = exports.default;
  7762. module.exports.default = exports.default;
  7763. },{"./util/assertString":99}],98:[function(require,module,exports){
  7764. "use strict";
  7765. Object.defineProperty(exports, "__esModule", {
  7766. value: true
  7767. });
  7768. exports.iso7064Check = iso7064Check;
  7769. exports.luhnCheck = luhnCheck;
  7770. exports.reverseMultiplyAndSum = reverseMultiplyAndSum;
  7771. exports.verhoeffCheck = verhoeffCheck;
  7772. /**
  7773. * Algorithmic validation functions
  7774. * May be used as is or implemented in the workflow of other validators.
  7775. */
  7776. /*
  7777. * ISO 7064 validation function
  7778. * Called with a string of numbers (incl. check digit)
  7779. * to validate according to ISO 7064 (MOD 11, 10).
  7780. */
  7781. function iso7064Check(str) {
  7782. var checkvalue = 10;
  7783. for (var i = 0; i < str.length - 1; i++) {
  7784. checkvalue = (parseInt(str[i], 10) + checkvalue) % 10 === 0 ? 10 * 2 % 11 : (parseInt(str[i], 10) + checkvalue) % 10 * 2 % 11;
  7785. }
  7786. checkvalue = checkvalue === 1 ? 0 : 11 - checkvalue;
  7787. return checkvalue === parseInt(str[10], 10);
  7788. }
  7789. /*
  7790. * Luhn (mod 10) validation function
  7791. * Called with a string of numbers (incl. check digit)
  7792. * to validate according to the Luhn algorithm.
  7793. */
  7794. function luhnCheck(str) {
  7795. var checksum = 0;
  7796. var second = false;
  7797. for (var i = str.length - 1; i >= 0; i--) {
  7798. if (second) {
  7799. var product = parseInt(str[i], 10) * 2;
  7800. if (product > 9) {
  7801. // sum digits of product and add to checksum
  7802. checksum += product.toString().split('').map(function (a) {
  7803. return parseInt(a, 10);
  7804. }).reduce(function (a, b) {
  7805. return a + b;
  7806. }, 0);
  7807. } else {
  7808. checksum += product;
  7809. }
  7810. } else {
  7811. checksum += parseInt(str[i], 10);
  7812. }
  7813. second = !second;
  7814. }
  7815. return checksum % 10 === 0;
  7816. }
  7817. /*
  7818. * Reverse TIN multiplication and summation helper function
  7819. * Called with an array of single-digit integers and a base multiplier
  7820. * to calculate the sum of the digits multiplied in reverse.
  7821. * Normally used in variations of MOD 11 algorithmic checks.
  7822. */
  7823. function reverseMultiplyAndSum(digits, base) {
  7824. var total = 0;
  7825. for (var i = 0; i < digits.length; i++) {
  7826. total += digits[i] * (base - i);
  7827. }
  7828. return total;
  7829. }
  7830. /*
  7831. * Verhoeff validation helper function
  7832. * Called with a string of numbers
  7833. * to validate according to the Verhoeff algorithm.
  7834. */
  7835. function verhoeffCheck(str) {
  7836. 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]];
  7837. var p_table = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 5, 7, 6, 2, 8, 3, 0, 9, 4], [5, 8, 0, 3, 7, 9, 6, 1, 4, 2], [8, 9, 1, 6, 0, 4, 3, 5, 2, 7], [9, 4, 5, 3, 1, 2, 6, 8, 7, 0], [4, 2, 8, 6, 5, 7, 3, 9, 0, 1], [2, 7, 9, 3, 8, 0, 6, 4, 1, 5], [7, 0, 4, 6, 9, 1, 3, 2, 5, 8]]; // Copy (to prevent replacement) and reverse
  7838. var str_copy = str.split('').reverse().join('');
  7839. var checksum = 0;
  7840. for (var i = 0; i < str_copy.length; i++) {
  7841. checksum = d_table[checksum][p_table[i % 8][parseInt(str_copy[i], 10)]];
  7842. }
  7843. return checksum === 0;
  7844. }
  7845. },{}],99:[function(require,module,exports){
  7846. "use strict";
  7847. Object.defineProperty(exports, "__esModule", {
  7848. value: true
  7849. });
  7850. exports.default = assertString;
  7851. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7852. function assertString(input) {
  7853. var isString = typeof input === 'string' || input instanceof String;
  7854. if (!isString) {
  7855. var invalidType = _typeof(input);
  7856. if (input === null) invalidType = 'null';else if (invalidType === 'object') invalidType = input.constructor.name;
  7857. throw new TypeError("Expected a string but received a ".concat(invalidType));
  7858. }
  7859. }
  7860. module.exports = exports.default;
  7861. module.exports.default = exports.default;
  7862. },{}],100:[function(require,module,exports){
  7863. "use strict";
  7864. Object.defineProperty(exports, "__esModule", {
  7865. value: true
  7866. });
  7867. exports.default = void 0;
  7868. var includes = function includes(arr, val) {
  7869. return arr.some(function (arrVal) {
  7870. return val === arrVal;
  7871. });
  7872. };
  7873. var _default = includes;
  7874. exports.default = _default;
  7875. module.exports = exports.default;
  7876. module.exports.default = exports.default;
  7877. },{}],101:[function(require,module,exports){
  7878. "use strict";
  7879. Object.defineProperty(exports, "__esModule", {
  7880. value: true
  7881. });
  7882. exports.default = merge;
  7883. function merge() {
  7884. var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7885. var defaults = arguments.length > 1 ? arguments[1] : undefined;
  7886. for (var key in defaults) {
  7887. if (typeof obj[key] === 'undefined') {
  7888. obj[key] = defaults[key];
  7889. }
  7890. }
  7891. return obj;
  7892. }
  7893. module.exports = exports.default;
  7894. module.exports.default = exports.default;
  7895. },{}],102:[function(require,module,exports){
  7896. "use strict";
  7897. Object.defineProperty(exports, "__esModule", {
  7898. value: true
  7899. });
  7900. exports.default = multilineRegexp;
  7901. /**
  7902. * Build RegExp object from an array
  7903. * of multiple/multi-line regexp parts
  7904. *
  7905. * @param {string[]} parts
  7906. * @param {string} flags
  7907. * @return {object} - RegExp object
  7908. */
  7909. function multilineRegexp(parts, flags) {
  7910. var regexpAsStringLiteral = parts.join('');
  7911. return new RegExp(regexpAsStringLiteral, flags);
  7912. }
  7913. module.exports = exports.default;
  7914. module.exports.default = exports.default;
  7915. },{}],103:[function(require,module,exports){
  7916. "use strict";
  7917. Object.defineProperty(exports, "__esModule", {
  7918. value: true
  7919. });
  7920. exports.default = toString;
  7921. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7922. function toString(input) {
  7923. if (_typeof(input) === 'object' && input !== null) {
  7924. if (typeof input.toString === 'function') {
  7925. input = input.toString();
  7926. } else {
  7927. input = '[object Object]';
  7928. }
  7929. } else if (input === null || typeof input === 'undefined' || isNaN(input) && !input.length) {
  7930. input = '';
  7931. }
  7932. return String(input);
  7933. }
  7934. module.exports = exports.default;
  7935. module.exports.default = exports.default;
  7936. },{}],104:[function(require,module,exports){
  7937. "use strict";
  7938. Object.defineProperty(exports, "__esModule", {
  7939. value: true
  7940. });
  7941. exports.default = whitelist;
  7942. var _assertString = _interopRequireDefault(require("./util/assertString"));
  7943. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7944. function whitelist(str, chars) {
  7945. (0, _assertString.default)(str);
  7946. return str.replace(new RegExp("[^".concat(chars, "]+"), 'g'), '');
  7947. }
  7948. module.exports = exports.default;
  7949. module.exports.default = exports.default;
  7950. },{"./util/assertString":99}],105:[function(require,module,exports){
  7951. "use strict";
  7952. module.exports = {
  7953. INVALID_TYPE: "Expected type {0} but found type {1}",
  7954. INVALID_FORMAT: "Object didn't pass validation for format {0}: {1}",
  7955. ENUM_MISMATCH: "No enum match for: {0}",
  7956. ENUM_CASE_MISMATCH: "Enum does not match case for: {0}",
  7957. ANY_OF_MISSING: "Data does not match any schemas from 'anyOf'",
  7958. ONE_OF_MISSING: "Data does not match any schemas from 'oneOf'",
  7959. ONE_OF_MULTIPLE: "Data is valid against more than one schema from 'oneOf'",
  7960. NOT_PASSED: "Data matches schema from 'not'",
  7961. // Array errors
  7962. ARRAY_LENGTH_SHORT: "Array is too short ({0}), minimum {1}",
  7963. ARRAY_LENGTH_LONG: "Array is too long ({0}), maximum {1}",
  7964. ARRAY_UNIQUE: "Array items are not unique (indexes {0} and {1})",
  7965. ARRAY_ADDITIONAL_ITEMS: "Additional items not allowed",
  7966. // Numeric errors
  7967. MULTIPLE_OF: "Value {0} is not a multiple of {1}",
  7968. MINIMUM: "Value {0} is less than minimum {1}",
  7969. MINIMUM_EXCLUSIVE: "Value {0} is equal or less than exclusive minimum {1}",
  7970. MAXIMUM: "Value {0} is greater than maximum {1}",
  7971. MAXIMUM_EXCLUSIVE: "Value {0} is equal or greater than exclusive maximum {1}",
  7972. // Object errors
  7973. OBJECT_PROPERTIES_MINIMUM: "Too few properties defined ({0}), minimum {1}",
  7974. OBJECT_PROPERTIES_MAXIMUM: "Too many properties defined ({0}), maximum {1}",
  7975. OBJECT_MISSING_REQUIRED_PROPERTY: "Missing required property: {0}",
  7976. OBJECT_ADDITIONAL_PROPERTIES: "Additional properties not allowed: {0}",
  7977. OBJECT_DEPENDENCY_KEY: "Dependency failed - key must exist: {0} (due to key: {1})",
  7978. // String errors
  7979. MIN_LENGTH: "String is too short ({0} chars), minimum {1}",
  7980. MAX_LENGTH: "String is too long ({0} chars), maximum {1}",
  7981. PATTERN: "String does not match pattern {0}: {1}",
  7982. // Schema validation errors
  7983. KEYWORD_TYPE_EXPECTED: "Keyword '{0}' is expected to be of type '{1}'",
  7984. KEYWORD_UNDEFINED_STRICT: "Keyword '{0}' must be defined in strict mode",
  7985. KEYWORD_UNEXPECTED: "Keyword '{0}' is not expected to appear in the schema",
  7986. KEYWORD_MUST_BE: "Keyword '{0}' must be {1}",
  7987. KEYWORD_DEPENDENCY: "Keyword '{0}' requires keyword '{1}'",
  7988. KEYWORD_PATTERN: "Keyword '{0}' is not a valid RegExp pattern: {1}",
  7989. KEYWORD_VALUE_TYPE: "Each element of keyword '{0}' array must be a '{1}'",
  7990. UNKNOWN_FORMAT: "There is no validation function for format '{0}'",
  7991. CUSTOM_MODE_FORCE_PROPERTIES: "{0} must define at least one property if present",
  7992. // Remote errors
  7993. REF_UNRESOLVED: "Reference has not been resolved during compilation: {0}",
  7994. UNRESOLVABLE_REFERENCE: "Reference could not be resolved: {0}",
  7995. SCHEMA_NOT_REACHABLE: "Validator was not able to read schema with uri: {0}",
  7996. SCHEMA_TYPE_EXPECTED: "Schema is expected to be of type 'object'",
  7997. SCHEMA_NOT_AN_OBJECT: "Schema is not an object: {0}",
  7998. ASYNC_TIMEOUT: "{0} asynchronous task(s) have timed out after {1} ms",
  7999. PARENT_SCHEMA_VALIDATION_FAILED: "Schema failed to validate against its parent schema, see inner errors for details.",
  8000. REMOTE_NOT_VALID: "Remote reference didn't compile successfully: {0}"
  8001. };
  8002. },{}],106:[function(require,module,exports){
  8003. /*jshint maxlen: false*/
  8004. var validator = require("validator");
  8005. var FormatValidators = {
  8006. "date": function (date) {
  8007. if (typeof date !== "string") {
  8008. return true;
  8009. }
  8010. // full-date from http://tools.ietf.org/html/rfc3339#section-5.6
  8011. var matches = /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.exec(date);
  8012. if (matches === null) {
  8013. return false;
  8014. }
  8015. // var year = matches[1];
  8016. // var month = matches[2];
  8017. // var day = matches[3];
  8018. if (matches[2] < "01" || matches[2] > "12" || matches[3] < "01" || matches[3] > "31") {
  8019. return false;
  8020. }
  8021. return true;
  8022. },
  8023. "date-time": function (dateTime) {
  8024. if (typeof dateTime !== "string") {
  8025. return true;
  8026. }
  8027. // date-time from http://tools.ietf.org/html/rfc3339#section-5.6
  8028. var s = dateTime.toLowerCase().split("t");
  8029. if (!FormatValidators.date(s[0])) {
  8030. return false;
  8031. }
  8032. var matches = /^([0-9]{2}):([0-9]{2}):([0-9]{2})(.[0-9]+)?(z|([+-][0-9]{2}:[0-9]{2}))$/.exec(s[1]);
  8033. if (matches === null) {
  8034. return false;
  8035. }
  8036. // var hour = matches[1];
  8037. // var minute = matches[2];
  8038. // var second = matches[3];
  8039. // var fraction = matches[4];
  8040. // var timezone = matches[5];
  8041. if (matches[1] > "23" || matches[2] > "59" || matches[3] > "59") {
  8042. return false;
  8043. }
  8044. return true;
  8045. },
  8046. "email": function (email) {
  8047. if (typeof email !== "string") {
  8048. return true;
  8049. }
  8050. return validator.isEmail(email, { "require_tld": true });
  8051. },
  8052. "hostname": function (hostname) {
  8053. if (typeof hostname !== "string") {
  8054. return true;
  8055. }
  8056. /*
  8057. http://json-schema.org/latest/json-schema-validation.html#anchor114
  8058. A string instance is valid against this attribute if it is a valid
  8059. representation for an Internet host name, as defined by RFC 1034, section 3.1 [RFC1034].
  8060. http://tools.ietf.org/html/rfc1034#section-3.5
  8061. <digit> ::= any one of the ten digits 0 through 9
  8062. var digit = /[0-9]/;
  8063. <letter> ::= any one of the 52 alphabetic characters A through Z in upper case and a through z in lower case
  8064. var letter = /[a-zA-Z]/;
  8065. <let-dig> ::= <letter> | <digit>
  8066. var letDig = /[0-9a-zA-Z]/;
  8067. <let-dig-hyp> ::= <let-dig> | "-"
  8068. var letDigHyp = /[-0-9a-zA-Z]/;
  8069. <ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>
  8070. var ldhStr = /[-0-9a-zA-Z]+/;
  8071. <label> ::= <letter> [ [ <ldh-str> ] <let-dig> ]
  8072. var label = /[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?/;
  8073. <subdomain> ::= <label> | <subdomain> "." <label>
  8074. var subdomain = /^[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?(\.[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?)*$/;
  8075. <domain> ::= <subdomain> | " "
  8076. var domain = null;
  8077. */
  8078. var valid = /^[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?(\.[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?)*$/.test(hostname);
  8079. if (valid) {
  8080. // the sum of all label octets and label lengths is limited to 255.
  8081. if (hostname.length > 255) { return false; }
  8082. // Each node has a label, which is zero to 63 octets in length
  8083. var labels = hostname.split(".");
  8084. for (var i = 0; i < labels.length; i++) { if (labels[i].length > 63) { return false; } }
  8085. }
  8086. return valid;
  8087. },
  8088. "host-name": function (hostname) {
  8089. return FormatValidators.hostname.call(this, hostname);
  8090. },
  8091. "ipv4": function (ipv4) {
  8092. if (typeof ipv4 !== "string") { return true; }
  8093. return validator.isIP(ipv4, 4);
  8094. },
  8095. "ipv6": function (ipv6) {
  8096. if (typeof ipv6 !== "string") { return true; }
  8097. return validator.isIP(ipv6, 6);
  8098. },
  8099. "regex": function (str) {
  8100. try {
  8101. RegExp(str);
  8102. return true;
  8103. } catch (e) {
  8104. return false;
  8105. }
  8106. },
  8107. "uri": function (uri) {
  8108. if (this.options.strictUris) {
  8109. return FormatValidators["strict-uri"].apply(this, arguments);
  8110. }
  8111. // https://github.com/zaggino/z-schema/issues/18
  8112. // RegExp from http://tools.ietf.org/html/rfc3986#appendix-B
  8113. return typeof uri !== "string" || RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?").test(uri);
  8114. },
  8115. "strict-uri": function (uri) {
  8116. return typeof uri !== "string" || validator.isURL(uri);
  8117. }
  8118. };
  8119. module.exports = FormatValidators;
  8120. },{"validator":4}],107:[function(require,module,exports){
  8121. "use strict";
  8122. var FormatValidators = require("./FormatValidators"),
  8123. Report = require("./Report"),
  8124. Utils = require("./Utils");
  8125. var shouldSkipValidate = function (options, errors) {
  8126. return options &&
  8127. Array.isArray(options.includeErrors) &&
  8128. options.includeErrors.length > 0 &&
  8129. !errors.some(function (err) { return options.includeErrors.includes(err);});
  8130. };
  8131. var JsonValidators = {
  8132. multipleOf: function (report, schema, json) {
  8133. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.1.1.2
  8134. if (shouldSkipValidate(this.validateOptions, ["MULTIPLE_OF"])) {
  8135. return;
  8136. }
  8137. if (typeof json !== "number") {
  8138. return;
  8139. }
  8140. var stringMultipleOf = String(schema.multipleOf);
  8141. var scale = Math.pow(10, stringMultipleOf.length - stringMultipleOf.indexOf(".") - 1);
  8142. if (Utils.whatIs((json * scale) / (schema.multipleOf * scale)) !== "integer") {
  8143. report.addError("MULTIPLE_OF", [json, schema.multipleOf], null, schema);
  8144. }
  8145. },
  8146. maximum: function (report, schema, json) {
  8147. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.1.2.2
  8148. if (shouldSkipValidate(this.validateOptions, ["MAXIMUM", "MAXIMUM_EXCLUSIVE"])) {
  8149. return;
  8150. }
  8151. if (typeof json !== "number") {
  8152. return;
  8153. }
  8154. if (schema.exclusiveMaximum !== true) {
  8155. if (json > schema.maximum) {
  8156. report.addError("MAXIMUM", [json, schema.maximum], null, schema);
  8157. }
  8158. } else {
  8159. if (json >= schema.maximum) {
  8160. report.addError("MAXIMUM_EXCLUSIVE", [json, schema.maximum], null, schema);
  8161. }
  8162. }
  8163. },
  8164. exclusiveMaximum: function () {
  8165. // covered in maximum
  8166. },
  8167. minimum: function (report, schema, json) {
  8168. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.1.3.2
  8169. if (shouldSkipValidate(this.validateOptions, ["MINIMUM", "MINIMUM_EXCLUSIVE"])) {
  8170. return;
  8171. }
  8172. if (typeof json !== "number") {
  8173. return;
  8174. }
  8175. if (schema.exclusiveMinimum !== true) {
  8176. if (json < schema.minimum) {
  8177. report.addError("MINIMUM", [json, schema.minimum], null, schema);
  8178. }
  8179. } else {
  8180. if (json <= schema.minimum) {
  8181. report.addError("MINIMUM_EXCLUSIVE", [json, schema.minimum], null, schema);
  8182. }
  8183. }
  8184. },
  8185. exclusiveMinimum: function () {
  8186. // covered in minimum
  8187. },
  8188. maxLength: function (report, schema, json) {
  8189. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.1.2
  8190. if (shouldSkipValidate(this.validateOptions, ["MAX_LENGTH"])) {
  8191. return;
  8192. }
  8193. if (typeof json !== "string") {
  8194. return;
  8195. }
  8196. if (Utils.ucs2decode(json).length > schema.maxLength) {
  8197. report.addError("MAX_LENGTH", [json.length, schema.maxLength], null, schema);
  8198. }
  8199. },
  8200. minLength: function (report, schema, json) {
  8201. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.2.2
  8202. if (shouldSkipValidate(this.validateOptions, ["MIN_LENGTH"])) {
  8203. return;
  8204. }
  8205. if (typeof json !== "string") {
  8206. return;
  8207. }
  8208. if (Utils.ucs2decode(json).length < schema.minLength) {
  8209. report.addError("MIN_LENGTH", [json.length, schema.minLength], null, schema);
  8210. }
  8211. },
  8212. pattern: function (report, schema, json) {
  8213. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.3.2
  8214. if (shouldSkipValidate(this.validateOptions, ["PATTERN"])) {
  8215. return;
  8216. }
  8217. if (typeof json !== "string") {
  8218. return;
  8219. }
  8220. if (RegExp(schema.pattern).test(json) === false) {
  8221. report.addError("PATTERN", [schema.pattern, json], null, schema);
  8222. }
  8223. },
  8224. additionalItems: function (report, schema, json) {
  8225. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.3.1.2
  8226. if (shouldSkipValidate(this.validateOptions, ["ARRAY_ADDITIONAL_ITEMS"])) {
  8227. return;
  8228. }
  8229. if (!Array.isArray(json)) {
  8230. return;
  8231. }
  8232. // if the value of "additionalItems" is boolean value false and the value of "items" is an array,
  8233. // the json is valid if its size is less than, or equal to, the size of "items".
  8234. if (schema.additionalItems === false && Array.isArray(schema.items)) {
  8235. if (json.length > schema.items.length) {
  8236. report.addError("ARRAY_ADDITIONAL_ITEMS", null, null, schema);
  8237. }
  8238. }
  8239. },
  8240. items: function () { /*report, schema, json*/
  8241. // covered in additionalItems
  8242. },
  8243. maxItems: function (report, schema, json) {
  8244. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.3.2.2
  8245. if (shouldSkipValidate(this.validateOptions, ["ARRAY_LENGTH_LONG"])) {
  8246. return;
  8247. }
  8248. if (!Array.isArray(json)) {
  8249. return;
  8250. }
  8251. if (json.length > schema.maxItems) {
  8252. report.addError("ARRAY_LENGTH_LONG", [json.length, schema.maxItems], null, schema);
  8253. }
  8254. },
  8255. minItems: function (report, schema, json) {
  8256. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.3.3.2
  8257. if (shouldSkipValidate(this.validateOptions, ["ARRAY_LENGTH_SHORT"])) {
  8258. return;
  8259. }
  8260. if (!Array.isArray(json)) {
  8261. return;
  8262. }
  8263. if (json.length < schema.minItems) {
  8264. report.addError("ARRAY_LENGTH_SHORT", [json.length, schema.minItems], null, schema);
  8265. }
  8266. },
  8267. uniqueItems: function (report, schema, json) {
  8268. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.3.4.2
  8269. if (shouldSkipValidate(this.validateOptions, ["ARRAY_UNIQUE"])) {
  8270. return;
  8271. }
  8272. if (!Array.isArray(json)) {
  8273. return;
  8274. }
  8275. if (schema.uniqueItems === true) {
  8276. var matches = [];
  8277. if (Utils.isUniqueArray(json, matches) === false) {
  8278. report.addError("ARRAY_UNIQUE", matches, null, schema);
  8279. }
  8280. }
  8281. },
  8282. maxProperties: function (report, schema, json) {
  8283. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.1.2
  8284. if (shouldSkipValidate(this.validateOptions, ["OBJECT_PROPERTIES_MAXIMUM"])) {
  8285. return;
  8286. }
  8287. if (Utils.whatIs(json) !== "object") {
  8288. return;
  8289. }
  8290. var keysCount = Object.keys(json).length;
  8291. if (keysCount > schema.maxProperties) {
  8292. report.addError("OBJECT_PROPERTIES_MAXIMUM", [keysCount, schema.maxProperties], null, schema);
  8293. }
  8294. },
  8295. minProperties: function (report, schema, json) {
  8296. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.2.2
  8297. if (shouldSkipValidate(this.validateOptions, ["OBJECT_PROPERTIES_MINIMUM"])) {
  8298. return;
  8299. }
  8300. if (Utils.whatIs(json) !== "object") {
  8301. return;
  8302. }
  8303. var keysCount = Object.keys(json).length;
  8304. if (keysCount < schema.minProperties) {
  8305. report.addError("OBJECT_PROPERTIES_MINIMUM", [keysCount, schema.minProperties], null, schema);
  8306. }
  8307. },
  8308. required: function (report, schema, json) {
  8309. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.3.2
  8310. if (shouldSkipValidate(this.validateOptions, ["OBJECT_MISSING_REQUIRED_PROPERTY"])) {
  8311. return;
  8312. }
  8313. if (Utils.whatIs(json) !== "object") {
  8314. return;
  8315. }
  8316. var idx = schema.required.length;
  8317. while (idx--) {
  8318. var requiredPropertyName = schema.required[idx];
  8319. if (json[requiredPropertyName] === undefined) {
  8320. report.addError("OBJECT_MISSING_REQUIRED_PROPERTY", [requiredPropertyName], null, schema);
  8321. }
  8322. }
  8323. },
  8324. additionalProperties: function (report, schema, json) {
  8325. // covered in properties and patternProperties
  8326. if (schema.properties === undefined && schema.patternProperties === undefined) {
  8327. return JsonValidators.properties.call(this, report, schema, json);
  8328. }
  8329. },
  8330. patternProperties: function (report, schema, json) {
  8331. // covered in properties
  8332. if (schema.properties === undefined) {
  8333. return JsonValidators.properties.call(this, report, schema, json);
  8334. }
  8335. },
  8336. properties: function (report, schema, json) {
  8337. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.4.2
  8338. if (shouldSkipValidate(this.validateOptions, ["OBJECT_ADDITIONAL_PROPERTIES"])) {
  8339. return;
  8340. }
  8341. if (Utils.whatIs(json) !== "object") {
  8342. return;
  8343. }
  8344. var properties = schema.properties !== undefined ? schema.properties : {};
  8345. var patternProperties = schema.patternProperties !== undefined ? schema.patternProperties : {};
  8346. if (schema.additionalProperties === false) {
  8347. // The property set of the json to validate.
  8348. var s = Object.keys(json);
  8349. // The property set from "properties".
  8350. var p = Object.keys(properties);
  8351. // The property set from "patternProperties".
  8352. var pp = Object.keys(patternProperties);
  8353. // remove from "s" all elements of "p", if any;
  8354. s = Utils.difference(s, p);
  8355. // for each regex in "pp", remove all elements of "s" which this regex matches.
  8356. var idx = pp.length;
  8357. while (idx--) {
  8358. var regExp = RegExp(pp[idx]),
  8359. idx2 = s.length;
  8360. while (idx2--) {
  8361. if (regExp.test(s[idx2]) === true) {
  8362. s.splice(idx2, 1);
  8363. }
  8364. }
  8365. }
  8366. // Validation of the json succeeds if, after these two steps, set "s" is empty.
  8367. if (s.length > 0) {
  8368. // assumeAdditional can be an array of allowed properties
  8369. var idx3 = this.options.assumeAdditional.length;
  8370. if (idx3) {
  8371. while (idx3--) {
  8372. var io = s.indexOf(this.options.assumeAdditional[idx3]);
  8373. if (io !== -1) {
  8374. s.splice(io, 1);
  8375. }
  8376. }
  8377. }
  8378. var idx4 = s.length;
  8379. if (idx4) {
  8380. while (idx4--) {
  8381. report.addError("OBJECT_ADDITIONAL_PROPERTIES", [s[idx4]], null, schema);
  8382. }
  8383. }
  8384. }
  8385. }
  8386. },
  8387. dependencies: function (report, schema, json) {
  8388. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.5.2
  8389. if (shouldSkipValidate(this.validateOptions, ["OBJECT_DEPENDENCY_KEY"])) {
  8390. return;
  8391. }
  8392. if (Utils.whatIs(json) !== "object") {
  8393. return;
  8394. }
  8395. var keys = Object.keys(schema.dependencies),
  8396. idx = keys.length;
  8397. while (idx--) {
  8398. // iterate all dependencies
  8399. var dependencyName = keys[idx];
  8400. if (json[dependencyName]) {
  8401. var dependencyDefinition = schema.dependencies[dependencyName];
  8402. if (Utils.whatIs(dependencyDefinition) === "object") {
  8403. // if dependency is a schema, validate against this schema
  8404. exports.validate.call(this, report, dependencyDefinition, json);
  8405. } else { // Array
  8406. // if dependency is an array, object needs to have all properties in this array
  8407. var idx2 = dependencyDefinition.length;
  8408. while (idx2--) {
  8409. var requiredPropertyName = dependencyDefinition[idx2];
  8410. if (json[requiredPropertyName] === undefined) {
  8411. report.addError("OBJECT_DEPENDENCY_KEY", [requiredPropertyName, dependencyName], null, schema);
  8412. }
  8413. }
  8414. }
  8415. }
  8416. }
  8417. },
  8418. enum: function (report, schema, json) {
  8419. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.1.2
  8420. if (shouldSkipValidate(this.validateOptions, ["ENUM_CASE_MISMATCH", "ENUM_MISMATCH"])) {
  8421. return;
  8422. }
  8423. var match = false,
  8424. caseInsensitiveMatch = false,
  8425. idx = schema.enum.length;
  8426. while (idx--) {
  8427. if (Utils.areEqual(json, schema.enum[idx])) {
  8428. match = true;
  8429. break;
  8430. } else if (Utils.areEqual(json, schema.enum[idx]), { caseInsensitiveComparison: true }) {
  8431. caseInsensitiveMatch = true;
  8432. }
  8433. }
  8434. if (match === false) {
  8435. var error = caseInsensitiveMatch && this.options.enumCaseInsensitiveComparison ? "ENUM_CASE_MISMATCH" : "ENUM_MISMATCH";
  8436. report.addError(error, [json], null, schema);
  8437. }
  8438. },
  8439. type: function (report, schema, json) {
  8440. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.2.2
  8441. if (shouldSkipValidate(this.validateOptions, ["INVALID_TYPE"])) {
  8442. return;
  8443. }
  8444. var jsonType = Utils.whatIs(json);
  8445. if (typeof schema.type === "string") {
  8446. if (jsonType !== schema.type && (jsonType !== "integer" || schema.type !== "number")) {
  8447. report.addError("INVALID_TYPE", [schema.type, jsonType], null, schema);
  8448. }
  8449. } else {
  8450. if (schema.type.indexOf(jsonType) === -1 && (jsonType !== "integer" || schema.type.indexOf("number") === -1)) {
  8451. report.addError("INVALID_TYPE", [schema.type, jsonType], null, schema);
  8452. }
  8453. }
  8454. },
  8455. allOf: function (report, schema, json) {
  8456. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.3.2
  8457. var idx = schema.allOf.length;
  8458. while (idx--) {
  8459. var validateResult = exports.validate.call(this, report, schema.allOf[idx], json);
  8460. if (this.options.breakOnFirstError && validateResult === false) {
  8461. break;
  8462. }
  8463. }
  8464. },
  8465. anyOf: function (report, schema, json) {
  8466. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.4.2
  8467. var subReports = [],
  8468. passed = false,
  8469. idx = schema.anyOf.length;
  8470. while (idx-- && passed === false) {
  8471. var subReport = new Report(report);
  8472. subReports.push(subReport);
  8473. passed = exports.validate.call(this, subReport, schema.anyOf[idx], json);
  8474. }
  8475. if (passed === false) {
  8476. report.addError("ANY_OF_MISSING", undefined, subReports, schema);
  8477. }
  8478. },
  8479. oneOf: function (report, schema, json) {
  8480. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.5.2
  8481. var passes = 0,
  8482. subReports = [],
  8483. idx = schema.oneOf.length;
  8484. while (idx--) {
  8485. var subReport = new Report(report, { maxErrors: 1 });
  8486. subReports.push(subReport);
  8487. if (exports.validate.call(this, subReport, schema.oneOf[idx], json) === true) {
  8488. passes++;
  8489. }
  8490. }
  8491. if (passes === 0) {
  8492. report.addError("ONE_OF_MISSING", undefined, subReports, schema);
  8493. } else if (passes > 1) {
  8494. report.addError("ONE_OF_MULTIPLE", null, null, schema);
  8495. }
  8496. },
  8497. not: function (report, schema, json) {
  8498. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.6.2
  8499. var subReport = new Report(report);
  8500. if (exports.validate.call(this, subReport, schema.not, json) === true) {
  8501. report.addError("NOT_PASSED", null, null, schema);
  8502. }
  8503. },
  8504. definitions: function () { /*report, schema, json*/
  8505. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.7.2
  8506. // nothing to do here
  8507. },
  8508. format: function (report, schema, json) {
  8509. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.7.2
  8510. var formatValidatorFn = FormatValidators[schema.format];
  8511. if (typeof formatValidatorFn === "function") {
  8512. if (shouldSkipValidate(this.validateOptions, ["INVALID_FORMAT"])) {
  8513. return;
  8514. }
  8515. if (formatValidatorFn.length === 2) {
  8516. // async - need to clone the path here, because it will change by the time async function reports back
  8517. var pathBeforeAsync = Utils.clone(report.path);
  8518. report.addAsyncTask(formatValidatorFn, [json], function (result) {
  8519. if (result !== true) {
  8520. var backup = report.path;
  8521. report.path = pathBeforeAsync;
  8522. report.addError("INVALID_FORMAT", [schema.format, json], null, schema);
  8523. report.path = backup;
  8524. }
  8525. });
  8526. } else {
  8527. // sync
  8528. if (formatValidatorFn.call(this, json) !== true) {
  8529. report.addError("INVALID_FORMAT", [schema.format, json], null, schema);
  8530. }
  8531. }
  8532. } else if (this.options.ignoreUnknownFormats !== true) {
  8533. report.addError("UNKNOWN_FORMAT", [schema.format], null, schema);
  8534. }
  8535. }
  8536. };
  8537. var recurseArray = function (report, schema, json) {
  8538. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.8.2
  8539. var idx = json.length;
  8540. // If "items" is an array, this situation, the schema depends on the index:
  8541. // if the index is less than, or equal to, the size of "items",
  8542. // the child instance must be valid against the corresponding schema in the "items" array;
  8543. // otherwise, it must be valid against the schema defined by "additionalItems".
  8544. if (Array.isArray(schema.items)) {
  8545. while (idx--) {
  8546. // equal to doesn't make sense here
  8547. if (idx < schema.items.length) {
  8548. report.path.push(idx);
  8549. exports.validate.call(this, report, schema.items[idx], json[idx]);
  8550. report.path.pop();
  8551. } else {
  8552. // might be boolean, so check that it's an object
  8553. if (typeof schema.additionalItems === "object") {
  8554. report.path.push(idx);
  8555. exports.validate.call(this, report, schema.additionalItems, json[idx]);
  8556. report.path.pop();
  8557. }
  8558. }
  8559. }
  8560. } else if (typeof schema.items === "object") {
  8561. // If items is a schema, then the child instance must be valid against this schema,
  8562. // regardless of its index, and regardless of the value of "additionalItems".
  8563. while (idx--) {
  8564. report.path.push(idx);
  8565. exports.validate.call(this, report, schema.items, json[idx]);
  8566. report.path.pop();
  8567. }
  8568. }
  8569. };
  8570. var recurseObject = function (report, schema, json) {
  8571. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.8.3
  8572. // If "additionalProperties" is absent, it is considered present with an empty schema as a value.
  8573. // In addition, boolean value true is considered equivalent to an empty schema.
  8574. var additionalProperties = schema.additionalProperties;
  8575. if (additionalProperties === true || additionalProperties === undefined) {
  8576. additionalProperties = {};
  8577. }
  8578. // p - The property set from "properties".
  8579. var p = schema.properties ? Object.keys(schema.properties) : [];
  8580. // pp - The property set from "patternProperties". Elements of this set will be called regexes for convenience.
  8581. var pp = schema.patternProperties ? Object.keys(schema.patternProperties) : [];
  8582. // m - The property name of the child.
  8583. var keys = Object.keys(json),
  8584. idx = keys.length;
  8585. while (idx--) {
  8586. var m = keys[idx],
  8587. propertyValue = json[m];
  8588. // s - The set of schemas for the child instance.
  8589. var s = [];
  8590. // 1. If set "p" contains value "m", then the corresponding schema in "properties" is added to "s".
  8591. if (p.indexOf(m) !== -1) {
  8592. s.push(schema.properties[m]);
  8593. }
  8594. // 2. For each regex in "pp", if it matches "m" successfully, the corresponding schema in "patternProperties" is added to "s".
  8595. var idx2 = pp.length;
  8596. while (idx2--) {
  8597. var regexString = pp[idx2];
  8598. if (RegExp(regexString).test(m) === true) {
  8599. s.push(schema.patternProperties[regexString]);
  8600. }
  8601. }
  8602. // 3. The schema defined by "additionalProperties" is added to "s" if and only if, at this stage, "s" is empty.
  8603. if (s.length === 0 && additionalProperties !== false) {
  8604. s.push(additionalProperties);
  8605. }
  8606. // we are passing tests even without this assert because this is covered by properties check
  8607. // if s is empty in this stage, no additionalProperties are allowed
  8608. // report.expect(s.length !== 0, 'E001', m);
  8609. // Instance property value must pass all schemas from s
  8610. idx2 = s.length;
  8611. while (idx2--) {
  8612. report.path.push(m);
  8613. exports.validate.call(this, report, s[idx2], propertyValue);
  8614. report.path.pop();
  8615. }
  8616. }
  8617. };
  8618. exports.JsonValidators = JsonValidators;
  8619. /**
  8620. *
  8621. * @param {Report} report
  8622. * @param {*} schema
  8623. * @param {*} json
  8624. */
  8625. exports.validate = function (report, schema, json) {
  8626. report.commonErrorMessage = "JSON_OBJECT_VALIDATION_FAILED";
  8627. // check if schema is an object
  8628. var to = Utils.whatIs(schema);
  8629. if (to !== "object") {
  8630. report.addError("SCHEMA_NOT_AN_OBJECT", [to], null, schema);
  8631. return false;
  8632. }
  8633. // check if schema is empty, everything is valid against empty schema
  8634. var keys = Object.keys(schema);
  8635. if (keys.length === 0) {
  8636. return true;
  8637. }
  8638. // this method can be called recursively, so we need to remember our root
  8639. var isRoot = false;
  8640. if (!report.rootSchema) {
  8641. report.rootSchema = schema;
  8642. isRoot = true;
  8643. }
  8644. // follow schema.$ref keys
  8645. if (schema.$ref !== undefined) {
  8646. // avoid infinite loop with maxRefs
  8647. var maxRefs = 99;
  8648. while (schema.$ref && maxRefs > 0) {
  8649. if (!schema.__$refResolved) {
  8650. report.addError("REF_UNRESOLVED", [schema.$ref], null, schema);
  8651. break;
  8652. } else if (schema.__$refResolved === schema) {
  8653. break;
  8654. } else {
  8655. schema = schema.__$refResolved;
  8656. keys = Object.keys(schema);
  8657. }
  8658. maxRefs--;
  8659. }
  8660. if (maxRefs === 0) {
  8661. throw new Error("Circular dependency by $ref references!");
  8662. }
  8663. }
  8664. // type checking first
  8665. var jsonType = Utils.whatIs(json);
  8666. if (schema.type) {
  8667. keys.splice(keys.indexOf("type"), 1);
  8668. JsonValidators.type.call(this, report, schema, json);
  8669. if (report.errors.length && this.options.breakOnFirstError) {
  8670. return false;
  8671. }
  8672. }
  8673. // now iterate all the keys in schema and execute validation methods
  8674. var idx = keys.length;
  8675. while (idx--) {
  8676. if (JsonValidators[keys[idx]]) {
  8677. JsonValidators[keys[idx]].call(this, report, schema, json);
  8678. if (report.errors.length && this.options.breakOnFirstError) { break; }
  8679. }
  8680. }
  8681. if (report.errors.length === 0 || this.options.breakOnFirstError === false) {
  8682. if (jsonType === "array") {
  8683. recurseArray.call(this, report, schema, json);
  8684. } else if (jsonType === "object") {
  8685. recurseObject.call(this, report, schema, json);
  8686. }
  8687. }
  8688. if (typeof this.options.customValidator === "function") {
  8689. this.options.customValidator.call(this, report, schema, json);
  8690. }
  8691. // we don't need the root pointer anymore
  8692. if (isRoot) {
  8693. report.rootSchema = undefined;
  8694. }
  8695. // return valid just to be able to break at some code points
  8696. return report.errors.length === 0;
  8697. };
  8698. },{"./FormatValidators":106,"./Report":109,"./Utils":113}],108:[function(require,module,exports){
  8699. // Number.isFinite polyfill
  8700. // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite
  8701. if (typeof Number.isFinite !== "function") {
  8702. Number.isFinite = function isFinite(value) {
  8703. // 1. If Type(number) is not Number, return false.
  8704. if (typeof value !== "number") {
  8705. return false;
  8706. }
  8707. // 2. If number is NaN, +∞, or −∞, return false.
  8708. if (value !== value || value === Infinity || value === -Infinity) {
  8709. return false;
  8710. }
  8711. // 3. Otherwise, return true.
  8712. return true;
  8713. };
  8714. }
  8715. },{}],109:[function(require,module,exports){
  8716. (function (process){(function (){
  8717. "use strict";
  8718. var get = require("lodash.get");
  8719. var Errors = require("./Errors");
  8720. var Utils = require("./Utils");
  8721. /**
  8722. * @class
  8723. *
  8724. * @param {Report|object} parentOrOptions
  8725. * @param {object} [reportOptions]
  8726. */
  8727. function Report(parentOrOptions, reportOptions) {
  8728. this.parentReport = parentOrOptions instanceof Report ?
  8729. parentOrOptions :
  8730. undefined;
  8731. this.options = parentOrOptions instanceof Report ?
  8732. parentOrOptions.options :
  8733. parentOrOptions || {};
  8734. this.reportOptions = reportOptions || {};
  8735. this.errors = [];
  8736. /**
  8737. * @type {string[]}
  8738. */
  8739. this.path = [];
  8740. this.asyncTasks = [];
  8741. this.rootSchema = undefined;
  8742. this.commonErrorMessage = undefined;
  8743. this.json = undefined;
  8744. }
  8745. /**
  8746. * @returns {boolean}
  8747. */
  8748. Report.prototype.isValid = function () {
  8749. if (this.asyncTasks.length > 0) {
  8750. throw new Error("Async tasks pending, can't answer isValid");
  8751. }
  8752. return this.errors.length === 0;
  8753. };
  8754. /**
  8755. *
  8756. * @param {*} fn
  8757. * @param {*} args
  8758. * @param {*} asyncTaskResultProcessFn
  8759. */
  8760. Report.prototype.addAsyncTask = function (fn, args, asyncTaskResultProcessFn) {
  8761. this.asyncTasks.push([fn, args, asyncTaskResultProcessFn]);
  8762. };
  8763. Report.prototype.getAncestor = function (id) {
  8764. if (!this.parentReport) {
  8765. return undefined;
  8766. }
  8767. if (this.parentReport.getSchemaId() === id) {
  8768. return this.parentReport;
  8769. }
  8770. return this.parentReport.getAncestor(id);
  8771. };
  8772. /**
  8773. *
  8774. * @param {*} timeout
  8775. * @param {function(*, *)} callback
  8776. *
  8777. * @returns {void}
  8778. */
  8779. Report.prototype.processAsyncTasks = function (timeout, callback) {
  8780. var validationTimeout = timeout || 2000,
  8781. tasksCount = this.asyncTasks.length,
  8782. idx = tasksCount,
  8783. timedOut = false,
  8784. self = this;
  8785. function finish() {
  8786. process.nextTick(function () {
  8787. var valid = self.errors.length === 0,
  8788. err = valid ? null : self.errors;
  8789. callback(err, valid);
  8790. });
  8791. }
  8792. function respond(asyncTaskResultProcessFn) {
  8793. return function (asyncTaskResult) {
  8794. if (timedOut) { return; }
  8795. asyncTaskResultProcessFn(asyncTaskResult);
  8796. if (--tasksCount === 0) {
  8797. finish();
  8798. }
  8799. };
  8800. }
  8801. // finish if tasks are completed or there are any errors and breaking on first error was requested
  8802. if (tasksCount === 0 || (this.errors.length > 0 && this.options.breakOnFirstError)) {
  8803. finish();
  8804. return;
  8805. }
  8806. while (idx--) {
  8807. var task = this.asyncTasks[idx];
  8808. task[0].apply(null, task[1].concat(respond(task[2])));
  8809. }
  8810. setTimeout(function () {
  8811. if (tasksCount > 0) {
  8812. timedOut = true;
  8813. self.addError("ASYNC_TIMEOUT", [tasksCount, validationTimeout]);
  8814. callback(self.errors, false);
  8815. }
  8816. }, validationTimeout);
  8817. };
  8818. /**
  8819. *
  8820. * @param {*} returnPathAsString
  8821. *
  8822. * @return {string[]|string}
  8823. */
  8824. Report.prototype.getPath = function (returnPathAsString) {
  8825. /**
  8826. * @type {string[]|string}
  8827. */
  8828. var path = [];
  8829. if (this.parentReport) {
  8830. path = path.concat(this.parentReport.path);
  8831. }
  8832. path = path.concat(this.path);
  8833. if (returnPathAsString !== true) {
  8834. // Sanitize the path segments (http://tools.ietf.org/html/rfc6901#section-4)
  8835. path = "#/" + path.map(function (segment) {
  8836. segment = segment.toString();
  8837. if (Utils.isAbsoluteUri(segment)) {
  8838. return "uri(" + segment + ")";
  8839. }
  8840. return segment.replace(/\~/g, "~0").replace(/\//g, "~1");
  8841. }).join("/");
  8842. }
  8843. return path;
  8844. };
  8845. Report.prototype.getSchemaId = function () {
  8846. if (!this.rootSchema) {
  8847. return null;
  8848. }
  8849. // get the error path as an array
  8850. var path = [];
  8851. if (this.parentReport) {
  8852. path = path.concat(this.parentReport.path);
  8853. }
  8854. path = path.concat(this.path);
  8855. // try to find id in the error path
  8856. while (path.length > 0) {
  8857. var obj = get(this.rootSchema, path);
  8858. if (obj && obj.id) { return obj.id; }
  8859. path.pop();
  8860. }
  8861. // return id of the root
  8862. return this.rootSchema.id;
  8863. };
  8864. /**
  8865. *
  8866. * @param {*} errorCode
  8867. * @param {*} params
  8868. *
  8869. * @return {boolean}
  8870. */
  8871. Report.prototype.hasError = function (errorCode, params) {
  8872. var idx = this.errors.length;
  8873. while (idx--) {
  8874. if (this.errors[idx].code === errorCode) {
  8875. // assume match
  8876. var match = true;
  8877. // check the params too
  8878. var idx2 = this.errors[idx].params.length;
  8879. while (idx2--) {
  8880. if (this.errors[idx].params[idx2] !== params[idx2]) {
  8881. match = false;
  8882. }
  8883. }
  8884. // if match, return true
  8885. if (match) { return match; }
  8886. }
  8887. }
  8888. return false;
  8889. };
  8890. /**
  8891. *
  8892. * @param {*} errorCode
  8893. * @param {*} params
  8894. * @param {Report[]|Report} [subReports]
  8895. * @param {*} [schema]
  8896. *
  8897. * @return {void}
  8898. */
  8899. Report.prototype.addError = function (errorCode, params, subReports, schema) {
  8900. if (!errorCode) { throw new Error("No errorCode passed into addError()"); }
  8901. this.addCustomError(errorCode, Errors[errorCode], params, subReports, schema);
  8902. };
  8903. Report.prototype.getJson = function () {
  8904. var self = this;
  8905. while (self.json === undefined) {
  8906. self = self.parentReport;
  8907. if (self === undefined) {
  8908. return undefined;
  8909. }
  8910. }
  8911. return self.json;
  8912. };
  8913. /**
  8914. *
  8915. * @param {*} errorCode
  8916. * @param {*} errorMessage
  8917. * @param {*[]} params
  8918. * @param {Report[]|Report} subReports
  8919. * @param {*} schema
  8920. *
  8921. * @returns {void}
  8922. */
  8923. Report.prototype.addCustomError = function (errorCode, errorMessage, params, subReports, schema) {
  8924. if (this.errors.length >= this.reportOptions.maxErrors) {
  8925. return;
  8926. }
  8927. if (!errorMessage) { throw new Error("No errorMessage known for code " + errorCode); }
  8928. params = params || [];
  8929. var idx = params.length;
  8930. while (idx--) {
  8931. var whatIs = Utils.whatIs(params[idx]);
  8932. var param = (whatIs === "object" || whatIs === "null") ? JSON.stringify(params[idx]) : params[idx];
  8933. errorMessage = errorMessage.replace("{" + idx + "}", param);
  8934. }
  8935. var err = {
  8936. code: errorCode,
  8937. params: params,
  8938. message: errorMessage,
  8939. path: this.getPath(this.options.reportPathAsArray),
  8940. schemaId: this.getSchemaId()
  8941. };
  8942. err[Utils.schemaSymbol] = schema;
  8943. err[Utils.jsonSymbol] = this.getJson();
  8944. if (schema && typeof schema === "string") {
  8945. err.description = schema;
  8946. } else if (schema && typeof schema === "object") {
  8947. if (schema.title) {
  8948. err.title = schema.title;
  8949. }
  8950. if (schema.description) {
  8951. err.description = schema.description;
  8952. }
  8953. }
  8954. if (subReports != null) {
  8955. if (!Array.isArray(subReports)) {
  8956. subReports = [subReports];
  8957. }
  8958. err.inner = [];
  8959. idx = subReports.length;
  8960. while (idx--) {
  8961. var subReport = subReports[idx],
  8962. idx2 = subReport.errors.length;
  8963. while (idx2--) {
  8964. err.inner.push(subReport.errors[idx2]);
  8965. }
  8966. }
  8967. if (err.inner.length === 0) {
  8968. err.inner = undefined;
  8969. }
  8970. }
  8971. this.errors.push(err);
  8972. };
  8973. module.exports = Report;
  8974. }).call(this)}).call(this,require('_process'))
  8975. },{"./Errors":105,"./Utils":113,"_process":3,"lodash.get":1}],110:[function(require,module,exports){
  8976. "use strict";
  8977. var isequal = require("lodash.isequal");
  8978. var Report = require("./Report");
  8979. var SchemaCompilation = require("./SchemaCompilation");
  8980. var SchemaValidation = require("./SchemaValidation");
  8981. var Utils = require("./Utils");
  8982. function decodeJSONPointer(str) {
  8983. // http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07#section-3
  8984. return decodeURIComponent(str).replace(/~[0-1]/g, function (x) {
  8985. return x === "~1" ? "/" : "~";
  8986. });
  8987. }
  8988. function getRemotePath(uri) {
  8989. var io = uri.indexOf("#");
  8990. return io === -1 ? uri : uri.slice(0, io);
  8991. }
  8992. function getQueryPath(uri) {
  8993. var io = uri.indexOf("#");
  8994. var res = io === -1 ? undefined : uri.slice(io + 1);
  8995. // WARN: do not slice slash, #/ means take root and go down from it
  8996. // if (res && res[0] === "/") { res = res.slice(1); }
  8997. return res;
  8998. }
  8999. function findId(schema, id) {
  9000. // process only arrays and objects
  9001. if (typeof schema !== "object" || schema === null) {
  9002. return;
  9003. }
  9004. // no id means root so return itself
  9005. if (!id) {
  9006. return schema;
  9007. }
  9008. if (schema.id) {
  9009. if (schema.id === id || schema.id[0] === "#" && schema.id.substring(1) === id) {
  9010. return schema;
  9011. }
  9012. }
  9013. var idx, result;
  9014. if (Array.isArray(schema)) {
  9015. idx = schema.length;
  9016. while (idx--) {
  9017. result = findId(schema[idx], id);
  9018. if (result) { return result; }
  9019. }
  9020. } else {
  9021. var keys = Object.keys(schema);
  9022. idx = keys.length;
  9023. while (idx--) {
  9024. var k = keys[idx];
  9025. if (k.indexOf("__$") === 0) {
  9026. continue;
  9027. }
  9028. result = findId(schema[k], id);
  9029. if (result) { return result; }
  9030. }
  9031. }
  9032. }
  9033. /**
  9034. *
  9035. * @param {*} uri
  9036. * @param {*} schema
  9037. *
  9038. * @returns {void}
  9039. */
  9040. exports.cacheSchemaByUri = function (uri, schema) {
  9041. var remotePath = getRemotePath(uri);
  9042. if (remotePath) {
  9043. this.cache[remotePath] = schema;
  9044. }
  9045. };
  9046. /**
  9047. *
  9048. * @param {*} uri
  9049. *
  9050. * @returns {void}
  9051. */
  9052. exports.removeFromCacheByUri = function (uri) {
  9053. var remotePath = getRemotePath(uri);
  9054. if (remotePath) {
  9055. delete this.cache[remotePath];
  9056. }
  9057. };
  9058. /**
  9059. *
  9060. * @param {*} uri
  9061. *
  9062. * @returns {boolean}
  9063. */
  9064. exports.checkCacheForUri = function (uri) {
  9065. var remotePath = getRemotePath(uri);
  9066. return remotePath ? this.cache[remotePath] != null : false;
  9067. };
  9068. exports.getSchema = function (report, schema) {
  9069. if (typeof schema === "object") {
  9070. schema = exports.getSchemaByReference.call(this, report, schema);
  9071. }
  9072. if (typeof schema === "string") {
  9073. schema = exports.getSchemaByUri.call(this, report, schema);
  9074. }
  9075. return schema;
  9076. };
  9077. exports.getSchemaByReference = function (report, key) {
  9078. var i = this.referenceCache.length;
  9079. while (i--) {
  9080. if (isequal(this.referenceCache[i][0], key)) {
  9081. return this.referenceCache[i][1];
  9082. }
  9083. }
  9084. // not found
  9085. var schema = Utils.cloneDeep(key);
  9086. this.referenceCache.push([key, schema]);
  9087. return schema;
  9088. };
  9089. exports.getSchemaByUri = function (report, uri, root) {
  9090. var remotePath = getRemotePath(uri),
  9091. queryPath = getQueryPath(uri),
  9092. result = remotePath ? this.cache[remotePath] : root;
  9093. if (result && remotePath) {
  9094. // we need to avoid compiling schemas in a recursive loop
  9095. var compileRemote = result !== root;
  9096. // now we need to compile and validate resolved schema (in case it's not already)
  9097. if (compileRemote) {
  9098. report.path.push(remotePath);
  9099. var remoteReport;
  9100. var anscestorReport = report.getAncestor(result.id);
  9101. if (anscestorReport) {
  9102. remoteReport = anscestorReport;
  9103. } else {
  9104. remoteReport = new Report(report);
  9105. if (SchemaCompilation.compileSchema.call(this, remoteReport, result)) {
  9106. var savedOptions = this.options;
  9107. try {
  9108. // If custom validationOptions were provided to setRemoteReference(),
  9109. // use them instead of the default options
  9110. this.options = result.__$validationOptions || this.options;
  9111. SchemaValidation.validateSchema.call(this, remoteReport, result);
  9112. } finally {
  9113. this.options = savedOptions;
  9114. }
  9115. }
  9116. }
  9117. var remoteReportIsValid = remoteReport.isValid();
  9118. if (!remoteReportIsValid) {
  9119. report.addError("REMOTE_NOT_VALID", [uri], remoteReport);
  9120. }
  9121. report.path.pop();
  9122. if (!remoteReportIsValid) {
  9123. return undefined;
  9124. }
  9125. }
  9126. }
  9127. if (result && queryPath) {
  9128. var parts = queryPath.split("/");
  9129. for (var idx = 0, lim = parts.length; result && idx < lim; idx++) {
  9130. var key = decodeJSONPointer(parts[idx]);
  9131. if (idx === 0) { // it's an id
  9132. result = findId(result, key);
  9133. } else { // it's a path behind id
  9134. result = result[key];
  9135. }
  9136. }
  9137. }
  9138. return result;
  9139. };
  9140. exports.getRemotePath = getRemotePath;
  9141. },{"./Report":109,"./SchemaCompilation":111,"./SchemaValidation":112,"./Utils":113,"lodash.isequal":2}],111:[function(require,module,exports){
  9142. "use strict";
  9143. var Report = require("./Report");
  9144. var SchemaCache = require("./SchemaCache");
  9145. var Utils = require("./Utils");
  9146. function mergeReference(scope, ref) {
  9147. if (Utils.isAbsoluteUri(ref)) {
  9148. return ref;
  9149. }
  9150. var joinedScope = scope.join(""),
  9151. isScopeAbsolute = Utils.isAbsoluteUri(joinedScope),
  9152. isScopeRelative = Utils.isRelativeUri(joinedScope),
  9153. isRefRelative = Utils.isRelativeUri(ref),
  9154. toRemove;
  9155. if (isScopeAbsolute && isRefRelative) {
  9156. toRemove = joinedScope.match(/\/[^\/]*$/);
  9157. if (toRemove) {
  9158. joinedScope = joinedScope.slice(0, toRemove.index + 1);
  9159. }
  9160. } else if (isScopeRelative && isRefRelative) {
  9161. joinedScope = "";
  9162. } else {
  9163. toRemove = joinedScope.match(/[^#/]+$/);
  9164. if (toRemove) {
  9165. joinedScope = joinedScope.slice(0, toRemove.index);
  9166. }
  9167. }
  9168. var res = joinedScope + ref;
  9169. res = res.replace(/##/, "#");
  9170. return res;
  9171. }
  9172. function collectReferences(obj, results, scope, path) {
  9173. results = results || [];
  9174. scope = scope || [];
  9175. path = path || [];
  9176. if (typeof obj !== "object" || obj === null) {
  9177. return results;
  9178. }
  9179. if (typeof obj.id === "string") {
  9180. scope.push(obj.id);
  9181. }
  9182. if (typeof obj.$ref === "string" && typeof obj.__$refResolved === "undefined") {
  9183. results.push({
  9184. ref: mergeReference(scope, obj.$ref),
  9185. key: "$ref",
  9186. obj: obj,
  9187. path: path.slice(0)
  9188. });
  9189. }
  9190. if (typeof obj.$schema === "string" && typeof obj.__$schemaResolved === "undefined") {
  9191. results.push({
  9192. ref: mergeReference(scope, obj.$schema),
  9193. key: "$schema",
  9194. obj: obj,
  9195. path: path.slice(0)
  9196. });
  9197. }
  9198. var idx;
  9199. if (Array.isArray(obj)) {
  9200. idx = obj.length;
  9201. while (idx--) {
  9202. path.push(idx.toString());
  9203. collectReferences(obj[idx], results, scope, path);
  9204. path.pop();
  9205. }
  9206. } else {
  9207. var keys = Object.keys(obj);
  9208. idx = keys.length;
  9209. while (idx--) {
  9210. // do not recurse through resolved references and other z-schema props
  9211. if (keys[idx].indexOf("__$") === 0) { continue; }
  9212. path.push(keys[idx]);
  9213. collectReferences(obj[keys[idx]], results, scope, path);
  9214. path.pop();
  9215. }
  9216. }
  9217. if (typeof obj.id === "string") {
  9218. scope.pop();
  9219. }
  9220. return results;
  9221. }
  9222. var compileArrayOfSchemasLoop = function (mainReport, arr) {
  9223. var idx = arr.length,
  9224. compiledCount = 0;
  9225. while (idx--) {
  9226. // try to compile each schema separately
  9227. var report = new Report(mainReport);
  9228. var isValid = exports.compileSchema.call(this, report, arr[idx]);
  9229. if (isValid) { compiledCount++; }
  9230. // copy errors to report
  9231. mainReport.errors = mainReport.errors.concat(report.errors);
  9232. }
  9233. return compiledCount;
  9234. };
  9235. function findId(arr, id) {
  9236. var idx = arr.length;
  9237. while (idx--) {
  9238. if (arr[idx].id === id) {
  9239. return arr[idx];
  9240. }
  9241. }
  9242. return null;
  9243. }
  9244. var compileArrayOfSchemas = function (report, arr) {
  9245. var compiled = 0,
  9246. lastLoopCompiled;
  9247. do {
  9248. // remove all UNRESOLVABLE_REFERENCE errors before compiling array again
  9249. var idx = report.errors.length;
  9250. while (idx--) {
  9251. if (report.errors[idx].code === "UNRESOLVABLE_REFERENCE") {
  9252. report.errors.splice(idx, 1);
  9253. }
  9254. }
  9255. // remember how many were compiled in the last loop
  9256. lastLoopCompiled = compiled;
  9257. // count how many are compiled now
  9258. compiled = compileArrayOfSchemasLoop.call(this, report, arr);
  9259. // fix __$missingReferences if possible
  9260. idx = arr.length;
  9261. while (idx--) {
  9262. var sch = arr[idx];
  9263. if (sch.__$missingReferences) {
  9264. var idx2 = sch.__$missingReferences.length;
  9265. while (idx2--) {
  9266. var refObj = sch.__$missingReferences[idx2];
  9267. var response = findId(arr, refObj.ref);
  9268. if (response) {
  9269. // this might create circular references
  9270. refObj.obj["__" + refObj.key + "Resolved"] = response;
  9271. // it's resolved now so delete it
  9272. sch.__$missingReferences.splice(idx2, 1);
  9273. }
  9274. }
  9275. if (sch.__$missingReferences.length === 0) {
  9276. delete sch.__$missingReferences;
  9277. }
  9278. }
  9279. }
  9280. // keep repeating if not all compiled and at least one more was compiled in the last loop
  9281. } while (compiled !== arr.length && compiled !== lastLoopCompiled);
  9282. return report.isValid();
  9283. };
  9284. exports.compileSchema = function (report, schema) {
  9285. report.commonErrorMessage = "SCHEMA_COMPILATION_FAILED";
  9286. // if schema is a string, assume it's a uri
  9287. if (typeof schema === "string") {
  9288. var loadedSchema = SchemaCache.getSchemaByUri.call(this, report, schema);
  9289. if (!loadedSchema) {
  9290. report.addError("SCHEMA_NOT_REACHABLE", [schema]);
  9291. return false;
  9292. }
  9293. schema = loadedSchema;
  9294. }
  9295. // if schema is an array, assume it's an array of schemas
  9296. if (Array.isArray(schema)) {
  9297. return compileArrayOfSchemas.call(this, report, schema);
  9298. }
  9299. // if we have an id than it should be cached already (if this instance has compiled it)
  9300. if (schema.__$compiled && schema.id && SchemaCache.checkCacheForUri.call(this, schema.id) === false) {
  9301. schema.__$compiled = undefined;
  9302. }
  9303. // do not re-compile schemas
  9304. if (schema.__$compiled) {
  9305. return true;
  9306. }
  9307. if (schema.id && typeof schema.id === "string") {
  9308. // add this to our schemaCache (before compilation in case we have references including id)
  9309. SchemaCache.cacheSchemaByUri.call(this, schema.id, schema);
  9310. }
  9311. // this method can be called recursively, so we need to remember our root
  9312. var isRoot = false;
  9313. if (!report.rootSchema) {
  9314. report.rootSchema = schema;
  9315. isRoot = true;
  9316. }
  9317. // delete all __$missingReferences from previous compilation attempts
  9318. var isValidExceptReferences = report.isValid();
  9319. delete schema.__$missingReferences;
  9320. // collect all references that need to be resolved - $ref and $schema
  9321. var refs = collectReferences.call(this, schema),
  9322. idx = refs.length;
  9323. while (idx--) {
  9324. // resolve all the collected references into __xxxResolved pointer
  9325. var refObj = refs[idx];
  9326. var response = SchemaCache.getSchemaByUri.call(this, report, refObj.ref, schema);
  9327. // we can try to use custom schemaReader if available
  9328. if (!response) {
  9329. var schemaReader = this.getSchemaReader();
  9330. if (schemaReader) {
  9331. // it's supposed to return a valid schema
  9332. var s = schemaReader(refObj.ref);
  9333. if (s) {
  9334. // it needs to have the id
  9335. s.id = refObj.ref;
  9336. // try to compile the schema
  9337. var subreport = new Report(report);
  9338. if (!exports.compileSchema.call(this, subreport, s)) {
  9339. // copy errors to report
  9340. report.errors = report.errors.concat(subreport.errors);
  9341. } else {
  9342. response = SchemaCache.getSchemaByUri.call(this, report, refObj.ref, schema);
  9343. }
  9344. }
  9345. }
  9346. }
  9347. if (!response) {
  9348. var hasNotValid = report.hasError("REMOTE_NOT_VALID", [refObj.ref]);
  9349. var isAbsolute = Utils.isAbsoluteUri(refObj.ref);
  9350. var isDownloaded = false;
  9351. var ignoreUnresolvableRemotes = this.options.ignoreUnresolvableReferences === true;
  9352. if (isAbsolute) {
  9353. // we shouldn't add UNRESOLVABLE_REFERENCE for schemas we already have downloaded
  9354. // and set through setRemoteReference method
  9355. isDownloaded = SchemaCache.checkCacheForUri.call(this, refObj.ref);
  9356. }
  9357. if (hasNotValid) {
  9358. // already has REMOTE_NOT_VALID error for this one
  9359. } else if (ignoreUnresolvableRemotes && isAbsolute) {
  9360. // ignoreUnresolvableRemotes is on and remote isAbsolute
  9361. } else if (isDownloaded) {
  9362. // remote is downloaded, so no UNRESOLVABLE_REFERENCE
  9363. } else {
  9364. Array.prototype.push.apply(report.path, refObj.path);
  9365. report.addError("UNRESOLVABLE_REFERENCE", [refObj.ref]);
  9366. report.path = report.path.slice(0, -refObj.path.length);
  9367. // pusblish unresolved references out
  9368. if (isValidExceptReferences) {
  9369. schema.__$missingReferences = schema.__$missingReferences || [];
  9370. schema.__$missingReferences.push(refObj);
  9371. }
  9372. }
  9373. }
  9374. // this might create circular references
  9375. refObj.obj["__" + refObj.key + "Resolved"] = response;
  9376. }
  9377. var isValid = report.isValid();
  9378. if (isValid) {
  9379. schema.__$compiled = true;
  9380. } else {
  9381. if (schema.id && typeof schema.id === "string") {
  9382. // remove this schema from schemaCache because it failed to compile
  9383. SchemaCache.removeFromCacheByUri.call(this, schema.id);
  9384. }
  9385. }
  9386. // we don't need the root pointer anymore
  9387. if (isRoot) {
  9388. report.rootSchema = undefined;
  9389. }
  9390. return isValid;
  9391. };
  9392. },{"./Report":109,"./SchemaCache":110,"./Utils":113}],112:[function(require,module,exports){
  9393. "use strict";
  9394. var FormatValidators = require("./FormatValidators"),
  9395. JsonValidation = require("./JsonValidation"),
  9396. Report = require("./Report"),
  9397. Utils = require("./Utils");
  9398. var SchemaValidators = {
  9399. $ref: function (report, schema) {
  9400. // http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07
  9401. // http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03
  9402. if (typeof schema.$ref !== "string") {
  9403. report.addError("KEYWORD_TYPE_EXPECTED", ["$ref", "string"]);
  9404. }
  9405. },
  9406. $schema: function (report, schema) {
  9407. // http://json-schema.org/latest/json-schema-core.html#rfc.section.6
  9408. if (typeof schema.$schema !== "string") {
  9409. report.addError("KEYWORD_TYPE_EXPECTED", ["$schema", "string"]);
  9410. }
  9411. },
  9412. multipleOf: function (report, schema) {
  9413. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.1.1.1
  9414. if (typeof schema.multipleOf !== "number") {
  9415. report.addError("KEYWORD_TYPE_EXPECTED", ["multipleOf", "number"]);
  9416. } else if (schema.multipleOf <= 0) {
  9417. report.addError("KEYWORD_MUST_BE", ["multipleOf", "strictly greater than 0"]);
  9418. }
  9419. },
  9420. maximum: function (report, schema) {
  9421. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.1.2.1
  9422. if (typeof schema.maximum !== "number") {
  9423. report.addError("KEYWORD_TYPE_EXPECTED", ["maximum", "number"]);
  9424. }
  9425. },
  9426. exclusiveMaximum: function (report, schema) {
  9427. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.1.2.1
  9428. if (typeof schema.exclusiveMaximum !== "boolean") {
  9429. report.addError("KEYWORD_TYPE_EXPECTED", ["exclusiveMaximum", "boolean"]);
  9430. } else if (schema.maximum === undefined) {
  9431. report.addError("KEYWORD_DEPENDENCY", ["exclusiveMaximum", "maximum"]);
  9432. }
  9433. },
  9434. minimum: function (report, schema) {
  9435. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.1.3.1
  9436. if (typeof schema.minimum !== "number") {
  9437. report.addError("KEYWORD_TYPE_EXPECTED", ["minimum", "number"]);
  9438. }
  9439. },
  9440. exclusiveMinimum: function (report, schema) {
  9441. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.1.3.1
  9442. if (typeof schema.exclusiveMinimum !== "boolean") {
  9443. report.addError("KEYWORD_TYPE_EXPECTED", ["exclusiveMinimum", "boolean"]);
  9444. } else if (schema.minimum === undefined) {
  9445. report.addError("KEYWORD_DEPENDENCY", ["exclusiveMinimum", "minimum"]);
  9446. }
  9447. },
  9448. maxLength: function (report, schema) {
  9449. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.1.1
  9450. if (Utils.whatIs(schema.maxLength) !== "integer") {
  9451. report.addError("KEYWORD_TYPE_EXPECTED", ["maxLength", "integer"]);
  9452. } else if (schema.maxLength < 0) {
  9453. report.addError("KEYWORD_MUST_BE", ["maxLength", "greater than, or equal to 0"]);
  9454. }
  9455. },
  9456. minLength: function (report, schema) {
  9457. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.2.1
  9458. if (Utils.whatIs(schema.minLength) !== "integer") {
  9459. report.addError("KEYWORD_TYPE_EXPECTED", ["minLength", "integer"]);
  9460. } else if (schema.minLength < 0) {
  9461. report.addError("KEYWORD_MUST_BE", ["minLength", "greater than, or equal to 0"]);
  9462. }
  9463. },
  9464. pattern: function (report, schema) {
  9465. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.3.1
  9466. if (typeof schema.pattern !== "string") {
  9467. report.addError("KEYWORD_TYPE_EXPECTED", ["pattern", "string"]);
  9468. } else {
  9469. try {
  9470. RegExp(schema.pattern);
  9471. } catch (e) {
  9472. report.addError("KEYWORD_PATTERN", ["pattern", schema.pattern]);
  9473. }
  9474. }
  9475. },
  9476. additionalItems: function (report, schema) {
  9477. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.3.1.1
  9478. var type = Utils.whatIs(schema.additionalItems);
  9479. if (type !== "boolean" && type !== "object") {
  9480. report.addError("KEYWORD_TYPE_EXPECTED", ["additionalItems", ["boolean", "object"]]);
  9481. } else if (type === "object") {
  9482. report.path.push("additionalItems");
  9483. exports.validateSchema.call(this, report, schema.additionalItems);
  9484. report.path.pop();
  9485. }
  9486. },
  9487. items: function (report, schema) {
  9488. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.3.1.1
  9489. var type = Utils.whatIs(schema.items);
  9490. if (type === "object") {
  9491. report.path.push("items");
  9492. exports.validateSchema.call(this, report, schema.items);
  9493. report.path.pop();
  9494. } else if (type === "array") {
  9495. var idx = schema.items.length;
  9496. while (idx--) {
  9497. report.path.push("items");
  9498. report.path.push(idx.toString());
  9499. exports.validateSchema.call(this, report, schema.items[idx]);
  9500. report.path.pop();
  9501. report.path.pop();
  9502. }
  9503. } else {
  9504. report.addError("KEYWORD_TYPE_EXPECTED", ["items", ["array", "object"]]);
  9505. }
  9506. // custom - strict mode
  9507. if (this.options.forceAdditional === true && schema.additionalItems === undefined && Array.isArray(schema.items)) {
  9508. report.addError("KEYWORD_UNDEFINED_STRICT", ["additionalItems"]);
  9509. }
  9510. // custome - assume defined false mode
  9511. if (this.options.assumeAdditional && schema.additionalItems === undefined && Array.isArray(schema.items)) {
  9512. schema.additionalItems = false;
  9513. }
  9514. },
  9515. maxItems: function (report, schema) {
  9516. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.3.2.1
  9517. if (typeof schema.maxItems !== "number") {
  9518. report.addError("KEYWORD_TYPE_EXPECTED", ["maxItems", "integer"]);
  9519. } else if (schema.maxItems < 0) {
  9520. report.addError("KEYWORD_MUST_BE", ["maxItems", "greater than, or equal to 0"]);
  9521. }
  9522. },
  9523. minItems: function (report, schema) {
  9524. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.3.3.1
  9525. if (Utils.whatIs(schema.minItems) !== "integer") {
  9526. report.addError("KEYWORD_TYPE_EXPECTED", ["minItems", "integer"]);
  9527. } else if (schema.minItems < 0) {
  9528. report.addError("KEYWORD_MUST_BE", ["minItems", "greater than, or equal to 0"]);
  9529. }
  9530. },
  9531. uniqueItems: function (report, schema) {
  9532. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.3.4.1
  9533. if (typeof schema.uniqueItems !== "boolean") {
  9534. report.addError("KEYWORD_TYPE_EXPECTED", ["uniqueItems", "boolean"]);
  9535. }
  9536. },
  9537. maxProperties: function (report, schema) {
  9538. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.1.1
  9539. if (Utils.whatIs(schema.maxProperties) !== "integer") {
  9540. report.addError("KEYWORD_TYPE_EXPECTED", ["maxProperties", "integer"]);
  9541. } else if (schema.maxProperties < 0) {
  9542. report.addError("KEYWORD_MUST_BE", ["maxProperties", "greater than, or equal to 0"]);
  9543. }
  9544. },
  9545. minProperties: function (report, schema) {
  9546. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.2.1
  9547. if (Utils.whatIs(schema.minProperties) !== "integer") {
  9548. report.addError("KEYWORD_TYPE_EXPECTED", ["minProperties", "integer"]);
  9549. } else if (schema.minProperties < 0) {
  9550. report.addError("KEYWORD_MUST_BE", ["minProperties", "greater than, or equal to 0"]);
  9551. }
  9552. },
  9553. required: function (report, schema) {
  9554. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.3.1
  9555. if (Utils.whatIs(schema.required) !== "array") {
  9556. report.addError("KEYWORD_TYPE_EXPECTED", ["required", "array"]);
  9557. } else if (schema.required.length === 0) {
  9558. report.addError("KEYWORD_MUST_BE", ["required", "an array with at least one element"]);
  9559. } else {
  9560. var idx = schema.required.length;
  9561. while (idx--) {
  9562. if (typeof schema.required[idx] !== "string") {
  9563. report.addError("KEYWORD_VALUE_TYPE", ["required", "string"]);
  9564. }
  9565. }
  9566. if (Utils.isUniqueArray(schema.required) === false) {
  9567. report.addError("KEYWORD_MUST_BE", ["required", "an array with unique items"]);
  9568. }
  9569. }
  9570. },
  9571. additionalProperties: function (report, schema) {
  9572. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.4.1
  9573. var type = Utils.whatIs(schema.additionalProperties);
  9574. if (type !== "boolean" && type !== "object") {
  9575. report.addError("KEYWORD_TYPE_EXPECTED", ["additionalProperties", ["boolean", "object"]]);
  9576. } else if (type === "object") {
  9577. report.path.push("additionalProperties");
  9578. exports.validateSchema.call(this, report, schema.additionalProperties);
  9579. report.path.pop();
  9580. }
  9581. },
  9582. properties: function (report, schema) {
  9583. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.4.1
  9584. if (Utils.whatIs(schema.properties) !== "object") {
  9585. report.addError("KEYWORD_TYPE_EXPECTED", ["properties", "object"]);
  9586. return;
  9587. }
  9588. var keys = Object.keys(schema.properties),
  9589. idx = keys.length;
  9590. while (idx--) {
  9591. var key = keys[idx],
  9592. val = schema.properties[key];
  9593. report.path.push("properties");
  9594. report.path.push(key);
  9595. exports.validateSchema.call(this, report, val);
  9596. report.path.pop();
  9597. report.path.pop();
  9598. }
  9599. // custom - strict mode
  9600. if (this.options.forceAdditional === true && schema.additionalProperties === undefined) {
  9601. report.addError("KEYWORD_UNDEFINED_STRICT", ["additionalProperties"]);
  9602. }
  9603. // custome - assume defined false mode
  9604. if (this.options.assumeAdditional && schema.additionalProperties === undefined) {
  9605. schema.additionalProperties = false;
  9606. }
  9607. // custom - forceProperties
  9608. if (this.options.forceProperties === true && keys.length === 0) {
  9609. report.addError("CUSTOM_MODE_FORCE_PROPERTIES", ["properties"]);
  9610. }
  9611. },
  9612. patternProperties: function (report, schema) {
  9613. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.4.1
  9614. if (Utils.whatIs(schema.patternProperties) !== "object") {
  9615. report.addError("KEYWORD_TYPE_EXPECTED", ["patternProperties", "object"]);
  9616. return;
  9617. }
  9618. var keys = Object.keys(schema.patternProperties),
  9619. idx = keys.length;
  9620. while (idx--) {
  9621. var key = keys[idx],
  9622. val = schema.patternProperties[key];
  9623. try {
  9624. RegExp(key);
  9625. } catch (e) {
  9626. report.addError("KEYWORD_PATTERN", ["patternProperties", key]);
  9627. }
  9628. report.path.push("patternProperties");
  9629. report.path.push(key.toString());
  9630. exports.validateSchema.call(this, report, val);
  9631. report.path.pop();
  9632. report.path.pop();
  9633. }
  9634. // custom - forceProperties
  9635. if (this.options.forceProperties === true && keys.length === 0) {
  9636. report.addError("CUSTOM_MODE_FORCE_PROPERTIES", ["patternProperties"]);
  9637. }
  9638. },
  9639. dependencies: function (report, schema) {
  9640. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.5.1
  9641. if (Utils.whatIs(schema.dependencies) !== "object") {
  9642. report.addError("KEYWORD_TYPE_EXPECTED", ["dependencies", "object"]);
  9643. } else {
  9644. var keys = Object.keys(schema.dependencies),
  9645. idx = keys.length;
  9646. while (idx--) {
  9647. var schemaKey = keys[idx],
  9648. schemaDependency = schema.dependencies[schemaKey],
  9649. type = Utils.whatIs(schemaDependency);
  9650. if (type === "object") {
  9651. report.path.push("dependencies");
  9652. report.path.push(schemaKey);
  9653. exports.validateSchema.call(this, report, schemaDependency);
  9654. report.path.pop();
  9655. report.path.pop();
  9656. } else if (type === "array") {
  9657. var idx2 = schemaDependency.length;
  9658. if (idx2 === 0) {
  9659. report.addError("KEYWORD_MUST_BE", ["dependencies", "not empty array"]);
  9660. }
  9661. while (idx2--) {
  9662. if (typeof schemaDependency[idx2] !== "string") {
  9663. report.addError("KEYWORD_VALUE_TYPE", ["dependensices", "string"]);
  9664. }
  9665. }
  9666. if (Utils.isUniqueArray(schemaDependency) === false) {
  9667. report.addError("KEYWORD_MUST_BE", ["dependencies", "an array with unique items"]);
  9668. }
  9669. } else {
  9670. report.addError("KEYWORD_VALUE_TYPE", ["dependencies", "object or array"]);
  9671. }
  9672. }
  9673. }
  9674. },
  9675. enum: function (report, schema) {
  9676. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.1.1
  9677. if (Array.isArray(schema.enum) === false) {
  9678. report.addError("KEYWORD_TYPE_EXPECTED", ["enum", "array"]);
  9679. } else if (schema.enum.length === 0) {
  9680. report.addError("KEYWORD_MUST_BE", ["enum", "an array with at least one element"]);
  9681. } else if (Utils.isUniqueArray(schema.enum) === false) {
  9682. report.addError("KEYWORD_MUST_BE", ["enum", "an array with unique elements"]);
  9683. }
  9684. },
  9685. type: function (report, schema) {
  9686. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.2.1
  9687. var primitiveTypes = ["array", "boolean", "integer", "number", "null", "object", "string"],
  9688. primitiveTypeStr = primitiveTypes.join(","),
  9689. isArray = Array.isArray(schema.type);
  9690. if (isArray) {
  9691. var idx = schema.type.length;
  9692. while (idx--) {
  9693. if (primitiveTypes.indexOf(schema.type[idx]) === -1) {
  9694. report.addError("KEYWORD_TYPE_EXPECTED", ["type", primitiveTypeStr]);
  9695. }
  9696. }
  9697. if (Utils.isUniqueArray(schema.type) === false) {
  9698. report.addError("KEYWORD_MUST_BE", ["type", "an object with unique properties"]);
  9699. }
  9700. } else if (typeof schema.type === "string") {
  9701. if (primitiveTypes.indexOf(schema.type) === -1) {
  9702. report.addError("KEYWORD_TYPE_EXPECTED", ["type", primitiveTypeStr]);
  9703. }
  9704. } else {
  9705. report.addError("KEYWORD_TYPE_EXPECTED", ["type", ["string", "array"]]);
  9706. }
  9707. if (this.options.noEmptyStrings === true) {
  9708. if (schema.type === "string" || isArray && schema.type.indexOf("string") !== -1) {
  9709. if (schema.minLength === undefined &&
  9710. schema.enum === undefined &&
  9711. schema.format === undefined) {
  9712. schema.minLength = 1;
  9713. }
  9714. }
  9715. }
  9716. if (this.options.noEmptyArrays === true) {
  9717. if (schema.type === "array" || isArray && schema.type.indexOf("array") !== -1) {
  9718. if (schema.minItems === undefined) {
  9719. schema.minItems = 1;
  9720. }
  9721. }
  9722. }
  9723. if (this.options.forceProperties === true) {
  9724. if (schema.type === "object" || isArray && schema.type.indexOf("object") !== -1) {
  9725. if (schema.properties === undefined && schema.patternProperties === undefined) {
  9726. report.addError("KEYWORD_UNDEFINED_STRICT", ["properties"]);
  9727. }
  9728. }
  9729. }
  9730. if (this.options.forceItems === true) {
  9731. if (schema.type === "array" || isArray && schema.type.indexOf("array") !== -1) {
  9732. if (schema.items === undefined) {
  9733. report.addError("KEYWORD_UNDEFINED_STRICT", ["items"]);
  9734. }
  9735. }
  9736. }
  9737. if (this.options.forceMinItems === true) {
  9738. if (schema.type === "array" || isArray && schema.type.indexOf("array") !== -1) {
  9739. if (schema.minItems === undefined) {
  9740. report.addError("KEYWORD_UNDEFINED_STRICT", ["minItems"]);
  9741. }
  9742. }
  9743. }
  9744. if (this.options.forceMaxItems === true) {
  9745. if (schema.type === "array" || isArray && schema.type.indexOf("array") !== -1) {
  9746. if (schema.maxItems === undefined) {
  9747. report.addError("KEYWORD_UNDEFINED_STRICT", ["maxItems"]);
  9748. }
  9749. }
  9750. }
  9751. if (this.options.forceMinLength === true) {
  9752. if (schema.type === "string" || isArray && schema.type.indexOf("string") !== -1) {
  9753. if (schema.minLength === undefined &&
  9754. schema.format === undefined &&
  9755. schema.enum === undefined &&
  9756. schema.pattern === undefined) {
  9757. report.addError("KEYWORD_UNDEFINED_STRICT", ["minLength"]);
  9758. }
  9759. }
  9760. }
  9761. if (this.options.forceMaxLength === true) {
  9762. if (schema.type === "string" || isArray && schema.type.indexOf("string") !== -1) {
  9763. if (schema.maxLength === undefined &&
  9764. schema.format === undefined &&
  9765. schema.enum === undefined &&
  9766. schema.pattern === undefined) {
  9767. report.addError("KEYWORD_UNDEFINED_STRICT", ["maxLength"]);
  9768. }
  9769. }
  9770. }
  9771. },
  9772. allOf: function (report, schema) {
  9773. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.3.1
  9774. if (Array.isArray(schema.allOf) === false) {
  9775. report.addError("KEYWORD_TYPE_EXPECTED", ["allOf", "array"]);
  9776. } else if (schema.allOf.length === 0) {
  9777. report.addError("KEYWORD_MUST_BE", ["allOf", "an array with at least one element"]);
  9778. } else {
  9779. var idx = schema.allOf.length;
  9780. while (idx--) {
  9781. report.path.push("allOf");
  9782. report.path.push(idx.toString());
  9783. exports.validateSchema.call(this, report, schema.allOf[idx]);
  9784. report.path.pop();
  9785. report.path.pop();
  9786. }
  9787. }
  9788. },
  9789. anyOf: function (report, schema) {
  9790. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.4.1
  9791. if (Array.isArray(schema.anyOf) === false) {
  9792. report.addError("KEYWORD_TYPE_EXPECTED", ["anyOf", "array"]);
  9793. } else if (schema.anyOf.length === 0) {
  9794. report.addError("KEYWORD_MUST_BE", ["anyOf", "an array with at least one element"]);
  9795. } else {
  9796. var idx = schema.anyOf.length;
  9797. while (idx--) {
  9798. report.path.push("anyOf");
  9799. report.path.push(idx.toString());
  9800. exports.validateSchema.call(this, report, schema.anyOf[idx]);
  9801. report.path.pop();
  9802. report.path.pop();
  9803. }
  9804. }
  9805. },
  9806. oneOf: function (report, schema) {
  9807. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.5.1
  9808. if (Array.isArray(schema.oneOf) === false) {
  9809. report.addError("KEYWORD_TYPE_EXPECTED", ["oneOf", "array"]);
  9810. } else if (schema.oneOf.length === 0) {
  9811. report.addError("KEYWORD_MUST_BE", ["oneOf", "an array with at least one element"]);
  9812. } else {
  9813. var idx = schema.oneOf.length;
  9814. while (idx--) {
  9815. report.path.push("oneOf");
  9816. report.path.push(idx.toString());
  9817. exports.validateSchema.call(this, report, schema.oneOf[idx]);
  9818. report.path.pop();
  9819. report.path.pop();
  9820. }
  9821. }
  9822. },
  9823. not: function (report, schema) {
  9824. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.6.1
  9825. if (Utils.whatIs(schema.not) !== "object") {
  9826. report.addError("KEYWORD_TYPE_EXPECTED", ["not", "object"]);
  9827. } else {
  9828. report.path.push("not");
  9829. exports.validateSchema.call(this, report, schema.not);
  9830. report.path.pop();
  9831. }
  9832. },
  9833. definitions: function (report, schema) {
  9834. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.7.1
  9835. if (Utils.whatIs(schema.definitions) !== "object") {
  9836. report.addError("KEYWORD_TYPE_EXPECTED", ["definitions", "object"]);
  9837. } else {
  9838. var keys = Object.keys(schema.definitions),
  9839. idx = keys.length;
  9840. while (idx--) {
  9841. var key = keys[idx],
  9842. val = schema.definitions[key];
  9843. report.path.push("definitions");
  9844. report.path.push(key);
  9845. exports.validateSchema.call(this, report, val);
  9846. report.path.pop();
  9847. report.path.pop();
  9848. }
  9849. }
  9850. },
  9851. format: function (report, schema) {
  9852. if (typeof schema.format !== "string") {
  9853. report.addError("KEYWORD_TYPE_EXPECTED", ["format", "string"]);
  9854. } else {
  9855. if (FormatValidators[schema.format] === undefined && this.options.ignoreUnknownFormats !== true) {
  9856. report.addError("UNKNOWN_FORMAT", [schema.format]);
  9857. }
  9858. }
  9859. },
  9860. id: function (report, schema) {
  9861. // http://json-schema.org/latest/json-schema-core.html#rfc.section.7.2
  9862. if (typeof schema.id !== "string") {
  9863. report.addError("KEYWORD_TYPE_EXPECTED", ["id", "string"]);
  9864. }
  9865. },
  9866. title: function (report, schema) {
  9867. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1
  9868. if (typeof schema.title !== "string") {
  9869. report.addError("KEYWORD_TYPE_EXPECTED", ["title", "string"]);
  9870. }
  9871. },
  9872. description: function (report, schema) {
  9873. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1
  9874. if (typeof schema.description !== "string") {
  9875. report.addError("KEYWORD_TYPE_EXPECTED", ["description", "string"]);
  9876. }
  9877. },
  9878. "default": function (/* report, schema */) {
  9879. // http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2
  9880. // There are no restrictions placed on the value of this keyword.
  9881. }
  9882. };
  9883. /**
  9884. *
  9885. * @param {Report} report
  9886. * @param {*[]} arr
  9887. *
  9888. * @returns {boolean}
  9889. */
  9890. var validateArrayOfSchemas = function (report, arr) {
  9891. var idx = arr.length;
  9892. while (idx--) {
  9893. exports.validateSchema.call(this, report, arr[idx]);
  9894. }
  9895. return report.isValid();
  9896. };
  9897. /**
  9898. *
  9899. * @param {Report} report
  9900. * @param {*} schema
  9901. */
  9902. exports.validateSchema = function (report, schema) {
  9903. report.commonErrorMessage = "SCHEMA_VALIDATION_FAILED";
  9904. // if schema is an array, assume it's an array of schemas
  9905. if (Array.isArray(schema)) {
  9906. return validateArrayOfSchemas.call(this, report, schema);
  9907. }
  9908. // do not revalidate schema that has already been validated once
  9909. if (schema.__$validated) {
  9910. return true;
  9911. }
  9912. // if $schema is present, this schema should validate against that $schema
  9913. var hasParentSchema = schema.$schema && schema.id !== schema.$schema;
  9914. if (hasParentSchema) {
  9915. if (schema.__$schemaResolved && schema.__$schemaResolved !== schema) {
  9916. var subReport = new Report(report);
  9917. var valid = JsonValidation.validate.call(this, subReport, schema.__$schemaResolved, schema);
  9918. if (valid === false) {
  9919. report.addError("PARENT_SCHEMA_VALIDATION_FAILED", null, subReport);
  9920. }
  9921. } else {
  9922. if (this.options.ignoreUnresolvableReferences !== true) {
  9923. report.addError("REF_UNRESOLVED", [schema.$schema]);
  9924. }
  9925. }
  9926. }
  9927. if (this.options.noTypeless === true) {
  9928. // issue #36 - inherit type to anyOf, oneOf, allOf if noTypeless is defined
  9929. if (schema.type !== undefined) {
  9930. var schemas = [];
  9931. if (Array.isArray(schema.anyOf)) { schemas = schemas.concat(schema.anyOf); }
  9932. if (Array.isArray(schema.oneOf)) { schemas = schemas.concat(schema.oneOf); }
  9933. if (Array.isArray(schema.allOf)) { schemas = schemas.concat(schema.allOf); }
  9934. schemas.forEach(function (sch) {
  9935. if (!sch.type) { sch.type = schema.type; }
  9936. });
  9937. }
  9938. // end issue #36
  9939. if (schema.enum === undefined &&
  9940. schema.type === undefined &&
  9941. schema.anyOf === undefined &&
  9942. schema.oneOf === undefined &&
  9943. schema.not === undefined &&
  9944. schema.$ref === undefined) {
  9945. report.addError("KEYWORD_UNDEFINED_STRICT", ["type"]);
  9946. }
  9947. }
  9948. var keys = Object.keys(schema),
  9949. idx = keys.length;
  9950. while (idx--) {
  9951. var key = keys[idx];
  9952. if (key.indexOf("__") === 0) { continue; }
  9953. if (SchemaValidators[key] !== undefined) {
  9954. SchemaValidators[key].call(this, report, schema);
  9955. } else if (!hasParentSchema) {
  9956. if (this.options.noExtraKeywords === true) {
  9957. report.addError("KEYWORD_UNEXPECTED", [key]);
  9958. }
  9959. }
  9960. }
  9961. if (this.options.pedanticCheck === true) {
  9962. if (schema.enum) {
  9963. // break recursion
  9964. var tmpSchema = Utils.clone(schema);
  9965. delete tmpSchema.enum;
  9966. delete tmpSchema.default;
  9967. report.path.push("enum");
  9968. idx = schema.enum.length;
  9969. while (idx--) {
  9970. report.path.push(idx.toString());
  9971. JsonValidation.validate.call(this, report, tmpSchema, schema.enum[idx]);
  9972. report.path.pop();
  9973. }
  9974. report.path.pop();
  9975. }
  9976. if (schema.default) {
  9977. report.path.push("default");
  9978. JsonValidation.validate.call(this, report, schema, schema.default);
  9979. report.path.pop();
  9980. }
  9981. }
  9982. var isValid = report.isValid();
  9983. if (isValid) {
  9984. schema.__$validated = true;
  9985. }
  9986. return isValid;
  9987. };
  9988. },{"./FormatValidators":106,"./JsonValidation":107,"./Report":109,"./Utils":113}],113:[function(require,module,exports){
  9989. "use strict";
  9990. exports.jsonSymbol = Symbol.for("z-schema/json");
  9991. exports.schemaSymbol = Symbol.for("z-schema/schema");
  9992. /**
  9993. * @param {object} obj
  9994. *
  9995. * @returns {string[]}
  9996. */
  9997. var sortedKeys = exports.sortedKeys = function (obj) {
  9998. return Object.keys(obj).sort();
  9999. };
  10000. /**
  10001. *
  10002. * @param {string} uri
  10003. *
  10004. * @returns {boolean}
  10005. */
  10006. exports.isAbsoluteUri = function (uri) {
  10007. return /^https?:\/\//.test(uri);
  10008. };
  10009. /**
  10010. *
  10011. * @param {string} uri
  10012. *
  10013. * @returns {boolean}
  10014. */
  10015. exports.isRelativeUri = function (uri) {
  10016. // relative URIs that end with a hash sign, issue #56
  10017. return /.+#/.test(uri);
  10018. };
  10019. exports.whatIs = function (what) {
  10020. var to = typeof what;
  10021. if (to === "object") {
  10022. if (what === null) {
  10023. return "null";
  10024. }
  10025. if (Array.isArray(what)) {
  10026. return "array";
  10027. }
  10028. return "object"; // typeof what === 'object' && what === Object(what) && !Array.isArray(what);
  10029. }
  10030. if (to === "number") {
  10031. if (Number.isFinite(what)) {
  10032. if (what % 1 === 0) {
  10033. return "integer";
  10034. } else {
  10035. return "number";
  10036. }
  10037. }
  10038. if (Number.isNaN(what)) {
  10039. return "not-a-number";
  10040. }
  10041. return "unknown-number";
  10042. }
  10043. return to; // undefined, boolean, string, function
  10044. };
  10045. /**
  10046. *
  10047. * @param {*} json1
  10048. * @param {*} json2
  10049. * @param {*} [options]
  10050. *
  10051. * @returns {boolean}
  10052. */
  10053. exports.areEqual = function areEqual(json1, json2, options) {
  10054. options = options || {};
  10055. var caseInsensitiveComparison = options.caseInsensitiveComparison || false;
  10056. // http://json-schema.org/latest/json-schema-core.html#rfc.section.3.6
  10057. // Two JSON values are said to be equal if and only if:
  10058. // both are nulls; or
  10059. // both are booleans, and have the same value; or
  10060. // both are strings, and have the same value; or
  10061. // both are numbers, and have the same mathematical value; or
  10062. if (json1 === json2) {
  10063. return true;
  10064. }
  10065. if (
  10066. caseInsensitiveComparison === true &&
  10067. typeof json1 === "string" && typeof json2 === "string" &&
  10068. json1.toUpperCase() === json2.toUpperCase()) {
  10069. return true;
  10070. }
  10071. var i, len;
  10072. // both are arrays, and:
  10073. if (Array.isArray(json1) && Array.isArray(json2)) {
  10074. // have the same number of items; and
  10075. if (json1.length !== json2.length) {
  10076. return false;
  10077. }
  10078. // items at the same index are equal according to this definition; or
  10079. len = json1.length;
  10080. for (i = 0; i < len; i++) {
  10081. if (!areEqual(json1[i], json2[i], { caseInsensitiveComparison: caseInsensitiveComparison })) {
  10082. return false;
  10083. }
  10084. }
  10085. return true;
  10086. }
  10087. // both are objects, and:
  10088. if (exports.whatIs(json1) === "object" && exports.whatIs(json2) === "object") {
  10089. // have the same set of property names; and
  10090. var keys1 = sortedKeys(json1);
  10091. var keys2 = sortedKeys(json2);
  10092. if (!areEqual(keys1, keys2, { caseInsensitiveComparison: caseInsensitiveComparison })) {
  10093. return false;
  10094. }
  10095. // values for a same property name are equal according to this definition.
  10096. len = keys1.length;
  10097. for (i = 0; i < len; i++) {
  10098. if (!areEqual(json1[keys1[i]], json2[keys1[i]], { caseInsensitiveComparison: caseInsensitiveComparison })) {
  10099. return false;
  10100. }
  10101. }
  10102. return true;
  10103. }
  10104. return false;
  10105. };
  10106. /**
  10107. *
  10108. * @param {*[]} arr
  10109. * @param {number[]} [indexes]
  10110. *
  10111. * @returns {boolean}
  10112. */
  10113. exports.isUniqueArray = function (arr, indexes) {
  10114. var i, j, l = arr.length;
  10115. for (i = 0; i < l; i++) {
  10116. for (j = i + 1; j < l; j++) {
  10117. if (exports.areEqual(arr[i], arr[j])) {
  10118. if (indexes) { indexes.push(i, j); }
  10119. return false;
  10120. }
  10121. }
  10122. }
  10123. return true;
  10124. };
  10125. /**
  10126. *
  10127. * @param {*} bigSet
  10128. * @param {*} subSet
  10129. *
  10130. * @returns {*[]}
  10131. */
  10132. exports.difference = function (bigSet, subSet) {
  10133. var arr = [],
  10134. idx = bigSet.length;
  10135. while (idx--) {
  10136. if (subSet.indexOf(bigSet[idx]) === -1) {
  10137. arr.push(bigSet[idx]);
  10138. }
  10139. }
  10140. return arr;
  10141. };
  10142. // NOT a deep version of clone
  10143. exports.clone = function (src) {
  10144. if (typeof src === "undefined") { return void 0; }
  10145. if (typeof src !== "object" || src === null) { return src; }
  10146. var res, idx;
  10147. if (Array.isArray(src)) {
  10148. res = [];
  10149. idx = src.length;
  10150. while (idx--) {
  10151. res[idx] = src[idx];
  10152. }
  10153. } else {
  10154. res = {};
  10155. var keys = Object.keys(src);
  10156. idx = keys.length;
  10157. while (idx--) {
  10158. var key = keys[idx];
  10159. res[key] = src[key];
  10160. }
  10161. }
  10162. return res;
  10163. };
  10164. exports.cloneDeep = function (src) {
  10165. var vidx = 0, visited = new Map(), cloned = [];
  10166. function cloneDeep(src) {
  10167. if (typeof src !== "object" || src === null) { return src; }
  10168. var res, idx, cidx;
  10169. cidx = visited.get(src);
  10170. if (cidx !== undefined) { return cloned[cidx]; }
  10171. visited.set(src, vidx++);
  10172. if (Array.isArray(src)) {
  10173. res = [];
  10174. cloned.push(res);
  10175. idx = src.length;
  10176. while (idx--) {
  10177. res[idx] = cloneDeep(src[idx]);
  10178. }
  10179. } else {
  10180. res = {};
  10181. cloned.push(res);
  10182. var keys = Object.keys(src);
  10183. idx = keys.length;
  10184. while (idx--) {
  10185. var key = keys[idx];
  10186. res[key] = cloneDeep(src[key]);
  10187. }
  10188. }
  10189. return res;
  10190. }
  10191. return cloneDeep(src);
  10192. };
  10193. /*
  10194. following function comes from punycode.js library
  10195. see: https://github.com/bestiejs/punycode.js
  10196. */
  10197. /*jshint -W016*/
  10198. /**
  10199. * Creates an array containing the numeric code points of each Unicode
  10200. * character in the string. While JavaScript uses UCS-2 internally,
  10201. * this function will convert a pair of surrogate halves (each of which
  10202. * UCS-2 exposes as separate characters) into a single code point,
  10203. * matching UTF-16.
  10204. * @see `punycode.ucs2.encode`
  10205. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  10206. * @memberOf punycode.ucs2
  10207. * @name decode
  10208. * @param {String} string The Unicode input string (UCS-2).
  10209. * @returns {Array} The new array of code points.
  10210. */
  10211. exports.ucs2decode = function (string) {
  10212. var output = [],
  10213. counter = 0,
  10214. length = string.length,
  10215. value,
  10216. extra;
  10217. while (counter < length) {
  10218. value = string.charCodeAt(counter++);
  10219. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  10220. // high surrogate, and there is a next character
  10221. extra = string.charCodeAt(counter++);
  10222. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  10223. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  10224. } else {
  10225. // unmatched surrogate; only append this code unit, in case the next
  10226. // code unit is the high surrogate of a surrogate pair
  10227. output.push(value);
  10228. counter--;
  10229. }
  10230. } else {
  10231. output.push(value);
  10232. }
  10233. }
  10234. return output;
  10235. };
  10236. /*jshint +W016*/
  10237. },{}],114:[function(require,module,exports){
  10238. (function (process){(function (){
  10239. "use strict";
  10240. require("./Polyfills");
  10241. var get = require("lodash.get");
  10242. var Report = require("./Report");
  10243. var FormatValidators = require("./FormatValidators");
  10244. var JsonValidation = require("./JsonValidation");
  10245. var SchemaCache = require("./SchemaCache");
  10246. var SchemaCompilation = require("./SchemaCompilation");
  10247. var SchemaValidation = require("./SchemaValidation");
  10248. var Utils = require("./Utils");
  10249. var Draft4Schema = require("./schemas/schema.json");
  10250. var Draft4HyperSchema = require("./schemas/hyper-schema.json");
  10251. /**
  10252. * default options
  10253. */
  10254. var defaultOptions = {
  10255. // default timeout for all async tasks
  10256. asyncTimeout: 2000,
  10257. // force additionalProperties and additionalItems to be defined on "object" and "array" types
  10258. forceAdditional: false,
  10259. // assume additionalProperties and additionalItems are defined as "false" where appropriate
  10260. assumeAdditional: false,
  10261. // do case insensitive comparison for enums
  10262. enumCaseInsensitiveComparison: false,
  10263. // force items to be defined on "array" types
  10264. forceItems: false,
  10265. // force minItems to be defined on "array" types
  10266. forceMinItems: false,
  10267. // force maxItems to be defined on "array" types
  10268. forceMaxItems: false,
  10269. // force minLength to be defined on "string" types
  10270. forceMinLength: false,
  10271. // force maxLength to be defined on "string" types
  10272. forceMaxLength: false,
  10273. // force properties or patternProperties to be defined on "object" types
  10274. forceProperties: false,
  10275. // ignore references that cannot be resolved (remote schemas) // TODO: make sure this is only for remote schemas, not local ones
  10276. ignoreUnresolvableReferences: false,
  10277. // disallow usage of keywords that this validator can't handle
  10278. noExtraKeywords: false,
  10279. // disallow usage of schema's without "type" defined
  10280. noTypeless: false,
  10281. // disallow zero length strings in validated objects
  10282. noEmptyStrings: false,
  10283. // disallow zero length arrays in validated objects
  10284. noEmptyArrays: false,
  10285. // forces "uri" format to be in fully rfc3986 compliant
  10286. strictUris: false,
  10287. // turn on some of the above
  10288. strictMode: false,
  10289. // report error paths as an array of path segments to get to the offending node
  10290. reportPathAsArray: false,
  10291. // stop validation as soon as an error is found
  10292. breakOnFirstError: false,
  10293. // check if schema follows best practices and common sense
  10294. pedanticCheck: false,
  10295. // ignore unknown formats (do not report them as an error)
  10296. ignoreUnknownFormats: false,
  10297. // function to be called on every schema
  10298. customValidator: null
  10299. };
  10300. function normalizeOptions(options) {
  10301. var normalized;
  10302. // options
  10303. if (typeof options === "object") {
  10304. var keys = Object.keys(options),
  10305. idx = keys.length,
  10306. key;
  10307. // check that the options are correctly configured
  10308. while (idx--) {
  10309. key = keys[idx];
  10310. if (defaultOptions[key] === undefined) {
  10311. throw new Error("Unexpected option passed to constructor: " + key);
  10312. }
  10313. }
  10314. // copy the default options into passed options
  10315. keys = Object.keys(defaultOptions);
  10316. idx = keys.length;
  10317. while (idx--) {
  10318. key = keys[idx];
  10319. if (options[key] === undefined) {
  10320. options[key] = Utils.clone(defaultOptions[key]);
  10321. }
  10322. }
  10323. normalized = options;
  10324. } else {
  10325. normalized = Utils.clone(defaultOptions);
  10326. }
  10327. if (normalized.strictMode === true) {
  10328. normalized.forceAdditional = true;
  10329. normalized.forceItems = true;
  10330. normalized.forceMaxLength = true;
  10331. normalized.forceProperties = true;
  10332. normalized.noExtraKeywords = true;
  10333. normalized.noTypeless = true;
  10334. normalized.noEmptyStrings = true;
  10335. normalized.noEmptyArrays = true;
  10336. }
  10337. return normalized;
  10338. }
  10339. /**
  10340. * @class
  10341. *
  10342. * @param {*} [options]
  10343. */
  10344. function ZSchema(options) {
  10345. this.cache = {};
  10346. this.referenceCache = [];
  10347. this.validateOptions = {};
  10348. this.options = normalizeOptions(options);
  10349. // Disable strict validation for the built-in schemas
  10350. var metaschemaOptions = normalizeOptions({ });
  10351. this.setRemoteReference("http://json-schema.org/draft-04/schema", Draft4Schema, metaschemaOptions);
  10352. this.setRemoteReference("http://json-schema.org/draft-04/hyper-schema", Draft4HyperSchema, metaschemaOptions);
  10353. }
  10354. /**
  10355. * instance methods
  10356. *
  10357. * @param {*} schema
  10358. *
  10359. * @returns {boolean}
  10360. */
  10361. ZSchema.prototype.compileSchema = function (schema) {
  10362. var report = new Report(this.options);
  10363. schema = SchemaCache.getSchema.call(this, report, schema);
  10364. SchemaCompilation.compileSchema.call(this, report, schema);
  10365. this.lastReport = report;
  10366. return report.isValid();
  10367. };
  10368. /**
  10369. *
  10370. * @param {*} schema
  10371. *
  10372. * @returns {boolean}
  10373. */
  10374. ZSchema.prototype.validateSchema = function (schema) {
  10375. if (Array.isArray(schema) && schema.length === 0) {
  10376. throw new Error(".validateSchema was called with an empty array");
  10377. }
  10378. var report = new Report(this.options);
  10379. schema = SchemaCache.getSchema.call(this, report, schema);
  10380. var compiled = SchemaCompilation.compileSchema.call(this, report, schema);
  10381. if (compiled) { SchemaValidation.validateSchema.call(this, report, schema); }
  10382. this.lastReport = report;
  10383. return report.isValid();
  10384. };
  10385. /**
  10386. *
  10387. * @param {*} json
  10388. * @param {*} schema
  10389. * @param {*} [options]
  10390. * @param {function(*, *)} [callback]
  10391. *
  10392. * @returns {boolean}
  10393. */
  10394. ZSchema.prototype.validate = function (json, schema, options, callback) {
  10395. if (Utils.whatIs(options) === "function") {
  10396. callback = options;
  10397. options = {};
  10398. }
  10399. if (!options) { options = {}; }
  10400. this.validateOptions = options;
  10401. var whatIs = Utils.whatIs(schema);
  10402. if (whatIs !== "string" && whatIs !== "object") {
  10403. var e = new Error("Invalid .validate call - schema must be a string or object but " + whatIs + " was passed!");
  10404. if (callback) {
  10405. process.nextTick(function () {
  10406. callback(e, false);
  10407. });
  10408. return;
  10409. }
  10410. throw e;
  10411. }
  10412. var foundError = false;
  10413. var report = new Report(this.options);
  10414. report.json = json;
  10415. if (typeof schema === "string") {
  10416. var schemaName = schema;
  10417. schema = SchemaCache.getSchema.call(this, report, schemaName);
  10418. if (!schema) {
  10419. throw new Error("Schema with id '" + schemaName + "' wasn't found in the validator cache!");
  10420. }
  10421. } else {
  10422. schema = SchemaCache.getSchema.call(this, report, schema);
  10423. }
  10424. var compiled = false;
  10425. if (!foundError) {
  10426. compiled = SchemaCompilation.compileSchema.call(this, report, schema);
  10427. }
  10428. if (!compiled) {
  10429. this.lastReport = report;
  10430. foundError = true;
  10431. }
  10432. var validated = false;
  10433. if (!foundError) {
  10434. validated = SchemaValidation.validateSchema.call(this, report, schema);
  10435. }
  10436. if (!validated) {
  10437. this.lastReport = report;
  10438. foundError = true;
  10439. }
  10440. if (options.schemaPath) {
  10441. report.rootSchema = schema;
  10442. schema = get(schema, options.schemaPath);
  10443. if (!schema) {
  10444. throw new Error("Schema path '" + options.schemaPath + "' wasn't found in the schema!");
  10445. }
  10446. }
  10447. if (!foundError) {
  10448. JsonValidation.validate.call(this, report, schema, json);
  10449. }
  10450. if (callback) {
  10451. report.processAsyncTasks(this.options.asyncTimeout, callback);
  10452. return;
  10453. } else if (report.asyncTasks.length > 0) {
  10454. throw new Error("This validation has async tasks and cannot be done in sync mode, please provide callback argument.");
  10455. }
  10456. // assign lastReport so errors are retrievable in sync mode
  10457. this.lastReport = report;
  10458. return report.isValid();
  10459. };
  10460. ZSchema.prototype.getLastError = function () {
  10461. if (this.lastReport.errors.length === 0) {
  10462. return null;
  10463. }
  10464. var e = new Error();
  10465. e.name = "z-schema validation error";
  10466. e.message = this.lastReport.commonErrorMessage;
  10467. e.details = this.lastReport.errors;
  10468. return e;
  10469. };
  10470. ZSchema.prototype.getLastErrors = function () {
  10471. return this.lastReport && this.lastReport.errors.length > 0 ? this.lastReport.errors : null;
  10472. };
  10473. ZSchema.prototype.getMissingReferences = function (arr) {
  10474. arr = arr || this.lastReport.errors;
  10475. var res = [],
  10476. idx = arr.length;
  10477. while (idx--) {
  10478. var error = arr[idx];
  10479. if (error.code === "UNRESOLVABLE_REFERENCE") {
  10480. var reference = error.params[0];
  10481. if (res.indexOf(reference) === -1) {
  10482. res.push(reference);
  10483. }
  10484. }
  10485. if (error.inner) {
  10486. res = res.concat(this.getMissingReferences(error.inner));
  10487. }
  10488. }
  10489. return res;
  10490. };
  10491. ZSchema.prototype.getMissingRemoteReferences = function () {
  10492. var missingReferences = this.getMissingReferences(),
  10493. missingRemoteReferences = [],
  10494. idx = missingReferences.length;
  10495. while (idx--) {
  10496. var remoteReference = SchemaCache.getRemotePath(missingReferences[idx]);
  10497. if (remoteReference && missingRemoteReferences.indexOf(remoteReference) === -1) {
  10498. missingRemoteReferences.push(remoteReference);
  10499. }
  10500. }
  10501. return missingRemoteReferences;
  10502. };
  10503. ZSchema.prototype.setRemoteReference = function (uri, schema, validationOptions) {
  10504. if (typeof schema === "string") {
  10505. schema = JSON.parse(schema);
  10506. } else {
  10507. schema = Utils.cloneDeep(schema);
  10508. }
  10509. if (validationOptions) {
  10510. schema.__$validationOptions = normalizeOptions(validationOptions);
  10511. }
  10512. SchemaCache.cacheSchemaByUri.call(this, uri, schema);
  10513. };
  10514. ZSchema.prototype.getResolvedSchema = function (schema) {
  10515. var report = new Report(this.options);
  10516. schema = SchemaCache.getSchema.call(this, report, schema);
  10517. // clone before making any modifications
  10518. schema = Utils.cloneDeep(schema);
  10519. var visited = [];
  10520. // clean-up the schema and resolve references
  10521. var cleanup = function (schema) {
  10522. var key,
  10523. typeOf = Utils.whatIs(schema);
  10524. if (typeOf !== "object" && typeOf !== "array") {
  10525. return;
  10526. }
  10527. if (schema.___$visited) {
  10528. return;
  10529. }
  10530. schema.___$visited = true;
  10531. visited.push(schema);
  10532. if (schema.$ref && schema.__$refResolved) {
  10533. var from = schema.__$refResolved;
  10534. var to = schema;
  10535. delete schema.$ref;
  10536. delete schema.__$refResolved;
  10537. for (key in from) {
  10538. if (from.hasOwnProperty(key)) {
  10539. to[key] = from[key];
  10540. }
  10541. }
  10542. }
  10543. for (key in schema) {
  10544. if (schema.hasOwnProperty(key)) {
  10545. if (key.indexOf("__$") === 0) {
  10546. delete schema[key];
  10547. } else {
  10548. cleanup(schema[key]);
  10549. }
  10550. }
  10551. }
  10552. };
  10553. cleanup(schema);
  10554. visited.forEach(function (s) {
  10555. delete s.___$visited;
  10556. });
  10557. this.lastReport = report;
  10558. if (report.isValid()) {
  10559. return schema;
  10560. } else {
  10561. throw this.getLastError();
  10562. }
  10563. };
  10564. /**
  10565. *
  10566. * @param {*} schemaReader
  10567. *
  10568. * @returns {void}
  10569. */
  10570. ZSchema.prototype.setSchemaReader = function (schemaReader) {
  10571. return ZSchema.setSchemaReader(schemaReader);
  10572. };
  10573. ZSchema.prototype.getSchemaReader = function () {
  10574. return ZSchema.schemaReader;
  10575. };
  10576. ZSchema.schemaReader = undefined;
  10577. /*
  10578. static methods
  10579. */
  10580. ZSchema.setSchemaReader = function (schemaReader) {
  10581. ZSchema.schemaReader = schemaReader;
  10582. };
  10583. ZSchema.registerFormat = function (formatName, validatorFunction) {
  10584. FormatValidators[formatName] = validatorFunction;
  10585. };
  10586. ZSchema.unregisterFormat = function (formatName) {
  10587. delete FormatValidators[formatName];
  10588. };
  10589. ZSchema.getRegisteredFormats = function () {
  10590. return Object.keys(FormatValidators);
  10591. };
  10592. ZSchema.getDefaultOptions = function () {
  10593. return Utils.cloneDeep(defaultOptions);
  10594. };
  10595. ZSchema.schemaSymbol = Utils.schemaSymbol;
  10596. ZSchema.jsonSymbol = Utils.jsonSymbol;
  10597. module.exports = ZSchema;
  10598. }).call(this)}).call(this,require('_process'))
  10599. },{"./FormatValidators":106,"./JsonValidation":107,"./Polyfills":108,"./Report":109,"./SchemaCache":110,"./SchemaCompilation":111,"./SchemaValidation":112,"./Utils":113,"./schemas/hyper-schema.json":115,"./schemas/schema.json":116,"_process":3,"lodash.get":1}],115:[function(require,module,exports){
  10600. module.exports={
  10601. "$schema": "http://json-schema.org/draft-04/hyper-schema#",
  10602. "id": "http://json-schema.org/draft-04/hyper-schema#",
  10603. "title": "JSON Hyper-Schema",
  10604. "allOf": [
  10605. {
  10606. "$ref": "http://json-schema.org/draft-04/schema#"
  10607. }
  10608. ],
  10609. "properties": {
  10610. "additionalItems": {
  10611. "anyOf": [
  10612. {
  10613. "type": "boolean"
  10614. },
  10615. {
  10616. "$ref": "#"
  10617. }
  10618. ]
  10619. },
  10620. "additionalProperties": {
  10621. "anyOf": [
  10622. {
  10623. "type": "boolean"
  10624. },
  10625. {
  10626. "$ref": "#"
  10627. }
  10628. ]
  10629. },
  10630. "dependencies": {
  10631. "additionalProperties": {
  10632. "anyOf": [
  10633. {
  10634. "$ref": "#"
  10635. },
  10636. {
  10637. "type": "array"
  10638. }
  10639. ]
  10640. }
  10641. },
  10642. "items": {
  10643. "anyOf": [
  10644. {
  10645. "$ref": "#"
  10646. },
  10647. {
  10648. "$ref": "#/definitions/schemaArray"
  10649. }
  10650. ]
  10651. },
  10652. "definitions": {
  10653. "additionalProperties": {
  10654. "$ref": "#"
  10655. }
  10656. },
  10657. "patternProperties": {
  10658. "additionalProperties": {
  10659. "$ref": "#"
  10660. }
  10661. },
  10662. "properties": {
  10663. "additionalProperties": {
  10664. "$ref": "#"
  10665. }
  10666. },
  10667. "allOf": {
  10668. "$ref": "#/definitions/schemaArray"
  10669. },
  10670. "anyOf": {
  10671. "$ref": "#/definitions/schemaArray"
  10672. },
  10673. "oneOf": {
  10674. "$ref": "#/definitions/schemaArray"
  10675. },
  10676. "not": {
  10677. "$ref": "#"
  10678. },
  10679. "links": {
  10680. "type": "array",
  10681. "items": {
  10682. "$ref": "#/definitions/linkDescription"
  10683. }
  10684. },
  10685. "fragmentResolution": {
  10686. "type": "string"
  10687. },
  10688. "media": {
  10689. "type": "object",
  10690. "properties": {
  10691. "type": {
  10692. "description": "A media type, as described in RFC 2046",
  10693. "type": "string"
  10694. },
  10695. "binaryEncoding": {
  10696. "description": "A content encoding scheme, as described in RFC 2045",
  10697. "type": "string"
  10698. }
  10699. }
  10700. },
  10701. "pathStart": {
  10702. "description": "Instances' URIs must start with this value for this schema to apply to them",
  10703. "type": "string",
  10704. "format": "uri"
  10705. }
  10706. },
  10707. "definitions": {
  10708. "schemaArray": {
  10709. "type": "array",
  10710. "items": {
  10711. "$ref": "#"
  10712. }
  10713. },
  10714. "linkDescription": {
  10715. "title": "Link Description Object",
  10716. "type": "object",
  10717. "required": [ "href", "rel" ],
  10718. "properties": {
  10719. "href": {
  10720. "description": "a URI template, as defined by RFC 6570, with the addition of the $, ( and ) characters for pre-processing",
  10721. "type": "string"
  10722. },
  10723. "rel": {
  10724. "description": "relation to the target resource of the link",
  10725. "type": "string"
  10726. },
  10727. "title": {
  10728. "description": "a title for the link",
  10729. "type": "string"
  10730. },
  10731. "targetSchema": {
  10732. "description": "JSON Schema describing the link target",
  10733. "$ref": "#"
  10734. },
  10735. "mediaType": {
  10736. "description": "media type (as defined by RFC 2046) describing the link target",
  10737. "type": "string"
  10738. },
  10739. "method": {
  10740. "description": "method for requesting the target of the link (e.g. for HTTP this might be \"GET\" or \"DELETE\")",
  10741. "type": "string"
  10742. },
  10743. "encType": {
  10744. "description": "The media type in which to submit data along with the request",
  10745. "type": "string",
  10746. "default": "application/json"
  10747. },
  10748. "schema": {
  10749. "description": "Schema describing the data to submit along with the request",
  10750. "$ref": "#"
  10751. }
  10752. }
  10753. }
  10754. }
  10755. }
  10756. },{}],116:[function(require,module,exports){
  10757. module.exports={
  10758. "id": "http://json-schema.org/draft-04/schema#",
  10759. "$schema": "http://json-schema.org/draft-04/schema#",
  10760. "description": "Core schema meta-schema",
  10761. "definitions": {
  10762. "schemaArray": {
  10763. "type": "array",
  10764. "minItems": 1,
  10765. "items": { "$ref": "#" }
  10766. },
  10767. "positiveInteger": {
  10768. "type": "integer",
  10769. "minimum": 0
  10770. },
  10771. "positiveIntegerDefault0": {
  10772. "allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ]
  10773. },
  10774. "simpleTypes": {
  10775. "enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ]
  10776. },
  10777. "stringArray": {
  10778. "type": "array",
  10779. "items": { "type": "string" },
  10780. "minItems": 1,
  10781. "uniqueItems": true
  10782. }
  10783. },
  10784. "type": "object",
  10785. "properties": {
  10786. "id": {
  10787. "type": "string",
  10788. "format": "uri"
  10789. },
  10790. "$schema": {
  10791. "type": "string",
  10792. "format": "uri"
  10793. },
  10794. "title": {
  10795. "type": "string"
  10796. },
  10797. "description": {
  10798. "type": "string"
  10799. },
  10800. "default": {},
  10801. "multipleOf": {
  10802. "type": "number",
  10803. "minimum": 0,
  10804. "exclusiveMinimum": true
  10805. },
  10806. "maximum": {
  10807. "type": "number"
  10808. },
  10809. "exclusiveMaximum": {
  10810. "type": "boolean",
  10811. "default": false
  10812. },
  10813. "minimum": {
  10814. "type": "number"
  10815. },
  10816. "exclusiveMinimum": {
  10817. "type": "boolean",
  10818. "default": false
  10819. },
  10820. "maxLength": { "$ref": "#/definitions/positiveInteger" },
  10821. "minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
  10822. "pattern": {
  10823. "type": "string",
  10824. "format": "regex"
  10825. },
  10826. "additionalItems": {
  10827. "anyOf": [
  10828. { "type": "boolean" },
  10829. { "$ref": "#" }
  10830. ],
  10831. "default": {}
  10832. },
  10833. "items": {
  10834. "anyOf": [
  10835. { "$ref": "#" },
  10836. { "$ref": "#/definitions/schemaArray" }
  10837. ],
  10838. "default": {}
  10839. },
  10840. "maxItems": { "$ref": "#/definitions/positiveInteger" },
  10841. "minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
  10842. "uniqueItems": {
  10843. "type": "boolean",
  10844. "default": false
  10845. },
  10846. "maxProperties": { "$ref": "#/definitions/positiveInteger" },
  10847. "minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
  10848. "required": { "$ref": "#/definitions/stringArray" },
  10849. "additionalProperties": {
  10850. "anyOf": [
  10851. { "type": "boolean" },
  10852. { "$ref": "#" }
  10853. ],
  10854. "default": {}
  10855. },
  10856. "definitions": {
  10857. "type": "object",
  10858. "additionalProperties": { "$ref": "#" },
  10859. "default": {}
  10860. },
  10861. "properties": {
  10862. "type": "object",
  10863. "additionalProperties": { "$ref": "#" },
  10864. "default": {}
  10865. },
  10866. "patternProperties": {
  10867. "type": "object",
  10868. "additionalProperties": { "$ref": "#" },
  10869. "default": {}
  10870. },
  10871. "dependencies": {
  10872. "type": "object",
  10873. "additionalProperties": {
  10874. "anyOf": [
  10875. { "$ref": "#" },
  10876. { "$ref": "#/definitions/stringArray" }
  10877. ]
  10878. }
  10879. },
  10880. "enum": {
  10881. "type": "array",
  10882. "minItems": 1,
  10883. "uniqueItems": true
  10884. },
  10885. "type": {
  10886. "anyOf": [
  10887. { "$ref": "#/definitions/simpleTypes" },
  10888. {
  10889. "type": "array",
  10890. "items": { "$ref": "#/definitions/simpleTypes" },
  10891. "minItems": 1,
  10892. "uniqueItems": true
  10893. }
  10894. ]
  10895. },
  10896. "format": { "type": "string" },
  10897. "allOf": { "$ref": "#/definitions/schemaArray" },
  10898. "anyOf": { "$ref": "#/definitions/schemaArray" },
  10899. "oneOf": { "$ref": "#/definitions/schemaArray" },
  10900. "not": { "$ref": "#" }
  10901. },
  10902. "dependencies": {
  10903. "exclusiveMaximum": [ "maximum" ],
  10904. "exclusiveMinimum": [ "minimum" ]
  10905. },
  10906. "default": {}
  10907. }
  10908. },{}]},{},[105,106,107,108,109,110,111,112,113,114])(114)
  10909. });