ajv.bundle.js 265 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166
  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.Ajv = 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. 'use strict';
  3. var Cache = module.exports = function Cache() {
  4. this._cache = {};
  5. };
  6. Cache.prototype.put = function Cache_put(key, value) {
  7. this._cache[key] = value;
  8. };
  9. Cache.prototype.get = function Cache_get(key) {
  10. return this._cache[key];
  11. };
  12. Cache.prototype.del = function Cache_del(key) {
  13. delete this._cache[key];
  14. };
  15. Cache.prototype.clear = function Cache_clear() {
  16. this._cache = {};
  17. };
  18. },{}],2:[function(require,module,exports){
  19. 'use strict';
  20. var MissingRefError = require('./error_classes').MissingRef;
  21. module.exports = compileAsync;
  22. /**
  23. * Creates validating function for passed schema with asynchronous loading of missing schemas.
  24. * `loadSchema` option should be a function that accepts schema uri and returns promise that resolves with the schema.
  25. * @this Ajv
  26. * @param {Object} schema schema object
  27. * @param {Boolean} meta optional true to compile meta-schema; this parameter can be skipped
  28. * @param {Function} callback an optional node-style callback, it is called with 2 parameters: error (or null) and validating function.
  29. * @return {Promise} promise that resolves with a validating function.
  30. */
  31. function compileAsync(schema, meta, callback) {
  32. /* eslint no-shadow: 0 */
  33. /* global Promise */
  34. /* jshint validthis: true */
  35. var self = this;
  36. if (typeof this._opts.loadSchema != 'function')
  37. throw new Error('options.loadSchema should be a function');
  38. if (typeof meta == 'function') {
  39. callback = meta;
  40. meta = undefined;
  41. }
  42. var p = loadMetaSchemaOf(schema).then(function () {
  43. var schemaObj = self._addSchema(schema, undefined, meta);
  44. return schemaObj.validate || _compileAsync(schemaObj);
  45. });
  46. if (callback) {
  47. p.then(
  48. function(v) { callback(null, v); },
  49. callback
  50. );
  51. }
  52. return p;
  53. function loadMetaSchemaOf(sch) {
  54. var $schema = sch.$schema;
  55. return $schema && !self.getSchema($schema)
  56. ? compileAsync.call(self, { $ref: $schema }, true)
  57. : Promise.resolve();
  58. }
  59. function _compileAsync(schemaObj) {
  60. try { return self._compile(schemaObj); }
  61. catch(e) {
  62. if (e instanceof MissingRefError) return loadMissingSchema(e);
  63. throw e;
  64. }
  65. function loadMissingSchema(e) {
  66. var ref = e.missingSchema;
  67. if (added(ref)) throw new Error('Schema ' + ref + ' is loaded but ' + e.missingRef + ' cannot be resolved');
  68. var schemaPromise = self._loadingSchemas[ref];
  69. if (!schemaPromise) {
  70. schemaPromise = self._loadingSchemas[ref] = self._opts.loadSchema(ref);
  71. schemaPromise.then(removePromise, removePromise);
  72. }
  73. return schemaPromise.then(function (sch) {
  74. if (!added(ref)) {
  75. return loadMetaSchemaOf(sch).then(function () {
  76. if (!added(ref)) self.addSchema(sch, ref, undefined, meta);
  77. });
  78. }
  79. }).then(function() {
  80. return _compileAsync(schemaObj);
  81. });
  82. function removePromise() {
  83. delete self._loadingSchemas[ref];
  84. }
  85. function added(ref) {
  86. return self._refs[ref] || self._schemas[ref];
  87. }
  88. }
  89. }
  90. }
  91. },{"./error_classes":3}],3:[function(require,module,exports){
  92. 'use strict';
  93. var resolve = require('./resolve');
  94. module.exports = {
  95. Validation: errorSubclass(ValidationError),
  96. MissingRef: errorSubclass(MissingRefError)
  97. };
  98. function ValidationError(errors) {
  99. this.message = 'validation failed';
  100. this.errors = errors;
  101. this.ajv = this.validation = true;
  102. }
  103. MissingRefError.message = function (baseId, ref) {
  104. return 'can\'t resolve reference ' + ref + ' from id ' + baseId;
  105. };
  106. function MissingRefError(baseId, ref, message) {
  107. this.message = message || MissingRefError.message(baseId, ref);
  108. this.missingRef = resolve.url(baseId, ref);
  109. this.missingSchema = resolve.normalizeId(resolve.fullPath(this.missingRef));
  110. }
  111. function errorSubclass(Subclass) {
  112. Subclass.prototype = Object.create(Error.prototype);
  113. Subclass.prototype.constructor = Subclass;
  114. return Subclass;
  115. }
  116. },{"./resolve":6}],4:[function(require,module,exports){
  117. 'use strict';
  118. var util = require('./util');
  119. var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
  120. var DAYS = [0,31,28,31,30,31,30,31,31,30,31,30,31];
  121. var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
  122. var HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i;
  123. var URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
  124. var URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
  125. // uri-template: https://tools.ietf.org/html/rfc6570
  126. var URITEMPLATE = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i;
  127. // For the source: https://gist.github.com/dperini/729294
  128. // For test cases: https://mathiasbynens.be/demo/url-regex
  129. // @todo Delete current URL in favour of the commented out URL rule when this issue is fixed https://github.com/eslint/eslint/issues/7983.
  130. // var URL = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
  131. var URL = /^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i;
  132. var UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
  133. var JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
  134. var JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
  135. var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
  136. module.exports = formats;
  137. function formats(mode) {
  138. mode = mode == 'full' ? 'full' : 'fast';
  139. return util.copy(formats[mode]);
  140. }
  141. formats.fast = {
  142. // date: http://tools.ietf.org/html/rfc3339#section-5.6
  143. date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/,
  144. // date-time: http://tools.ietf.org/html/rfc3339#section-5.6
  145. time: /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,
  146. 'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,
  147. // uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
  148. uri: /^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i,
  149. 'uri-reference': /^(?:(?:[a-z][a-z0-9+-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,
  150. 'uri-template': URITEMPLATE,
  151. url: URL,
  152. // email (sources from jsen validator):
  153. // http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363
  154. // http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'willful violation')
  155. email: /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,
  156. hostname: HOSTNAME,
  157. // optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
  158. ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
  159. // optimized http://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses
  160. ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
  161. regex: regex,
  162. // uuid: http://tools.ietf.org/html/rfc4122
  163. uuid: UUID,
  164. // JSON-pointer: https://tools.ietf.org/html/rfc6901
  165. // uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A
  166. 'json-pointer': JSON_POINTER,
  167. 'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT,
  168. // relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00
  169. 'relative-json-pointer': RELATIVE_JSON_POINTER
  170. };
  171. formats.full = {
  172. date: date,
  173. time: time,
  174. 'date-time': date_time,
  175. uri: uri,
  176. 'uri-reference': URIREF,
  177. 'uri-template': URITEMPLATE,
  178. url: URL,
  179. email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
  180. hostname: HOSTNAME,
  181. ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
  182. ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
  183. regex: regex,
  184. uuid: UUID,
  185. 'json-pointer': JSON_POINTER,
  186. 'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT,
  187. 'relative-json-pointer': RELATIVE_JSON_POINTER
  188. };
  189. function isLeapYear(year) {
  190. // https://tools.ietf.org/html/rfc3339#appendix-C
  191. return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
  192. }
  193. function date(str) {
  194. // full-date from http://tools.ietf.org/html/rfc3339#section-5.6
  195. var matches = str.match(DATE);
  196. if (!matches) return false;
  197. var year = +matches[1];
  198. var month = +matches[2];
  199. var day = +matches[3];
  200. return month >= 1 && month <= 12 && day >= 1 &&
  201. day <= (month == 2 && isLeapYear(year) ? 29 : DAYS[month]);
  202. }
  203. function time(str, full) {
  204. var matches = str.match(TIME);
  205. if (!matches) return false;
  206. var hour = matches[1];
  207. var minute = matches[2];
  208. var second = matches[3];
  209. var timeZone = matches[5];
  210. return ((hour <= 23 && minute <= 59 && second <= 59) ||
  211. (hour == 23 && minute == 59 && second == 60)) &&
  212. (!full || timeZone);
  213. }
  214. var DATE_TIME_SEPARATOR = /t|\s/i;
  215. function date_time(str) {
  216. // http://tools.ietf.org/html/rfc3339#section-5.6
  217. var dateTime = str.split(DATE_TIME_SEPARATOR);
  218. return dateTime.length == 2 && date(dateTime[0]) && time(dateTime[1], true);
  219. }
  220. var NOT_URI_FRAGMENT = /\/|:/;
  221. function uri(str) {
  222. // http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
  223. return NOT_URI_FRAGMENT.test(str) && URI.test(str);
  224. }
  225. var Z_ANCHOR = /[^\\]\\Z/;
  226. function regex(str) {
  227. if (Z_ANCHOR.test(str)) return false;
  228. try {
  229. new RegExp(str);
  230. return true;
  231. } catch(e) {
  232. return false;
  233. }
  234. }
  235. },{"./util":10}],5:[function(require,module,exports){
  236. 'use strict';
  237. var resolve = require('./resolve')
  238. , util = require('./util')
  239. , errorClasses = require('./error_classes')
  240. , stableStringify = require('fast-json-stable-stringify');
  241. var validateGenerator = require('../dotjs/validate');
  242. /**
  243. * Functions below are used inside compiled validations function
  244. */
  245. var ucs2length = util.ucs2length;
  246. var equal = require('fast-deep-equal');
  247. // this error is thrown by async schemas to return validation errors via exception
  248. var ValidationError = errorClasses.Validation;
  249. module.exports = compile;
  250. /**
  251. * Compiles schema to validation function
  252. * @this Ajv
  253. * @param {Object} schema schema object
  254. * @param {Object} root object with information about the root schema for this schema
  255. * @param {Object} localRefs the hash of local references inside the schema (created by resolve.id), used for inline resolution
  256. * @param {String} baseId base ID for IDs in the schema
  257. * @return {Function} validation function
  258. */
  259. function compile(schema, root, localRefs, baseId) {
  260. /* jshint validthis: true, evil: true */
  261. /* eslint no-shadow: 0 */
  262. var self = this
  263. , opts = this._opts
  264. , refVal = [ undefined ]
  265. , refs = {}
  266. , patterns = []
  267. , patternsHash = {}
  268. , defaults = []
  269. , defaultsHash = {}
  270. , customRules = [];
  271. root = root || { schema: schema, refVal: refVal, refs: refs };
  272. var c = checkCompiling.call(this, schema, root, baseId);
  273. var compilation = this._compilations[c.index];
  274. if (c.compiling) return (compilation.callValidate = callValidate);
  275. var formats = this._formats;
  276. var RULES = this.RULES;
  277. try {
  278. var v = localCompile(schema, root, localRefs, baseId);
  279. compilation.validate = v;
  280. var cv = compilation.callValidate;
  281. if (cv) {
  282. cv.schema = v.schema;
  283. cv.errors = null;
  284. cv.refs = v.refs;
  285. cv.refVal = v.refVal;
  286. cv.root = v.root;
  287. cv.$async = v.$async;
  288. if (opts.sourceCode) cv.source = v.source;
  289. }
  290. return v;
  291. } finally {
  292. endCompiling.call(this, schema, root, baseId);
  293. }
  294. /* @this {*} - custom context, see passContext option */
  295. function callValidate() {
  296. /* jshint validthis: true */
  297. var validate = compilation.validate;
  298. var result = validate.apply(this, arguments);
  299. callValidate.errors = validate.errors;
  300. return result;
  301. }
  302. function localCompile(_schema, _root, localRefs, baseId) {
  303. var isRoot = !_root || (_root && _root.schema == _schema);
  304. if (_root.schema != root.schema)
  305. return compile.call(self, _schema, _root, localRefs, baseId);
  306. var $async = _schema.$async === true;
  307. var sourceCode = validateGenerator({
  308. isTop: true,
  309. schema: _schema,
  310. isRoot: isRoot,
  311. baseId: baseId,
  312. root: _root,
  313. schemaPath: '',
  314. errSchemaPath: '#',
  315. errorPath: '""',
  316. MissingRefError: errorClasses.MissingRef,
  317. RULES: RULES,
  318. validate: validateGenerator,
  319. util: util,
  320. resolve: resolve,
  321. resolveRef: resolveRef,
  322. usePattern: usePattern,
  323. useDefault: useDefault,
  324. useCustomRule: useCustomRule,
  325. opts: opts,
  326. formats: formats,
  327. logger: self.logger,
  328. self: self
  329. });
  330. sourceCode = vars(refVal, refValCode) + vars(patterns, patternCode)
  331. + vars(defaults, defaultCode) + vars(customRules, customRuleCode)
  332. + sourceCode;
  333. if (opts.processCode) sourceCode = opts.processCode(sourceCode);
  334. // console.log('\n\n\n *** \n', JSON.stringify(sourceCode));
  335. var validate;
  336. try {
  337. var makeValidate = new Function(
  338. 'self',
  339. 'RULES',
  340. 'formats',
  341. 'root',
  342. 'refVal',
  343. 'defaults',
  344. 'customRules',
  345. 'equal',
  346. 'ucs2length',
  347. 'ValidationError',
  348. sourceCode
  349. );
  350. validate = makeValidate(
  351. self,
  352. RULES,
  353. formats,
  354. root,
  355. refVal,
  356. defaults,
  357. customRules,
  358. equal,
  359. ucs2length,
  360. ValidationError
  361. );
  362. refVal[0] = validate;
  363. } catch(e) {
  364. self.logger.error('Error compiling schema, function code:', sourceCode);
  365. throw e;
  366. }
  367. validate.schema = _schema;
  368. validate.errors = null;
  369. validate.refs = refs;
  370. validate.refVal = refVal;
  371. validate.root = isRoot ? validate : _root;
  372. if ($async) validate.$async = true;
  373. if (opts.sourceCode === true) {
  374. validate.source = {
  375. code: sourceCode,
  376. patterns: patterns,
  377. defaults: defaults
  378. };
  379. }
  380. return validate;
  381. }
  382. function resolveRef(baseId, ref, isRoot) {
  383. ref = resolve.url(baseId, ref);
  384. var refIndex = refs[ref];
  385. var _refVal, refCode;
  386. if (refIndex !== undefined) {
  387. _refVal = refVal[refIndex];
  388. refCode = 'refVal[' + refIndex + ']';
  389. return resolvedRef(_refVal, refCode);
  390. }
  391. if (!isRoot && root.refs) {
  392. var rootRefId = root.refs[ref];
  393. if (rootRefId !== undefined) {
  394. _refVal = root.refVal[rootRefId];
  395. refCode = addLocalRef(ref, _refVal);
  396. return resolvedRef(_refVal, refCode);
  397. }
  398. }
  399. refCode = addLocalRef(ref);
  400. var v = resolve.call(self, localCompile, root, ref);
  401. if (v === undefined) {
  402. var localSchema = localRefs && localRefs[ref];
  403. if (localSchema) {
  404. v = resolve.inlineRef(localSchema, opts.inlineRefs)
  405. ? localSchema
  406. : compile.call(self, localSchema, root, localRefs, baseId);
  407. }
  408. }
  409. if (v === undefined) {
  410. removeLocalRef(ref);
  411. } else {
  412. replaceLocalRef(ref, v);
  413. return resolvedRef(v, refCode);
  414. }
  415. }
  416. function addLocalRef(ref, v) {
  417. var refId = refVal.length;
  418. refVal[refId] = v;
  419. refs[ref] = refId;
  420. return 'refVal' + refId;
  421. }
  422. function removeLocalRef(ref) {
  423. delete refs[ref];
  424. }
  425. function replaceLocalRef(ref, v) {
  426. var refId = refs[ref];
  427. refVal[refId] = v;
  428. }
  429. function resolvedRef(refVal, code) {
  430. return typeof refVal == 'object' || typeof refVal == 'boolean'
  431. ? { code: code, schema: refVal, inline: true }
  432. : { code: code, $async: refVal && !!refVal.$async };
  433. }
  434. function usePattern(regexStr) {
  435. var index = patternsHash[regexStr];
  436. if (index === undefined) {
  437. index = patternsHash[regexStr] = patterns.length;
  438. patterns[index] = regexStr;
  439. }
  440. return 'pattern' + index;
  441. }
  442. function useDefault(value) {
  443. switch (typeof value) {
  444. case 'boolean':
  445. case 'number':
  446. return '' + value;
  447. case 'string':
  448. return util.toQuotedString(value);
  449. case 'object':
  450. if (value === null) return 'null';
  451. var valueStr = stableStringify(value);
  452. var index = defaultsHash[valueStr];
  453. if (index === undefined) {
  454. index = defaultsHash[valueStr] = defaults.length;
  455. defaults[index] = value;
  456. }
  457. return 'default' + index;
  458. }
  459. }
  460. function useCustomRule(rule, schema, parentSchema, it) {
  461. if (self._opts.validateSchema !== false) {
  462. var deps = rule.definition.dependencies;
  463. if (deps && !deps.every(function(keyword) {
  464. return Object.prototype.hasOwnProperty.call(parentSchema, keyword);
  465. }))
  466. throw new Error('parent schema must have all required keywords: ' + deps.join(','));
  467. var validateSchema = rule.definition.validateSchema;
  468. if (validateSchema) {
  469. var valid = validateSchema(schema);
  470. if (!valid) {
  471. var message = 'keyword schema is invalid: ' + self.errorsText(validateSchema.errors);
  472. if (self._opts.validateSchema == 'log') self.logger.error(message);
  473. else throw new Error(message);
  474. }
  475. }
  476. }
  477. var compile = rule.definition.compile
  478. , inline = rule.definition.inline
  479. , macro = rule.definition.macro;
  480. var validate;
  481. if (compile) {
  482. validate = compile.call(self, schema, parentSchema, it);
  483. } else if (macro) {
  484. validate = macro.call(self, schema, parentSchema, it);
  485. if (opts.validateSchema !== false) self.validateSchema(validate, true);
  486. } else if (inline) {
  487. validate = inline.call(self, it, rule.keyword, schema, parentSchema);
  488. } else {
  489. validate = rule.definition.validate;
  490. if (!validate) return;
  491. }
  492. if (validate === undefined)
  493. throw new Error('custom keyword "' + rule.keyword + '"failed to compile');
  494. var index = customRules.length;
  495. customRules[index] = validate;
  496. return {
  497. code: 'customRule' + index,
  498. validate: validate
  499. };
  500. }
  501. }
  502. /**
  503. * Checks if the schema is currently compiled
  504. * @this Ajv
  505. * @param {Object} schema schema to compile
  506. * @param {Object} root root object
  507. * @param {String} baseId base schema ID
  508. * @return {Object} object with properties "index" (compilation index) and "compiling" (boolean)
  509. */
  510. function checkCompiling(schema, root, baseId) {
  511. /* jshint validthis: true */
  512. var index = compIndex.call(this, schema, root, baseId);
  513. if (index >= 0) return { index: index, compiling: true };
  514. index = this._compilations.length;
  515. this._compilations[index] = {
  516. schema: schema,
  517. root: root,
  518. baseId: baseId
  519. };
  520. return { index: index, compiling: false };
  521. }
  522. /**
  523. * Removes the schema from the currently compiled list
  524. * @this Ajv
  525. * @param {Object} schema schema to compile
  526. * @param {Object} root root object
  527. * @param {String} baseId base schema ID
  528. */
  529. function endCompiling(schema, root, baseId) {
  530. /* jshint validthis: true */
  531. var i = compIndex.call(this, schema, root, baseId);
  532. if (i >= 0) this._compilations.splice(i, 1);
  533. }
  534. /**
  535. * Index of schema compilation in the currently compiled list
  536. * @this Ajv
  537. * @param {Object} schema schema to compile
  538. * @param {Object} root root object
  539. * @param {String} baseId base schema ID
  540. * @return {Integer} compilation index
  541. */
  542. function compIndex(schema, root, baseId) {
  543. /* jshint validthis: true */
  544. for (var i=0; i<this._compilations.length; i++) {
  545. var c = this._compilations[i];
  546. if (c.schema == schema && c.root == root && c.baseId == baseId) return i;
  547. }
  548. return -1;
  549. }
  550. function patternCode(i, patterns) {
  551. return 'var pattern' + i + ' = new RegExp(' + util.toQuotedString(patterns[i]) + ');';
  552. }
  553. function defaultCode(i) {
  554. return 'var default' + i + ' = defaults[' + i + '];';
  555. }
  556. function refValCode(i, refVal) {
  557. return refVal[i] === undefined ? '' : 'var refVal' + i + ' = refVal[' + i + '];';
  558. }
  559. function customRuleCode(i) {
  560. return 'var customRule' + i + ' = customRules[' + i + '];';
  561. }
  562. function vars(arr, statement) {
  563. if (!arr.length) return '';
  564. var code = '';
  565. for (var i=0; i<arr.length; i++)
  566. code += statement(i, arr);
  567. return code;
  568. }
  569. },{"../dotjs/validate":38,"./error_classes":3,"./resolve":6,"./util":10,"fast-deep-equal":42,"fast-json-stable-stringify":43}],6:[function(require,module,exports){
  570. 'use strict';
  571. var URI = require('uri-js')
  572. , equal = require('fast-deep-equal')
  573. , util = require('./util')
  574. , SchemaObject = require('./schema_obj')
  575. , traverse = require('json-schema-traverse');
  576. module.exports = resolve;
  577. resolve.normalizeId = normalizeId;
  578. resolve.fullPath = getFullPath;
  579. resolve.url = resolveUrl;
  580. resolve.ids = resolveIds;
  581. resolve.inlineRef = inlineRef;
  582. resolve.schema = resolveSchema;
  583. /**
  584. * [resolve and compile the references ($ref)]
  585. * @this Ajv
  586. * @param {Function} compile reference to schema compilation funciton (localCompile)
  587. * @param {Object} root object with information about the root schema for the current schema
  588. * @param {String} ref reference to resolve
  589. * @return {Object|Function} schema object (if the schema can be inlined) or validation function
  590. */
  591. function resolve(compile, root, ref) {
  592. /* jshint validthis: true */
  593. var refVal = this._refs[ref];
  594. if (typeof refVal == 'string') {
  595. if (this._refs[refVal]) refVal = this._refs[refVal];
  596. else return resolve.call(this, compile, root, refVal);
  597. }
  598. refVal = refVal || this._schemas[ref];
  599. if (refVal instanceof SchemaObject) {
  600. return inlineRef(refVal.schema, this._opts.inlineRefs)
  601. ? refVal.schema
  602. : refVal.validate || this._compile(refVal);
  603. }
  604. var res = resolveSchema.call(this, root, ref);
  605. var schema, v, baseId;
  606. if (res) {
  607. schema = res.schema;
  608. root = res.root;
  609. baseId = res.baseId;
  610. }
  611. if (schema instanceof SchemaObject) {
  612. v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId);
  613. } else if (schema !== undefined) {
  614. v = inlineRef(schema, this._opts.inlineRefs)
  615. ? schema
  616. : compile.call(this, schema, root, undefined, baseId);
  617. }
  618. return v;
  619. }
  620. /**
  621. * Resolve schema, its root and baseId
  622. * @this Ajv
  623. * @param {Object} root root object with properties schema, refVal, refs
  624. * @param {String} ref reference to resolve
  625. * @return {Object} object with properties schema, root, baseId
  626. */
  627. function resolveSchema(root, ref) {
  628. /* jshint validthis: true */
  629. var p = URI.parse(ref)
  630. , refPath = _getFullPath(p)
  631. , baseId = getFullPath(this._getId(root.schema));
  632. if (Object.keys(root.schema).length === 0 || refPath !== baseId) {
  633. var id = normalizeId(refPath);
  634. var refVal = this._refs[id];
  635. if (typeof refVal == 'string') {
  636. return resolveRecursive.call(this, root, refVal, p);
  637. } else if (refVal instanceof SchemaObject) {
  638. if (!refVal.validate) this._compile(refVal);
  639. root = refVal;
  640. } else {
  641. refVal = this._schemas[id];
  642. if (refVal instanceof SchemaObject) {
  643. if (!refVal.validate) this._compile(refVal);
  644. if (id == normalizeId(ref))
  645. return { schema: refVal, root: root, baseId: baseId };
  646. root = refVal;
  647. } else {
  648. return;
  649. }
  650. }
  651. if (!root.schema) return;
  652. baseId = getFullPath(this._getId(root.schema));
  653. }
  654. return getJsonPointer.call(this, p, baseId, root.schema, root);
  655. }
  656. /* @this Ajv */
  657. function resolveRecursive(root, ref, parsedRef) {
  658. /* jshint validthis: true */
  659. var res = resolveSchema.call(this, root, ref);
  660. if (res) {
  661. var schema = res.schema;
  662. var baseId = res.baseId;
  663. root = res.root;
  664. var id = this._getId(schema);
  665. if (id) baseId = resolveUrl(baseId, id);
  666. return getJsonPointer.call(this, parsedRef, baseId, schema, root);
  667. }
  668. }
  669. var PREVENT_SCOPE_CHANGE = util.toHash(['properties', 'patternProperties', 'enum', 'dependencies', 'definitions']);
  670. /* @this Ajv */
  671. function getJsonPointer(parsedRef, baseId, schema, root) {
  672. /* jshint validthis: true */
  673. parsedRef.fragment = parsedRef.fragment || '';
  674. if (parsedRef.fragment.slice(0,1) != '/') return;
  675. var parts = parsedRef.fragment.split('/');
  676. for (var i = 1; i < parts.length; i++) {
  677. var part = parts[i];
  678. if (part) {
  679. part = util.unescapeFragment(part);
  680. schema = schema[part];
  681. if (schema === undefined) break;
  682. var id;
  683. if (!PREVENT_SCOPE_CHANGE[part]) {
  684. id = this._getId(schema);
  685. if (id) baseId = resolveUrl(baseId, id);
  686. if (schema.$ref) {
  687. var $ref = resolveUrl(baseId, schema.$ref);
  688. var res = resolveSchema.call(this, root, $ref);
  689. if (res) {
  690. schema = res.schema;
  691. root = res.root;
  692. baseId = res.baseId;
  693. }
  694. }
  695. }
  696. }
  697. }
  698. if (schema !== undefined && schema !== root.schema)
  699. return { schema: schema, root: root, baseId: baseId };
  700. }
  701. var SIMPLE_INLINED = util.toHash([
  702. 'type', 'format', 'pattern',
  703. 'maxLength', 'minLength',
  704. 'maxProperties', 'minProperties',
  705. 'maxItems', 'minItems',
  706. 'maximum', 'minimum',
  707. 'uniqueItems', 'multipleOf',
  708. 'required', 'enum'
  709. ]);
  710. function inlineRef(schema, limit) {
  711. if (limit === false) return false;
  712. if (limit === undefined || limit === true) return checkNoRef(schema);
  713. else if (limit) return countKeys(schema) <= limit;
  714. }
  715. function checkNoRef(schema) {
  716. var item;
  717. if (Array.isArray(schema)) {
  718. for (var i=0; i<schema.length; i++) {
  719. item = schema[i];
  720. if (typeof item == 'object' && !checkNoRef(item)) return false;
  721. }
  722. } else {
  723. for (var key in schema) {
  724. if (key == '$ref') return false;
  725. item = schema[key];
  726. if (typeof item == 'object' && !checkNoRef(item)) return false;
  727. }
  728. }
  729. return true;
  730. }
  731. function countKeys(schema) {
  732. var count = 0, item;
  733. if (Array.isArray(schema)) {
  734. for (var i=0; i<schema.length; i++) {
  735. item = schema[i];
  736. if (typeof item == 'object') count += countKeys(item);
  737. if (count == Infinity) return Infinity;
  738. }
  739. } else {
  740. for (var key in schema) {
  741. if (key == '$ref') return Infinity;
  742. if (SIMPLE_INLINED[key]) {
  743. count++;
  744. } else {
  745. item = schema[key];
  746. if (typeof item == 'object') count += countKeys(item) + 1;
  747. if (count == Infinity) return Infinity;
  748. }
  749. }
  750. }
  751. return count;
  752. }
  753. function getFullPath(id, normalize) {
  754. if (normalize !== false) id = normalizeId(id);
  755. var p = URI.parse(id);
  756. return _getFullPath(p);
  757. }
  758. function _getFullPath(p) {
  759. return URI.serialize(p).split('#')[0] + '#';
  760. }
  761. var TRAILING_SLASH_HASH = /#\/?$/;
  762. function normalizeId(id) {
  763. return id ? id.replace(TRAILING_SLASH_HASH, '') : '';
  764. }
  765. function resolveUrl(baseId, id) {
  766. id = normalizeId(id);
  767. return URI.resolve(baseId, id);
  768. }
  769. /* @this Ajv */
  770. function resolveIds(schema) {
  771. var schemaId = normalizeId(this._getId(schema));
  772. var baseIds = {'': schemaId};
  773. var fullPaths = {'': getFullPath(schemaId, false)};
  774. var localRefs = {};
  775. var self = this;
  776. traverse(schema, {allKeys: true}, function(sch, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
  777. if (jsonPtr === '') return;
  778. var id = self._getId(sch);
  779. var baseId = baseIds[parentJsonPtr];
  780. var fullPath = fullPaths[parentJsonPtr] + '/' + parentKeyword;
  781. if (keyIndex !== undefined)
  782. fullPath += '/' + (typeof keyIndex == 'number' ? keyIndex : util.escapeFragment(keyIndex));
  783. if (typeof id == 'string') {
  784. id = baseId = normalizeId(baseId ? URI.resolve(baseId, id) : id);
  785. var refVal = self._refs[id];
  786. if (typeof refVal == 'string') refVal = self._refs[refVal];
  787. if (refVal && refVal.schema) {
  788. if (!equal(sch, refVal.schema))
  789. throw new Error('id "' + id + '" resolves to more than one schema');
  790. } else if (id != normalizeId(fullPath)) {
  791. if (id[0] == '#') {
  792. if (localRefs[id] && !equal(sch, localRefs[id]))
  793. throw new Error('id "' + id + '" resolves to more than one schema');
  794. localRefs[id] = sch;
  795. } else {
  796. self._refs[id] = fullPath;
  797. }
  798. }
  799. }
  800. baseIds[jsonPtr] = baseId;
  801. fullPaths[jsonPtr] = fullPath;
  802. });
  803. return localRefs;
  804. }
  805. },{"./schema_obj":8,"./util":10,"fast-deep-equal":42,"json-schema-traverse":44,"uri-js":45}],7:[function(require,module,exports){
  806. 'use strict';
  807. var ruleModules = require('../dotjs')
  808. , toHash = require('./util').toHash;
  809. module.exports = function rules() {
  810. var RULES = [
  811. { type: 'number',
  812. rules: [ { 'maximum': ['exclusiveMaximum'] },
  813. { 'minimum': ['exclusiveMinimum'] }, 'multipleOf', 'format'] },
  814. { type: 'string',
  815. rules: [ 'maxLength', 'minLength', 'pattern', 'format' ] },
  816. { type: 'array',
  817. rules: [ 'maxItems', 'minItems', 'items', 'contains', 'uniqueItems' ] },
  818. { type: 'object',
  819. rules: [ 'maxProperties', 'minProperties', 'required', 'dependencies', 'propertyNames',
  820. { 'properties': ['additionalProperties', 'patternProperties'] } ] },
  821. { rules: [ '$ref', 'const', 'enum', 'not', 'anyOf', 'oneOf', 'allOf', 'if' ] }
  822. ];
  823. var ALL = [ 'type', '$comment' ];
  824. var KEYWORDS = [
  825. '$schema', '$id', 'id', '$data', '$async', 'title',
  826. 'description', 'default', 'definitions',
  827. 'examples', 'readOnly', 'writeOnly',
  828. 'contentMediaType', 'contentEncoding',
  829. 'additionalItems', 'then', 'else'
  830. ];
  831. var TYPES = [ 'number', 'integer', 'string', 'array', 'object', 'boolean', 'null' ];
  832. RULES.all = toHash(ALL);
  833. RULES.types = toHash(TYPES);
  834. RULES.forEach(function (group) {
  835. group.rules = group.rules.map(function (keyword) {
  836. var implKeywords;
  837. if (typeof keyword == 'object') {
  838. var key = Object.keys(keyword)[0];
  839. implKeywords = keyword[key];
  840. keyword = key;
  841. implKeywords.forEach(function (k) {
  842. ALL.push(k);
  843. RULES.all[k] = true;
  844. });
  845. }
  846. ALL.push(keyword);
  847. var rule = RULES.all[keyword] = {
  848. keyword: keyword,
  849. code: ruleModules[keyword],
  850. implements: implKeywords
  851. };
  852. return rule;
  853. });
  854. RULES.all.$comment = {
  855. keyword: '$comment',
  856. code: ruleModules.$comment
  857. };
  858. if (group.type) RULES.types[group.type] = group;
  859. });
  860. RULES.keywords = toHash(ALL.concat(KEYWORDS));
  861. RULES.custom = {};
  862. return RULES;
  863. };
  864. },{"../dotjs":27,"./util":10}],8:[function(require,module,exports){
  865. 'use strict';
  866. var util = require('./util');
  867. module.exports = SchemaObject;
  868. function SchemaObject(obj) {
  869. util.copy(obj, this);
  870. }
  871. },{"./util":10}],9:[function(require,module,exports){
  872. 'use strict';
  873. // https://mathiasbynens.be/notes/javascript-encoding
  874. // https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
  875. module.exports = function ucs2length(str) {
  876. var length = 0
  877. , len = str.length
  878. , pos = 0
  879. , value;
  880. while (pos < len) {
  881. length++;
  882. value = str.charCodeAt(pos++);
  883. if (value >= 0xD800 && value <= 0xDBFF && pos < len) {
  884. // high surrogate, and there is a next character
  885. value = str.charCodeAt(pos);
  886. if ((value & 0xFC00) == 0xDC00) pos++; // low surrogate
  887. }
  888. }
  889. return length;
  890. };
  891. },{}],10:[function(require,module,exports){
  892. 'use strict';
  893. module.exports = {
  894. copy: copy,
  895. checkDataType: checkDataType,
  896. checkDataTypes: checkDataTypes,
  897. coerceToTypes: coerceToTypes,
  898. toHash: toHash,
  899. getProperty: getProperty,
  900. escapeQuotes: escapeQuotes,
  901. equal: require('fast-deep-equal'),
  902. ucs2length: require('./ucs2length'),
  903. varOccurences: varOccurences,
  904. varReplace: varReplace,
  905. cleanUpCode: cleanUpCode,
  906. finalCleanUpCode: finalCleanUpCode,
  907. schemaHasRules: schemaHasRules,
  908. schemaHasRulesExcept: schemaHasRulesExcept,
  909. schemaUnknownRules: schemaUnknownRules,
  910. toQuotedString: toQuotedString,
  911. getPathExpr: getPathExpr,
  912. getPath: getPath,
  913. getData: getData,
  914. unescapeFragment: unescapeFragment,
  915. unescapeJsonPointer: unescapeJsonPointer,
  916. escapeFragment: escapeFragment,
  917. escapeJsonPointer: escapeJsonPointer
  918. };
  919. function copy(o, to) {
  920. to = to || {};
  921. for (var key in o) to[key] = o[key];
  922. return to;
  923. }
  924. function checkDataType(dataType, data, negate) {
  925. var EQUAL = negate ? ' !== ' : ' === '
  926. , AND = negate ? ' || ' : ' && '
  927. , OK = negate ? '!' : ''
  928. , NOT = negate ? '' : '!';
  929. switch (dataType) {
  930. case 'null': return data + EQUAL + 'null';
  931. case 'array': return OK + 'Array.isArray(' + data + ')';
  932. case 'object': return '(' + OK + data + AND +
  933. 'typeof ' + data + EQUAL + '"object"' + AND +
  934. NOT + 'Array.isArray(' + data + '))';
  935. case 'integer': return '(typeof ' + data + EQUAL + '"number"' + AND +
  936. NOT + '(' + data + ' % 1)' +
  937. AND + data + EQUAL + data + ')';
  938. default: return 'typeof ' + data + EQUAL + '"' + dataType + '"';
  939. }
  940. }
  941. function checkDataTypes(dataTypes, data) {
  942. switch (dataTypes.length) {
  943. case 1: return checkDataType(dataTypes[0], data, true);
  944. default:
  945. var code = '';
  946. var types = toHash(dataTypes);
  947. if (types.array && types.object) {
  948. code = types.null ? '(': '(!' + data + ' || ';
  949. code += 'typeof ' + data + ' !== "object")';
  950. delete types.null;
  951. delete types.array;
  952. delete types.object;
  953. }
  954. if (types.number) delete types.integer;
  955. for (var t in types)
  956. code += (code ? ' && ' : '' ) + checkDataType(t, data, true);
  957. return code;
  958. }
  959. }
  960. var COERCE_TO_TYPES = toHash([ 'string', 'number', 'integer', 'boolean', 'null' ]);
  961. function coerceToTypes(optionCoerceTypes, dataTypes) {
  962. if (Array.isArray(dataTypes)) {
  963. var types = [];
  964. for (var i=0; i<dataTypes.length; i++) {
  965. var t = dataTypes[i];
  966. if (COERCE_TO_TYPES[t]) types[types.length] = t;
  967. else if (optionCoerceTypes === 'array' && t === 'array') types[types.length] = t;
  968. }
  969. if (types.length) return types;
  970. } else if (COERCE_TO_TYPES[dataTypes]) {
  971. return [dataTypes];
  972. } else if (optionCoerceTypes === 'array' && dataTypes === 'array') {
  973. return ['array'];
  974. }
  975. }
  976. function toHash(arr) {
  977. var hash = {};
  978. for (var i=0; i<arr.length; i++) hash[arr[i]] = true;
  979. return hash;
  980. }
  981. var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
  982. var SINGLE_QUOTE = /'|\\/g;
  983. function getProperty(key) {
  984. return typeof key == 'number'
  985. ? '[' + key + ']'
  986. : IDENTIFIER.test(key)
  987. ? '.' + key
  988. : "['" + escapeQuotes(key) + "']";
  989. }
  990. function escapeQuotes(str) {
  991. return str.replace(SINGLE_QUOTE, '\\$&')
  992. .replace(/\n/g, '\\n')
  993. .replace(/\r/g, '\\r')
  994. .replace(/\f/g, '\\f')
  995. .replace(/\t/g, '\\t');
  996. }
  997. function varOccurences(str, dataVar) {
  998. dataVar += '[^0-9]';
  999. var matches = str.match(new RegExp(dataVar, 'g'));
  1000. return matches ? matches.length : 0;
  1001. }
  1002. function varReplace(str, dataVar, expr) {
  1003. dataVar += '([^0-9])';
  1004. expr = expr.replace(/\$/g, '$$$$');
  1005. return str.replace(new RegExp(dataVar, 'g'), expr + '$1');
  1006. }
  1007. var EMPTY_ELSE = /else\s*{\s*}/g
  1008. , EMPTY_IF_NO_ELSE = /if\s*\([^)]+\)\s*\{\s*\}(?!\s*else)/g
  1009. , EMPTY_IF_WITH_ELSE = /if\s*\(([^)]+)\)\s*\{\s*\}\s*else(?!\s*if)/g;
  1010. function cleanUpCode(out) {
  1011. return out.replace(EMPTY_ELSE, '')
  1012. .replace(EMPTY_IF_NO_ELSE, '')
  1013. .replace(EMPTY_IF_WITH_ELSE, 'if (!($1))');
  1014. }
  1015. var ERRORS_REGEXP = /[^v.]errors/g
  1016. , REMOVE_ERRORS = /var errors = 0;|var vErrors = null;|validate.errors = vErrors;/g
  1017. , REMOVE_ERRORS_ASYNC = /var errors = 0;|var vErrors = null;/g
  1018. , RETURN_VALID = 'return errors === 0;'
  1019. , RETURN_TRUE = 'validate.errors = null; return true;'
  1020. , RETURN_ASYNC = /if \(errors === 0\) return data;\s*else throw new ValidationError\(vErrors\);/
  1021. , RETURN_DATA_ASYNC = 'return data;'
  1022. , ROOTDATA_REGEXP = /[^A-Za-z_$]rootData[^A-Za-z0-9_$]/g
  1023. , REMOVE_ROOTDATA = /if \(rootData === undefined\) rootData = data;/;
  1024. function finalCleanUpCode(out, async) {
  1025. var matches = out.match(ERRORS_REGEXP);
  1026. if (matches && matches.length == 2) {
  1027. out = async
  1028. ? out.replace(REMOVE_ERRORS_ASYNC, '')
  1029. .replace(RETURN_ASYNC, RETURN_DATA_ASYNC)
  1030. : out.replace(REMOVE_ERRORS, '')
  1031. .replace(RETURN_VALID, RETURN_TRUE);
  1032. }
  1033. matches = out.match(ROOTDATA_REGEXP);
  1034. if (!matches || matches.length !== 3) return out;
  1035. return out.replace(REMOVE_ROOTDATA, '');
  1036. }
  1037. function schemaHasRules(schema, rules) {
  1038. if (typeof schema == 'boolean') return !schema;
  1039. for (var key in schema) if (rules[key]) return true;
  1040. }
  1041. function schemaHasRulesExcept(schema, rules, exceptKeyword) {
  1042. if (typeof schema == 'boolean') return !schema && exceptKeyword != 'not';
  1043. for (var key in schema) if (key != exceptKeyword && rules[key]) return true;
  1044. }
  1045. function schemaUnknownRules(schema, rules) {
  1046. if (typeof schema == 'boolean') return;
  1047. for (var key in schema) if (!rules[key]) return key;
  1048. }
  1049. function toQuotedString(str) {
  1050. return '\'' + escapeQuotes(str) + '\'';
  1051. }
  1052. function getPathExpr(currentPath, expr, jsonPointers, isNumber) {
  1053. var path = jsonPointers // false by default
  1054. ? '\'/\' + ' + expr + (isNumber ? '' : '.replace(/~/g, \'~0\').replace(/\\//g, \'~1\')')
  1055. : (isNumber ? '\'[\' + ' + expr + ' + \']\'' : '\'[\\\'\' + ' + expr + ' + \'\\\']\'');
  1056. return joinPaths(currentPath, path);
  1057. }
  1058. function getPath(currentPath, prop, jsonPointers) {
  1059. var path = jsonPointers // false by default
  1060. ? toQuotedString('/' + escapeJsonPointer(prop))
  1061. : toQuotedString(getProperty(prop));
  1062. return joinPaths(currentPath, path);
  1063. }
  1064. var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
  1065. var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
  1066. function getData($data, lvl, paths) {
  1067. var up, jsonPointer, data, matches;
  1068. if ($data === '') return 'rootData';
  1069. if ($data[0] == '/') {
  1070. if (!JSON_POINTER.test($data)) throw new Error('Invalid JSON-pointer: ' + $data);
  1071. jsonPointer = $data;
  1072. data = 'rootData';
  1073. } else {
  1074. matches = $data.match(RELATIVE_JSON_POINTER);
  1075. if (!matches) throw new Error('Invalid JSON-pointer: ' + $data);
  1076. up = +matches[1];
  1077. jsonPointer = matches[2];
  1078. if (jsonPointer == '#') {
  1079. if (up >= lvl) throw new Error('Cannot access property/index ' + up + ' levels up, current level is ' + lvl);
  1080. return paths[lvl - up];
  1081. }
  1082. if (up > lvl) throw new Error('Cannot access data ' + up + ' levels up, current level is ' + lvl);
  1083. data = 'data' + ((lvl - up) || '');
  1084. if (!jsonPointer) return data;
  1085. }
  1086. var expr = data;
  1087. var segments = jsonPointer.split('/');
  1088. for (var i=0; i<segments.length; i++) {
  1089. var segment = segments[i];
  1090. if (segment) {
  1091. data += getProperty(unescapeJsonPointer(segment));
  1092. expr += ' && ' + data;
  1093. }
  1094. }
  1095. return expr;
  1096. }
  1097. function joinPaths (a, b) {
  1098. if (a == '""') return b;
  1099. return (a + ' + ' + b).replace(/' \+ '/g, '');
  1100. }
  1101. function unescapeFragment(str) {
  1102. return unescapeJsonPointer(decodeURIComponent(str));
  1103. }
  1104. function escapeFragment(str) {
  1105. return encodeURIComponent(escapeJsonPointer(str));
  1106. }
  1107. function escapeJsonPointer(str) {
  1108. return str.replace(/~/g, '~0').replace(/\//g, '~1');
  1109. }
  1110. function unescapeJsonPointer(str) {
  1111. return str.replace(/~1/g, '/').replace(/~0/g, '~');
  1112. }
  1113. },{"./ucs2length":9,"fast-deep-equal":42}],11:[function(require,module,exports){
  1114. 'use strict';
  1115. var KEYWORDS = [
  1116. 'multipleOf',
  1117. 'maximum',
  1118. 'exclusiveMaximum',
  1119. 'minimum',
  1120. 'exclusiveMinimum',
  1121. 'maxLength',
  1122. 'minLength',
  1123. 'pattern',
  1124. 'additionalItems',
  1125. 'maxItems',
  1126. 'minItems',
  1127. 'uniqueItems',
  1128. 'maxProperties',
  1129. 'minProperties',
  1130. 'required',
  1131. 'additionalProperties',
  1132. 'enum',
  1133. 'format',
  1134. 'const'
  1135. ];
  1136. module.exports = function (metaSchema, keywordsJsonPointers) {
  1137. for (var i=0; i<keywordsJsonPointers.length; i++) {
  1138. metaSchema = JSON.parse(JSON.stringify(metaSchema));
  1139. var segments = keywordsJsonPointers[i].split('/');
  1140. var keywords = metaSchema;
  1141. var j;
  1142. for (j=1; j<segments.length; j++)
  1143. keywords = keywords[segments[j]];
  1144. for (j=0; j<KEYWORDS.length; j++) {
  1145. var key = KEYWORDS[j];
  1146. var schema = keywords[key];
  1147. if (schema) {
  1148. keywords[key] = {
  1149. anyOf: [
  1150. schema,
  1151. { $ref: 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#' }
  1152. ]
  1153. };
  1154. }
  1155. }
  1156. }
  1157. return metaSchema;
  1158. };
  1159. },{}],12:[function(require,module,exports){
  1160. 'use strict';
  1161. var metaSchema = require('./refs/json-schema-draft-07.json');
  1162. module.exports = {
  1163. $id: 'https://github.com/epoberezkin/ajv/blob/master/lib/definition_schema.js',
  1164. definitions: {
  1165. simpleTypes: metaSchema.definitions.simpleTypes
  1166. },
  1167. type: 'object',
  1168. dependencies: {
  1169. schema: ['validate'],
  1170. $data: ['validate'],
  1171. statements: ['inline'],
  1172. valid: {not: {required: ['macro']}}
  1173. },
  1174. properties: {
  1175. type: metaSchema.properties.type,
  1176. schema: {type: 'boolean'},
  1177. statements: {type: 'boolean'},
  1178. dependencies: {
  1179. type: 'array',
  1180. items: {type: 'string'}
  1181. },
  1182. metaSchema: {type: 'object'},
  1183. modifying: {type: 'boolean'},
  1184. valid: {type: 'boolean'},
  1185. $data: {type: 'boolean'},
  1186. async: {type: 'boolean'},
  1187. errors: {
  1188. anyOf: [
  1189. {type: 'boolean'},
  1190. {const: 'full'}
  1191. ]
  1192. }
  1193. }
  1194. };
  1195. },{"./refs/json-schema-draft-07.json":41}],13:[function(require,module,exports){
  1196. 'use strict';
  1197. module.exports = function generate__limit(it, $keyword, $ruleType) {
  1198. var out = ' ';
  1199. var $lvl = it.level;
  1200. var $dataLvl = it.dataLevel;
  1201. var $schema = it.schema[$keyword];
  1202. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  1203. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  1204. var $breakOnError = !it.opts.allErrors;
  1205. var $errorKeyword;
  1206. var $data = 'data' + ($dataLvl || '');
  1207. var $isData = it.opts.$data && $schema && $schema.$data,
  1208. $schemaValue;
  1209. if ($isData) {
  1210. out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  1211. $schemaValue = 'schema' + $lvl;
  1212. } else {
  1213. $schemaValue = $schema;
  1214. }
  1215. var $isMax = $keyword == 'maximum',
  1216. $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum',
  1217. $schemaExcl = it.schema[$exclusiveKeyword],
  1218. $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data,
  1219. $op = $isMax ? '<' : '>',
  1220. $notOp = $isMax ? '>' : '<',
  1221. $errorKeyword = undefined;
  1222. if ($isDataExcl) {
  1223. var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr),
  1224. $exclusive = 'exclusive' + $lvl,
  1225. $exclType = 'exclType' + $lvl,
  1226. $exclIsNumber = 'exclIsNumber' + $lvl,
  1227. $opExpr = 'op' + $lvl,
  1228. $opStr = '\' + ' + $opExpr + ' + \'';
  1229. out += ' var schemaExcl' + ($lvl) + ' = ' + ($schemaValueExcl) + '; ';
  1230. $schemaValueExcl = 'schemaExcl' + $lvl;
  1231. out += ' var ' + ($exclusive) + '; var ' + ($exclType) + ' = typeof ' + ($schemaValueExcl) + '; if (' + ($exclType) + ' != \'boolean\' && ' + ($exclType) + ' != \'undefined\' && ' + ($exclType) + ' != \'number\') { ';
  1232. var $errorKeyword = $exclusiveKeyword;
  1233. var $$outStack = $$outStack || [];
  1234. $$outStack.push(out);
  1235. out = ''; /* istanbul ignore else */
  1236. if (it.createErrors !== false) {
  1237. out += ' { keyword: \'' + ($errorKeyword || '_exclusiveLimit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
  1238. if (it.opts.messages !== false) {
  1239. out += ' , message: \'' + ($exclusiveKeyword) + ' should be boolean\' ';
  1240. }
  1241. if (it.opts.verbose) {
  1242. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  1243. }
  1244. out += ' } ';
  1245. } else {
  1246. out += ' {} ';
  1247. }
  1248. var __err = out;
  1249. out = $$outStack.pop();
  1250. if (!it.compositeRule && $breakOnError) {
  1251. /* istanbul ignore if */
  1252. if (it.async) {
  1253. out += ' throw new ValidationError([' + (__err) + ']); ';
  1254. } else {
  1255. out += ' validate.errors = [' + (__err) + ']; return false; ';
  1256. }
  1257. } else {
  1258. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  1259. }
  1260. out += ' } else if ( ';
  1261. if ($isData) {
  1262. out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
  1263. }
  1264. out += ' ' + ($exclType) + ' == \'number\' ? ( (' + ($exclusive) + ' = ' + ($schemaValue) + ' === undefined || ' + ($schemaValueExcl) + ' ' + ($op) + '= ' + ($schemaValue) + ') ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaValueExcl) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) : ( (' + ($exclusive) + ' = ' + ($schemaValueExcl) + ' === true) ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaValue) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) || ' + ($data) + ' !== ' + ($data) + ') { var op' + ($lvl) + ' = ' + ($exclusive) + ' ? \'' + ($op) + '\' : \'' + ($op) + '=\'; ';
  1265. if ($schema === undefined) {
  1266. $errorKeyword = $exclusiveKeyword;
  1267. $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
  1268. $schemaValue = $schemaValueExcl;
  1269. $isData = $isDataExcl;
  1270. }
  1271. } else {
  1272. var $exclIsNumber = typeof $schemaExcl == 'number',
  1273. $opStr = $op;
  1274. if ($exclIsNumber && $isData) {
  1275. var $opExpr = '\'' + $opStr + '\'';
  1276. out += ' if ( ';
  1277. if ($isData) {
  1278. out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
  1279. }
  1280. out += ' ( ' + ($schemaValue) + ' === undefined || ' + ($schemaExcl) + ' ' + ($op) + '= ' + ($schemaValue) + ' ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaExcl) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) || ' + ($data) + ' !== ' + ($data) + ') { ';
  1281. } else {
  1282. if ($exclIsNumber && $schema === undefined) {
  1283. $exclusive = true;
  1284. $errorKeyword = $exclusiveKeyword;
  1285. $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
  1286. $schemaValue = $schemaExcl;
  1287. $notOp += '=';
  1288. } else {
  1289. if ($exclIsNumber) $schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema);
  1290. if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) {
  1291. $exclusive = true;
  1292. $errorKeyword = $exclusiveKeyword;
  1293. $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
  1294. $notOp += '=';
  1295. } else {
  1296. $exclusive = false;
  1297. $opStr += '=';
  1298. }
  1299. }
  1300. var $opExpr = '\'' + $opStr + '\'';
  1301. out += ' if ( ';
  1302. if ($isData) {
  1303. out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
  1304. }
  1305. out += ' ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' || ' + ($data) + ' !== ' + ($data) + ') { ';
  1306. }
  1307. }
  1308. $errorKeyword = $errorKeyword || $keyword;
  1309. var $$outStack = $$outStack || [];
  1310. $$outStack.push(out);
  1311. out = ''; /* istanbul ignore else */
  1312. if (it.createErrors !== false) {
  1313. out += ' { keyword: \'' + ($errorKeyword || '_limit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { comparison: ' + ($opExpr) + ', limit: ' + ($schemaValue) + ', exclusive: ' + ($exclusive) + ' } ';
  1314. if (it.opts.messages !== false) {
  1315. out += ' , message: \'should be ' + ($opStr) + ' ';
  1316. if ($isData) {
  1317. out += '\' + ' + ($schemaValue);
  1318. } else {
  1319. out += '' + ($schemaValue) + '\'';
  1320. }
  1321. }
  1322. if (it.opts.verbose) {
  1323. out += ' , schema: ';
  1324. if ($isData) {
  1325. out += 'validate.schema' + ($schemaPath);
  1326. } else {
  1327. out += '' + ($schema);
  1328. }
  1329. out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  1330. }
  1331. out += ' } ';
  1332. } else {
  1333. out += ' {} ';
  1334. }
  1335. var __err = out;
  1336. out = $$outStack.pop();
  1337. if (!it.compositeRule && $breakOnError) {
  1338. /* istanbul ignore if */
  1339. if (it.async) {
  1340. out += ' throw new ValidationError([' + (__err) + ']); ';
  1341. } else {
  1342. out += ' validate.errors = [' + (__err) + ']; return false; ';
  1343. }
  1344. } else {
  1345. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  1346. }
  1347. out += ' } ';
  1348. if ($breakOnError) {
  1349. out += ' else { ';
  1350. }
  1351. return out;
  1352. }
  1353. },{}],14:[function(require,module,exports){
  1354. 'use strict';
  1355. module.exports = function generate__limitItems(it, $keyword, $ruleType) {
  1356. var out = ' ';
  1357. var $lvl = it.level;
  1358. var $dataLvl = it.dataLevel;
  1359. var $schema = it.schema[$keyword];
  1360. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  1361. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  1362. var $breakOnError = !it.opts.allErrors;
  1363. var $errorKeyword;
  1364. var $data = 'data' + ($dataLvl || '');
  1365. var $isData = it.opts.$data && $schema && $schema.$data,
  1366. $schemaValue;
  1367. if ($isData) {
  1368. out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  1369. $schemaValue = 'schema' + $lvl;
  1370. } else {
  1371. $schemaValue = $schema;
  1372. }
  1373. var $op = $keyword == 'maxItems' ? '>' : '<';
  1374. out += 'if ( ';
  1375. if ($isData) {
  1376. out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
  1377. }
  1378. out += ' ' + ($data) + '.length ' + ($op) + ' ' + ($schemaValue) + ') { ';
  1379. var $errorKeyword = $keyword;
  1380. var $$outStack = $$outStack || [];
  1381. $$outStack.push(out);
  1382. out = ''; /* istanbul ignore else */
  1383. if (it.createErrors !== false) {
  1384. out += ' { keyword: \'' + ($errorKeyword || '_limitItems') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } ';
  1385. if (it.opts.messages !== false) {
  1386. out += ' , message: \'should NOT have ';
  1387. if ($keyword == 'maxItems') {
  1388. out += 'more';
  1389. } else {
  1390. out += 'fewer';
  1391. }
  1392. out += ' than ';
  1393. if ($isData) {
  1394. out += '\' + ' + ($schemaValue) + ' + \'';
  1395. } else {
  1396. out += '' + ($schema);
  1397. }
  1398. out += ' items\' ';
  1399. }
  1400. if (it.opts.verbose) {
  1401. out += ' , schema: ';
  1402. if ($isData) {
  1403. out += 'validate.schema' + ($schemaPath);
  1404. } else {
  1405. out += '' + ($schema);
  1406. }
  1407. out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  1408. }
  1409. out += ' } ';
  1410. } else {
  1411. out += ' {} ';
  1412. }
  1413. var __err = out;
  1414. out = $$outStack.pop();
  1415. if (!it.compositeRule && $breakOnError) {
  1416. /* istanbul ignore if */
  1417. if (it.async) {
  1418. out += ' throw new ValidationError([' + (__err) + ']); ';
  1419. } else {
  1420. out += ' validate.errors = [' + (__err) + ']; return false; ';
  1421. }
  1422. } else {
  1423. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  1424. }
  1425. out += '} ';
  1426. if ($breakOnError) {
  1427. out += ' else { ';
  1428. }
  1429. return out;
  1430. }
  1431. },{}],15:[function(require,module,exports){
  1432. 'use strict';
  1433. module.exports = function generate__limitLength(it, $keyword, $ruleType) {
  1434. var out = ' ';
  1435. var $lvl = it.level;
  1436. var $dataLvl = it.dataLevel;
  1437. var $schema = it.schema[$keyword];
  1438. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  1439. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  1440. var $breakOnError = !it.opts.allErrors;
  1441. var $errorKeyword;
  1442. var $data = 'data' + ($dataLvl || '');
  1443. var $isData = it.opts.$data && $schema && $schema.$data,
  1444. $schemaValue;
  1445. if ($isData) {
  1446. out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  1447. $schemaValue = 'schema' + $lvl;
  1448. } else {
  1449. $schemaValue = $schema;
  1450. }
  1451. var $op = $keyword == 'maxLength' ? '>' : '<';
  1452. out += 'if ( ';
  1453. if ($isData) {
  1454. out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
  1455. }
  1456. if (it.opts.unicode === false) {
  1457. out += ' ' + ($data) + '.length ';
  1458. } else {
  1459. out += ' ucs2length(' + ($data) + ') ';
  1460. }
  1461. out += ' ' + ($op) + ' ' + ($schemaValue) + ') { ';
  1462. var $errorKeyword = $keyword;
  1463. var $$outStack = $$outStack || [];
  1464. $$outStack.push(out);
  1465. out = ''; /* istanbul ignore else */
  1466. if (it.createErrors !== false) {
  1467. out += ' { keyword: \'' + ($errorKeyword || '_limitLength') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } ';
  1468. if (it.opts.messages !== false) {
  1469. out += ' , message: \'should NOT be ';
  1470. if ($keyword == 'maxLength') {
  1471. out += 'longer';
  1472. } else {
  1473. out += 'shorter';
  1474. }
  1475. out += ' than ';
  1476. if ($isData) {
  1477. out += '\' + ' + ($schemaValue) + ' + \'';
  1478. } else {
  1479. out += '' + ($schema);
  1480. }
  1481. out += ' characters\' ';
  1482. }
  1483. if (it.opts.verbose) {
  1484. out += ' , schema: ';
  1485. if ($isData) {
  1486. out += 'validate.schema' + ($schemaPath);
  1487. } else {
  1488. out += '' + ($schema);
  1489. }
  1490. out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  1491. }
  1492. out += ' } ';
  1493. } else {
  1494. out += ' {} ';
  1495. }
  1496. var __err = out;
  1497. out = $$outStack.pop();
  1498. if (!it.compositeRule && $breakOnError) {
  1499. /* istanbul ignore if */
  1500. if (it.async) {
  1501. out += ' throw new ValidationError([' + (__err) + ']); ';
  1502. } else {
  1503. out += ' validate.errors = [' + (__err) + ']; return false; ';
  1504. }
  1505. } else {
  1506. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  1507. }
  1508. out += '} ';
  1509. if ($breakOnError) {
  1510. out += ' else { ';
  1511. }
  1512. return out;
  1513. }
  1514. },{}],16:[function(require,module,exports){
  1515. 'use strict';
  1516. module.exports = function generate__limitProperties(it, $keyword, $ruleType) {
  1517. var out = ' ';
  1518. var $lvl = it.level;
  1519. var $dataLvl = it.dataLevel;
  1520. var $schema = it.schema[$keyword];
  1521. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  1522. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  1523. var $breakOnError = !it.opts.allErrors;
  1524. var $errorKeyword;
  1525. var $data = 'data' + ($dataLvl || '');
  1526. var $isData = it.opts.$data && $schema && $schema.$data,
  1527. $schemaValue;
  1528. if ($isData) {
  1529. out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  1530. $schemaValue = 'schema' + $lvl;
  1531. } else {
  1532. $schemaValue = $schema;
  1533. }
  1534. var $op = $keyword == 'maxProperties' ? '>' : '<';
  1535. out += 'if ( ';
  1536. if ($isData) {
  1537. out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
  1538. }
  1539. out += ' Object.keys(' + ($data) + ').length ' + ($op) + ' ' + ($schemaValue) + ') { ';
  1540. var $errorKeyword = $keyword;
  1541. var $$outStack = $$outStack || [];
  1542. $$outStack.push(out);
  1543. out = ''; /* istanbul ignore else */
  1544. if (it.createErrors !== false) {
  1545. out += ' { keyword: \'' + ($errorKeyword || '_limitProperties') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } ';
  1546. if (it.opts.messages !== false) {
  1547. out += ' , message: \'should NOT have ';
  1548. if ($keyword == 'maxProperties') {
  1549. out += 'more';
  1550. } else {
  1551. out += 'fewer';
  1552. }
  1553. out += ' than ';
  1554. if ($isData) {
  1555. out += '\' + ' + ($schemaValue) + ' + \'';
  1556. } else {
  1557. out += '' + ($schema);
  1558. }
  1559. out += ' properties\' ';
  1560. }
  1561. if (it.opts.verbose) {
  1562. out += ' , schema: ';
  1563. if ($isData) {
  1564. out += 'validate.schema' + ($schemaPath);
  1565. } else {
  1566. out += '' + ($schema);
  1567. }
  1568. out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  1569. }
  1570. out += ' } ';
  1571. } else {
  1572. out += ' {} ';
  1573. }
  1574. var __err = out;
  1575. out = $$outStack.pop();
  1576. if (!it.compositeRule && $breakOnError) {
  1577. /* istanbul ignore if */
  1578. if (it.async) {
  1579. out += ' throw new ValidationError([' + (__err) + ']); ';
  1580. } else {
  1581. out += ' validate.errors = [' + (__err) + ']; return false; ';
  1582. }
  1583. } else {
  1584. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  1585. }
  1586. out += '} ';
  1587. if ($breakOnError) {
  1588. out += ' else { ';
  1589. }
  1590. return out;
  1591. }
  1592. },{}],17:[function(require,module,exports){
  1593. 'use strict';
  1594. module.exports = function generate_allOf(it, $keyword, $ruleType) {
  1595. var out = ' ';
  1596. var $schema = it.schema[$keyword];
  1597. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  1598. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  1599. var $breakOnError = !it.opts.allErrors;
  1600. var $it = it.util.copy(it);
  1601. var $closingBraces = '';
  1602. $it.level++;
  1603. var $nextValid = 'valid' + $it.level;
  1604. var $currentBaseId = $it.baseId,
  1605. $allSchemasEmpty = true;
  1606. var arr1 = $schema;
  1607. if (arr1) {
  1608. var $sch, $i = -1,
  1609. l1 = arr1.length - 1;
  1610. while ($i < l1) {
  1611. $sch = arr1[$i += 1];
  1612. if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) {
  1613. $allSchemasEmpty = false;
  1614. $it.schema = $sch;
  1615. $it.schemaPath = $schemaPath + '[' + $i + ']';
  1616. $it.errSchemaPath = $errSchemaPath + '/' + $i;
  1617. out += ' ' + (it.validate($it)) + ' ';
  1618. $it.baseId = $currentBaseId;
  1619. if ($breakOnError) {
  1620. out += ' if (' + ($nextValid) + ') { ';
  1621. $closingBraces += '}';
  1622. }
  1623. }
  1624. }
  1625. }
  1626. if ($breakOnError) {
  1627. if ($allSchemasEmpty) {
  1628. out += ' if (true) { ';
  1629. } else {
  1630. out += ' ' + ($closingBraces.slice(0, -1)) + ' ';
  1631. }
  1632. }
  1633. out = it.util.cleanUpCode(out);
  1634. return out;
  1635. }
  1636. },{}],18:[function(require,module,exports){
  1637. 'use strict';
  1638. module.exports = function generate_anyOf(it, $keyword, $ruleType) {
  1639. var out = ' ';
  1640. var $lvl = it.level;
  1641. var $dataLvl = it.dataLevel;
  1642. var $schema = it.schema[$keyword];
  1643. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  1644. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  1645. var $breakOnError = !it.opts.allErrors;
  1646. var $data = 'data' + ($dataLvl || '');
  1647. var $valid = 'valid' + $lvl;
  1648. var $errs = 'errs__' + $lvl;
  1649. var $it = it.util.copy(it);
  1650. var $closingBraces = '';
  1651. $it.level++;
  1652. var $nextValid = 'valid' + $it.level;
  1653. var $noEmptySchema = $schema.every(function($sch) {
  1654. return (it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all));
  1655. });
  1656. if ($noEmptySchema) {
  1657. var $currentBaseId = $it.baseId;
  1658. out += ' var ' + ($errs) + ' = errors; var ' + ($valid) + ' = false; ';
  1659. var $wasComposite = it.compositeRule;
  1660. it.compositeRule = $it.compositeRule = true;
  1661. var arr1 = $schema;
  1662. if (arr1) {
  1663. var $sch, $i = -1,
  1664. l1 = arr1.length - 1;
  1665. while ($i < l1) {
  1666. $sch = arr1[$i += 1];
  1667. $it.schema = $sch;
  1668. $it.schemaPath = $schemaPath + '[' + $i + ']';
  1669. $it.errSchemaPath = $errSchemaPath + '/' + $i;
  1670. out += ' ' + (it.validate($it)) + ' ';
  1671. $it.baseId = $currentBaseId;
  1672. out += ' ' + ($valid) + ' = ' + ($valid) + ' || ' + ($nextValid) + '; if (!' + ($valid) + ') { ';
  1673. $closingBraces += '}';
  1674. }
  1675. }
  1676. it.compositeRule = $it.compositeRule = $wasComposite;
  1677. out += ' ' + ($closingBraces) + ' if (!' + ($valid) + ') { var err = '; /* istanbul ignore else */
  1678. if (it.createErrors !== false) {
  1679. out += ' { keyword: \'' + ('anyOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
  1680. if (it.opts.messages !== false) {
  1681. out += ' , message: \'should match some schema in anyOf\' ';
  1682. }
  1683. if (it.opts.verbose) {
  1684. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  1685. }
  1686. out += ' } ';
  1687. } else {
  1688. out += ' {} ';
  1689. }
  1690. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  1691. if (!it.compositeRule && $breakOnError) {
  1692. /* istanbul ignore if */
  1693. if (it.async) {
  1694. out += ' throw new ValidationError(vErrors); ';
  1695. } else {
  1696. out += ' validate.errors = vErrors; return false; ';
  1697. }
  1698. }
  1699. out += ' } else { errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } ';
  1700. if (it.opts.allErrors) {
  1701. out += ' } ';
  1702. }
  1703. out = it.util.cleanUpCode(out);
  1704. } else {
  1705. if ($breakOnError) {
  1706. out += ' if (true) { ';
  1707. }
  1708. }
  1709. return out;
  1710. }
  1711. },{}],19:[function(require,module,exports){
  1712. 'use strict';
  1713. module.exports = function generate_comment(it, $keyword, $ruleType) {
  1714. var out = ' ';
  1715. var $schema = it.schema[$keyword];
  1716. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  1717. var $breakOnError = !it.opts.allErrors;
  1718. var $comment = it.util.toQuotedString($schema);
  1719. if (it.opts.$comment === true) {
  1720. out += ' console.log(' + ($comment) + ');';
  1721. } else if (typeof it.opts.$comment == 'function') {
  1722. out += ' self._opts.$comment(' + ($comment) + ', ' + (it.util.toQuotedString($errSchemaPath)) + ', validate.root.schema);';
  1723. }
  1724. return out;
  1725. }
  1726. },{}],20:[function(require,module,exports){
  1727. 'use strict';
  1728. module.exports = function generate_const(it, $keyword, $ruleType) {
  1729. var out = ' ';
  1730. var $lvl = it.level;
  1731. var $dataLvl = it.dataLevel;
  1732. var $schema = it.schema[$keyword];
  1733. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  1734. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  1735. var $breakOnError = !it.opts.allErrors;
  1736. var $data = 'data' + ($dataLvl || '');
  1737. var $valid = 'valid' + $lvl;
  1738. var $isData = it.opts.$data && $schema && $schema.$data,
  1739. $schemaValue;
  1740. if ($isData) {
  1741. out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  1742. $schemaValue = 'schema' + $lvl;
  1743. } else {
  1744. $schemaValue = $schema;
  1745. }
  1746. if (!$isData) {
  1747. out += ' var schema' + ($lvl) + ' = validate.schema' + ($schemaPath) + ';';
  1748. }
  1749. out += 'var ' + ($valid) + ' = equal(' + ($data) + ', schema' + ($lvl) + '); if (!' + ($valid) + ') { ';
  1750. var $$outStack = $$outStack || [];
  1751. $$outStack.push(out);
  1752. out = ''; /* istanbul ignore else */
  1753. if (it.createErrors !== false) {
  1754. out += ' { keyword: \'' + ('const') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { allowedValue: schema' + ($lvl) + ' } ';
  1755. if (it.opts.messages !== false) {
  1756. out += ' , message: \'should be equal to constant\' ';
  1757. }
  1758. if (it.opts.verbose) {
  1759. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  1760. }
  1761. out += ' } ';
  1762. } else {
  1763. out += ' {} ';
  1764. }
  1765. var __err = out;
  1766. out = $$outStack.pop();
  1767. if (!it.compositeRule && $breakOnError) {
  1768. /* istanbul ignore if */
  1769. if (it.async) {
  1770. out += ' throw new ValidationError([' + (__err) + ']); ';
  1771. } else {
  1772. out += ' validate.errors = [' + (__err) + ']; return false; ';
  1773. }
  1774. } else {
  1775. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  1776. }
  1777. out += ' }';
  1778. if ($breakOnError) {
  1779. out += ' else { ';
  1780. }
  1781. return out;
  1782. }
  1783. },{}],21:[function(require,module,exports){
  1784. 'use strict';
  1785. module.exports = function generate_contains(it, $keyword, $ruleType) {
  1786. var out = ' ';
  1787. var $lvl = it.level;
  1788. var $dataLvl = it.dataLevel;
  1789. var $schema = it.schema[$keyword];
  1790. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  1791. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  1792. var $breakOnError = !it.opts.allErrors;
  1793. var $data = 'data' + ($dataLvl || '');
  1794. var $valid = 'valid' + $lvl;
  1795. var $errs = 'errs__' + $lvl;
  1796. var $it = it.util.copy(it);
  1797. var $closingBraces = '';
  1798. $it.level++;
  1799. var $nextValid = 'valid' + $it.level;
  1800. var $idx = 'i' + $lvl,
  1801. $dataNxt = $it.dataLevel = it.dataLevel + 1,
  1802. $nextData = 'data' + $dataNxt,
  1803. $currentBaseId = it.baseId,
  1804. $nonEmptySchema = (it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all));
  1805. out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';';
  1806. if ($nonEmptySchema) {
  1807. var $wasComposite = it.compositeRule;
  1808. it.compositeRule = $it.compositeRule = true;
  1809. $it.schema = $schema;
  1810. $it.schemaPath = $schemaPath;
  1811. $it.errSchemaPath = $errSchemaPath;
  1812. out += ' var ' + ($nextValid) + ' = false; for (var ' + ($idx) + ' = 0; ' + ($idx) + ' < ' + ($data) + '.length; ' + ($idx) + '++) { ';
  1813. $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
  1814. var $passData = $data + '[' + $idx + ']';
  1815. $it.dataPathArr[$dataNxt] = $idx;
  1816. var $code = it.validate($it);
  1817. $it.baseId = $currentBaseId;
  1818. if (it.util.varOccurences($code, $nextData) < 2) {
  1819. out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
  1820. } else {
  1821. out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
  1822. }
  1823. out += ' if (' + ($nextValid) + ') break; } ';
  1824. it.compositeRule = $it.compositeRule = $wasComposite;
  1825. out += ' ' + ($closingBraces) + ' if (!' + ($nextValid) + ') {';
  1826. } else {
  1827. out += ' if (' + ($data) + '.length == 0) {';
  1828. }
  1829. var $$outStack = $$outStack || [];
  1830. $$outStack.push(out);
  1831. out = ''; /* istanbul ignore else */
  1832. if (it.createErrors !== false) {
  1833. out += ' { keyword: \'' + ('contains') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
  1834. if (it.opts.messages !== false) {
  1835. out += ' , message: \'should contain a valid item\' ';
  1836. }
  1837. if (it.opts.verbose) {
  1838. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  1839. }
  1840. out += ' } ';
  1841. } else {
  1842. out += ' {} ';
  1843. }
  1844. var __err = out;
  1845. out = $$outStack.pop();
  1846. if (!it.compositeRule && $breakOnError) {
  1847. /* istanbul ignore if */
  1848. if (it.async) {
  1849. out += ' throw new ValidationError([' + (__err) + ']); ';
  1850. } else {
  1851. out += ' validate.errors = [' + (__err) + ']; return false; ';
  1852. }
  1853. } else {
  1854. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  1855. }
  1856. out += ' } else { ';
  1857. if ($nonEmptySchema) {
  1858. out += ' errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } ';
  1859. }
  1860. if (it.opts.allErrors) {
  1861. out += ' } ';
  1862. }
  1863. out = it.util.cleanUpCode(out);
  1864. return out;
  1865. }
  1866. },{}],22:[function(require,module,exports){
  1867. 'use strict';
  1868. module.exports = function generate_custom(it, $keyword, $ruleType) {
  1869. var out = ' ';
  1870. var $lvl = it.level;
  1871. var $dataLvl = it.dataLevel;
  1872. var $schema = it.schema[$keyword];
  1873. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  1874. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  1875. var $breakOnError = !it.opts.allErrors;
  1876. var $errorKeyword;
  1877. var $data = 'data' + ($dataLvl || '');
  1878. var $valid = 'valid' + $lvl;
  1879. var $errs = 'errs__' + $lvl;
  1880. var $isData = it.opts.$data && $schema && $schema.$data,
  1881. $schemaValue;
  1882. if ($isData) {
  1883. out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  1884. $schemaValue = 'schema' + $lvl;
  1885. } else {
  1886. $schemaValue = $schema;
  1887. }
  1888. var $rule = this,
  1889. $definition = 'definition' + $lvl,
  1890. $rDef = $rule.definition,
  1891. $closingBraces = '';
  1892. var $compile, $inline, $macro, $ruleValidate, $validateCode;
  1893. if ($isData && $rDef.$data) {
  1894. $validateCode = 'keywordValidate' + $lvl;
  1895. var $validateSchema = $rDef.validateSchema;
  1896. out += ' var ' + ($definition) + ' = RULES.custom[\'' + ($keyword) + '\'].definition; var ' + ($validateCode) + ' = ' + ($definition) + '.validate;';
  1897. } else {
  1898. $ruleValidate = it.useCustomRule($rule, $schema, it.schema, it);
  1899. if (!$ruleValidate) return;
  1900. $schemaValue = 'validate.schema' + $schemaPath;
  1901. $validateCode = $ruleValidate.code;
  1902. $compile = $rDef.compile;
  1903. $inline = $rDef.inline;
  1904. $macro = $rDef.macro;
  1905. }
  1906. var $ruleErrs = $validateCode + '.errors',
  1907. $i = 'i' + $lvl,
  1908. $ruleErr = 'ruleErr' + $lvl,
  1909. $asyncKeyword = $rDef.async;
  1910. if ($asyncKeyword && !it.async) throw new Error('async keyword in sync schema');
  1911. if (!($inline || $macro)) {
  1912. out += '' + ($ruleErrs) + ' = null;';
  1913. }
  1914. out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';';
  1915. if ($isData && $rDef.$data) {
  1916. $closingBraces += '}';
  1917. out += ' if (' + ($schemaValue) + ' === undefined) { ' + ($valid) + ' = true; } else { ';
  1918. if ($validateSchema) {
  1919. $closingBraces += '}';
  1920. out += ' ' + ($valid) + ' = ' + ($definition) + '.validateSchema(' + ($schemaValue) + '); if (' + ($valid) + ') { ';
  1921. }
  1922. }
  1923. if ($inline) {
  1924. if ($rDef.statements) {
  1925. out += ' ' + ($ruleValidate.validate) + ' ';
  1926. } else {
  1927. out += ' ' + ($valid) + ' = ' + ($ruleValidate.validate) + '; ';
  1928. }
  1929. } else if ($macro) {
  1930. var $it = it.util.copy(it);
  1931. var $closingBraces = '';
  1932. $it.level++;
  1933. var $nextValid = 'valid' + $it.level;
  1934. $it.schema = $ruleValidate.validate;
  1935. $it.schemaPath = '';
  1936. var $wasComposite = it.compositeRule;
  1937. it.compositeRule = $it.compositeRule = true;
  1938. var $code = it.validate($it).replace(/validate\.schema/g, $validateCode);
  1939. it.compositeRule = $it.compositeRule = $wasComposite;
  1940. out += ' ' + ($code);
  1941. } else {
  1942. var $$outStack = $$outStack || [];
  1943. $$outStack.push(out);
  1944. out = '';
  1945. out += ' ' + ($validateCode) + '.call( ';
  1946. if (it.opts.passContext) {
  1947. out += 'this';
  1948. } else {
  1949. out += 'self';
  1950. }
  1951. if ($compile || $rDef.schema === false) {
  1952. out += ' , ' + ($data) + ' ';
  1953. } else {
  1954. out += ' , ' + ($schemaValue) + ' , ' + ($data) + ' , validate.schema' + (it.schemaPath) + ' ';
  1955. }
  1956. out += ' , (dataPath || \'\')';
  1957. if (it.errorPath != '""') {
  1958. out += ' + ' + (it.errorPath);
  1959. }
  1960. var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData',
  1961. $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
  1962. out += ' , ' + ($parentData) + ' , ' + ($parentDataProperty) + ' , rootData ) ';
  1963. var def_callRuleValidate = out;
  1964. out = $$outStack.pop();
  1965. if ($rDef.errors === false) {
  1966. out += ' ' + ($valid) + ' = ';
  1967. if ($asyncKeyword) {
  1968. out += 'await ';
  1969. }
  1970. out += '' + (def_callRuleValidate) + '; ';
  1971. } else {
  1972. if ($asyncKeyword) {
  1973. $ruleErrs = 'customErrors' + $lvl;
  1974. out += ' var ' + ($ruleErrs) + ' = null; try { ' + ($valid) + ' = await ' + (def_callRuleValidate) + '; } catch (e) { ' + ($valid) + ' = false; if (e instanceof ValidationError) ' + ($ruleErrs) + ' = e.errors; else throw e; } ';
  1975. } else {
  1976. out += ' ' + ($ruleErrs) + ' = null; ' + ($valid) + ' = ' + (def_callRuleValidate) + '; ';
  1977. }
  1978. }
  1979. }
  1980. if ($rDef.modifying) {
  1981. out += ' if (' + ($parentData) + ') ' + ($data) + ' = ' + ($parentData) + '[' + ($parentDataProperty) + '];';
  1982. }
  1983. out += '' + ($closingBraces);
  1984. if ($rDef.valid) {
  1985. if ($breakOnError) {
  1986. out += ' if (true) { ';
  1987. }
  1988. } else {
  1989. out += ' if ( ';
  1990. if ($rDef.valid === undefined) {
  1991. out += ' !';
  1992. if ($macro) {
  1993. out += '' + ($nextValid);
  1994. } else {
  1995. out += '' + ($valid);
  1996. }
  1997. } else {
  1998. out += ' ' + (!$rDef.valid) + ' ';
  1999. }
  2000. out += ') { ';
  2001. $errorKeyword = $rule.keyword;
  2002. var $$outStack = $$outStack || [];
  2003. $$outStack.push(out);
  2004. out = '';
  2005. var $$outStack = $$outStack || [];
  2006. $$outStack.push(out);
  2007. out = ''; /* istanbul ignore else */
  2008. if (it.createErrors !== false) {
  2009. out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { keyword: \'' + ($rule.keyword) + '\' } ';
  2010. if (it.opts.messages !== false) {
  2011. out += ' , message: \'should pass "' + ($rule.keyword) + '" keyword validation\' ';
  2012. }
  2013. if (it.opts.verbose) {
  2014. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  2015. }
  2016. out += ' } ';
  2017. } else {
  2018. out += ' {} ';
  2019. }
  2020. var __err = out;
  2021. out = $$outStack.pop();
  2022. if (!it.compositeRule && $breakOnError) {
  2023. /* istanbul ignore if */
  2024. if (it.async) {
  2025. out += ' throw new ValidationError([' + (__err) + ']); ';
  2026. } else {
  2027. out += ' validate.errors = [' + (__err) + ']; return false; ';
  2028. }
  2029. } else {
  2030. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  2031. }
  2032. var def_customError = out;
  2033. out = $$outStack.pop();
  2034. if ($inline) {
  2035. if ($rDef.errors) {
  2036. if ($rDef.errors != 'full') {
  2037. out += ' for (var ' + ($i) + '=' + ($errs) + '; ' + ($i) + '<errors; ' + ($i) + '++) { var ' + ($ruleErr) + ' = vErrors[' + ($i) + ']; if (' + ($ruleErr) + '.dataPath === undefined) ' + ($ruleErr) + '.dataPath = (dataPath || \'\') + ' + (it.errorPath) + '; if (' + ($ruleErr) + '.schemaPath === undefined) { ' + ($ruleErr) + '.schemaPath = "' + ($errSchemaPath) + '"; } ';
  2038. if (it.opts.verbose) {
  2039. out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
  2040. }
  2041. out += ' } ';
  2042. }
  2043. } else {
  2044. if ($rDef.errors === false) {
  2045. out += ' ' + (def_customError) + ' ';
  2046. } else {
  2047. out += ' if (' + ($errs) + ' == errors) { ' + (def_customError) + ' } else { for (var ' + ($i) + '=' + ($errs) + '; ' + ($i) + '<errors; ' + ($i) + '++) { var ' + ($ruleErr) + ' = vErrors[' + ($i) + ']; if (' + ($ruleErr) + '.dataPath === undefined) ' + ($ruleErr) + '.dataPath = (dataPath || \'\') + ' + (it.errorPath) + '; if (' + ($ruleErr) + '.schemaPath === undefined) { ' + ($ruleErr) + '.schemaPath = "' + ($errSchemaPath) + '"; } ';
  2048. if (it.opts.verbose) {
  2049. out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
  2050. }
  2051. out += ' } } ';
  2052. }
  2053. }
  2054. } else if ($macro) {
  2055. out += ' var err = '; /* istanbul ignore else */
  2056. if (it.createErrors !== false) {
  2057. out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { keyword: \'' + ($rule.keyword) + '\' } ';
  2058. if (it.opts.messages !== false) {
  2059. out += ' , message: \'should pass "' + ($rule.keyword) + '" keyword validation\' ';
  2060. }
  2061. if (it.opts.verbose) {
  2062. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  2063. }
  2064. out += ' } ';
  2065. } else {
  2066. out += ' {} ';
  2067. }
  2068. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  2069. if (!it.compositeRule && $breakOnError) {
  2070. /* istanbul ignore if */
  2071. if (it.async) {
  2072. out += ' throw new ValidationError(vErrors); ';
  2073. } else {
  2074. out += ' validate.errors = vErrors; return false; ';
  2075. }
  2076. }
  2077. } else {
  2078. if ($rDef.errors === false) {
  2079. out += ' ' + (def_customError) + ' ';
  2080. } else {
  2081. out += ' if (Array.isArray(' + ($ruleErrs) + ')) { if (vErrors === null) vErrors = ' + ($ruleErrs) + '; else vErrors = vErrors.concat(' + ($ruleErrs) + '); errors = vErrors.length; for (var ' + ($i) + '=' + ($errs) + '; ' + ($i) + '<errors; ' + ($i) + '++) { var ' + ($ruleErr) + ' = vErrors[' + ($i) + ']; if (' + ($ruleErr) + '.dataPath === undefined) ' + ($ruleErr) + '.dataPath = (dataPath || \'\') + ' + (it.errorPath) + '; ' + ($ruleErr) + '.schemaPath = "' + ($errSchemaPath) + '"; ';
  2082. if (it.opts.verbose) {
  2083. out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
  2084. }
  2085. out += ' } } else { ' + (def_customError) + ' } ';
  2086. }
  2087. }
  2088. out += ' } ';
  2089. if ($breakOnError) {
  2090. out += ' else { ';
  2091. }
  2092. }
  2093. return out;
  2094. }
  2095. },{}],23:[function(require,module,exports){
  2096. 'use strict';
  2097. module.exports = function generate_dependencies(it, $keyword, $ruleType) {
  2098. var out = ' ';
  2099. var $lvl = it.level;
  2100. var $dataLvl = it.dataLevel;
  2101. var $schema = it.schema[$keyword];
  2102. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  2103. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  2104. var $breakOnError = !it.opts.allErrors;
  2105. var $data = 'data' + ($dataLvl || '');
  2106. var $errs = 'errs__' + $lvl;
  2107. var $it = it.util.copy(it);
  2108. var $closingBraces = '';
  2109. $it.level++;
  2110. var $nextValid = 'valid' + $it.level;
  2111. var $schemaDeps = {},
  2112. $propertyDeps = {},
  2113. $ownProperties = it.opts.ownProperties;
  2114. for ($property in $schema) {
  2115. var $sch = $schema[$property];
  2116. var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
  2117. $deps[$property] = $sch;
  2118. }
  2119. out += 'var ' + ($errs) + ' = errors;';
  2120. var $currentErrorPath = it.errorPath;
  2121. out += 'var missing' + ($lvl) + ';';
  2122. for (var $property in $propertyDeps) {
  2123. $deps = $propertyDeps[$property];
  2124. if ($deps.length) {
  2125. out += ' if ( ' + ($data) + (it.util.getProperty($property)) + ' !== undefined ';
  2126. if ($ownProperties) {
  2127. out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($property)) + '\') ';
  2128. }
  2129. if ($breakOnError) {
  2130. out += ' && ( ';
  2131. var arr1 = $deps;
  2132. if (arr1) {
  2133. var $propertyKey, $i = -1,
  2134. l1 = arr1.length - 1;
  2135. while ($i < l1) {
  2136. $propertyKey = arr1[$i += 1];
  2137. if ($i) {
  2138. out += ' || ';
  2139. }
  2140. var $prop = it.util.getProperty($propertyKey),
  2141. $useData = $data + $prop;
  2142. out += ' ( ( ' + ($useData) + ' === undefined ';
  2143. if ($ownProperties) {
  2144. out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
  2145. }
  2146. out += ') && (missing' + ($lvl) + ' = ' + (it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop)) + ') ) ';
  2147. }
  2148. }
  2149. out += ')) { ';
  2150. var $propertyPath = 'missing' + $lvl,
  2151. $missingProperty = '\' + ' + $propertyPath + ' + \'';
  2152. if (it.opts._errorDataPathProperty) {
  2153. it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath;
  2154. }
  2155. var $$outStack = $$outStack || [];
  2156. $$outStack.push(out);
  2157. out = ''; /* istanbul ignore else */
  2158. if (it.createErrors !== false) {
  2159. out += ' { keyword: \'' + ('dependencies') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { property: \'' + (it.util.escapeQuotes($property)) + '\', missingProperty: \'' + ($missingProperty) + '\', depsCount: ' + ($deps.length) + ', deps: \'' + (it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", "))) + '\' } ';
  2160. if (it.opts.messages !== false) {
  2161. out += ' , message: \'should have ';
  2162. if ($deps.length == 1) {
  2163. out += 'property ' + (it.util.escapeQuotes($deps[0]));
  2164. } else {
  2165. out += 'properties ' + (it.util.escapeQuotes($deps.join(", ")));
  2166. }
  2167. out += ' when property ' + (it.util.escapeQuotes($property)) + ' is present\' ';
  2168. }
  2169. if (it.opts.verbose) {
  2170. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  2171. }
  2172. out += ' } ';
  2173. } else {
  2174. out += ' {} ';
  2175. }
  2176. var __err = out;
  2177. out = $$outStack.pop();
  2178. if (!it.compositeRule && $breakOnError) {
  2179. /* istanbul ignore if */
  2180. if (it.async) {
  2181. out += ' throw new ValidationError([' + (__err) + ']); ';
  2182. } else {
  2183. out += ' validate.errors = [' + (__err) + ']; return false; ';
  2184. }
  2185. } else {
  2186. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  2187. }
  2188. } else {
  2189. out += ' ) { ';
  2190. var arr2 = $deps;
  2191. if (arr2) {
  2192. var $propertyKey, i2 = -1,
  2193. l2 = arr2.length - 1;
  2194. while (i2 < l2) {
  2195. $propertyKey = arr2[i2 += 1];
  2196. var $prop = it.util.getProperty($propertyKey),
  2197. $missingProperty = it.util.escapeQuotes($propertyKey),
  2198. $useData = $data + $prop;
  2199. if (it.opts._errorDataPathProperty) {
  2200. it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
  2201. }
  2202. out += ' if ( ' + ($useData) + ' === undefined ';
  2203. if ($ownProperties) {
  2204. out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
  2205. }
  2206. out += ') { var err = '; /* istanbul ignore else */
  2207. if (it.createErrors !== false) {
  2208. out += ' { keyword: \'' + ('dependencies') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { property: \'' + (it.util.escapeQuotes($property)) + '\', missingProperty: \'' + ($missingProperty) + '\', depsCount: ' + ($deps.length) + ', deps: \'' + (it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", "))) + '\' } ';
  2209. if (it.opts.messages !== false) {
  2210. out += ' , message: \'should have ';
  2211. if ($deps.length == 1) {
  2212. out += 'property ' + (it.util.escapeQuotes($deps[0]));
  2213. } else {
  2214. out += 'properties ' + (it.util.escapeQuotes($deps.join(", ")));
  2215. }
  2216. out += ' when property ' + (it.util.escapeQuotes($property)) + ' is present\' ';
  2217. }
  2218. if (it.opts.verbose) {
  2219. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  2220. }
  2221. out += ' } ';
  2222. } else {
  2223. out += ' {} ';
  2224. }
  2225. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ';
  2226. }
  2227. }
  2228. }
  2229. out += ' } ';
  2230. if ($breakOnError) {
  2231. $closingBraces += '}';
  2232. out += ' else { ';
  2233. }
  2234. }
  2235. }
  2236. it.errorPath = $currentErrorPath;
  2237. var $currentBaseId = $it.baseId;
  2238. for (var $property in $schemaDeps) {
  2239. var $sch = $schemaDeps[$property];
  2240. if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) {
  2241. out += ' ' + ($nextValid) + ' = true; if ( ' + ($data) + (it.util.getProperty($property)) + ' !== undefined ';
  2242. if ($ownProperties) {
  2243. out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($property)) + '\') ';
  2244. }
  2245. out += ') { ';
  2246. $it.schema = $sch;
  2247. $it.schemaPath = $schemaPath + it.util.getProperty($property);
  2248. $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($property);
  2249. out += ' ' + (it.validate($it)) + ' ';
  2250. $it.baseId = $currentBaseId;
  2251. out += ' } ';
  2252. if ($breakOnError) {
  2253. out += ' if (' + ($nextValid) + ') { ';
  2254. $closingBraces += '}';
  2255. }
  2256. }
  2257. }
  2258. if ($breakOnError) {
  2259. out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
  2260. }
  2261. out = it.util.cleanUpCode(out);
  2262. return out;
  2263. }
  2264. },{}],24:[function(require,module,exports){
  2265. 'use strict';
  2266. module.exports = function generate_enum(it, $keyword, $ruleType) {
  2267. var out = ' ';
  2268. var $lvl = it.level;
  2269. var $dataLvl = it.dataLevel;
  2270. var $schema = it.schema[$keyword];
  2271. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  2272. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  2273. var $breakOnError = !it.opts.allErrors;
  2274. var $data = 'data' + ($dataLvl || '');
  2275. var $valid = 'valid' + $lvl;
  2276. var $isData = it.opts.$data && $schema && $schema.$data,
  2277. $schemaValue;
  2278. if ($isData) {
  2279. out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  2280. $schemaValue = 'schema' + $lvl;
  2281. } else {
  2282. $schemaValue = $schema;
  2283. }
  2284. var $i = 'i' + $lvl,
  2285. $vSchema = 'schema' + $lvl;
  2286. if (!$isData) {
  2287. out += ' var ' + ($vSchema) + ' = validate.schema' + ($schemaPath) + ';';
  2288. }
  2289. out += 'var ' + ($valid) + ';';
  2290. if ($isData) {
  2291. out += ' if (schema' + ($lvl) + ' === undefined) ' + ($valid) + ' = true; else if (!Array.isArray(schema' + ($lvl) + ')) ' + ($valid) + ' = false; else {';
  2292. }
  2293. out += '' + ($valid) + ' = false;for (var ' + ($i) + '=0; ' + ($i) + '<' + ($vSchema) + '.length; ' + ($i) + '++) if (equal(' + ($data) + ', ' + ($vSchema) + '[' + ($i) + '])) { ' + ($valid) + ' = true; break; }';
  2294. if ($isData) {
  2295. out += ' } ';
  2296. }
  2297. out += ' if (!' + ($valid) + ') { ';
  2298. var $$outStack = $$outStack || [];
  2299. $$outStack.push(out);
  2300. out = ''; /* istanbul ignore else */
  2301. if (it.createErrors !== false) {
  2302. out += ' { keyword: \'' + ('enum') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { allowedValues: schema' + ($lvl) + ' } ';
  2303. if (it.opts.messages !== false) {
  2304. out += ' , message: \'should be equal to one of the allowed values\' ';
  2305. }
  2306. if (it.opts.verbose) {
  2307. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  2308. }
  2309. out += ' } ';
  2310. } else {
  2311. out += ' {} ';
  2312. }
  2313. var __err = out;
  2314. out = $$outStack.pop();
  2315. if (!it.compositeRule && $breakOnError) {
  2316. /* istanbul ignore if */
  2317. if (it.async) {
  2318. out += ' throw new ValidationError([' + (__err) + ']); ';
  2319. } else {
  2320. out += ' validate.errors = [' + (__err) + ']; return false; ';
  2321. }
  2322. } else {
  2323. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  2324. }
  2325. out += ' }';
  2326. if ($breakOnError) {
  2327. out += ' else { ';
  2328. }
  2329. return out;
  2330. }
  2331. },{}],25:[function(require,module,exports){
  2332. 'use strict';
  2333. module.exports = function generate_format(it, $keyword, $ruleType) {
  2334. var out = ' ';
  2335. var $lvl = it.level;
  2336. var $dataLvl = it.dataLevel;
  2337. var $schema = it.schema[$keyword];
  2338. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  2339. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  2340. var $breakOnError = !it.opts.allErrors;
  2341. var $data = 'data' + ($dataLvl || '');
  2342. if (it.opts.format === false) {
  2343. if ($breakOnError) {
  2344. out += ' if (true) { ';
  2345. }
  2346. return out;
  2347. }
  2348. var $isData = it.opts.$data && $schema && $schema.$data,
  2349. $schemaValue;
  2350. if ($isData) {
  2351. out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  2352. $schemaValue = 'schema' + $lvl;
  2353. } else {
  2354. $schemaValue = $schema;
  2355. }
  2356. var $unknownFormats = it.opts.unknownFormats,
  2357. $allowUnknown = Array.isArray($unknownFormats);
  2358. if ($isData) {
  2359. var $format = 'format' + $lvl,
  2360. $isObject = 'isObject' + $lvl,
  2361. $formatType = 'formatType' + $lvl;
  2362. out += ' var ' + ($format) + ' = formats[' + ($schemaValue) + ']; var ' + ($isObject) + ' = typeof ' + ($format) + ' == \'object\' && !(' + ($format) + ' instanceof RegExp) && ' + ($format) + '.validate; var ' + ($formatType) + ' = ' + ($isObject) + ' && ' + ($format) + '.type || \'string\'; if (' + ($isObject) + ') { ';
  2363. if (it.async) {
  2364. out += ' var async' + ($lvl) + ' = ' + ($format) + '.async; ';
  2365. }
  2366. out += ' ' + ($format) + ' = ' + ($format) + '.validate; } if ( ';
  2367. if ($isData) {
  2368. out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'string\') || ';
  2369. }
  2370. out += ' (';
  2371. if ($unknownFormats != 'ignore') {
  2372. out += ' (' + ($schemaValue) + ' && !' + ($format) + ' ';
  2373. if ($allowUnknown) {
  2374. out += ' && self._opts.unknownFormats.indexOf(' + ($schemaValue) + ') == -1 ';
  2375. }
  2376. out += ') || ';
  2377. }
  2378. out += ' (' + ($format) + ' && ' + ($formatType) + ' == \'' + ($ruleType) + '\' && !(typeof ' + ($format) + ' == \'function\' ? ';
  2379. if (it.async) {
  2380. out += ' (async' + ($lvl) + ' ? await ' + ($format) + '(' + ($data) + ') : ' + ($format) + '(' + ($data) + ')) ';
  2381. } else {
  2382. out += ' ' + ($format) + '(' + ($data) + ') ';
  2383. }
  2384. out += ' : ' + ($format) + '.test(' + ($data) + '))))) {';
  2385. } else {
  2386. var $format = it.formats[$schema];
  2387. if (!$format) {
  2388. if ($unknownFormats == 'ignore') {
  2389. it.logger.warn('unknown format "' + $schema + '" ignored in schema at path "' + it.errSchemaPath + '"');
  2390. if ($breakOnError) {
  2391. out += ' if (true) { ';
  2392. }
  2393. return out;
  2394. } else if ($allowUnknown && $unknownFormats.indexOf($schema) >= 0) {
  2395. if ($breakOnError) {
  2396. out += ' if (true) { ';
  2397. }
  2398. return out;
  2399. } else {
  2400. throw new Error('unknown format "' + $schema + '" is used in schema at path "' + it.errSchemaPath + '"');
  2401. }
  2402. }
  2403. var $isObject = typeof $format == 'object' && !($format instanceof RegExp) && $format.validate;
  2404. var $formatType = $isObject && $format.type || 'string';
  2405. if ($isObject) {
  2406. var $async = $format.async === true;
  2407. $format = $format.validate;
  2408. }
  2409. if ($formatType != $ruleType) {
  2410. if ($breakOnError) {
  2411. out += ' if (true) { ';
  2412. }
  2413. return out;
  2414. }
  2415. if ($async) {
  2416. if (!it.async) throw new Error('async format in sync schema');
  2417. var $formatRef = 'formats' + it.util.getProperty($schema) + '.validate';
  2418. out += ' if (!(await ' + ($formatRef) + '(' + ($data) + '))) { ';
  2419. } else {
  2420. out += ' if (! ';
  2421. var $formatRef = 'formats' + it.util.getProperty($schema);
  2422. if ($isObject) $formatRef += '.validate';
  2423. if (typeof $format == 'function') {
  2424. out += ' ' + ($formatRef) + '(' + ($data) + ') ';
  2425. } else {
  2426. out += ' ' + ($formatRef) + '.test(' + ($data) + ') ';
  2427. }
  2428. out += ') { ';
  2429. }
  2430. }
  2431. var $$outStack = $$outStack || [];
  2432. $$outStack.push(out);
  2433. out = ''; /* istanbul ignore else */
  2434. if (it.createErrors !== false) {
  2435. out += ' { keyword: \'' + ('format') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { format: ';
  2436. if ($isData) {
  2437. out += '' + ($schemaValue);
  2438. } else {
  2439. out += '' + (it.util.toQuotedString($schema));
  2440. }
  2441. out += ' } ';
  2442. if (it.opts.messages !== false) {
  2443. out += ' , message: \'should match format "';
  2444. if ($isData) {
  2445. out += '\' + ' + ($schemaValue) + ' + \'';
  2446. } else {
  2447. out += '' + (it.util.escapeQuotes($schema));
  2448. }
  2449. out += '"\' ';
  2450. }
  2451. if (it.opts.verbose) {
  2452. out += ' , schema: ';
  2453. if ($isData) {
  2454. out += 'validate.schema' + ($schemaPath);
  2455. } else {
  2456. out += '' + (it.util.toQuotedString($schema));
  2457. }
  2458. out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  2459. }
  2460. out += ' } ';
  2461. } else {
  2462. out += ' {} ';
  2463. }
  2464. var __err = out;
  2465. out = $$outStack.pop();
  2466. if (!it.compositeRule && $breakOnError) {
  2467. /* istanbul ignore if */
  2468. if (it.async) {
  2469. out += ' throw new ValidationError([' + (__err) + ']); ';
  2470. } else {
  2471. out += ' validate.errors = [' + (__err) + ']; return false; ';
  2472. }
  2473. } else {
  2474. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  2475. }
  2476. out += ' } ';
  2477. if ($breakOnError) {
  2478. out += ' else { ';
  2479. }
  2480. return out;
  2481. }
  2482. },{}],26:[function(require,module,exports){
  2483. 'use strict';
  2484. module.exports = function generate_if(it, $keyword, $ruleType) {
  2485. var out = ' ';
  2486. var $lvl = it.level;
  2487. var $dataLvl = it.dataLevel;
  2488. var $schema = it.schema[$keyword];
  2489. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  2490. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  2491. var $breakOnError = !it.opts.allErrors;
  2492. var $data = 'data' + ($dataLvl || '');
  2493. var $valid = 'valid' + $lvl;
  2494. var $errs = 'errs__' + $lvl;
  2495. var $it = it.util.copy(it);
  2496. $it.level++;
  2497. var $nextValid = 'valid' + $it.level;
  2498. var $thenSch = it.schema['then'],
  2499. $elseSch = it.schema['else'],
  2500. $thenPresent = $thenSch !== undefined && (it.opts.strictKeywords ? typeof $thenSch == 'object' && Object.keys($thenSch).length > 0 : it.util.schemaHasRules($thenSch, it.RULES.all)),
  2501. $elsePresent = $elseSch !== undefined && (it.opts.strictKeywords ? typeof $elseSch == 'object' && Object.keys($elseSch).length > 0 : it.util.schemaHasRules($elseSch, it.RULES.all)),
  2502. $currentBaseId = $it.baseId;
  2503. if ($thenPresent || $elsePresent) {
  2504. var $ifClause;
  2505. $it.createErrors = false;
  2506. $it.schema = $schema;
  2507. $it.schemaPath = $schemaPath;
  2508. $it.errSchemaPath = $errSchemaPath;
  2509. out += ' var ' + ($errs) + ' = errors; var ' + ($valid) + ' = true; ';
  2510. var $wasComposite = it.compositeRule;
  2511. it.compositeRule = $it.compositeRule = true;
  2512. out += ' ' + (it.validate($it)) + ' ';
  2513. $it.baseId = $currentBaseId;
  2514. $it.createErrors = true;
  2515. out += ' errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } ';
  2516. it.compositeRule = $it.compositeRule = $wasComposite;
  2517. if ($thenPresent) {
  2518. out += ' if (' + ($nextValid) + ') { ';
  2519. $it.schema = it.schema['then'];
  2520. $it.schemaPath = it.schemaPath + '.then';
  2521. $it.errSchemaPath = it.errSchemaPath + '/then';
  2522. out += ' ' + (it.validate($it)) + ' ';
  2523. $it.baseId = $currentBaseId;
  2524. out += ' ' + ($valid) + ' = ' + ($nextValid) + '; ';
  2525. if ($thenPresent && $elsePresent) {
  2526. $ifClause = 'ifClause' + $lvl;
  2527. out += ' var ' + ($ifClause) + ' = \'then\'; ';
  2528. } else {
  2529. $ifClause = '\'then\'';
  2530. }
  2531. out += ' } ';
  2532. if ($elsePresent) {
  2533. out += ' else { ';
  2534. }
  2535. } else {
  2536. out += ' if (!' + ($nextValid) + ') { ';
  2537. }
  2538. if ($elsePresent) {
  2539. $it.schema = it.schema['else'];
  2540. $it.schemaPath = it.schemaPath + '.else';
  2541. $it.errSchemaPath = it.errSchemaPath + '/else';
  2542. out += ' ' + (it.validate($it)) + ' ';
  2543. $it.baseId = $currentBaseId;
  2544. out += ' ' + ($valid) + ' = ' + ($nextValid) + '; ';
  2545. if ($thenPresent && $elsePresent) {
  2546. $ifClause = 'ifClause' + $lvl;
  2547. out += ' var ' + ($ifClause) + ' = \'else\'; ';
  2548. } else {
  2549. $ifClause = '\'else\'';
  2550. }
  2551. out += ' } ';
  2552. }
  2553. out += ' if (!' + ($valid) + ') { var err = '; /* istanbul ignore else */
  2554. if (it.createErrors !== false) {
  2555. out += ' { keyword: \'' + ('if') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { failingKeyword: ' + ($ifClause) + ' } ';
  2556. if (it.opts.messages !== false) {
  2557. out += ' , message: \'should match "\' + ' + ($ifClause) + ' + \'" schema\' ';
  2558. }
  2559. if (it.opts.verbose) {
  2560. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  2561. }
  2562. out += ' } ';
  2563. } else {
  2564. out += ' {} ';
  2565. }
  2566. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  2567. if (!it.compositeRule && $breakOnError) {
  2568. /* istanbul ignore if */
  2569. if (it.async) {
  2570. out += ' throw new ValidationError(vErrors); ';
  2571. } else {
  2572. out += ' validate.errors = vErrors; return false; ';
  2573. }
  2574. }
  2575. out += ' } ';
  2576. if ($breakOnError) {
  2577. out += ' else { ';
  2578. }
  2579. out = it.util.cleanUpCode(out);
  2580. } else {
  2581. if ($breakOnError) {
  2582. out += ' if (true) { ';
  2583. }
  2584. }
  2585. return out;
  2586. }
  2587. },{}],27:[function(require,module,exports){
  2588. 'use strict';
  2589. //all requires must be explicit because browserify won't work with dynamic requires
  2590. module.exports = {
  2591. '$ref': require('./ref'),
  2592. allOf: require('./allOf'),
  2593. anyOf: require('./anyOf'),
  2594. '$comment': require('./comment'),
  2595. const: require('./const'),
  2596. contains: require('./contains'),
  2597. dependencies: require('./dependencies'),
  2598. 'enum': require('./enum'),
  2599. format: require('./format'),
  2600. 'if': require('./if'),
  2601. items: require('./items'),
  2602. maximum: require('./_limit'),
  2603. minimum: require('./_limit'),
  2604. maxItems: require('./_limitItems'),
  2605. minItems: require('./_limitItems'),
  2606. maxLength: require('./_limitLength'),
  2607. minLength: require('./_limitLength'),
  2608. maxProperties: require('./_limitProperties'),
  2609. minProperties: require('./_limitProperties'),
  2610. multipleOf: require('./multipleOf'),
  2611. not: require('./not'),
  2612. oneOf: require('./oneOf'),
  2613. pattern: require('./pattern'),
  2614. properties: require('./properties'),
  2615. propertyNames: require('./propertyNames'),
  2616. required: require('./required'),
  2617. uniqueItems: require('./uniqueItems'),
  2618. validate: require('./validate')
  2619. };
  2620. },{"./_limit":13,"./_limitItems":14,"./_limitLength":15,"./_limitProperties":16,"./allOf":17,"./anyOf":18,"./comment":19,"./const":20,"./contains":21,"./dependencies":23,"./enum":24,"./format":25,"./if":26,"./items":28,"./multipleOf":29,"./not":30,"./oneOf":31,"./pattern":32,"./properties":33,"./propertyNames":34,"./ref":35,"./required":36,"./uniqueItems":37,"./validate":38}],28:[function(require,module,exports){
  2621. 'use strict';
  2622. module.exports = function generate_items(it, $keyword, $ruleType) {
  2623. var out = ' ';
  2624. var $lvl = it.level;
  2625. var $dataLvl = it.dataLevel;
  2626. var $schema = it.schema[$keyword];
  2627. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  2628. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  2629. var $breakOnError = !it.opts.allErrors;
  2630. var $data = 'data' + ($dataLvl || '');
  2631. var $valid = 'valid' + $lvl;
  2632. var $errs = 'errs__' + $lvl;
  2633. var $it = it.util.copy(it);
  2634. var $closingBraces = '';
  2635. $it.level++;
  2636. var $nextValid = 'valid' + $it.level;
  2637. var $idx = 'i' + $lvl,
  2638. $dataNxt = $it.dataLevel = it.dataLevel + 1,
  2639. $nextData = 'data' + $dataNxt,
  2640. $currentBaseId = it.baseId;
  2641. out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';';
  2642. if (Array.isArray($schema)) {
  2643. var $additionalItems = it.schema.additionalItems;
  2644. if ($additionalItems === false) {
  2645. out += ' ' + ($valid) + ' = ' + ($data) + '.length <= ' + ($schema.length) + '; ';
  2646. var $currErrSchemaPath = $errSchemaPath;
  2647. $errSchemaPath = it.errSchemaPath + '/additionalItems';
  2648. out += ' if (!' + ($valid) + ') { ';
  2649. var $$outStack = $$outStack || [];
  2650. $$outStack.push(out);
  2651. out = ''; /* istanbul ignore else */
  2652. if (it.createErrors !== false) {
  2653. out += ' { keyword: \'' + ('additionalItems') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schema.length) + ' } ';
  2654. if (it.opts.messages !== false) {
  2655. out += ' , message: \'should NOT have more than ' + ($schema.length) + ' items\' ';
  2656. }
  2657. if (it.opts.verbose) {
  2658. out += ' , schema: false , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  2659. }
  2660. out += ' } ';
  2661. } else {
  2662. out += ' {} ';
  2663. }
  2664. var __err = out;
  2665. out = $$outStack.pop();
  2666. if (!it.compositeRule && $breakOnError) {
  2667. /* istanbul ignore if */
  2668. if (it.async) {
  2669. out += ' throw new ValidationError([' + (__err) + ']); ';
  2670. } else {
  2671. out += ' validate.errors = [' + (__err) + ']; return false; ';
  2672. }
  2673. } else {
  2674. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  2675. }
  2676. out += ' } ';
  2677. $errSchemaPath = $currErrSchemaPath;
  2678. if ($breakOnError) {
  2679. $closingBraces += '}';
  2680. out += ' else { ';
  2681. }
  2682. }
  2683. var arr1 = $schema;
  2684. if (arr1) {
  2685. var $sch, $i = -1,
  2686. l1 = arr1.length - 1;
  2687. while ($i < l1) {
  2688. $sch = arr1[$i += 1];
  2689. if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) {
  2690. out += ' ' + ($nextValid) + ' = true; if (' + ($data) + '.length > ' + ($i) + ') { ';
  2691. var $passData = $data + '[' + $i + ']';
  2692. $it.schema = $sch;
  2693. $it.schemaPath = $schemaPath + '[' + $i + ']';
  2694. $it.errSchemaPath = $errSchemaPath + '/' + $i;
  2695. $it.errorPath = it.util.getPathExpr(it.errorPath, $i, it.opts.jsonPointers, true);
  2696. $it.dataPathArr[$dataNxt] = $i;
  2697. var $code = it.validate($it);
  2698. $it.baseId = $currentBaseId;
  2699. if (it.util.varOccurences($code, $nextData) < 2) {
  2700. out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
  2701. } else {
  2702. out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
  2703. }
  2704. out += ' } ';
  2705. if ($breakOnError) {
  2706. out += ' if (' + ($nextValid) + ') { ';
  2707. $closingBraces += '}';
  2708. }
  2709. }
  2710. }
  2711. }
  2712. if (typeof $additionalItems == 'object' && (it.opts.strictKeywords ? typeof $additionalItems == 'object' && Object.keys($additionalItems).length > 0 : it.util.schemaHasRules($additionalItems, it.RULES.all))) {
  2713. $it.schema = $additionalItems;
  2714. $it.schemaPath = it.schemaPath + '.additionalItems';
  2715. $it.errSchemaPath = it.errSchemaPath + '/additionalItems';
  2716. out += ' ' + ($nextValid) + ' = true; if (' + ($data) + '.length > ' + ($schema.length) + ') { for (var ' + ($idx) + ' = ' + ($schema.length) + '; ' + ($idx) + ' < ' + ($data) + '.length; ' + ($idx) + '++) { ';
  2717. $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
  2718. var $passData = $data + '[' + $idx + ']';
  2719. $it.dataPathArr[$dataNxt] = $idx;
  2720. var $code = it.validate($it);
  2721. $it.baseId = $currentBaseId;
  2722. if (it.util.varOccurences($code, $nextData) < 2) {
  2723. out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
  2724. } else {
  2725. out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
  2726. }
  2727. if ($breakOnError) {
  2728. out += ' if (!' + ($nextValid) + ') break; ';
  2729. }
  2730. out += ' } } ';
  2731. if ($breakOnError) {
  2732. out += ' if (' + ($nextValid) + ') { ';
  2733. $closingBraces += '}';
  2734. }
  2735. }
  2736. } else if ((it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all))) {
  2737. $it.schema = $schema;
  2738. $it.schemaPath = $schemaPath;
  2739. $it.errSchemaPath = $errSchemaPath;
  2740. out += ' for (var ' + ($idx) + ' = ' + (0) + '; ' + ($idx) + ' < ' + ($data) + '.length; ' + ($idx) + '++) { ';
  2741. $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
  2742. var $passData = $data + '[' + $idx + ']';
  2743. $it.dataPathArr[$dataNxt] = $idx;
  2744. var $code = it.validate($it);
  2745. $it.baseId = $currentBaseId;
  2746. if (it.util.varOccurences($code, $nextData) < 2) {
  2747. out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
  2748. } else {
  2749. out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
  2750. }
  2751. if ($breakOnError) {
  2752. out += ' if (!' + ($nextValid) + ') break; ';
  2753. }
  2754. out += ' }';
  2755. }
  2756. if ($breakOnError) {
  2757. out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
  2758. }
  2759. out = it.util.cleanUpCode(out);
  2760. return out;
  2761. }
  2762. },{}],29:[function(require,module,exports){
  2763. 'use strict';
  2764. module.exports = function generate_multipleOf(it, $keyword, $ruleType) {
  2765. var out = ' ';
  2766. var $lvl = it.level;
  2767. var $dataLvl = it.dataLevel;
  2768. var $schema = it.schema[$keyword];
  2769. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  2770. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  2771. var $breakOnError = !it.opts.allErrors;
  2772. var $data = 'data' + ($dataLvl || '');
  2773. var $isData = it.opts.$data && $schema && $schema.$data,
  2774. $schemaValue;
  2775. if ($isData) {
  2776. out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  2777. $schemaValue = 'schema' + $lvl;
  2778. } else {
  2779. $schemaValue = $schema;
  2780. }
  2781. out += 'var division' + ($lvl) + ';if (';
  2782. if ($isData) {
  2783. out += ' ' + ($schemaValue) + ' !== undefined && ( typeof ' + ($schemaValue) + ' != \'number\' || ';
  2784. }
  2785. out += ' (division' + ($lvl) + ' = ' + ($data) + ' / ' + ($schemaValue) + ', ';
  2786. if (it.opts.multipleOfPrecision) {
  2787. out += ' Math.abs(Math.round(division' + ($lvl) + ') - division' + ($lvl) + ') > 1e-' + (it.opts.multipleOfPrecision) + ' ';
  2788. } else {
  2789. out += ' division' + ($lvl) + ' !== parseInt(division' + ($lvl) + ') ';
  2790. }
  2791. out += ' ) ';
  2792. if ($isData) {
  2793. out += ' ) ';
  2794. }
  2795. out += ' ) { ';
  2796. var $$outStack = $$outStack || [];
  2797. $$outStack.push(out);
  2798. out = ''; /* istanbul ignore else */
  2799. if (it.createErrors !== false) {
  2800. out += ' { keyword: \'' + ('multipleOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { multipleOf: ' + ($schemaValue) + ' } ';
  2801. if (it.opts.messages !== false) {
  2802. out += ' , message: \'should be multiple of ';
  2803. if ($isData) {
  2804. out += '\' + ' + ($schemaValue);
  2805. } else {
  2806. out += '' + ($schemaValue) + '\'';
  2807. }
  2808. }
  2809. if (it.opts.verbose) {
  2810. out += ' , schema: ';
  2811. if ($isData) {
  2812. out += 'validate.schema' + ($schemaPath);
  2813. } else {
  2814. out += '' + ($schema);
  2815. }
  2816. out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  2817. }
  2818. out += ' } ';
  2819. } else {
  2820. out += ' {} ';
  2821. }
  2822. var __err = out;
  2823. out = $$outStack.pop();
  2824. if (!it.compositeRule && $breakOnError) {
  2825. /* istanbul ignore if */
  2826. if (it.async) {
  2827. out += ' throw new ValidationError([' + (__err) + ']); ';
  2828. } else {
  2829. out += ' validate.errors = [' + (__err) + ']; return false; ';
  2830. }
  2831. } else {
  2832. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  2833. }
  2834. out += '} ';
  2835. if ($breakOnError) {
  2836. out += ' else { ';
  2837. }
  2838. return out;
  2839. }
  2840. },{}],30:[function(require,module,exports){
  2841. 'use strict';
  2842. module.exports = function generate_not(it, $keyword, $ruleType) {
  2843. var out = ' ';
  2844. var $lvl = it.level;
  2845. var $dataLvl = it.dataLevel;
  2846. var $schema = it.schema[$keyword];
  2847. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  2848. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  2849. var $breakOnError = !it.opts.allErrors;
  2850. var $data = 'data' + ($dataLvl || '');
  2851. var $errs = 'errs__' + $lvl;
  2852. var $it = it.util.copy(it);
  2853. $it.level++;
  2854. var $nextValid = 'valid' + $it.level;
  2855. if ((it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all))) {
  2856. $it.schema = $schema;
  2857. $it.schemaPath = $schemaPath;
  2858. $it.errSchemaPath = $errSchemaPath;
  2859. out += ' var ' + ($errs) + ' = errors; ';
  2860. var $wasComposite = it.compositeRule;
  2861. it.compositeRule = $it.compositeRule = true;
  2862. $it.createErrors = false;
  2863. var $allErrorsOption;
  2864. if ($it.opts.allErrors) {
  2865. $allErrorsOption = $it.opts.allErrors;
  2866. $it.opts.allErrors = false;
  2867. }
  2868. out += ' ' + (it.validate($it)) + ' ';
  2869. $it.createErrors = true;
  2870. if ($allErrorsOption) $it.opts.allErrors = $allErrorsOption;
  2871. it.compositeRule = $it.compositeRule = $wasComposite;
  2872. out += ' if (' + ($nextValid) + ') { ';
  2873. var $$outStack = $$outStack || [];
  2874. $$outStack.push(out);
  2875. out = ''; /* istanbul ignore else */
  2876. if (it.createErrors !== false) {
  2877. out += ' { keyword: \'' + ('not') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
  2878. if (it.opts.messages !== false) {
  2879. out += ' , message: \'should NOT be valid\' ';
  2880. }
  2881. if (it.opts.verbose) {
  2882. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  2883. }
  2884. out += ' } ';
  2885. } else {
  2886. out += ' {} ';
  2887. }
  2888. var __err = out;
  2889. out = $$outStack.pop();
  2890. if (!it.compositeRule && $breakOnError) {
  2891. /* istanbul ignore if */
  2892. if (it.async) {
  2893. out += ' throw new ValidationError([' + (__err) + ']); ';
  2894. } else {
  2895. out += ' validate.errors = [' + (__err) + ']; return false; ';
  2896. }
  2897. } else {
  2898. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  2899. }
  2900. out += ' } else { errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } ';
  2901. if (it.opts.allErrors) {
  2902. out += ' } ';
  2903. }
  2904. } else {
  2905. out += ' var err = '; /* istanbul ignore else */
  2906. if (it.createErrors !== false) {
  2907. out += ' { keyword: \'' + ('not') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
  2908. if (it.opts.messages !== false) {
  2909. out += ' , message: \'should NOT be valid\' ';
  2910. }
  2911. if (it.opts.verbose) {
  2912. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  2913. }
  2914. out += ' } ';
  2915. } else {
  2916. out += ' {} ';
  2917. }
  2918. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  2919. if ($breakOnError) {
  2920. out += ' if (false) { ';
  2921. }
  2922. }
  2923. return out;
  2924. }
  2925. },{}],31:[function(require,module,exports){
  2926. 'use strict';
  2927. module.exports = function generate_oneOf(it, $keyword, $ruleType) {
  2928. var out = ' ';
  2929. var $lvl = it.level;
  2930. var $dataLvl = it.dataLevel;
  2931. var $schema = it.schema[$keyword];
  2932. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  2933. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  2934. var $breakOnError = !it.opts.allErrors;
  2935. var $data = 'data' + ($dataLvl || '');
  2936. var $valid = 'valid' + $lvl;
  2937. var $errs = 'errs__' + $lvl;
  2938. var $it = it.util.copy(it);
  2939. var $closingBraces = '';
  2940. $it.level++;
  2941. var $nextValid = 'valid' + $it.level;
  2942. var $currentBaseId = $it.baseId,
  2943. $prevValid = 'prevValid' + $lvl,
  2944. $passingSchemas = 'passingSchemas' + $lvl;
  2945. out += 'var ' + ($errs) + ' = errors , ' + ($prevValid) + ' = false , ' + ($valid) + ' = false , ' + ($passingSchemas) + ' = null; ';
  2946. var $wasComposite = it.compositeRule;
  2947. it.compositeRule = $it.compositeRule = true;
  2948. var arr1 = $schema;
  2949. if (arr1) {
  2950. var $sch, $i = -1,
  2951. l1 = arr1.length - 1;
  2952. while ($i < l1) {
  2953. $sch = arr1[$i += 1];
  2954. if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) {
  2955. $it.schema = $sch;
  2956. $it.schemaPath = $schemaPath + '[' + $i + ']';
  2957. $it.errSchemaPath = $errSchemaPath + '/' + $i;
  2958. out += ' ' + (it.validate($it)) + ' ';
  2959. $it.baseId = $currentBaseId;
  2960. } else {
  2961. out += ' var ' + ($nextValid) + ' = true; ';
  2962. }
  2963. if ($i) {
  2964. out += ' if (' + ($nextValid) + ' && ' + ($prevValid) + ') { ' + ($valid) + ' = false; ' + ($passingSchemas) + ' = [' + ($passingSchemas) + ', ' + ($i) + ']; } else { ';
  2965. $closingBraces += '}';
  2966. }
  2967. out += ' if (' + ($nextValid) + ') { ' + ($valid) + ' = ' + ($prevValid) + ' = true; ' + ($passingSchemas) + ' = ' + ($i) + '; }';
  2968. }
  2969. }
  2970. it.compositeRule = $it.compositeRule = $wasComposite;
  2971. out += '' + ($closingBraces) + 'if (!' + ($valid) + ') { var err = '; /* istanbul ignore else */
  2972. if (it.createErrors !== false) {
  2973. out += ' { keyword: \'' + ('oneOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { passingSchemas: ' + ($passingSchemas) + ' } ';
  2974. if (it.opts.messages !== false) {
  2975. out += ' , message: \'should match exactly one schema in oneOf\' ';
  2976. }
  2977. if (it.opts.verbose) {
  2978. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  2979. }
  2980. out += ' } ';
  2981. } else {
  2982. out += ' {} ';
  2983. }
  2984. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  2985. if (!it.compositeRule && $breakOnError) {
  2986. /* istanbul ignore if */
  2987. if (it.async) {
  2988. out += ' throw new ValidationError(vErrors); ';
  2989. } else {
  2990. out += ' validate.errors = vErrors; return false; ';
  2991. }
  2992. }
  2993. out += '} else { errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; }';
  2994. if (it.opts.allErrors) {
  2995. out += ' } ';
  2996. }
  2997. return out;
  2998. }
  2999. },{}],32:[function(require,module,exports){
  3000. 'use strict';
  3001. module.exports = function generate_pattern(it, $keyword, $ruleType) {
  3002. var out = ' ';
  3003. var $lvl = it.level;
  3004. var $dataLvl = it.dataLevel;
  3005. var $schema = it.schema[$keyword];
  3006. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  3007. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  3008. var $breakOnError = !it.opts.allErrors;
  3009. var $data = 'data' + ($dataLvl || '');
  3010. var $isData = it.opts.$data && $schema && $schema.$data,
  3011. $schemaValue;
  3012. if ($isData) {
  3013. out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  3014. $schemaValue = 'schema' + $lvl;
  3015. } else {
  3016. $schemaValue = $schema;
  3017. }
  3018. var $regexp = $isData ? '(new RegExp(' + $schemaValue + '))' : it.usePattern($schema);
  3019. out += 'if ( ';
  3020. if ($isData) {
  3021. out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'string\') || ';
  3022. }
  3023. out += ' !' + ($regexp) + '.test(' + ($data) + ') ) { ';
  3024. var $$outStack = $$outStack || [];
  3025. $$outStack.push(out);
  3026. out = ''; /* istanbul ignore else */
  3027. if (it.createErrors !== false) {
  3028. out += ' { keyword: \'' + ('pattern') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { pattern: ';
  3029. if ($isData) {
  3030. out += '' + ($schemaValue);
  3031. } else {
  3032. out += '' + (it.util.toQuotedString($schema));
  3033. }
  3034. out += ' } ';
  3035. if (it.opts.messages !== false) {
  3036. out += ' , message: \'should match pattern "';
  3037. if ($isData) {
  3038. out += '\' + ' + ($schemaValue) + ' + \'';
  3039. } else {
  3040. out += '' + (it.util.escapeQuotes($schema));
  3041. }
  3042. out += '"\' ';
  3043. }
  3044. if (it.opts.verbose) {
  3045. out += ' , schema: ';
  3046. if ($isData) {
  3047. out += 'validate.schema' + ($schemaPath);
  3048. } else {
  3049. out += '' + (it.util.toQuotedString($schema));
  3050. }
  3051. out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  3052. }
  3053. out += ' } ';
  3054. } else {
  3055. out += ' {} ';
  3056. }
  3057. var __err = out;
  3058. out = $$outStack.pop();
  3059. if (!it.compositeRule && $breakOnError) {
  3060. /* istanbul ignore if */
  3061. if (it.async) {
  3062. out += ' throw new ValidationError([' + (__err) + ']); ';
  3063. } else {
  3064. out += ' validate.errors = [' + (__err) + ']; return false; ';
  3065. }
  3066. } else {
  3067. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  3068. }
  3069. out += '} ';
  3070. if ($breakOnError) {
  3071. out += ' else { ';
  3072. }
  3073. return out;
  3074. }
  3075. },{}],33:[function(require,module,exports){
  3076. 'use strict';
  3077. module.exports = function generate_properties(it, $keyword, $ruleType) {
  3078. var out = ' ';
  3079. var $lvl = it.level;
  3080. var $dataLvl = it.dataLevel;
  3081. var $schema = it.schema[$keyword];
  3082. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  3083. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  3084. var $breakOnError = !it.opts.allErrors;
  3085. var $data = 'data' + ($dataLvl || '');
  3086. var $errs = 'errs__' + $lvl;
  3087. var $it = it.util.copy(it);
  3088. var $closingBraces = '';
  3089. $it.level++;
  3090. var $nextValid = 'valid' + $it.level;
  3091. var $key = 'key' + $lvl,
  3092. $idx = 'idx' + $lvl,
  3093. $dataNxt = $it.dataLevel = it.dataLevel + 1,
  3094. $nextData = 'data' + $dataNxt,
  3095. $dataProperties = 'dataProperties' + $lvl;
  3096. var $schemaKeys = Object.keys($schema || {}),
  3097. $pProperties = it.schema.patternProperties || {},
  3098. $pPropertyKeys = Object.keys($pProperties),
  3099. $aProperties = it.schema.additionalProperties,
  3100. $someProperties = $schemaKeys.length || $pPropertyKeys.length,
  3101. $noAdditional = $aProperties === false,
  3102. $additionalIsSchema = typeof $aProperties == 'object' && Object.keys($aProperties).length,
  3103. $removeAdditional = it.opts.removeAdditional,
  3104. $checkAdditional = $noAdditional || $additionalIsSchema || $removeAdditional,
  3105. $ownProperties = it.opts.ownProperties,
  3106. $currentBaseId = it.baseId;
  3107. var $required = it.schema.required;
  3108. if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) var $requiredHash = it.util.toHash($required);
  3109. out += 'var ' + ($errs) + ' = errors;var ' + ($nextValid) + ' = true;';
  3110. if ($ownProperties) {
  3111. out += ' var ' + ($dataProperties) + ' = undefined;';
  3112. }
  3113. if ($checkAdditional) {
  3114. if ($ownProperties) {
  3115. out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; ';
  3116. } else {
  3117. out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
  3118. }
  3119. if ($someProperties) {
  3120. out += ' var isAdditional' + ($lvl) + ' = !(false ';
  3121. if ($schemaKeys.length) {
  3122. if ($schemaKeys.length > 8) {
  3123. out += ' || validate.schema' + ($schemaPath) + '.hasOwnProperty(' + ($key) + ') ';
  3124. } else {
  3125. var arr1 = $schemaKeys;
  3126. if (arr1) {
  3127. var $propertyKey, i1 = -1,
  3128. l1 = arr1.length - 1;
  3129. while (i1 < l1) {
  3130. $propertyKey = arr1[i1 += 1];
  3131. out += ' || ' + ($key) + ' == ' + (it.util.toQuotedString($propertyKey)) + ' ';
  3132. }
  3133. }
  3134. }
  3135. }
  3136. if ($pPropertyKeys.length) {
  3137. var arr2 = $pPropertyKeys;
  3138. if (arr2) {
  3139. var $pProperty, $i = -1,
  3140. l2 = arr2.length - 1;
  3141. while ($i < l2) {
  3142. $pProperty = arr2[$i += 1];
  3143. out += ' || ' + (it.usePattern($pProperty)) + '.test(' + ($key) + ') ';
  3144. }
  3145. }
  3146. }
  3147. out += ' ); if (isAdditional' + ($lvl) + ') { ';
  3148. }
  3149. if ($removeAdditional == 'all') {
  3150. out += ' delete ' + ($data) + '[' + ($key) + ']; ';
  3151. } else {
  3152. var $currentErrorPath = it.errorPath;
  3153. var $additionalProperty = '\' + ' + $key + ' + \'';
  3154. if (it.opts._errorDataPathProperty) {
  3155. it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
  3156. }
  3157. if ($noAdditional) {
  3158. if ($removeAdditional) {
  3159. out += ' delete ' + ($data) + '[' + ($key) + ']; ';
  3160. } else {
  3161. out += ' ' + ($nextValid) + ' = false; ';
  3162. var $currErrSchemaPath = $errSchemaPath;
  3163. $errSchemaPath = it.errSchemaPath + '/additionalProperties';
  3164. var $$outStack = $$outStack || [];
  3165. $$outStack.push(out);
  3166. out = ''; /* istanbul ignore else */
  3167. if (it.createErrors !== false) {
  3168. out += ' { keyword: \'' + ('additionalProperties') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { additionalProperty: \'' + ($additionalProperty) + '\' } ';
  3169. if (it.opts.messages !== false) {
  3170. out += ' , message: \'';
  3171. if (it.opts._errorDataPathProperty) {
  3172. out += 'is an invalid additional property';
  3173. } else {
  3174. out += 'should NOT have additional properties';
  3175. }
  3176. out += '\' ';
  3177. }
  3178. if (it.opts.verbose) {
  3179. out += ' , schema: false , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  3180. }
  3181. out += ' } ';
  3182. } else {
  3183. out += ' {} ';
  3184. }
  3185. var __err = out;
  3186. out = $$outStack.pop();
  3187. if (!it.compositeRule && $breakOnError) {
  3188. /* istanbul ignore if */
  3189. if (it.async) {
  3190. out += ' throw new ValidationError([' + (__err) + ']); ';
  3191. } else {
  3192. out += ' validate.errors = [' + (__err) + ']; return false; ';
  3193. }
  3194. } else {
  3195. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  3196. }
  3197. $errSchemaPath = $currErrSchemaPath;
  3198. if ($breakOnError) {
  3199. out += ' break; ';
  3200. }
  3201. }
  3202. } else if ($additionalIsSchema) {
  3203. if ($removeAdditional == 'failing') {
  3204. out += ' var ' + ($errs) + ' = errors; ';
  3205. var $wasComposite = it.compositeRule;
  3206. it.compositeRule = $it.compositeRule = true;
  3207. $it.schema = $aProperties;
  3208. $it.schemaPath = it.schemaPath + '.additionalProperties';
  3209. $it.errSchemaPath = it.errSchemaPath + '/additionalProperties';
  3210. $it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
  3211. var $passData = $data + '[' + $key + ']';
  3212. $it.dataPathArr[$dataNxt] = $key;
  3213. var $code = it.validate($it);
  3214. $it.baseId = $currentBaseId;
  3215. if (it.util.varOccurences($code, $nextData) < 2) {
  3216. out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
  3217. } else {
  3218. out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
  3219. }
  3220. out += ' if (!' + ($nextValid) + ') { errors = ' + ($errs) + '; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete ' + ($data) + '[' + ($key) + ']; } ';
  3221. it.compositeRule = $it.compositeRule = $wasComposite;
  3222. } else {
  3223. $it.schema = $aProperties;
  3224. $it.schemaPath = it.schemaPath + '.additionalProperties';
  3225. $it.errSchemaPath = it.errSchemaPath + '/additionalProperties';
  3226. $it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
  3227. var $passData = $data + '[' + $key + ']';
  3228. $it.dataPathArr[$dataNxt] = $key;
  3229. var $code = it.validate($it);
  3230. $it.baseId = $currentBaseId;
  3231. if (it.util.varOccurences($code, $nextData) < 2) {
  3232. out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
  3233. } else {
  3234. out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
  3235. }
  3236. if ($breakOnError) {
  3237. out += ' if (!' + ($nextValid) + ') break; ';
  3238. }
  3239. }
  3240. }
  3241. it.errorPath = $currentErrorPath;
  3242. }
  3243. if ($someProperties) {
  3244. out += ' } ';
  3245. }
  3246. out += ' } ';
  3247. if ($breakOnError) {
  3248. out += ' if (' + ($nextValid) + ') { ';
  3249. $closingBraces += '}';
  3250. }
  3251. }
  3252. var $useDefaults = it.opts.useDefaults && !it.compositeRule;
  3253. if ($schemaKeys.length) {
  3254. var arr3 = $schemaKeys;
  3255. if (arr3) {
  3256. var $propertyKey, i3 = -1,
  3257. l3 = arr3.length - 1;
  3258. while (i3 < l3) {
  3259. $propertyKey = arr3[i3 += 1];
  3260. var $sch = $schema[$propertyKey];
  3261. if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) {
  3262. var $prop = it.util.getProperty($propertyKey),
  3263. $passData = $data + $prop,
  3264. $hasDefault = $useDefaults && $sch.default !== undefined;
  3265. $it.schema = $sch;
  3266. $it.schemaPath = $schemaPath + $prop;
  3267. $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($propertyKey);
  3268. $it.errorPath = it.util.getPath(it.errorPath, $propertyKey, it.opts.jsonPointers);
  3269. $it.dataPathArr[$dataNxt] = it.util.toQuotedString($propertyKey);
  3270. var $code = it.validate($it);
  3271. $it.baseId = $currentBaseId;
  3272. if (it.util.varOccurences($code, $nextData) < 2) {
  3273. $code = it.util.varReplace($code, $nextData, $passData);
  3274. var $useData = $passData;
  3275. } else {
  3276. var $useData = $nextData;
  3277. out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ';
  3278. }
  3279. if ($hasDefault) {
  3280. out += ' ' + ($code) + ' ';
  3281. } else {
  3282. if ($requiredHash && $requiredHash[$propertyKey]) {
  3283. out += ' if ( ' + ($useData) + ' === undefined ';
  3284. if ($ownProperties) {
  3285. out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
  3286. }
  3287. out += ') { ' + ($nextValid) + ' = false; ';
  3288. var $currentErrorPath = it.errorPath,
  3289. $currErrSchemaPath = $errSchemaPath,
  3290. $missingProperty = it.util.escapeQuotes($propertyKey);
  3291. if (it.opts._errorDataPathProperty) {
  3292. it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
  3293. }
  3294. $errSchemaPath = it.errSchemaPath + '/required';
  3295. var $$outStack = $$outStack || [];
  3296. $$outStack.push(out);
  3297. out = ''; /* istanbul ignore else */
  3298. if (it.createErrors !== false) {
  3299. out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
  3300. if (it.opts.messages !== false) {
  3301. out += ' , message: \'';
  3302. if (it.opts._errorDataPathProperty) {
  3303. out += 'is a required property';
  3304. } else {
  3305. out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
  3306. }
  3307. out += '\' ';
  3308. }
  3309. if (it.opts.verbose) {
  3310. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  3311. }
  3312. out += ' } ';
  3313. } else {
  3314. out += ' {} ';
  3315. }
  3316. var __err = out;
  3317. out = $$outStack.pop();
  3318. if (!it.compositeRule && $breakOnError) {
  3319. /* istanbul ignore if */
  3320. if (it.async) {
  3321. out += ' throw new ValidationError([' + (__err) + ']); ';
  3322. } else {
  3323. out += ' validate.errors = [' + (__err) + ']; return false; ';
  3324. }
  3325. } else {
  3326. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  3327. }
  3328. $errSchemaPath = $currErrSchemaPath;
  3329. it.errorPath = $currentErrorPath;
  3330. out += ' } else { ';
  3331. } else {
  3332. if ($breakOnError) {
  3333. out += ' if ( ' + ($useData) + ' === undefined ';
  3334. if ($ownProperties) {
  3335. out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
  3336. }
  3337. out += ') { ' + ($nextValid) + ' = true; } else { ';
  3338. } else {
  3339. out += ' if (' + ($useData) + ' !== undefined ';
  3340. if ($ownProperties) {
  3341. out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
  3342. }
  3343. out += ' ) { ';
  3344. }
  3345. }
  3346. out += ' ' + ($code) + ' } ';
  3347. }
  3348. }
  3349. if ($breakOnError) {
  3350. out += ' if (' + ($nextValid) + ') { ';
  3351. $closingBraces += '}';
  3352. }
  3353. }
  3354. }
  3355. }
  3356. if ($pPropertyKeys.length) {
  3357. var arr4 = $pPropertyKeys;
  3358. if (arr4) {
  3359. var $pProperty, i4 = -1,
  3360. l4 = arr4.length - 1;
  3361. while (i4 < l4) {
  3362. $pProperty = arr4[i4 += 1];
  3363. var $sch = $pProperties[$pProperty];
  3364. if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) {
  3365. $it.schema = $sch;
  3366. $it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty);
  3367. $it.errSchemaPath = it.errSchemaPath + '/patternProperties/' + it.util.escapeFragment($pProperty);
  3368. if ($ownProperties) {
  3369. out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; ';
  3370. } else {
  3371. out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
  3372. }
  3373. out += ' if (' + (it.usePattern($pProperty)) + '.test(' + ($key) + ')) { ';
  3374. $it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
  3375. var $passData = $data + '[' + $key + ']';
  3376. $it.dataPathArr[$dataNxt] = $key;
  3377. var $code = it.validate($it);
  3378. $it.baseId = $currentBaseId;
  3379. if (it.util.varOccurences($code, $nextData) < 2) {
  3380. out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
  3381. } else {
  3382. out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
  3383. }
  3384. if ($breakOnError) {
  3385. out += ' if (!' + ($nextValid) + ') break; ';
  3386. }
  3387. out += ' } ';
  3388. if ($breakOnError) {
  3389. out += ' else ' + ($nextValid) + ' = true; ';
  3390. }
  3391. out += ' } ';
  3392. if ($breakOnError) {
  3393. out += ' if (' + ($nextValid) + ') { ';
  3394. $closingBraces += '}';
  3395. }
  3396. }
  3397. }
  3398. }
  3399. }
  3400. if ($breakOnError) {
  3401. out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
  3402. }
  3403. out = it.util.cleanUpCode(out);
  3404. return out;
  3405. }
  3406. },{}],34:[function(require,module,exports){
  3407. 'use strict';
  3408. module.exports = function generate_propertyNames(it, $keyword, $ruleType) {
  3409. var out = ' ';
  3410. var $lvl = it.level;
  3411. var $dataLvl = it.dataLevel;
  3412. var $schema = it.schema[$keyword];
  3413. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  3414. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  3415. var $breakOnError = !it.opts.allErrors;
  3416. var $data = 'data' + ($dataLvl || '');
  3417. var $errs = 'errs__' + $lvl;
  3418. var $it = it.util.copy(it);
  3419. var $closingBraces = '';
  3420. $it.level++;
  3421. var $nextValid = 'valid' + $it.level;
  3422. out += 'var ' + ($errs) + ' = errors;';
  3423. if ((it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all))) {
  3424. $it.schema = $schema;
  3425. $it.schemaPath = $schemaPath;
  3426. $it.errSchemaPath = $errSchemaPath;
  3427. var $key = 'key' + $lvl,
  3428. $idx = 'idx' + $lvl,
  3429. $i = 'i' + $lvl,
  3430. $invalidName = '\' + ' + $key + ' + \'',
  3431. $dataNxt = $it.dataLevel = it.dataLevel + 1,
  3432. $nextData = 'data' + $dataNxt,
  3433. $dataProperties = 'dataProperties' + $lvl,
  3434. $ownProperties = it.opts.ownProperties,
  3435. $currentBaseId = it.baseId;
  3436. if ($ownProperties) {
  3437. out += ' var ' + ($dataProperties) + ' = undefined; ';
  3438. }
  3439. if ($ownProperties) {
  3440. out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; ';
  3441. } else {
  3442. out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
  3443. }
  3444. out += ' var startErrs' + ($lvl) + ' = errors; ';
  3445. var $passData = $key;
  3446. var $wasComposite = it.compositeRule;
  3447. it.compositeRule = $it.compositeRule = true;
  3448. var $code = it.validate($it);
  3449. $it.baseId = $currentBaseId;
  3450. if (it.util.varOccurences($code, $nextData) < 2) {
  3451. out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
  3452. } else {
  3453. out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
  3454. }
  3455. it.compositeRule = $it.compositeRule = $wasComposite;
  3456. out += ' if (!' + ($nextValid) + ') { for (var ' + ($i) + '=startErrs' + ($lvl) + '; ' + ($i) + '<errors; ' + ($i) + '++) { vErrors[' + ($i) + '].propertyName = ' + ($key) + '; } var err = '; /* istanbul ignore else */
  3457. if (it.createErrors !== false) {
  3458. out += ' { keyword: \'' + ('propertyNames') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { propertyName: \'' + ($invalidName) + '\' } ';
  3459. if (it.opts.messages !== false) {
  3460. out += ' , message: \'property name \\\'' + ($invalidName) + '\\\' is invalid\' ';
  3461. }
  3462. if (it.opts.verbose) {
  3463. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  3464. }
  3465. out += ' } ';
  3466. } else {
  3467. out += ' {} ';
  3468. }
  3469. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  3470. if (!it.compositeRule && $breakOnError) {
  3471. /* istanbul ignore if */
  3472. if (it.async) {
  3473. out += ' throw new ValidationError(vErrors); ';
  3474. } else {
  3475. out += ' validate.errors = vErrors; return false; ';
  3476. }
  3477. }
  3478. if ($breakOnError) {
  3479. out += ' break; ';
  3480. }
  3481. out += ' } }';
  3482. }
  3483. if ($breakOnError) {
  3484. out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
  3485. }
  3486. out = it.util.cleanUpCode(out);
  3487. return out;
  3488. }
  3489. },{}],35:[function(require,module,exports){
  3490. 'use strict';
  3491. module.exports = function generate_ref(it, $keyword, $ruleType) {
  3492. var out = ' ';
  3493. var $lvl = it.level;
  3494. var $dataLvl = it.dataLevel;
  3495. var $schema = it.schema[$keyword];
  3496. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  3497. var $breakOnError = !it.opts.allErrors;
  3498. var $data = 'data' + ($dataLvl || '');
  3499. var $valid = 'valid' + $lvl;
  3500. var $async, $refCode;
  3501. if ($schema == '#' || $schema == '#/') {
  3502. if (it.isRoot) {
  3503. $async = it.async;
  3504. $refCode = 'validate';
  3505. } else {
  3506. $async = it.root.schema.$async === true;
  3507. $refCode = 'root.refVal[0]';
  3508. }
  3509. } else {
  3510. var $refVal = it.resolveRef(it.baseId, $schema, it.isRoot);
  3511. if ($refVal === undefined) {
  3512. var $message = it.MissingRefError.message(it.baseId, $schema);
  3513. if (it.opts.missingRefs == 'fail') {
  3514. it.logger.error($message);
  3515. var $$outStack = $$outStack || [];
  3516. $$outStack.push(out);
  3517. out = ''; /* istanbul ignore else */
  3518. if (it.createErrors !== false) {
  3519. out += ' { keyword: \'' + ('$ref') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { ref: \'' + (it.util.escapeQuotes($schema)) + '\' } ';
  3520. if (it.opts.messages !== false) {
  3521. out += ' , message: \'can\\\'t resolve reference ' + (it.util.escapeQuotes($schema)) + '\' ';
  3522. }
  3523. if (it.opts.verbose) {
  3524. out += ' , schema: ' + (it.util.toQuotedString($schema)) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  3525. }
  3526. out += ' } ';
  3527. } else {
  3528. out += ' {} ';
  3529. }
  3530. var __err = out;
  3531. out = $$outStack.pop();
  3532. if (!it.compositeRule && $breakOnError) {
  3533. /* istanbul ignore if */
  3534. if (it.async) {
  3535. out += ' throw new ValidationError([' + (__err) + ']); ';
  3536. } else {
  3537. out += ' validate.errors = [' + (__err) + ']; return false; ';
  3538. }
  3539. } else {
  3540. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  3541. }
  3542. if ($breakOnError) {
  3543. out += ' if (false) { ';
  3544. }
  3545. } else if (it.opts.missingRefs == 'ignore') {
  3546. it.logger.warn($message);
  3547. if ($breakOnError) {
  3548. out += ' if (true) { ';
  3549. }
  3550. } else {
  3551. throw new it.MissingRefError(it.baseId, $schema, $message);
  3552. }
  3553. } else if ($refVal.inline) {
  3554. var $it = it.util.copy(it);
  3555. $it.level++;
  3556. var $nextValid = 'valid' + $it.level;
  3557. $it.schema = $refVal.schema;
  3558. $it.schemaPath = '';
  3559. $it.errSchemaPath = $schema;
  3560. var $code = it.validate($it).replace(/validate\.schema/g, $refVal.code);
  3561. out += ' ' + ($code) + ' ';
  3562. if ($breakOnError) {
  3563. out += ' if (' + ($nextValid) + ') { ';
  3564. }
  3565. } else {
  3566. $async = $refVal.$async === true || (it.async && $refVal.$async !== false);
  3567. $refCode = $refVal.code;
  3568. }
  3569. }
  3570. if ($refCode) {
  3571. var $$outStack = $$outStack || [];
  3572. $$outStack.push(out);
  3573. out = '';
  3574. if (it.opts.passContext) {
  3575. out += ' ' + ($refCode) + '.call(this, ';
  3576. } else {
  3577. out += ' ' + ($refCode) + '( ';
  3578. }
  3579. out += ' ' + ($data) + ', (dataPath || \'\')';
  3580. if (it.errorPath != '""') {
  3581. out += ' + ' + (it.errorPath);
  3582. }
  3583. var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData',
  3584. $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
  3585. out += ' , ' + ($parentData) + ' , ' + ($parentDataProperty) + ', rootData) ';
  3586. var __callValidate = out;
  3587. out = $$outStack.pop();
  3588. if ($async) {
  3589. if (!it.async) throw new Error('async schema referenced by sync schema');
  3590. if ($breakOnError) {
  3591. out += ' var ' + ($valid) + '; ';
  3592. }
  3593. out += ' try { await ' + (__callValidate) + '; ';
  3594. if ($breakOnError) {
  3595. out += ' ' + ($valid) + ' = true; ';
  3596. }
  3597. out += ' } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ';
  3598. if ($breakOnError) {
  3599. out += ' ' + ($valid) + ' = false; ';
  3600. }
  3601. out += ' } ';
  3602. if ($breakOnError) {
  3603. out += ' if (' + ($valid) + ') { ';
  3604. }
  3605. } else {
  3606. out += ' if (!' + (__callValidate) + ') { if (vErrors === null) vErrors = ' + ($refCode) + '.errors; else vErrors = vErrors.concat(' + ($refCode) + '.errors); errors = vErrors.length; } ';
  3607. if ($breakOnError) {
  3608. out += ' else { ';
  3609. }
  3610. }
  3611. }
  3612. return out;
  3613. }
  3614. },{}],36:[function(require,module,exports){
  3615. 'use strict';
  3616. module.exports = function generate_required(it, $keyword, $ruleType) {
  3617. var out = ' ';
  3618. var $lvl = it.level;
  3619. var $dataLvl = it.dataLevel;
  3620. var $schema = it.schema[$keyword];
  3621. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  3622. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  3623. var $breakOnError = !it.opts.allErrors;
  3624. var $data = 'data' + ($dataLvl || '');
  3625. var $valid = 'valid' + $lvl;
  3626. var $isData = it.opts.$data && $schema && $schema.$data,
  3627. $schemaValue;
  3628. if ($isData) {
  3629. out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  3630. $schemaValue = 'schema' + $lvl;
  3631. } else {
  3632. $schemaValue = $schema;
  3633. }
  3634. var $vSchema = 'schema' + $lvl;
  3635. if (!$isData) {
  3636. if ($schema.length < it.opts.loopRequired && it.schema.properties && Object.keys(it.schema.properties).length) {
  3637. var $required = [];
  3638. var arr1 = $schema;
  3639. if (arr1) {
  3640. var $property, i1 = -1,
  3641. l1 = arr1.length - 1;
  3642. while (i1 < l1) {
  3643. $property = arr1[i1 += 1];
  3644. var $propertySch = it.schema.properties[$property];
  3645. if (!($propertySch && (it.opts.strictKeywords ? typeof $propertySch == 'object' && Object.keys($propertySch).length > 0 : it.util.schemaHasRules($propertySch, it.RULES.all)))) {
  3646. $required[$required.length] = $property;
  3647. }
  3648. }
  3649. }
  3650. } else {
  3651. var $required = $schema;
  3652. }
  3653. }
  3654. if ($isData || $required.length) {
  3655. var $currentErrorPath = it.errorPath,
  3656. $loopRequired = $isData || $required.length >= it.opts.loopRequired,
  3657. $ownProperties = it.opts.ownProperties;
  3658. if ($breakOnError) {
  3659. out += ' var missing' + ($lvl) + '; ';
  3660. if ($loopRequired) {
  3661. if (!$isData) {
  3662. out += ' var ' + ($vSchema) + ' = validate.schema' + ($schemaPath) + '; ';
  3663. }
  3664. var $i = 'i' + $lvl,
  3665. $propertyPath = 'schema' + $lvl + '[' + $i + ']',
  3666. $missingProperty = '\' + ' + $propertyPath + ' + \'';
  3667. if (it.opts._errorDataPathProperty) {
  3668. it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers);
  3669. }
  3670. out += ' var ' + ($valid) + ' = true; ';
  3671. if ($isData) {
  3672. out += ' if (schema' + ($lvl) + ' === undefined) ' + ($valid) + ' = true; else if (!Array.isArray(schema' + ($lvl) + ')) ' + ($valid) + ' = false; else {';
  3673. }
  3674. out += ' for (var ' + ($i) + ' = 0; ' + ($i) + ' < ' + ($vSchema) + '.length; ' + ($i) + '++) { ' + ($valid) + ' = ' + ($data) + '[' + ($vSchema) + '[' + ($i) + ']] !== undefined ';
  3675. if ($ownProperties) {
  3676. out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', ' + ($vSchema) + '[' + ($i) + ']) ';
  3677. }
  3678. out += '; if (!' + ($valid) + ') break; } ';
  3679. if ($isData) {
  3680. out += ' } ';
  3681. }
  3682. out += ' if (!' + ($valid) + ') { ';
  3683. var $$outStack = $$outStack || [];
  3684. $$outStack.push(out);
  3685. out = ''; /* istanbul ignore else */
  3686. if (it.createErrors !== false) {
  3687. out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
  3688. if (it.opts.messages !== false) {
  3689. out += ' , message: \'';
  3690. if (it.opts._errorDataPathProperty) {
  3691. out += 'is a required property';
  3692. } else {
  3693. out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
  3694. }
  3695. out += '\' ';
  3696. }
  3697. if (it.opts.verbose) {
  3698. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  3699. }
  3700. out += ' } ';
  3701. } else {
  3702. out += ' {} ';
  3703. }
  3704. var __err = out;
  3705. out = $$outStack.pop();
  3706. if (!it.compositeRule && $breakOnError) {
  3707. /* istanbul ignore if */
  3708. if (it.async) {
  3709. out += ' throw new ValidationError([' + (__err) + ']); ';
  3710. } else {
  3711. out += ' validate.errors = [' + (__err) + ']; return false; ';
  3712. }
  3713. } else {
  3714. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  3715. }
  3716. out += ' } else { ';
  3717. } else {
  3718. out += ' if ( ';
  3719. var arr2 = $required;
  3720. if (arr2) {
  3721. var $propertyKey, $i = -1,
  3722. l2 = arr2.length - 1;
  3723. while ($i < l2) {
  3724. $propertyKey = arr2[$i += 1];
  3725. if ($i) {
  3726. out += ' || ';
  3727. }
  3728. var $prop = it.util.getProperty($propertyKey),
  3729. $useData = $data + $prop;
  3730. out += ' ( ( ' + ($useData) + ' === undefined ';
  3731. if ($ownProperties) {
  3732. out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
  3733. }
  3734. out += ') && (missing' + ($lvl) + ' = ' + (it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop)) + ') ) ';
  3735. }
  3736. }
  3737. out += ') { ';
  3738. var $propertyPath = 'missing' + $lvl,
  3739. $missingProperty = '\' + ' + $propertyPath + ' + \'';
  3740. if (it.opts._errorDataPathProperty) {
  3741. it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath;
  3742. }
  3743. var $$outStack = $$outStack || [];
  3744. $$outStack.push(out);
  3745. out = ''; /* istanbul ignore else */
  3746. if (it.createErrors !== false) {
  3747. out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
  3748. if (it.opts.messages !== false) {
  3749. out += ' , message: \'';
  3750. if (it.opts._errorDataPathProperty) {
  3751. out += 'is a required property';
  3752. } else {
  3753. out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
  3754. }
  3755. out += '\' ';
  3756. }
  3757. if (it.opts.verbose) {
  3758. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  3759. }
  3760. out += ' } ';
  3761. } else {
  3762. out += ' {} ';
  3763. }
  3764. var __err = out;
  3765. out = $$outStack.pop();
  3766. if (!it.compositeRule && $breakOnError) {
  3767. /* istanbul ignore if */
  3768. if (it.async) {
  3769. out += ' throw new ValidationError([' + (__err) + ']); ';
  3770. } else {
  3771. out += ' validate.errors = [' + (__err) + ']; return false; ';
  3772. }
  3773. } else {
  3774. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  3775. }
  3776. out += ' } else { ';
  3777. }
  3778. } else {
  3779. if ($loopRequired) {
  3780. if (!$isData) {
  3781. out += ' var ' + ($vSchema) + ' = validate.schema' + ($schemaPath) + '; ';
  3782. }
  3783. var $i = 'i' + $lvl,
  3784. $propertyPath = 'schema' + $lvl + '[' + $i + ']',
  3785. $missingProperty = '\' + ' + $propertyPath + ' + \'';
  3786. if (it.opts._errorDataPathProperty) {
  3787. it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers);
  3788. }
  3789. if ($isData) {
  3790. out += ' if (' + ($vSchema) + ' && !Array.isArray(' + ($vSchema) + ')) { var err = '; /* istanbul ignore else */
  3791. if (it.createErrors !== false) {
  3792. out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
  3793. if (it.opts.messages !== false) {
  3794. out += ' , message: \'';
  3795. if (it.opts._errorDataPathProperty) {
  3796. out += 'is a required property';
  3797. } else {
  3798. out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
  3799. }
  3800. out += '\' ';
  3801. }
  3802. if (it.opts.verbose) {
  3803. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  3804. }
  3805. out += ' } ';
  3806. } else {
  3807. out += ' {} ';
  3808. }
  3809. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if (' + ($vSchema) + ' !== undefined) { ';
  3810. }
  3811. out += ' for (var ' + ($i) + ' = 0; ' + ($i) + ' < ' + ($vSchema) + '.length; ' + ($i) + '++) { if (' + ($data) + '[' + ($vSchema) + '[' + ($i) + ']] === undefined ';
  3812. if ($ownProperties) {
  3813. out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', ' + ($vSchema) + '[' + ($i) + ']) ';
  3814. }
  3815. out += ') { var err = '; /* istanbul ignore else */
  3816. if (it.createErrors !== false) {
  3817. out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
  3818. if (it.opts.messages !== false) {
  3819. out += ' , message: \'';
  3820. if (it.opts._errorDataPathProperty) {
  3821. out += 'is a required property';
  3822. } else {
  3823. out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
  3824. }
  3825. out += '\' ';
  3826. }
  3827. if (it.opts.verbose) {
  3828. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  3829. }
  3830. out += ' } ';
  3831. } else {
  3832. out += ' {} ';
  3833. }
  3834. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } ';
  3835. if ($isData) {
  3836. out += ' } ';
  3837. }
  3838. } else {
  3839. var arr3 = $required;
  3840. if (arr3) {
  3841. var $propertyKey, i3 = -1,
  3842. l3 = arr3.length - 1;
  3843. while (i3 < l3) {
  3844. $propertyKey = arr3[i3 += 1];
  3845. var $prop = it.util.getProperty($propertyKey),
  3846. $missingProperty = it.util.escapeQuotes($propertyKey),
  3847. $useData = $data + $prop;
  3848. if (it.opts._errorDataPathProperty) {
  3849. it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
  3850. }
  3851. out += ' if ( ' + ($useData) + ' === undefined ';
  3852. if ($ownProperties) {
  3853. out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
  3854. }
  3855. out += ') { var err = '; /* istanbul ignore else */
  3856. if (it.createErrors !== false) {
  3857. out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
  3858. if (it.opts.messages !== false) {
  3859. out += ' , message: \'';
  3860. if (it.opts._errorDataPathProperty) {
  3861. out += 'is a required property';
  3862. } else {
  3863. out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
  3864. }
  3865. out += '\' ';
  3866. }
  3867. if (it.opts.verbose) {
  3868. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  3869. }
  3870. out += ' } ';
  3871. } else {
  3872. out += ' {} ';
  3873. }
  3874. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ';
  3875. }
  3876. }
  3877. }
  3878. }
  3879. it.errorPath = $currentErrorPath;
  3880. } else if ($breakOnError) {
  3881. out += ' if (true) {';
  3882. }
  3883. return out;
  3884. }
  3885. },{}],37:[function(require,module,exports){
  3886. 'use strict';
  3887. module.exports = function generate_uniqueItems(it, $keyword, $ruleType) {
  3888. var out = ' ';
  3889. var $lvl = it.level;
  3890. var $dataLvl = it.dataLevel;
  3891. var $schema = it.schema[$keyword];
  3892. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  3893. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  3894. var $breakOnError = !it.opts.allErrors;
  3895. var $data = 'data' + ($dataLvl || '');
  3896. var $valid = 'valid' + $lvl;
  3897. var $isData = it.opts.$data && $schema && $schema.$data,
  3898. $schemaValue;
  3899. if ($isData) {
  3900. out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  3901. $schemaValue = 'schema' + $lvl;
  3902. } else {
  3903. $schemaValue = $schema;
  3904. }
  3905. if (($schema || $isData) && it.opts.uniqueItems !== false) {
  3906. if ($isData) {
  3907. out += ' var ' + ($valid) + '; if (' + ($schemaValue) + ' === false || ' + ($schemaValue) + ' === undefined) ' + ($valid) + ' = true; else if (typeof ' + ($schemaValue) + ' != \'boolean\') ' + ($valid) + ' = false; else { ';
  3908. }
  3909. out += ' var i = ' + ($data) + '.length , ' + ($valid) + ' = true , j; if (i > 1) { ';
  3910. var $itemType = it.schema.items && it.schema.items.type,
  3911. $typeIsArray = Array.isArray($itemType);
  3912. if (!$itemType || $itemType == 'object' || $itemType == 'array' || ($typeIsArray && ($itemType.indexOf('object') >= 0 || $itemType.indexOf('array') >= 0))) {
  3913. out += ' outer: for (;i--;) { for (j = i; j--;) { if (equal(' + ($data) + '[i], ' + ($data) + '[j])) { ' + ($valid) + ' = false; break outer; } } } ';
  3914. } else {
  3915. out += ' var itemIndices = {}, item; for (;i--;) { var item = ' + ($data) + '[i]; ';
  3916. var $method = 'checkDataType' + ($typeIsArray ? 's' : '');
  3917. out += ' if (' + (it.util[$method]($itemType, 'item', true)) + ') continue; ';
  3918. if ($typeIsArray) {
  3919. out += ' if (typeof item == \'string\') item = \'"\' + item; ';
  3920. }
  3921. out += ' if (typeof itemIndices[item] == \'number\') { ' + ($valid) + ' = false; j = itemIndices[item]; break; } itemIndices[item] = i; } ';
  3922. }
  3923. out += ' } ';
  3924. if ($isData) {
  3925. out += ' } ';
  3926. }
  3927. out += ' if (!' + ($valid) + ') { ';
  3928. var $$outStack = $$outStack || [];
  3929. $$outStack.push(out);
  3930. out = ''; /* istanbul ignore else */
  3931. if (it.createErrors !== false) {
  3932. out += ' { keyword: \'' + ('uniqueItems') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { i: i, j: j } ';
  3933. if (it.opts.messages !== false) {
  3934. out += ' , message: \'should NOT have duplicate items (items ## \' + j + \' and \' + i + \' are identical)\' ';
  3935. }
  3936. if (it.opts.verbose) {
  3937. out += ' , schema: ';
  3938. if ($isData) {
  3939. out += 'validate.schema' + ($schemaPath);
  3940. } else {
  3941. out += '' + ($schema);
  3942. }
  3943. out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  3944. }
  3945. out += ' } ';
  3946. } else {
  3947. out += ' {} ';
  3948. }
  3949. var __err = out;
  3950. out = $$outStack.pop();
  3951. if (!it.compositeRule && $breakOnError) {
  3952. /* istanbul ignore if */
  3953. if (it.async) {
  3954. out += ' throw new ValidationError([' + (__err) + ']); ';
  3955. } else {
  3956. out += ' validate.errors = [' + (__err) + ']; return false; ';
  3957. }
  3958. } else {
  3959. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  3960. }
  3961. out += ' } ';
  3962. if ($breakOnError) {
  3963. out += ' else { ';
  3964. }
  3965. } else {
  3966. if ($breakOnError) {
  3967. out += ' if (true) { ';
  3968. }
  3969. }
  3970. return out;
  3971. }
  3972. },{}],38:[function(require,module,exports){
  3973. 'use strict';
  3974. module.exports = function generate_validate(it, $keyword, $ruleType) {
  3975. var out = '';
  3976. var $async = it.schema.$async === true,
  3977. $refKeywords = it.util.schemaHasRulesExcept(it.schema, it.RULES.all, '$ref'),
  3978. $id = it.self._getId(it.schema);
  3979. if (it.opts.strictKeywords) {
  3980. var $unknownKwd = it.util.schemaUnknownRules(it.schema, it.RULES.keywords);
  3981. if ($unknownKwd) {
  3982. var $keywordsMsg = 'unknown keyword: ' + $unknownKwd;
  3983. if (it.opts.strictKeywords === 'log') it.logger.warn($keywordsMsg);
  3984. else throw new Error($keywordsMsg);
  3985. }
  3986. }
  3987. if (it.isTop) {
  3988. out += ' var validate = ';
  3989. if ($async) {
  3990. it.async = true;
  3991. out += 'async ';
  3992. }
  3993. out += 'function(data, dataPath, parentData, parentDataProperty, rootData) { \'use strict\'; ';
  3994. if ($id && (it.opts.sourceCode || it.opts.processCode)) {
  3995. out += ' ' + ('/\*# sourceURL=' + $id + ' */') + ' ';
  3996. }
  3997. }
  3998. if (typeof it.schema == 'boolean' || !($refKeywords || it.schema.$ref)) {
  3999. var $keyword = 'false schema';
  4000. var $lvl = it.level;
  4001. var $dataLvl = it.dataLevel;
  4002. var $schema = it.schema[$keyword];
  4003. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  4004. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  4005. var $breakOnError = !it.opts.allErrors;
  4006. var $errorKeyword;
  4007. var $data = 'data' + ($dataLvl || '');
  4008. var $valid = 'valid' + $lvl;
  4009. if (it.schema === false) {
  4010. if (it.isTop) {
  4011. $breakOnError = true;
  4012. } else {
  4013. out += ' var ' + ($valid) + ' = false; ';
  4014. }
  4015. var $$outStack = $$outStack || [];
  4016. $$outStack.push(out);
  4017. out = ''; /* istanbul ignore else */
  4018. if (it.createErrors !== false) {
  4019. out += ' { keyword: \'' + ($errorKeyword || 'false schema') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
  4020. if (it.opts.messages !== false) {
  4021. out += ' , message: \'boolean schema is false\' ';
  4022. }
  4023. if (it.opts.verbose) {
  4024. out += ' , schema: false , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  4025. }
  4026. out += ' } ';
  4027. } else {
  4028. out += ' {} ';
  4029. }
  4030. var __err = out;
  4031. out = $$outStack.pop();
  4032. if (!it.compositeRule && $breakOnError) {
  4033. /* istanbul ignore if */
  4034. if (it.async) {
  4035. out += ' throw new ValidationError([' + (__err) + ']); ';
  4036. } else {
  4037. out += ' validate.errors = [' + (__err) + ']; return false; ';
  4038. }
  4039. } else {
  4040. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  4041. }
  4042. } else {
  4043. if (it.isTop) {
  4044. if ($async) {
  4045. out += ' return data; ';
  4046. } else {
  4047. out += ' validate.errors = null; return true; ';
  4048. }
  4049. } else {
  4050. out += ' var ' + ($valid) + ' = true; ';
  4051. }
  4052. }
  4053. if (it.isTop) {
  4054. out += ' }; return validate; ';
  4055. }
  4056. return out;
  4057. }
  4058. if (it.isTop) {
  4059. var $top = it.isTop,
  4060. $lvl = it.level = 0,
  4061. $dataLvl = it.dataLevel = 0,
  4062. $data = 'data';
  4063. it.rootId = it.resolve.fullPath(it.self._getId(it.root.schema));
  4064. it.baseId = it.baseId || it.rootId;
  4065. delete it.isTop;
  4066. it.dataPathArr = [undefined];
  4067. if (it.schema.default !== undefined && it.opts.useDefaults && it.opts.strictDefaults) {
  4068. var $defaultMsg = 'default is ignored in the schema root';
  4069. if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);
  4070. else throw new Error($defaultMsg);
  4071. }
  4072. out += ' var vErrors = null; ';
  4073. out += ' var errors = 0; ';
  4074. out += ' if (rootData === undefined) rootData = data; ';
  4075. } else {
  4076. var $lvl = it.level,
  4077. $dataLvl = it.dataLevel,
  4078. $data = 'data' + ($dataLvl || '');
  4079. if ($id) it.baseId = it.resolve.url(it.baseId, $id);
  4080. if ($async && !it.async) throw new Error('async schema in sync schema');
  4081. out += ' var errs_' + ($lvl) + ' = errors;';
  4082. }
  4083. var $valid = 'valid' + $lvl,
  4084. $breakOnError = !it.opts.allErrors,
  4085. $closingBraces1 = '',
  4086. $closingBraces2 = '';
  4087. var $errorKeyword;
  4088. var $typeSchema = it.schema.type,
  4089. $typeIsArray = Array.isArray($typeSchema);
  4090. if ($typeSchema && it.opts.nullable && it.schema.nullable === true) {
  4091. if ($typeIsArray) {
  4092. if ($typeSchema.indexOf('null') == -1) $typeSchema = $typeSchema.concat('null');
  4093. } else if ($typeSchema != 'null') {
  4094. $typeSchema = [$typeSchema, 'null'];
  4095. $typeIsArray = true;
  4096. }
  4097. }
  4098. if ($typeIsArray && $typeSchema.length == 1) {
  4099. $typeSchema = $typeSchema[0];
  4100. $typeIsArray = false;
  4101. }
  4102. if (it.schema.$ref && $refKeywords) {
  4103. if (it.opts.extendRefs == 'fail') {
  4104. throw new Error('$ref: validation keywords used in schema at path "' + it.errSchemaPath + '" (see option extendRefs)');
  4105. } else if (it.opts.extendRefs !== true) {
  4106. $refKeywords = false;
  4107. it.logger.warn('$ref: keywords ignored in schema at path "' + it.errSchemaPath + '"');
  4108. }
  4109. }
  4110. if (it.schema.$comment && it.opts.$comment) {
  4111. out += ' ' + (it.RULES.all.$comment.code(it, '$comment'));
  4112. }
  4113. if ($typeSchema) {
  4114. if (it.opts.coerceTypes) {
  4115. var $coerceToTypes = it.util.coerceToTypes(it.opts.coerceTypes, $typeSchema);
  4116. }
  4117. var $rulesGroup = it.RULES.types[$typeSchema];
  4118. if ($coerceToTypes || $typeIsArray || $rulesGroup === true || ($rulesGroup && !$shouldUseGroup($rulesGroup))) {
  4119. var $schemaPath = it.schemaPath + '.type',
  4120. $errSchemaPath = it.errSchemaPath + '/type';
  4121. var $schemaPath = it.schemaPath + '.type',
  4122. $errSchemaPath = it.errSchemaPath + '/type',
  4123. $method = $typeIsArray ? 'checkDataTypes' : 'checkDataType';
  4124. out += ' if (' + (it.util[$method]($typeSchema, $data, true)) + ') { ';
  4125. if ($coerceToTypes) {
  4126. var $dataType = 'dataType' + $lvl,
  4127. $coerced = 'coerced' + $lvl;
  4128. out += ' var ' + ($dataType) + ' = typeof ' + ($data) + '; ';
  4129. if (it.opts.coerceTypes == 'array') {
  4130. out += ' if (' + ($dataType) + ' == \'object\' && Array.isArray(' + ($data) + ')) ' + ($dataType) + ' = \'array\'; ';
  4131. }
  4132. out += ' var ' + ($coerced) + ' = undefined; ';
  4133. var $bracesCoercion = '';
  4134. var arr1 = $coerceToTypes;
  4135. if (arr1) {
  4136. var $type, $i = -1,
  4137. l1 = arr1.length - 1;
  4138. while ($i < l1) {
  4139. $type = arr1[$i += 1];
  4140. if ($i) {
  4141. out += ' if (' + ($coerced) + ' === undefined) { ';
  4142. $bracesCoercion += '}';
  4143. }
  4144. if (it.opts.coerceTypes == 'array' && $type != 'array') {
  4145. out += ' if (' + ($dataType) + ' == \'array\' && ' + ($data) + '.length == 1) { ' + ($coerced) + ' = ' + ($data) + ' = ' + ($data) + '[0]; ' + ($dataType) + ' = typeof ' + ($data) + '; } ';
  4146. }
  4147. if ($type == 'string') {
  4148. out += ' if (' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\') ' + ($coerced) + ' = \'\' + ' + ($data) + '; else if (' + ($data) + ' === null) ' + ($coerced) + ' = \'\'; ';
  4149. } else if ($type == 'number' || $type == 'integer') {
  4150. out += ' if (' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' === null || (' + ($dataType) + ' == \'string\' && ' + ($data) + ' && ' + ($data) + ' == +' + ($data) + ' ';
  4151. if ($type == 'integer') {
  4152. out += ' && !(' + ($data) + ' % 1)';
  4153. }
  4154. out += ')) ' + ($coerced) + ' = +' + ($data) + '; ';
  4155. } else if ($type == 'boolean') {
  4156. out += ' if (' + ($data) + ' === \'false\' || ' + ($data) + ' === 0 || ' + ($data) + ' === null) ' + ($coerced) + ' = false; else if (' + ($data) + ' === \'true\' || ' + ($data) + ' === 1) ' + ($coerced) + ' = true; ';
  4157. } else if ($type == 'null') {
  4158. out += ' if (' + ($data) + ' === \'\' || ' + ($data) + ' === 0 || ' + ($data) + ' === false) ' + ($coerced) + ' = null; ';
  4159. } else if (it.opts.coerceTypes == 'array' && $type == 'array') {
  4160. out += ' if (' + ($dataType) + ' == \'string\' || ' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' == null) ' + ($coerced) + ' = [' + ($data) + ']; ';
  4161. }
  4162. }
  4163. }
  4164. out += ' ' + ($bracesCoercion) + ' if (' + ($coerced) + ' === undefined) { ';
  4165. var $$outStack = $$outStack || [];
  4166. $$outStack.push(out);
  4167. out = ''; /* istanbul ignore else */
  4168. if (it.createErrors !== false) {
  4169. out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \'';
  4170. if ($typeIsArray) {
  4171. out += '' + ($typeSchema.join(","));
  4172. } else {
  4173. out += '' + ($typeSchema);
  4174. }
  4175. out += '\' } ';
  4176. if (it.opts.messages !== false) {
  4177. out += ' , message: \'should be ';
  4178. if ($typeIsArray) {
  4179. out += '' + ($typeSchema.join(","));
  4180. } else {
  4181. out += '' + ($typeSchema);
  4182. }
  4183. out += '\' ';
  4184. }
  4185. if (it.opts.verbose) {
  4186. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  4187. }
  4188. out += ' } ';
  4189. } else {
  4190. out += ' {} ';
  4191. }
  4192. var __err = out;
  4193. out = $$outStack.pop();
  4194. if (!it.compositeRule && $breakOnError) {
  4195. /* istanbul ignore if */
  4196. if (it.async) {
  4197. out += ' throw new ValidationError([' + (__err) + ']); ';
  4198. } else {
  4199. out += ' validate.errors = [' + (__err) + ']; return false; ';
  4200. }
  4201. } else {
  4202. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  4203. }
  4204. out += ' } else { ';
  4205. var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData',
  4206. $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
  4207. out += ' ' + ($data) + ' = ' + ($coerced) + '; ';
  4208. if (!$dataLvl) {
  4209. out += 'if (' + ($parentData) + ' !== undefined)';
  4210. }
  4211. out += ' ' + ($parentData) + '[' + ($parentDataProperty) + '] = ' + ($coerced) + '; } ';
  4212. } else {
  4213. var $$outStack = $$outStack || [];
  4214. $$outStack.push(out);
  4215. out = ''; /* istanbul ignore else */
  4216. if (it.createErrors !== false) {
  4217. out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \'';
  4218. if ($typeIsArray) {
  4219. out += '' + ($typeSchema.join(","));
  4220. } else {
  4221. out += '' + ($typeSchema);
  4222. }
  4223. out += '\' } ';
  4224. if (it.opts.messages !== false) {
  4225. out += ' , message: \'should be ';
  4226. if ($typeIsArray) {
  4227. out += '' + ($typeSchema.join(","));
  4228. } else {
  4229. out += '' + ($typeSchema);
  4230. }
  4231. out += '\' ';
  4232. }
  4233. if (it.opts.verbose) {
  4234. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  4235. }
  4236. out += ' } ';
  4237. } else {
  4238. out += ' {} ';
  4239. }
  4240. var __err = out;
  4241. out = $$outStack.pop();
  4242. if (!it.compositeRule && $breakOnError) {
  4243. /* istanbul ignore if */
  4244. if (it.async) {
  4245. out += ' throw new ValidationError([' + (__err) + ']); ';
  4246. } else {
  4247. out += ' validate.errors = [' + (__err) + ']; return false; ';
  4248. }
  4249. } else {
  4250. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  4251. }
  4252. }
  4253. out += ' } ';
  4254. }
  4255. }
  4256. if (it.schema.$ref && !$refKeywords) {
  4257. out += ' ' + (it.RULES.all.$ref.code(it, '$ref')) + ' ';
  4258. if ($breakOnError) {
  4259. out += ' } if (errors === ';
  4260. if ($top) {
  4261. out += '0';
  4262. } else {
  4263. out += 'errs_' + ($lvl);
  4264. }
  4265. out += ') { ';
  4266. $closingBraces2 += '}';
  4267. }
  4268. } else {
  4269. var arr2 = it.RULES;
  4270. if (arr2) {
  4271. var $rulesGroup, i2 = -1,
  4272. l2 = arr2.length - 1;
  4273. while (i2 < l2) {
  4274. $rulesGroup = arr2[i2 += 1];
  4275. if ($shouldUseGroup($rulesGroup)) {
  4276. if ($rulesGroup.type) {
  4277. out += ' if (' + (it.util.checkDataType($rulesGroup.type, $data)) + ') { ';
  4278. }
  4279. if (it.opts.useDefaults) {
  4280. if ($rulesGroup.type == 'object' && it.schema.properties) {
  4281. var $schema = it.schema.properties,
  4282. $schemaKeys = Object.keys($schema);
  4283. var arr3 = $schemaKeys;
  4284. if (arr3) {
  4285. var $propertyKey, i3 = -1,
  4286. l3 = arr3.length - 1;
  4287. while (i3 < l3) {
  4288. $propertyKey = arr3[i3 += 1];
  4289. var $sch = $schema[$propertyKey];
  4290. if ($sch.default !== undefined) {
  4291. var $passData = $data + it.util.getProperty($propertyKey);
  4292. if (it.compositeRule) {
  4293. if (it.opts.strictDefaults) {
  4294. var $defaultMsg = 'default is ignored for: ' + $passData;
  4295. if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);
  4296. else throw new Error($defaultMsg);
  4297. }
  4298. } else {
  4299. out += ' if (' + ($passData) + ' === undefined ';
  4300. if (it.opts.useDefaults == 'empty') {
  4301. out += ' || ' + ($passData) + ' === null || ' + ($passData) + ' === \'\' ';
  4302. }
  4303. out += ' ) ' + ($passData) + ' = ';
  4304. if (it.opts.useDefaults == 'shared') {
  4305. out += ' ' + (it.useDefault($sch.default)) + ' ';
  4306. } else {
  4307. out += ' ' + (JSON.stringify($sch.default)) + ' ';
  4308. }
  4309. out += '; ';
  4310. }
  4311. }
  4312. }
  4313. }
  4314. } else if ($rulesGroup.type == 'array' && Array.isArray(it.schema.items)) {
  4315. var arr4 = it.schema.items;
  4316. if (arr4) {
  4317. var $sch, $i = -1,
  4318. l4 = arr4.length - 1;
  4319. while ($i < l4) {
  4320. $sch = arr4[$i += 1];
  4321. if ($sch.default !== undefined) {
  4322. var $passData = $data + '[' + $i + ']';
  4323. if (it.compositeRule) {
  4324. if (it.opts.strictDefaults) {
  4325. var $defaultMsg = 'default is ignored for: ' + $passData;
  4326. if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);
  4327. else throw new Error($defaultMsg);
  4328. }
  4329. } else {
  4330. out += ' if (' + ($passData) + ' === undefined ';
  4331. if (it.opts.useDefaults == 'empty') {
  4332. out += ' || ' + ($passData) + ' === null || ' + ($passData) + ' === \'\' ';
  4333. }
  4334. out += ' ) ' + ($passData) + ' = ';
  4335. if (it.opts.useDefaults == 'shared') {
  4336. out += ' ' + (it.useDefault($sch.default)) + ' ';
  4337. } else {
  4338. out += ' ' + (JSON.stringify($sch.default)) + ' ';
  4339. }
  4340. out += '; ';
  4341. }
  4342. }
  4343. }
  4344. }
  4345. }
  4346. }
  4347. var arr5 = $rulesGroup.rules;
  4348. if (arr5) {
  4349. var $rule, i5 = -1,
  4350. l5 = arr5.length - 1;
  4351. while (i5 < l5) {
  4352. $rule = arr5[i5 += 1];
  4353. if ($shouldUseRule($rule)) {
  4354. var $code = $rule.code(it, $rule.keyword, $rulesGroup.type);
  4355. if ($code) {
  4356. out += ' ' + ($code) + ' ';
  4357. if ($breakOnError) {
  4358. $closingBraces1 += '}';
  4359. }
  4360. }
  4361. }
  4362. }
  4363. }
  4364. if ($breakOnError) {
  4365. out += ' ' + ($closingBraces1) + ' ';
  4366. $closingBraces1 = '';
  4367. }
  4368. if ($rulesGroup.type) {
  4369. out += ' } ';
  4370. if ($typeSchema && $typeSchema === $rulesGroup.type && !$coerceToTypes) {
  4371. out += ' else { ';
  4372. var $schemaPath = it.schemaPath + '.type',
  4373. $errSchemaPath = it.errSchemaPath + '/type';
  4374. var $$outStack = $$outStack || [];
  4375. $$outStack.push(out);
  4376. out = ''; /* istanbul ignore else */
  4377. if (it.createErrors !== false) {
  4378. out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \'';
  4379. if ($typeIsArray) {
  4380. out += '' + ($typeSchema.join(","));
  4381. } else {
  4382. out += '' + ($typeSchema);
  4383. }
  4384. out += '\' } ';
  4385. if (it.opts.messages !== false) {
  4386. out += ' , message: \'should be ';
  4387. if ($typeIsArray) {
  4388. out += '' + ($typeSchema.join(","));
  4389. } else {
  4390. out += '' + ($typeSchema);
  4391. }
  4392. out += '\' ';
  4393. }
  4394. if (it.opts.verbose) {
  4395. out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  4396. }
  4397. out += ' } ';
  4398. } else {
  4399. out += ' {} ';
  4400. }
  4401. var __err = out;
  4402. out = $$outStack.pop();
  4403. if (!it.compositeRule && $breakOnError) {
  4404. /* istanbul ignore if */
  4405. if (it.async) {
  4406. out += ' throw new ValidationError([' + (__err) + ']); ';
  4407. } else {
  4408. out += ' validate.errors = [' + (__err) + ']; return false; ';
  4409. }
  4410. } else {
  4411. out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  4412. }
  4413. out += ' } ';
  4414. }
  4415. }
  4416. if ($breakOnError) {
  4417. out += ' if (errors === ';
  4418. if ($top) {
  4419. out += '0';
  4420. } else {
  4421. out += 'errs_' + ($lvl);
  4422. }
  4423. out += ') { ';
  4424. $closingBraces2 += '}';
  4425. }
  4426. }
  4427. }
  4428. }
  4429. }
  4430. if ($breakOnError) {
  4431. out += ' ' + ($closingBraces2) + ' ';
  4432. }
  4433. if ($top) {
  4434. if ($async) {
  4435. out += ' if (errors === 0) return data; ';
  4436. out += ' else throw new ValidationError(vErrors); ';
  4437. } else {
  4438. out += ' validate.errors = vErrors; ';
  4439. out += ' return errors === 0; ';
  4440. }
  4441. out += ' }; return validate;';
  4442. } else {
  4443. out += ' var ' + ($valid) + ' = errors === errs_' + ($lvl) + ';';
  4444. }
  4445. out = it.util.cleanUpCode(out);
  4446. if ($top) {
  4447. out = it.util.finalCleanUpCode(out, $async);
  4448. }
  4449. function $shouldUseGroup($rulesGroup) {
  4450. var rules = $rulesGroup.rules;
  4451. for (var i = 0; i < rules.length; i++)
  4452. if ($shouldUseRule(rules[i])) return true;
  4453. }
  4454. function $shouldUseRule($rule) {
  4455. return it.schema[$rule.keyword] !== undefined || ($rule.implements && $ruleImplementsSomeKeyword($rule));
  4456. }
  4457. function $ruleImplementsSomeKeyword($rule) {
  4458. var impl = $rule.implements;
  4459. for (var i = 0; i < impl.length; i++)
  4460. if (it.schema[impl[i]] !== undefined) return true;
  4461. }
  4462. return out;
  4463. }
  4464. },{}],39:[function(require,module,exports){
  4465. 'use strict';
  4466. var IDENTIFIER = /^[a-z_$][a-z0-9_$-]*$/i;
  4467. var customRuleCode = require('./dotjs/custom');
  4468. var definitionSchema = require('./definition_schema');
  4469. module.exports = {
  4470. add: addKeyword,
  4471. get: getKeyword,
  4472. remove: removeKeyword,
  4473. validate: validateKeyword
  4474. };
  4475. /**
  4476. * Define custom keyword
  4477. * @this Ajv
  4478. * @param {String} keyword custom keyword, should be unique (including different from all standard, custom and macro keywords).
  4479. * @param {Object} definition keyword definition object with properties `type` (type(s) which the keyword applies to), `validate` or `compile`.
  4480. * @return {Ajv} this for method chaining
  4481. */
  4482. function addKeyword(keyword, definition) {
  4483. /* jshint validthis: true */
  4484. /* eslint no-shadow: 0 */
  4485. var RULES = this.RULES;
  4486. if (RULES.keywords[keyword])
  4487. throw new Error('Keyword ' + keyword + ' is already defined');
  4488. if (!IDENTIFIER.test(keyword))
  4489. throw new Error('Keyword ' + keyword + ' is not a valid identifier');
  4490. if (definition) {
  4491. this.validateKeyword(definition, true);
  4492. var dataType = definition.type;
  4493. if (Array.isArray(dataType)) {
  4494. for (var i=0; i<dataType.length; i++)
  4495. _addRule(keyword, dataType[i], definition);
  4496. } else {
  4497. _addRule(keyword, dataType, definition);
  4498. }
  4499. var metaSchema = definition.metaSchema;
  4500. if (metaSchema) {
  4501. if (definition.$data && this._opts.$data) {
  4502. metaSchema = {
  4503. anyOf: [
  4504. metaSchema,
  4505. { '$ref': 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#' }
  4506. ]
  4507. };
  4508. }
  4509. definition.validateSchema = this.compile(metaSchema, true);
  4510. }
  4511. }
  4512. RULES.keywords[keyword] = RULES.all[keyword] = true;
  4513. function _addRule(keyword, dataType, definition) {
  4514. var ruleGroup;
  4515. for (var i=0; i<RULES.length; i++) {
  4516. var rg = RULES[i];
  4517. if (rg.type == dataType) {
  4518. ruleGroup = rg;
  4519. break;
  4520. }
  4521. }
  4522. if (!ruleGroup) {
  4523. ruleGroup = { type: dataType, rules: [] };
  4524. RULES.push(ruleGroup);
  4525. }
  4526. var rule = {
  4527. keyword: keyword,
  4528. definition: definition,
  4529. custom: true,
  4530. code: customRuleCode,
  4531. implements: definition.implements
  4532. };
  4533. ruleGroup.rules.push(rule);
  4534. RULES.custom[keyword] = rule;
  4535. }
  4536. return this;
  4537. }
  4538. /**
  4539. * Get keyword
  4540. * @this Ajv
  4541. * @param {String} keyword pre-defined or custom keyword.
  4542. * @return {Object|Boolean} custom keyword definition, `true` if it is a predefined keyword, `false` otherwise.
  4543. */
  4544. function getKeyword(keyword) {
  4545. /* jshint validthis: true */
  4546. var rule = this.RULES.custom[keyword];
  4547. return rule ? rule.definition : this.RULES.keywords[keyword] || false;
  4548. }
  4549. /**
  4550. * Remove keyword
  4551. * @this Ajv
  4552. * @param {String} keyword pre-defined or custom keyword.
  4553. * @return {Ajv} this for method chaining
  4554. */
  4555. function removeKeyword(keyword) {
  4556. /* jshint validthis: true */
  4557. var RULES = this.RULES;
  4558. delete RULES.keywords[keyword];
  4559. delete RULES.all[keyword];
  4560. delete RULES.custom[keyword];
  4561. for (var i=0; i<RULES.length; i++) {
  4562. var rules = RULES[i].rules;
  4563. for (var j=0; j<rules.length; j++) {
  4564. if (rules[j].keyword == keyword) {
  4565. rules.splice(j, 1);
  4566. break;
  4567. }
  4568. }
  4569. }
  4570. return this;
  4571. }
  4572. /**
  4573. * Validate keyword definition
  4574. * @this Ajv
  4575. * @param {Object} definition keyword definition object.
  4576. * @param {Boolean} throwError true to throw exception if definition is invalid
  4577. * @return {boolean} validation result
  4578. */
  4579. function validateKeyword(definition, throwError) {
  4580. validateKeyword.errors = null;
  4581. var v = this._validateKeyword = this._validateKeyword
  4582. || this.compile(definitionSchema, true);
  4583. if (v(definition)) return true;
  4584. validateKeyword.errors = v.errors;
  4585. if (throwError)
  4586. throw new Error('custom keyword definition is invalid: ' + this.errorsText(v.errors));
  4587. else
  4588. return false;
  4589. }
  4590. },{"./definition_schema":12,"./dotjs/custom":22}],40:[function(require,module,exports){
  4591. module.exports={
  4592. "$schema": "http://json-schema.org/draft-07/schema#",
  4593. "$id": "https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#",
  4594. "description": "Meta-schema for $data reference (JSON Schema extension proposal)",
  4595. "type": "object",
  4596. "required": [ "$data" ],
  4597. "properties": {
  4598. "$data": {
  4599. "type": "string",
  4600. "anyOf": [
  4601. { "format": "relative-json-pointer" },
  4602. { "format": "json-pointer" }
  4603. ]
  4604. }
  4605. },
  4606. "additionalProperties": false
  4607. }
  4608. },{}],41:[function(require,module,exports){
  4609. module.exports={
  4610. "$schema": "http://json-schema.org/draft-07/schema#",
  4611. "$id": "http://json-schema.org/draft-07/schema#",
  4612. "title": "Core schema meta-schema",
  4613. "definitions": {
  4614. "schemaArray": {
  4615. "type": "array",
  4616. "minItems": 1,
  4617. "items": { "$ref": "#" }
  4618. },
  4619. "nonNegativeInteger": {
  4620. "type": "integer",
  4621. "minimum": 0
  4622. },
  4623. "nonNegativeIntegerDefault0": {
  4624. "allOf": [
  4625. { "$ref": "#/definitions/nonNegativeInteger" },
  4626. { "default": 0 }
  4627. ]
  4628. },
  4629. "simpleTypes": {
  4630. "enum": [
  4631. "array",
  4632. "boolean",
  4633. "integer",
  4634. "null",
  4635. "number",
  4636. "object",
  4637. "string"
  4638. ]
  4639. },
  4640. "stringArray": {
  4641. "type": "array",
  4642. "items": { "type": "string" },
  4643. "uniqueItems": true,
  4644. "default": []
  4645. }
  4646. },
  4647. "type": ["object", "boolean"],
  4648. "properties": {
  4649. "$id": {
  4650. "type": "string",
  4651. "format": "uri-reference"
  4652. },
  4653. "$schema": {
  4654. "type": "string",
  4655. "format": "uri"
  4656. },
  4657. "$ref": {
  4658. "type": "string",
  4659. "format": "uri-reference"
  4660. },
  4661. "$comment": {
  4662. "type": "string"
  4663. },
  4664. "title": {
  4665. "type": "string"
  4666. },
  4667. "description": {
  4668. "type": "string"
  4669. },
  4670. "default": true,
  4671. "readOnly": {
  4672. "type": "boolean",
  4673. "default": false
  4674. },
  4675. "examples": {
  4676. "type": "array",
  4677. "items": true
  4678. },
  4679. "multipleOf": {
  4680. "type": "number",
  4681. "exclusiveMinimum": 0
  4682. },
  4683. "maximum": {
  4684. "type": "number"
  4685. },
  4686. "exclusiveMaximum": {
  4687. "type": "number"
  4688. },
  4689. "minimum": {
  4690. "type": "number"
  4691. },
  4692. "exclusiveMinimum": {
  4693. "type": "number"
  4694. },
  4695. "maxLength": { "$ref": "#/definitions/nonNegativeInteger" },
  4696. "minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
  4697. "pattern": {
  4698. "type": "string",
  4699. "format": "regex"
  4700. },
  4701. "additionalItems": { "$ref": "#" },
  4702. "items": {
  4703. "anyOf": [
  4704. { "$ref": "#" },
  4705. { "$ref": "#/definitions/schemaArray" }
  4706. ],
  4707. "default": true
  4708. },
  4709. "maxItems": { "$ref": "#/definitions/nonNegativeInteger" },
  4710. "minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
  4711. "uniqueItems": {
  4712. "type": "boolean",
  4713. "default": false
  4714. },
  4715. "contains": { "$ref": "#" },
  4716. "maxProperties": { "$ref": "#/definitions/nonNegativeInteger" },
  4717. "minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
  4718. "required": { "$ref": "#/definitions/stringArray" },
  4719. "additionalProperties": { "$ref": "#" },
  4720. "definitions": {
  4721. "type": "object",
  4722. "additionalProperties": { "$ref": "#" },
  4723. "default": {}
  4724. },
  4725. "properties": {
  4726. "type": "object",
  4727. "additionalProperties": { "$ref": "#" },
  4728. "default": {}
  4729. },
  4730. "patternProperties": {
  4731. "type": "object",
  4732. "additionalProperties": { "$ref": "#" },
  4733. "propertyNames": { "format": "regex" },
  4734. "default": {}
  4735. },
  4736. "dependencies": {
  4737. "type": "object",
  4738. "additionalProperties": {
  4739. "anyOf": [
  4740. { "$ref": "#" },
  4741. { "$ref": "#/definitions/stringArray" }
  4742. ]
  4743. }
  4744. },
  4745. "propertyNames": { "$ref": "#" },
  4746. "const": true,
  4747. "enum": {
  4748. "type": "array",
  4749. "items": true,
  4750. "minItems": 1,
  4751. "uniqueItems": true
  4752. },
  4753. "type": {
  4754. "anyOf": [
  4755. { "$ref": "#/definitions/simpleTypes" },
  4756. {
  4757. "type": "array",
  4758. "items": { "$ref": "#/definitions/simpleTypes" },
  4759. "minItems": 1,
  4760. "uniqueItems": true
  4761. }
  4762. ]
  4763. },
  4764. "format": { "type": "string" },
  4765. "contentMediaType": { "type": "string" },
  4766. "contentEncoding": { "type": "string" },
  4767. "if": {"$ref": "#"},
  4768. "then": {"$ref": "#"},
  4769. "else": {"$ref": "#"},
  4770. "allOf": { "$ref": "#/definitions/schemaArray" },
  4771. "anyOf": { "$ref": "#/definitions/schemaArray" },
  4772. "oneOf": { "$ref": "#/definitions/schemaArray" },
  4773. "not": { "$ref": "#" }
  4774. },
  4775. "default": true
  4776. }
  4777. },{}],42:[function(require,module,exports){
  4778. 'use strict';
  4779. // do not edit .js files directly - edit src/index.jst
  4780. module.exports = function equal(a, b) {
  4781. if (a === b) return true;
  4782. if (a && b && typeof a == 'object' && typeof b == 'object') {
  4783. if (a.constructor !== b.constructor) return false;
  4784. var length, i, keys;
  4785. if (Array.isArray(a)) {
  4786. length = a.length;
  4787. if (length != b.length) return false;
  4788. for (i = length; i-- !== 0;)
  4789. if (!equal(a[i], b[i])) return false;
  4790. return true;
  4791. }
  4792. if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
  4793. if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
  4794. if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
  4795. keys = Object.keys(a);
  4796. length = keys.length;
  4797. if (length !== Object.keys(b).length) return false;
  4798. for (i = length; i-- !== 0;)
  4799. if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
  4800. for (i = length; i-- !== 0;) {
  4801. var key = keys[i];
  4802. if (!equal(a[key], b[key])) return false;
  4803. }
  4804. return true;
  4805. }
  4806. // true if both NaN, false otherwise
  4807. return a!==a && b!==b;
  4808. };
  4809. },{}],43:[function(require,module,exports){
  4810. 'use strict';
  4811. module.exports = function (data, opts) {
  4812. if (!opts) opts = {};
  4813. if (typeof opts === 'function') opts = { cmp: opts };
  4814. var cycles = (typeof opts.cycles === 'boolean') ? opts.cycles : false;
  4815. var cmp = opts.cmp && (function (f) {
  4816. return function (node) {
  4817. return function (a, b) {
  4818. var aobj = { key: a, value: node[a] };
  4819. var bobj = { key: b, value: node[b] };
  4820. return f(aobj, bobj);
  4821. };
  4822. };
  4823. })(opts.cmp);
  4824. var seen = [];
  4825. return (function stringify (node) {
  4826. if (node && node.toJSON && typeof node.toJSON === 'function') {
  4827. node = node.toJSON();
  4828. }
  4829. if (node === undefined) return;
  4830. if (typeof node == 'number') return isFinite(node) ? '' + node : 'null';
  4831. if (typeof node !== 'object') return JSON.stringify(node);
  4832. var i, out;
  4833. if (Array.isArray(node)) {
  4834. out = '[';
  4835. for (i = 0; i < node.length; i++) {
  4836. if (i) out += ',';
  4837. out += stringify(node[i]) || 'null';
  4838. }
  4839. return out + ']';
  4840. }
  4841. if (node === null) return 'null';
  4842. if (seen.indexOf(node) !== -1) {
  4843. if (cycles) return JSON.stringify('__cycle__');
  4844. throw new TypeError('Converting circular structure to JSON');
  4845. }
  4846. var seenIndex = seen.push(node) - 1;
  4847. var keys = Object.keys(node).sort(cmp && cmp(node));
  4848. out = '';
  4849. for (i = 0; i < keys.length; i++) {
  4850. var key = keys[i];
  4851. var value = stringify(node[key]);
  4852. if (!value) continue;
  4853. if (out) out += ',';
  4854. out += JSON.stringify(key) + ':' + value;
  4855. }
  4856. seen.splice(seenIndex, 1);
  4857. return '{' + out + '}';
  4858. })(data);
  4859. };
  4860. },{}],44:[function(require,module,exports){
  4861. 'use strict';
  4862. var traverse = module.exports = function (schema, opts, cb) {
  4863. // Legacy support for v0.3.1 and earlier.
  4864. if (typeof opts == 'function') {
  4865. cb = opts;
  4866. opts = {};
  4867. }
  4868. cb = opts.cb || cb;
  4869. var pre = (typeof cb == 'function') ? cb : cb.pre || function() {};
  4870. var post = cb.post || function() {};
  4871. _traverse(opts, pre, post, schema, '', schema);
  4872. };
  4873. traverse.keywords = {
  4874. additionalItems: true,
  4875. items: true,
  4876. contains: true,
  4877. additionalProperties: true,
  4878. propertyNames: true,
  4879. not: true
  4880. };
  4881. traverse.arrayKeywords = {
  4882. items: true,
  4883. allOf: true,
  4884. anyOf: true,
  4885. oneOf: true
  4886. };
  4887. traverse.propsKeywords = {
  4888. definitions: true,
  4889. properties: true,
  4890. patternProperties: true,
  4891. dependencies: true
  4892. };
  4893. traverse.skipKeywords = {
  4894. default: true,
  4895. enum: true,
  4896. const: true,
  4897. required: true,
  4898. maximum: true,
  4899. minimum: true,
  4900. exclusiveMaximum: true,
  4901. exclusiveMinimum: true,
  4902. multipleOf: true,
  4903. maxLength: true,
  4904. minLength: true,
  4905. pattern: true,
  4906. format: true,
  4907. maxItems: true,
  4908. minItems: true,
  4909. uniqueItems: true,
  4910. maxProperties: true,
  4911. minProperties: true
  4912. };
  4913. function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
  4914. if (schema && typeof schema == 'object' && !Array.isArray(schema)) {
  4915. pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
  4916. for (var key in schema) {
  4917. var sch = schema[key];
  4918. if (Array.isArray(sch)) {
  4919. if (key in traverse.arrayKeywords) {
  4920. for (var i=0; i<sch.length; i++)
  4921. _traverse(opts, pre, post, sch[i], jsonPtr + '/' + key + '/' + i, rootSchema, jsonPtr, key, schema, i);
  4922. }
  4923. } else if (key in traverse.propsKeywords) {
  4924. if (sch && typeof sch == 'object') {
  4925. for (var prop in sch)
  4926. _traverse(opts, pre, post, sch[prop], jsonPtr + '/' + key + '/' + escapeJsonPtr(prop), rootSchema, jsonPtr, key, schema, prop);
  4927. }
  4928. } else if (key in traverse.keywords || (opts.allKeys && !(key in traverse.skipKeywords))) {
  4929. _traverse(opts, pre, post, sch, jsonPtr + '/' + key, rootSchema, jsonPtr, key, schema);
  4930. }
  4931. }
  4932. post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
  4933. }
  4934. }
  4935. function escapeJsonPtr(str) {
  4936. return str.replace(/~/g, '~0').replace(/\//g, '~1');
  4937. }
  4938. },{}],45:[function(require,module,exports){
  4939. /** @license URI.js v4.2.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
  4940. (function (global, factory) {
  4941. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  4942. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  4943. (factory((global.URI = global.URI || {})));
  4944. }(this, (function (exports) { 'use strict';
  4945. function merge() {
  4946. for (var _len = arguments.length, sets = Array(_len), _key = 0; _key < _len; _key++) {
  4947. sets[_key] = arguments[_key];
  4948. }
  4949. if (sets.length > 1) {
  4950. sets[0] = sets[0].slice(0, -1);
  4951. var xl = sets.length - 1;
  4952. for (var x = 1; x < xl; ++x) {
  4953. sets[x] = sets[x].slice(1, -1);
  4954. }
  4955. sets[xl] = sets[xl].slice(1);
  4956. return sets.join('');
  4957. } else {
  4958. return sets[0];
  4959. }
  4960. }
  4961. function subexp(str) {
  4962. return "(?:" + str + ")";
  4963. }
  4964. function typeOf(o) {
  4965. return o === undefined ? "undefined" : o === null ? "null" : Object.prototype.toString.call(o).split(" ").pop().split("]").shift().toLowerCase();
  4966. }
  4967. function toUpperCase(str) {
  4968. return str.toUpperCase();
  4969. }
  4970. function toArray(obj) {
  4971. return obj !== undefined && obj !== null ? obj instanceof Array ? obj : typeof obj.length !== "number" || obj.split || obj.setInterval || obj.call ? [obj] : Array.prototype.slice.call(obj) : [];
  4972. }
  4973. function assign(target, source) {
  4974. var obj = target;
  4975. if (source) {
  4976. for (var key in source) {
  4977. obj[key] = source[key];
  4978. }
  4979. }
  4980. return obj;
  4981. }
  4982. function buildExps(isIRI) {
  4983. var ALPHA$$ = "[A-Za-z]",
  4984. CR$ = "[\\x0D]",
  4985. DIGIT$$ = "[0-9]",
  4986. DQUOTE$$ = "[\\x22]",
  4987. HEXDIG$$ = merge(DIGIT$$, "[A-Fa-f]"),
  4988. //case-insensitive
  4989. LF$$ = "[\\x0A]",
  4990. SP$$ = "[\\x20]",
  4991. PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)),
  4992. //expanded
  4993. GEN_DELIMS$$ = "[\\:\\/\\?\\#\\[\\]\\@]",
  4994. SUB_DELIMS$$ = "[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",
  4995. RESERVED$$ = merge(GEN_DELIMS$$, SUB_DELIMS$$),
  4996. UCSCHAR$$ = isIRI ? "[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]" : "[]",
  4997. //subset, excludes bidi control characters
  4998. IPRIVATE$$ = isIRI ? "[\\uE000-\\uF8FF]" : "[]",
  4999. //subset
  5000. UNRESERVED$$ = merge(ALPHA$$, DIGIT$$, "[\\-\\.\\_\\~]", UCSCHAR$$),
  5001. SCHEME$ = subexp(ALPHA$$ + merge(ALPHA$$, DIGIT$$, "[\\+\\-\\.]") + "*"),
  5002. USERINFO$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]")) + "*"),
  5003. DEC_OCTET$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("[1-9]" + DIGIT$$) + "|" + DIGIT$$),
  5004. DEC_OCTET_RELAXED$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("0?[1-9]" + DIGIT$$) + "|0?0?" + DIGIT$$),
  5005. //relaxed parsing rules
  5006. IPV4ADDRESS$ = subexp(DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$),
  5007. H16$ = subexp(HEXDIG$$ + "{1,4}"),
  5008. LS32$ = subexp(subexp(H16$ + "\\:" + H16$) + "|" + IPV4ADDRESS$),
  5009. IPV6ADDRESS1$ = subexp(subexp(H16$ + "\\:") + "{6}" + LS32$),
  5010. // 6( h16 ":" ) ls32
  5011. IPV6ADDRESS2$ = subexp("\\:\\:" + subexp(H16$ + "\\:") + "{5}" + LS32$),
  5012. // "::" 5( h16 ":" ) ls32
  5013. IPV6ADDRESS3$ = subexp(subexp(H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{4}" + LS32$),
  5014. //[ h16 ] "::" 4( h16 ":" ) ls32
  5015. IPV6ADDRESS4$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,1}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{3}" + LS32$),
  5016. //[ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32
  5017. IPV6ADDRESS5$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,2}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{2}" + LS32$),
  5018. //[ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32
  5019. IPV6ADDRESS6$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,3}" + H16$) + "?\\:\\:" + H16$ + "\\:" + LS32$),
  5020. //[ *3( h16 ":" ) h16 ] "::" h16 ":" ls32
  5021. IPV6ADDRESS7$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,4}" + H16$) + "?\\:\\:" + LS32$),
  5022. //[ *4( h16 ":" ) h16 ] "::" ls32
  5023. IPV6ADDRESS8$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,5}" + H16$) + "?\\:\\:" + H16$),
  5024. //[ *5( h16 ":" ) h16 ] "::" h16
  5025. IPV6ADDRESS9$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,6}" + H16$) + "?\\:\\:"),
  5026. //[ *6( h16 ":" ) h16 ] "::"
  5027. IPV6ADDRESS$ = subexp([IPV6ADDRESS1$, IPV6ADDRESS2$, IPV6ADDRESS3$, IPV6ADDRESS4$, IPV6ADDRESS5$, IPV6ADDRESS6$, IPV6ADDRESS7$, IPV6ADDRESS8$, IPV6ADDRESS9$].join("|")),
  5028. ZONEID$ = subexp(subexp(UNRESERVED$$ + "|" + PCT_ENCODED$) + "+"),
  5029. //RFC 6874
  5030. IPV6ADDRZ$ = subexp(IPV6ADDRESS$ + "\\%25" + ZONEID$),
  5031. //RFC 6874
  5032. IPV6ADDRZ_RELAXED$ = subexp(IPV6ADDRESS$ + subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + ZONEID$),
  5033. //RFC 6874, with relaxed parsing rules
  5034. IPVFUTURE$ = subexp("[vV]" + HEXDIG$$ + "+\\." + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]") + "+"),
  5035. IP_LITERAL$ = subexp("\\[" + subexp(IPV6ADDRZ_RELAXED$ + "|" + IPV6ADDRESS$ + "|" + IPVFUTURE$) + "\\]"),
  5036. //RFC 6874
  5037. REG_NAME$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$)) + "*"),
  5038. HOST$ = subexp(IP_LITERAL$ + "|" + IPV4ADDRESS$ + "(?!" + REG_NAME$ + ")" + "|" + REG_NAME$),
  5039. PORT$ = subexp(DIGIT$$ + "*"),
  5040. AUTHORITY$ = subexp(subexp(USERINFO$ + "@") + "?" + HOST$ + subexp("\\:" + PORT$) + "?"),
  5041. PCHAR$ = subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@]")),
  5042. SEGMENT$ = subexp(PCHAR$ + "*"),
  5043. SEGMENT_NZ$ = subexp(PCHAR$ + "+"),
  5044. SEGMENT_NZ_NC$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\@]")) + "+"),
  5045. PATH_ABEMPTY$ = subexp(subexp("\\/" + SEGMENT$) + "*"),
  5046. PATH_ABSOLUTE$ = subexp("\\/" + subexp(SEGMENT_NZ$ + PATH_ABEMPTY$) + "?"),
  5047. //simplified
  5048. PATH_NOSCHEME$ = subexp(SEGMENT_NZ_NC$ + PATH_ABEMPTY$),
  5049. //simplified
  5050. PATH_ROOTLESS$ = subexp(SEGMENT_NZ$ + PATH_ABEMPTY$),
  5051. //simplified
  5052. PATH_EMPTY$ = "(?!" + PCHAR$ + ")",
  5053. PATH$ = subexp(PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$),
  5054. QUERY$ = subexp(subexp(PCHAR$ + "|" + merge("[\\/\\?]", IPRIVATE$$)) + "*"),
  5055. FRAGMENT$ = subexp(subexp(PCHAR$ + "|[\\/\\?]") + "*"),
  5056. HIER_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$),
  5057. URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"),
  5058. RELATIVE_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$),
  5059. RELATIVE$ = subexp(RELATIVE_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"),
  5060. URI_REFERENCE$ = subexp(URI$ + "|" + RELATIVE$),
  5061. ABSOLUTE_URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?"),
  5062. GENERIC_REF$ = "^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
  5063. RELATIVE_REF$ = "^(){0}" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
  5064. ABSOLUTE_REF$ = "^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?$",
  5065. SAMEDOC_REF$ = "^" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
  5066. AUTHORITY_REF$ = "^" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?$";
  5067. return {
  5068. NOT_SCHEME: new RegExp(merge("[^]", ALPHA$$, DIGIT$$, "[\\+\\-\\.]"), "g"),
  5069. NOT_USERINFO: new RegExp(merge("[^\\%\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"),
  5070. NOT_HOST: new RegExp(merge("[^\\%\\[\\]\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"),
  5071. NOT_PATH: new RegExp(merge("[^\\%\\/\\:\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"),
  5072. NOT_PATH_NOSCHEME: new RegExp(merge("[^\\%\\/\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"),
  5073. NOT_QUERY: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]", IPRIVATE$$), "g"),
  5074. NOT_FRAGMENT: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]"), "g"),
  5075. ESCAPE: new RegExp(merge("[^]", UNRESERVED$$, SUB_DELIMS$$), "g"),
  5076. UNRESERVED: new RegExp(UNRESERVED$$, "g"),
  5077. OTHER_CHARS: new RegExp(merge("[^\\%]", UNRESERVED$$, RESERVED$$), "g"),
  5078. PCT_ENCODED: new RegExp(PCT_ENCODED$, "g"),
  5079. IPV4ADDRESS: new RegExp("^(" + IPV4ADDRESS$ + ")$"),
  5080. IPV6ADDRESS: new RegExp("^\\[?(" + IPV6ADDRESS$ + ")" + subexp(subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + "(" + ZONEID$ + ")") + "?\\]?$") //RFC 6874, with relaxed parsing rules
  5081. };
  5082. }
  5083. var URI_PROTOCOL = buildExps(false);
  5084. var IRI_PROTOCOL = buildExps(true);
  5085. var slicedToArray = function () {
  5086. function sliceIterator(arr, i) {
  5087. var _arr = [];
  5088. var _n = true;
  5089. var _d = false;
  5090. var _e = undefined;
  5091. try {
  5092. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  5093. _arr.push(_s.value);
  5094. if (i && _arr.length === i) break;
  5095. }
  5096. } catch (err) {
  5097. _d = true;
  5098. _e = err;
  5099. } finally {
  5100. try {
  5101. if (!_n && _i["return"]) _i["return"]();
  5102. } finally {
  5103. if (_d) throw _e;
  5104. }
  5105. }
  5106. return _arr;
  5107. }
  5108. return function (arr, i) {
  5109. if (Array.isArray(arr)) {
  5110. return arr;
  5111. } else if (Symbol.iterator in Object(arr)) {
  5112. return sliceIterator(arr, i);
  5113. } else {
  5114. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  5115. }
  5116. };
  5117. }();
  5118. var toConsumableArray = function (arr) {
  5119. if (Array.isArray(arr)) {
  5120. for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
  5121. return arr2;
  5122. } else {
  5123. return Array.from(arr);
  5124. }
  5125. };
  5126. /** Highest positive signed 32-bit float value */
  5127. var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
  5128. /** Bootstring parameters */
  5129. var base = 36;
  5130. var tMin = 1;
  5131. var tMax = 26;
  5132. var skew = 38;
  5133. var damp = 700;
  5134. var initialBias = 72;
  5135. var initialN = 128; // 0x80
  5136. var delimiter = '-'; // '\x2D'
  5137. /** Regular expressions */
  5138. var regexPunycode = /^xn--/;
  5139. var regexNonASCII = /[^\0-\x7E]/; // non-ASCII chars
  5140. var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
  5141. /** Error messages */
  5142. var errors = {
  5143. 'overflow': 'Overflow: input needs wider integers to process',
  5144. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  5145. 'invalid-input': 'Invalid input'
  5146. };
  5147. /** Convenience shortcuts */
  5148. var baseMinusTMin = base - tMin;
  5149. var floor = Math.floor;
  5150. var stringFromCharCode = String.fromCharCode;
  5151. /*--------------------------------------------------------------------------*/
  5152. /**
  5153. * A generic error utility function.
  5154. * @private
  5155. * @param {String} type The error type.
  5156. * @returns {Error} Throws a `RangeError` with the applicable error message.
  5157. */
  5158. function error$1(type) {
  5159. throw new RangeError(errors[type]);
  5160. }
  5161. /**
  5162. * A generic `Array#map` utility function.
  5163. * @private
  5164. * @param {Array} array The array to iterate over.
  5165. * @param {Function} callback The function that gets called for every array
  5166. * item.
  5167. * @returns {Array} A new array of values returned by the callback function.
  5168. */
  5169. function map(array, fn) {
  5170. var result = [];
  5171. var length = array.length;
  5172. while (length--) {
  5173. result[length] = fn(array[length]);
  5174. }
  5175. return result;
  5176. }
  5177. /**
  5178. * A simple `Array#map`-like wrapper to work with domain name strings or email
  5179. * addresses.
  5180. * @private
  5181. * @param {String} domain The domain name or email address.
  5182. * @param {Function} callback The function that gets called for every
  5183. * character.
  5184. * @returns {Array} A new string of characters returned by the callback
  5185. * function.
  5186. */
  5187. function mapDomain(string, fn) {
  5188. var parts = string.split('@');
  5189. var result = '';
  5190. if (parts.length > 1) {
  5191. // In email addresses, only the domain name should be punycoded. Leave
  5192. // the local part (i.e. everything up to `@`) intact.
  5193. result = parts[0] + '@';
  5194. string = parts[1];
  5195. }
  5196. // Avoid `split(regex)` for IE8 compatibility. See #17.
  5197. string = string.replace(regexSeparators, '\x2E');
  5198. var labels = string.split('.');
  5199. var encoded = map(labels, fn).join('.');
  5200. return result + encoded;
  5201. }
  5202. /**
  5203. * Creates an array containing the numeric code points of each Unicode
  5204. * character in the string. While JavaScript uses UCS-2 internally,
  5205. * this function will convert a pair of surrogate halves (each of which
  5206. * UCS-2 exposes as separate characters) into a single code point,
  5207. * matching UTF-16.
  5208. * @see `punycode.ucs2.encode`
  5209. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  5210. * @memberOf punycode.ucs2
  5211. * @name decode
  5212. * @param {String} string The Unicode input string (UCS-2).
  5213. * @returns {Array} The new array of code points.
  5214. */
  5215. function ucs2decode(string) {
  5216. var output = [];
  5217. var counter = 0;
  5218. var length = string.length;
  5219. while (counter < length) {
  5220. var value = string.charCodeAt(counter++);
  5221. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  5222. // It's a high surrogate, and there is a next character.
  5223. var extra = string.charCodeAt(counter++);
  5224. if ((extra & 0xFC00) == 0xDC00) {
  5225. // Low surrogate.
  5226. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  5227. } else {
  5228. // It's an unmatched surrogate; only append this code unit, in case the
  5229. // next code unit is the high surrogate of a surrogate pair.
  5230. output.push(value);
  5231. counter--;
  5232. }
  5233. } else {
  5234. output.push(value);
  5235. }
  5236. }
  5237. return output;
  5238. }
  5239. /**
  5240. * Creates a string based on an array of numeric code points.
  5241. * @see `punycode.ucs2.decode`
  5242. * @memberOf punycode.ucs2
  5243. * @name encode
  5244. * @param {Array} codePoints The array of numeric code points.
  5245. * @returns {String} The new Unicode string (UCS-2).
  5246. */
  5247. var ucs2encode = function ucs2encode(array) {
  5248. return String.fromCodePoint.apply(String, toConsumableArray(array));
  5249. };
  5250. /**
  5251. * Converts a basic code point into a digit/integer.
  5252. * @see `digitToBasic()`
  5253. * @private
  5254. * @param {Number} codePoint The basic numeric code point value.
  5255. * @returns {Number} The numeric value of a basic code point (for use in
  5256. * representing integers) in the range `0` to `base - 1`, or `base` if
  5257. * the code point does not represent a value.
  5258. */
  5259. var basicToDigit = function basicToDigit(codePoint) {
  5260. if (codePoint - 0x30 < 0x0A) {
  5261. return codePoint - 0x16;
  5262. }
  5263. if (codePoint - 0x41 < 0x1A) {
  5264. return codePoint - 0x41;
  5265. }
  5266. if (codePoint - 0x61 < 0x1A) {
  5267. return codePoint - 0x61;
  5268. }
  5269. return base;
  5270. };
  5271. /**
  5272. * Converts a digit/integer into a basic code point.
  5273. * @see `basicToDigit()`
  5274. * @private
  5275. * @param {Number} digit The numeric value of a basic code point.
  5276. * @returns {Number} The basic code point whose value (when used for
  5277. * representing integers) is `digit`, which needs to be in the range
  5278. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  5279. * used; else, the lowercase form is used. The behavior is undefined
  5280. * if `flag` is non-zero and `digit` has no uppercase form.
  5281. */
  5282. var digitToBasic = function digitToBasic(digit, flag) {
  5283. // 0..25 map to ASCII a..z or A..Z
  5284. // 26..35 map to ASCII 0..9
  5285. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  5286. };
  5287. /**
  5288. * Bias adaptation function as per section 3.4 of RFC 3492.
  5289. * https://tools.ietf.org/html/rfc3492#section-3.4
  5290. * @private
  5291. */
  5292. var adapt = function adapt(delta, numPoints, firstTime) {
  5293. var k = 0;
  5294. delta = firstTime ? floor(delta / damp) : delta >> 1;
  5295. delta += floor(delta / numPoints);
  5296. for (; /* no initialization */delta > baseMinusTMin * tMax >> 1; k += base) {
  5297. delta = floor(delta / baseMinusTMin);
  5298. }
  5299. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  5300. };
  5301. /**
  5302. * Converts a Punycode string of ASCII-only symbols to a string of Unicode
  5303. * symbols.
  5304. * @memberOf punycode
  5305. * @param {String} input The Punycode string of ASCII-only symbols.
  5306. * @returns {String} The resulting string of Unicode symbols.
  5307. */
  5308. var decode = function decode(input) {
  5309. // Don't use UCS-2.
  5310. var output = [];
  5311. var inputLength = input.length;
  5312. var i = 0;
  5313. var n = initialN;
  5314. var bias = initialBias;
  5315. // Handle the basic code points: let `basic` be the number of input code
  5316. // points before the last delimiter, or `0` if there is none, then copy
  5317. // the first basic code points to the output.
  5318. var basic = input.lastIndexOf(delimiter);
  5319. if (basic < 0) {
  5320. basic = 0;
  5321. }
  5322. for (var j = 0; j < basic; ++j) {
  5323. // if it's not a basic code point
  5324. if (input.charCodeAt(j) >= 0x80) {
  5325. error$1('not-basic');
  5326. }
  5327. output.push(input.charCodeAt(j));
  5328. }
  5329. // Main decoding loop: start just after the last delimiter if any basic code
  5330. // points were copied; start at the beginning otherwise.
  5331. for (var index = basic > 0 ? basic + 1 : 0; index < inputLength;) /* no final expression */{
  5332. // `index` is the index of the next character to be consumed.
  5333. // Decode a generalized variable-length integer into `delta`,
  5334. // which gets added to `i`. The overflow checking is easier
  5335. // if we increase `i` as we go, then subtract off its starting
  5336. // value at the end to obtain `delta`.
  5337. var oldi = i;
  5338. for (var w = 1, k = base;; /* no condition */k += base) {
  5339. if (index >= inputLength) {
  5340. error$1('invalid-input');
  5341. }
  5342. var digit = basicToDigit(input.charCodeAt(index++));
  5343. if (digit >= base || digit > floor((maxInt - i) / w)) {
  5344. error$1('overflow');
  5345. }
  5346. i += digit * w;
  5347. var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
  5348. if (digit < t) {
  5349. break;
  5350. }
  5351. var baseMinusT = base - t;
  5352. if (w > floor(maxInt / baseMinusT)) {
  5353. error$1('overflow');
  5354. }
  5355. w *= baseMinusT;
  5356. }
  5357. var out = output.length + 1;
  5358. bias = adapt(i - oldi, out, oldi == 0);
  5359. // `i` was supposed to wrap around from `out` to `0`,
  5360. // incrementing `n` each time, so we'll fix that now:
  5361. if (floor(i / out) > maxInt - n) {
  5362. error$1('overflow');
  5363. }
  5364. n += floor(i / out);
  5365. i %= out;
  5366. // Insert `n` at position `i` of the output.
  5367. output.splice(i++, 0, n);
  5368. }
  5369. return String.fromCodePoint.apply(String, output);
  5370. };
  5371. /**
  5372. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  5373. * Punycode string of ASCII-only symbols.
  5374. * @memberOf punycode
  5375. * @param {String} input The string of Unicode symbols.
  5376. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  5377. */
  5378. var encode = function encode(input) {
  5379. var output = [];
  5380. // Convert the input in UCS-2 to an array of Unicode code points.
  5381. input = ucs2decode(input);
  5382. // Cache the length.
  5383. var inputLength = input.length;
  5384. // Initialize the state.
  5385. var n = initialN;
  5386. var delta = 0;
  5387. var bias = initialBias;
  5388. // Handle the basic code points.
  5389. var _iteratorNormalCompletion = true;
  5390. var _didIteratorError = false;
  5391. var _iteratorError = undefined;
  5392. try {
  5393. for (var _iterator = input[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  5394. var _currentValue2 = _step.value;
  5395. if (_currentValue2 < 0x80) {
  5396. output.push(stringFromCharCode(_currentValue2));
  5397. }
  5398. }
  5399. } catch (err) {
  5400. _didIteratorError = true;
  5401. _iteratorError = err;
  5402. } finally {
  5403. try {
  5404. if (!_iteratorNormalCompletion && _iterator.return) {
  5405. _iterator.return();
  5406. }
  5407. } finally {
  5408. if (_didIteratorError) {
  5409. throw _iteratorError;
  5410. }
  5411. }
  5412. }
  5413. var basicLength = output.length;
  5414. var handledCPCount = basicLength;
  5415. // `handledCPCount` is the number of code points that have been handled;
  5416. // `basicLength` is the number of basic code points.
  5417. // Finish the basic string with a delimiter unless it's empty.
  5418. if (basicLength) {
  5419. output.push(delimiter);
  5420. }
  5421. // Main encoding loop:
  5422. while (handledCPCount < inputLength) {
  5423. // All non-basic code points < n have been handled already. Find the next
  5424. // larger one:
  5425. var m = maxInt;
  5426. var _iteratorNormalCompletion2 = true;
  5427. var _didIteratorError2 = false;
  5428. var _iteratorError2 = undefined;
  5429. try {
  5430. for (var _iterator2 = input[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  5431. var currentValue = _step2.value;
  5432. if (currentValue >= n && currentValue < m) {
  5433. m = currentValue;
  5434. }
  5435. }
  5436. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  5437. // but guard against overflow.
  5438. } catch (err) {
  5439. _didIteratorError2 = true;
  5440. _iteratorError2 = err;
  5441. } finally {
  5442. try {
  5443. if (!_iteratorNormalCompletion2 && _iterator2.return) {
  5444. _iterator2.return();
  5445. }
  5446. } finally {
  5447. if (_didIteratorError2) {
  5448. throw _iteratorError2;
  5449. }
  5450. }
  5451. }
  5452. var handledCPCountPlusOne = handledCPCount + 1;
  5453. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  5454. error$1('overflow');
  5455. }
  5456. delta += (m - n) * handledCPCountPlusOne;
  5457. n = m;
  5458. var _iteratorNormalCompletion3 = true;
  5459. var _didIteratorError3 = false;
  5460. var _iteratorError3 = undefined;
  5461. try {
  5462. for (var _iterator3 = input[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  5463. var _currentValue = _step3.value;
  5464. if (_currentValue < n && ++delta > maxInt) {
  5465. error$1('overflow');
  5466. }
  5467. if (_currentValue == n) {
  5468. // Represent delta as a generalized variable-length integer.
  5469. var q = delta;
  5470. for (var k = base;; /* no condition */k += base) {
  5471. var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
  5472. if (q < t) {
  5473. break;
  5474. }
  5475. var qMinusT = q - t;
  5476. var baseMinusT = base - t;
  5477. output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
  5478. q = floor(qMinusT / baseMinusT);
  5479. }
  5480. output.push(stringFromCharCode(digitToBasic(q, 0)));
  5481. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  5482. delta = 0;
  5483. ++handledCPCount;
  5484. }
  5485. }
  5486. } catch (err) {
  5487. _didIteratorError3 = true;
  5488. _iteratorError3 = err;
  5489. } finally {
  5490. try {
  5491. if (!_iteratorNormalCompletion3 && _iterator3.return) {
  5492. _iterator3.return();
  5493. }
  5494. } finally {
  5495. if (_didIteratorError3) {
  5496. throw _iteratorError3;
  5497. }
  5498. }
  5499. }
  5500. ++delta;
  5501. ++n;
  5502. }
  5503. return output.join('');
  5504. };
  5505. /**
  5506. * Converts a Punycode string representing a domain name or an email address
  5507. * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
  5508. * it doesn't matter if you call it on a string that has already been
  5509. * converted to Unicode.
  5510. * @memberOf punycode
  5511. * @param {String} input The Punycoded domain name or email address to
  5512. * convert to Unicode.
  5513. * @returns {String} The Unicode representation of the given Punycode
  5514. * string.
  5515. */
  5516. var toUnicode = function toUnicode(input) {
  5517. return mapDomain(input, function (string) {
  5518. return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
  5519. });
  5520. };
  5521. /**
  5522. * Converts a Unicode string representing a domain name or an email address to
  5523. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  5524. * i.e. it doesn't matter if you call it with a domain that's already in
  5525. * ASCII.
  5526. * @memberOf punycode
  5527. * @param {String} input The domain name or email address to convert, as a
  5528. * Unicode string.
  5529. * @returns {String} The Punycode representation of the given domain name or
  5530. * email address.
  5531. */
  5532. var toASCII = function toASCII(input) {
  5533. return mapDomain(input, function (string) {
  5534. return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;
  5535. });
  5536. };
  5537. /*--------------------------------------------------------------------------*/
  5538. /** Define the public API */
  5539. var punycode = {
  5540. /**
  5541. * A string representing the current Punycode.js version number.
  5542. * @memberOf punycode
  5543. * @type String
  5544. */
  5545. 'version': '2.1.0',
  5546. /**
  5547. * An object of methods to convert from JavaScript's internal character
  5548. * representation (UCS-2) to Unicode code points, and back.
  5549. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  5550. * @memberOf punycode
  5551. * @type Object
  5552. */
  5553. 'ucs2': {
  5554. 'decode': ucs2decode,
  5555. 'encode': ucs2encode
  5556. },
  5557. 'decode': decode,
  5558. 'encode': encode,
  5559. 'toASCII': toASCII,
  5560. 'toUnicode': toUnicode
  5561. };
  5562. /**
  5563. * URI.js
  5564. *
  5565. * @fileoverview An RFC 3986 compliant, scheme extendable URI parsing/validating/resolving library for JavaScript.
  5566. * @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
  5567. * @see http://github.com/garycourt/uri-js
  5568. */
  5569. /**
  5570. * Copyright 2011 Gary Court. All rights reserved.
  5571. *
  5572. * Redistribution and use in source and binary forms, with or without modification, are
  5573. * permitted provided that the following conditions are met:
  5574. *
  5575. * 1. Redistributions of source code must retain the above copyright notice, this list of
  5576. * conditions and the following disclaimer.
  5577. *
  5578. * 2. Redistributions in binary form must reproduce the above copyright notice, this list
  5579. * of conditions and the following disclaimer in the documentation and/or other materials
  5580. * provided with the distribution.
  5581. *
  5582. * THIS SOFTWARE IS PROVIDED BY GARY COURT ``AS IS'' AND ANY EXPRESS OR IMPLIED
  5583. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  5584. * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARY COURT OR
  5585. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  5586. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  5587. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  5588. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  5589. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  5590. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5591. *
  5592. * The views and conclusions contained in the software and documentation are those of the
  5593. * authors and should not be interpreted as representing official policies, either expressed
  5594. * or implied, of Gary Court.
  5595. */
  5596. var SCHEMES = {};
  5597. function pctEncChar(chr) {
  5598. var c = chr.charCodeAt(0);
  5599. var e = void 0;
  5600. if (c < 16) e = "%0" + c.toString(16).toUpperCase();else if (c < 128) e = "%" + c.toString(16).toUpperCase();else if (c < 2048) e = "%" + (c >> 6 | 192).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase();else e = "%" + (c >> 12 | 224).toString(16).toUpperCase() + "%" + (c >> 6 & 63 | 128).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase();
  5601. return e;
  5602. }
  5603. function pctDecChars(str) {
  5604. var newStr = "";
  5605. var i = 0;
  5606. var il = str.length;
  5607. while (i < il) {
  5608. var c = parseInt(str.substr(i + 1, 2), 16);
  5609. if (c < 128) {
  5610. newStr += String.fromCharCode(c);
  5611. i += 3;
  5612. } else if (c >= 194 && c < 224) {
  5613. if (il - i >= 6) {
  5614. var c2 = parseInt(str.substr(i + 4, 2), 16);
  5615. newStr += String.fromCharCode((c & 31) << 6 | c2 & 63);
  5616. } else {
  5617. newStr += str.substr(i, 6);
  5618. }
  5619. i += 6;
  5620. } else if (c >= 224) {
  5621. if (il - i >= 9) {
  5622. var _c = parseInt(str.substr(i + 4, 2), 16);
  5623. var c3 = parseInt(str.substr(i + 7, 2), 16);
  5624. newStr += String.fromCharCode((c & 15) << 12 | (_c & 63) << 6 | c3 & 63);
  5625. } else {
  5626. newStr += str.substr(i, 9);
  5627. }
  5628. i += 9;
  5629. } else {
  5630. newStr += str.substr(i, 3);
  5631. i += 3;
  5632. }
  5633. }
  5634. return newStr;
  5635. }
  5636. function _normalizeComponentEncoding(components, protocol) {
  5637. function decodeUnreserved(str) {
  5638. var decStr = pctDecChars(str);
  5639. return !decStr.match(protocol.UNRESERVED) ? str : decStr;
  5640. }
  5641. if (components.scheme) components.scheme = String(components.scheme).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_SCHEME, "");
  5642. if (components.userinfo !== undefined) components.userinfo = String(components.userinfo).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_USERINFO, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
  5643. if (components.host !== undefined) components.host = String(components.host).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_HOST, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
  5644. if (components.path !== undefined) components.path = String(components.path).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(components.scheme ? protocol.NOT_PATH : protocol.NOT_PATH_NOSCHEME, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
  5645. if (components.query !== undefined) components.query = String(components.query).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_QUERY, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
  5646. if (components.fragment !== undefined) components.fragment = String(components.fragment).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_FRAGMENT, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
  5647. return components;
  5648. }
  5649. function _stripLeadingZeros(str) {
  5650. return str.replace(/^0*(.*)/, "$1") || "0";
  5651. }
  5652. function _normalizeIPv4(host, protocol) {
  5653. var matches = host.match(protocol.IPV4ADDRESS) || [];
  5654. var _matches = slicedToArray(matches, 2),
  5655. address = _matches[1];
  5656. if (address) {
  5657. return address.split(".").map(_stripLeadingZeros).join(".");
  5658. } else {
  5659. return host;
  5660. }
  5661. }
  5662. function _normalizeIPv6(host, protocol) {
  5663. var matches = host.match(protocol.IPV6ADDRESS) || [];
  5664. var _matches2 = slicedToArray(matches, 3),
  5665. address = _matches2[1],
  5666. zone = _matches2[2];
  5667. if (address) {
  5668. var _address$toLowerCase$ = address.toLowerCase().split('::').reverse(),
  5669. _address$toLowerCase$2 = slicedToArray(_address$toLowerCase$, 2),
  5670. last = _address$toLowerCase$2[0],
  5671. first = _address$toLowerCase$2[1];
  5672. var firstFields = first ? first.split(":").map(_stripLeadingZeros) : [];
  5673. var lastFields = last.split(":").map(_stripLeadingZeros);
  5674. var isLastFieldIPv4Address = protocol.IPV4ADDRESS.test(lastFields[lastFields.length - 1]);
  5675. var fieldCount = isLastFieldIPv4Address ? 7 : 8;
  5676. var lastFieldsStart = lastFields.length - fieldCount;
  5677. var fields = Array(fieldCount);
  5678. for (var x = 0; x < fieldCount; ++x) {
  5679. fields[x] = firstFields[x] || lastFields[lastFieldsStart + x] || '';
  5680. }
  5681. if (isLastFieldIPv4Address) {
  5682. fields[fieldCount - 1] = _normalizeIPv4(fields[fieldCount - 1], protocol);
  5683. }
  5684. var allZeroFields = fields.reduce(function (acc, field, index) {
  5685. if (!field || field === "0") {
  5686. var lastLongest = acc[acc.length - 1];
  5687. if (lastLongest && lastLongest.index + lastLongest.length === index) {
  5688. lastLongest.length++;
  5689. } else {
  5690. acc.push({ index: index, length: 1 });
  5691. }
  5692. }
  5693. return acc;
  5694. }, []);
  5695. var longestZeroFields = allZeroFields.sort(function (a, b) {
  5696. return b.length - a.length;
  5697. })[0];
  5698. var newHost = void 0;
  5699. if (longestZeroFields && longestZeroFields.length > 1) {
  5700. var newFirst = fields.slice(0, longestZeroFields.index);
  5701. var newLast = fields.slice(longestZeroFields.index + longestZeroFields.length);
  5702. newHost = newFirst.join(":") + "::" + newLast.join(":");
  5703. } else {
  5704. newHost = fields.join(":");
  5705. }
  5706. if (zone) {
  5707. newHost += "%" + zone;
  5708. }
  5709. return newHost;
  5710. } else {
  5711. return host;
  5712. }
  5713. }
  5714. var URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;
  5715. var NO_MATCH_IS_UNDEFINED = "".match(/(){0}/)[1] === undefined;
  5716. function parse(uriString) {
  5717. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  5718. var components = {};
  5719. var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
  5720. if (options.reference === "suffix") uriString = (options.scheme ? options.scheme + ":" : "") + "//" + uriString;
  5721. var matches = uriString.match(URI_PARSE);
  5722. if (matches) {
  5723. if (NO_MATCH_IS_UNDEFINED) {
  5724. //store each component
  5725. components.scheme = matches[1];
  5726. components.userinfo = matches[3];
  5727. components.host = matches[4];
  5728. components.port = parseInt(matches[5], 10);
  5729. components.path = matches[6] || "";
  5730. components.query = matches[7];
  5731. components.fragment = matches[8];
  5732. //fix port number
  5733. if (isNaN(components.port)) {
  5734. components.port = matches[5];
  5735. }
  5736. } else {
  5737. //IE FIX for improper RegExp matching
  5738. //store each component
  5739. components.scheme = matches[1] || undefined;
  5740. components.userinfo = uriString.indexOf("@") !== -1 ? matches[3] : undefined;
  5741. components.host = uriString.indexOf("//") !== -1 ? matches[4] : undefined;
  5742. components.port = parseInt(matches[5], 10);
  5743. components.path = matches[6] || "";
  5744. components.query = uriString.indexOf("?") !== -1 ? matches[7] : undefined;
  5745. components.fragment = uriString.indexOf("#") !== -1 ? matches[8] : undefined;
  5746. //fix port number
  5747. if (isNaN(components.port)) {
  5748. components.port = uriString.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/) ? matches[4] : undefined;
  5749. }
  5750. }
  5751. if (components.host) {
  5752. //normalize IP hosts
  5753. components.host = _normalizeIPv6(_normalizeIPv4(components.host, protocol), protocol);
  5754. }
  5755. //determine reference type
  5756. if (components.scheme === undefined && components.userinfo === undefined && components.host === undefined && components.port === undefined && !components.path && components.query === undefined) {
  5757. components.reference = "same-document";
  5758. } else if (components.scheme === undefined) {
  5759. components.reference = "relative";
  5760. } else if (components.fragment === undefined) {
  5761. components.reference = "absolute";
  5762. } else {
  5763. components.reference = "uri";
  5764. }
  5765. //check for reference errors
  5766. if (options.reference && options.reference !== "suffix" && options.reference !== components.reference) {
  5767. components.error = components.error || "URI is not a " + options.reference + " reference.";
  5768. }
  5769. //find scheme handler
  5770. var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
  5771. //check if scheme can't handle IRIs
  5772. if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
  5773. //if host component is a domain name
  5774. if (components.host && (options.domainHost || schemeHandler && schemeHandler.domainHost)) {
  5775. //convert Unicode IDN -> ASCII IDN
  5776. try {
  5777. components.host = punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase());
  5778. } catch (e) {
  5779. components.error = components.error || "Host's domain name can not be converted to ASCII via punycode: " + e;
  5780. }
  5781. }
  5782. //convert IRI -> URI
  5783. _normalizeComponentEncoding(components, URI_PROTOCOL);
  5784. } else {
  5785. //normalize encodings
  5786. _normalizeComponentEncoding(components, protocol);
  5787. }
  5788. //perform scheme specific parsing
  5789. if (schemeHandler && schemeHandler.parse) {
  5790. schemeHandler.parse(components, options);
  5791. }
  5792. } else {
  5793. components.error = components.error || "URI can not be parsed.";
  5794. }
  5795. return components;
  5796. }
  5797. function _recomposeAuthority(components, options) {
  5798. var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
  5799. var uriTokens = [];
  5800. if (components.userinfo !== undefined) {
  5801. uriTokens.push(components.userinfo);
  5802. uriTokens.push("@");
  5803. }
  5804. if (components.host !== undefined) {
  5805. //normalize IP hosts, add brackets and escape zone separator for IPv6
  5806. uriTokens.push(_normalizeIPv6(_normalizeIPv4(String(components.host), protocol), protocol).replace(protocol.IPV6ADDRESS, function (_, $1, $2) {
  5807. return "[" + $1 + ($2 ? "%25" + $2 : "") + "]";
  5808. }));
  5809. }
  5810. if (typeof components.port === "number") {
  5811. uriTokens.push(":");
  5812. uriTokens.push(components.port.toString(10));
  5813. }
  5814. return uriTokens.length ? uriTokens.join("") : undefined;
  5815. }
  5816. var RDS1 = /^\.\.?\//;
  5817. var RDS2 = /^\/\.(\/|$)/;
  5818. var RDS3 = /^\/\.\.(\/|$)/;
  5819. var RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/;
  5820. function removeDotSegments(input) {
  5821. var output = [];
  5822. while (input.length) {
  5823. if (input.match(RDS1)) {
  5824. input = input.replace(RDS1, "");
  5825. } else if (input.match(RDS2)) {
  5826. input = input.replace(RDS2, "/");
  5827. } else if (input.match(RDS3)) {
  5828. input = input.replace(RDS3, "/");
  5829. output.pop();
  5830. } else if (input === "." || input === "..") {
  5831. input = "";
  5832. } else {
  5833. var im = input.match(RDS5);
  5834. if (im) {
  5835. var s = im[0];
  5836. input = input.slice(s.length);
  5837. output.push(s);
  5838. } else {
  5839. throw new Error("Unexpected dot segment condition");
  5840. }
  5841. }
  5842. }
  5843. return output.join("");
  5844. }
  5845. function serialize(components) {
  5846. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  5847. var protocol = options.iri ? IRI_PROTOCOL : URI_PROTOCOL;
  5848. var uriTokens = [];
  5849. //find scheme handler
  5850. var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
  5851. //perform scheme specific serialization
  5852. if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(components, options);
  5853. if (components.host) {
  5854. //if host component is an IPv6 address
  5855. if (protocol.IPV6ADDRESS.test(components.host)) {}
  5856. //TODO: normalize IPv6 address as per RFC 5952
  5857. //if host component is a domain name
  5858. else if (options.domainHost || schemeHandler && schemeHandler.domainHost) {
  5859. //convert IDN via punycode
  5860. try {
  5861. components.host = !options.iri ? punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()) : punycode.toUnicode(components.host);
  5862. } catch (e) {
  5863. components.error = components.error || "Host's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
  5864. }
  5865. }
  5866. }
  5867. //normalize encoding
  5868. _normalizeComponentEncoding(components, protocol);
  5869. if (options.reference !== "suffix" && components.scheme) {
  5870. uriTokens.push(components.scheme);
  5871. uriTokens.push(":");
  5872. }
  5873. var authority = _recomposeAuthority(components, options);
  5874. if (authority !== undefined) {
  5875. if (options.reference !== "suffix") {
  5876. uriTokens.push("//");
  5877. }
  5878. uriTokens.push(authority);
  5879. if (components.path && components.path.charAt(0) !== "/") {
  5880. uriTokens.push("/");
  5881. }
  5882. }
  5883. if (components.path !== undefined) {
  5884. var s = components.path;
  5885. if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
  5886. s = removeDotSegments(s);
  5887. }
  5888. if (authority === undefined) {
  5889. s = s.replace(/^\/\//, "/%2F"); //don't allow the path to start with "//"
  5890. }
  5891. uriTokens.push(s);
  5892. }
  5893. if (components.query !== undefined) {
  5894. uriTokens.push("?");
  5895. uriTokens.push(components.query);
  5896. }
  5897. if (components.fragment !== undefined) {
  5898. uriTokens.push("#");
  5899. uriTokens.push(components.fragment);
  5900. }
  5901. return uriTokens.join(""); //merge tokens into a string
  5902. }
  5903. function resolveComponents(base, relative) {
  5904. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  5905. var skipNormalization = arguments[3];
  5906. var target = {};
  5907. if (!skipNormalization) {
  5908. base = parse(serialize(base, options), options); //normalize base components
  5909. relative = parse(serialize(relative, options), options); //normalize relative components
  5910. }
  5911. options = options || {};
  5912. if (!options.tolerant && relative.scheme) {
  5913. target.scheme = relative.scheme;
  5914. //target.authority = relative.authority;
  5915. target.userinfo = relative.userinfo;
  5916. target.host = relative.host;
  5917. target.port = relative.port;
  5918. target.path = removeDotSegments(relative.path || "");
  5919. target.query = relative.query;
  5920. } else {
  5921. if (relative.userinfo !== undefined || relative.host !== undefined || relative.port !== undefined) {
  5922. //target.authority = relative.authority;
  5923. target.userinfo = relative.userinfo;
  5924. target.host = relative.host;
  5925. target.port = relative.port;
  5926. target.path = removeDotSegments(relative.path || "");
  5927. target.query = relative.query;
  5928. } else {
  5929. if (!relative.path) {
  5930. target.path = base.path;
  5931. if (relative.query !== undefined) {
  5932. target.query = relative.query;
  5933. } else {
  5934. target.query = base.query;
  5935. }
  5936. } else {
  5937. if (relative.path.charAt(0) === "/") {
  5938. target.path = removeDotSegments(relative.path);
  5939. } else {
  5940. if ((base.userinfo !== undefined || base.host !== undefined || base.port !== undefined) && !base.path) {
  5941. target.path = "/" + relative.path;
  5942. } else if (!base.path) {
  5943. target.path = relative.path;
  5944. } else {
  5945. target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
  5946. }
  5947. target.path = removeDotSegments(target.path);
  5948. }
  5949. target.query = relative.query;
  5950. }
  5951. //target.authority = base.authority;
  5952. target.userinfo = base.userinfo;
  5953. target.host = base.host;
  5954. target.port = base.port;
  5955. }
  5956. target.scheme = base.scheme;
  5957. }
  5958. target.fragment = relative.fragment;
  5959. return target;
  5960. }
  5961. function resolve(baseURI, relativeURI, options) {
  5962. var schemelessOptions = assign({ scheme: 'null' }, options);
  5963. return serialize(resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
  5964. }
  5965. function normalize(uri, options) {
  5966. if (typeof uri === "string") {
  5967. uri = serialize(parse(uri, options), options);
  5968. } else if (typeOf(uri) === "object") {
  5969. uri = parse(serialize(uri, options), options);
  5970. }
  5971. return uri;
  5972. }
  5973. function equal(uriA, uriB, options) {
  5974. if (typeof uriA === "string") {
  5975. uriA = serialize(parse(uriA, options), options);
  5976. } else if (typeOf(uriA) === "object") {
  5977. uriA = serialize(uriA, options);
  5978. }
  5979. if (typeof uriB === "string") {
  5980. uriB = serialize(parse(uriB, options), options);
  5981. } else if (typeOf(uriB) === "object") {
  5982. uriB = serialize(uriB, options);
  5983. }
  5984. return uriA === uriB;
  5985. }
  5986. function escapeComponent(str, options) {
  5987. return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.ESCAPE : IRI_PROTOCOL.ESCAPE, pctEncChar);
  5988. }
  5989. function unescapeComponent(str, options) {
  5990. return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.PCT_ENCODED : IRI_PROTOCOL.PCT_ENCODED, pctDecChars);
  5991. }
  5992. var handler = {
  5993. scheme: "http",
  5994. domainHost: true,
  5995. parse: function parse(components, options) {
  5996. //report missing host
  5997. if (!components.host) {
  5998. components.error = components.error || "HTTP URIs must have a host.";
  5999. }
  6000. return components;
  6001. },
  6002. serialize: function serialize(components, options) {
  6003. //normalize the default port
  6004. if (components.port === (String(components.scheme).toLowerCase() !== "https" ? 80 : 443) || components.port === "") {
  6005. components.port = undefined;
  6006. }
  6007. //normalize the empty path
  6008. if (!components.path) {
  6009. components.path = "/";
  6010. }
  6011. //NOTE: We do not parse query strings for HTTP URIs
  6012. //as WWW Form Url Encoded query strings are part of the HTML4+ spec,
  6013. //and not the HTTP spec.
  6014. return components;
  6015. }
  6016. };
  6017. var handler$1 = {
  6018. scheme: "https",
  6019. domainHost: handler.domainHost,
  6020. parse: handler.parse,
  6021. serialize: handler.serialize
  6022. };
  6023. var O = {};
  6024. var isIRI = true;
  6025. //RFC 3986
  6026. var UNRESERVED$$ = "[A-Za-z0-9\\-\\.\\_\\~" + (isIRI ? "\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF" : "") + "]";
  6027. var HEXDIG$$ = "[0-9A-Fa-f]"; //case-insensitive
  6028. var PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)); //expanded
  6029. //RFC 5322, except these symbols as per RFC 6068: @ : / ? # [ ] & ; =
  6030. //const ATEXT$$ = "[A-Za-z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]";
  6031. //const WSP$$ = "[\\x20\\x09]";
  6032. //const OBS_QTEXT$$ = "[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x7F]"; //(%d1-8 / %d11-12 / %d14-31 / %d127)
  6033. //const QTEXT$$ = merge("[\\x21\\x23-\\x5B\\x5D-\\x7E]", OBS_QTEXT$$); //%d33 / %d35-91 / %d93-126 / obs-qtext
  6034. //const VCHAR$$ = "[\\x21-\\x7E]";
  6035. //const WSP$$ = "[\\x20\\x09]";
  6036. //const OBS_QP$ = subexp("\\\\" + merge("[\\x00\\x0D\\x0A]", OBS_QTEXT$$)); //%d0 / CR / LF / obs-qtext
  6037. //const FWS$ = subexp(subexp(WSP$$ + "*" + "\\x0D\\x0A") + "?" + WSP$$ + "+");
  6038. //const QUOTED_PAIR$ = subexp(subexp("\\\\" + subexp(VCHAR$$ + "|" + WSP$$)) + "|" + OBS_QP$);
  6039. //const QUOTED_STRING$ = subexp('\\"' + subexp(FWS$ + "?" + QCONTENT$) + "*" + FWS$ + "?" + '\\"');
  6040. var ATEXT$$ = "[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]";
  6041. var QTEXT$$ = "[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]";
  6042. var VCHAR$$ = merge(QTEXT$$, "[\\\"\\\\]");
  6043. var SOME_DELIMS$$ = "[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]";
  6044. var UNRESERVED = new RegExp(UNRESERVED$$, "g");
  6045. var PCT_ENCODED = new RegExp(PCT_ENCODED$, "g");
  6046. var NOT_LOCAL_PART = new RegExp(merge("[^]", ATEXT$$, "[\\.]", '[\\"]', VCHAR$$), "g");
  6047. var NOT_HFNAME = new RegExp(merge("[^]", UNRESERVED$$, SOME_DELIMS$$), "g");
  6048. var NOT_HFVALUE = NOT_HFNAME;
  6049. function decodeUnreserved(str) {
  6050. var decStr = pctDecChars(str);
  6051. return !decStr.match(UNRESERVED) ? str : decStr;
  6052. }
  6053. var handler$2 = {
  6054. scheme: "mailto",
  6055. parse: function parse$$1(components, options) {
  6056. var mailtoComponents = components;
  6057. var to = mailtoComponents.to = mailtoComponents.path ? mailtoComponents.path.split(",") : [];
  6058. mailtoComponents.path = undefined;
  6059. if (mailtoComponents.query) {
  6060. var unknownHeaders = false;
  6061. var headers = {};
  6062. var hfields = mailtoComponents.query.split("&");
  6063. for (var x = 0, xl = hfields.length; x < xl; ++x) {
  6064. var hfield = hfields[x].split("=");
  6065. switch (hfield[0]) {
  6066. case "to":
  6067. var toAddrs = hfield[1].split(",");
  6068. for (var _x = 0, _xl = toAddrs.length; _x < _xl; ++_x) {
  6069. to.push(toAddrs[_x]);
  6070. }
  6071. break;
  6072. case "subject":
  6073. mailtoComponents.subject = unescapeComponent(hfield[1], options);
  6074. break;
  6075. case "body":
  6076. mailtoComponents.body = unescapeComponent(hfield[1], options);
  6077. break;
  6078. default:
  6079. unknownHeaders = true;
  6080. headers[unescapeComponent(hfield[0], options)] = unescapeComponent(hfield[1], options);
  6081. break;
  6082. }
  6083. }
  6084. if (unknownHeaders) mailtoComponents.headers = headers;
  6085. }
  6086. mailtoComponents.query = undefined;
  6087. for (var _x2 = 0, _xl2 = to.length; _x2 < _xl2; ++_x2) {
  6088. var addr = to[_x2].split("@");
  6089. addr[0] = unescapeComponent(addr[0]);
  6090. if (!options.unicodeSupport) {
  6091. //convert Unicode IDN -> ASCII IDN
  6092. try {
  6093. addr[1] = punycode.toASCII(unescapeComponent(addr[1], options).toLowerCase());
  6094. } catch (e) {
  6095. mailtoComponents.error = mailtoComponents.error || "Email address's domain name can not be converted to ASCII via punycode: " + e;
  6096. }
  6097. } else {
  6098. addr[1] = unescapeComponent(addr[1], options).toLowerCase();
  6099. }
  6100. to[_x2] = addr.join("@");
  6101. }
  6102. return mailtoComponents;
  6103. },
  6104. serialize: function serialize$$1(mailtoComponents, options) {
  6105. var components = mailtoComponents;
  6106. var to = toArray(mailtoComponents.to);
  6107. if (to) {
  6108. for (var x = 0, xl = to.length; x < xl; ++x) {
  6109. var toAddr = String(to[x]);
  6110. var atIdx = toAddr.lastIndexOf("@");
  6111. var localPart = toAddr.slice(0, atIdx).replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_LOCAL_PART, pctEncChar);
  6112. var domain = toAddr.slice(atIdx + 1);
  6113. //convert IDN via punycode
  6114. try {
  6115. domain = !options.iri ? punycode.toASCII(unescapeComponent(domain, options).toLowerCase()) : punycode.toUnicode(domain);
  6116. } catch (e) {
  6117. components.error = components.error || "Email address's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
  6118. }
  6119. to[x] = localPart + "@" + domain;
  6120. }
  6121. components.path = to.join(",");
  6122. }
  6123. var headers = mailtoComponents.headers = mailtoComponents.headers || {};
  6124. if (mailtoComponents.subject) headers["subject"] = mailtoComponents.subject;
  6125. if (mailtoComponents.body) headers["body"] = mailtoComponents.body;
  6126. var fields = [];
  6127. for (var name in headers) {
  6128. if (headers[name] !== O[name]) {
  6129. fields.push(name.replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFNAME, pctEncChar) + "=" + headers[name].replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFVALUE, pctEncChar));
  6130. }
  6131. }
  6132. if (fields.length) {
  6133. components.query = fields.join("&");
  6134. }
  6135. return components;
  6136. }
  6137. };
  6138. var URN_PARSE = /^([^\:]+)\:(.*)/;
  6139. //RFC 2141
  6140. var handler$3 = {
  6141. scheme: "urn",
  6142. parse: function parse$$1(components, options) {
  6143. var matches = components.path && components.path.match(URN_PARSE);
  6144. var urnComponents = components;
  6145. if (matches) {
  6146. var scheme = options.scheme || urnComponents.scheme || "urn";
  6147. var nid = matches[1].toLowerCase();
  6148. var nss = matches[2];
  6149. var urnScheme = scheme + ":" + (options.nid || nid);
  6150. var schemeHandler = SCHEMES[urnScheme];
  6151. urnComponents.nid = nid;
  6152. urnComponents.nss = nss;
  6153. urnComponents.path = undefined;
  6154. if (schemeHandler) {
  6155. urnComponents = schemeHandler.parse(urnComponents, options);
  6156. }
  6157. } else {
  6158. urnComponents.error = urnComponents.error || "URN can not be parsed.";
  6159. }
  6160. return urnComponents;
  6161. },
  6162. serialize: function serialize$$1(urnComponents, options) {
  6163. var scheme = options.scheme || urnComponents.scheme || "urn";
  6164. var nid = urnComponents.nid;
  6165. var urnScheme = scheme + ":" + (options.nid || nid);
  6166. var schemeHandler = SCHEMES[urnScheme];
  6167. if (schemeHandler) {
  6168. urnComponents = schemeHandler.serialize(urnComponents, options);
  6169. }
  6170. var uriComponents = urnComponents;
  6171. var nss = urnComponents.nss;
  6172. uriComponents.path = (nid || options.nid) + ":" + nss;
  6173. return uriComponents;
  6174. }
  6175. };
  6176. var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/;
  6177. //RFC 4122
  6178. var handler$4 = {
  6179. scheme: "urn:uuid",
  6180. parse: function parse(urnComponents, options) {
  6181. var uuidComponents = urnComponents;
  6182. uuidComponents.uuid = uuidComponents.nss;
  6183. uuidComponents.nss = undefined;
  6184. if (!options.tolerant && (!uuidComponents.uuid || !uuidComponents.uuid.match(UUID))) {
  6185. uuidComponents.error = uuidComponents.error || "UUID is not valid.";
  6186. }
  6187. return uuidComponents;
  6188. },
  6189. serialize: function serialize(uuidComponents, options) {
  6190. var urnComponents = uuidComponents;
  6191. //normalize UUID
  6192. urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
  6193. return urnComponents;
  6194. }
  6195. };
  6196. SCHEMES[handler.scheme] = handler;
  6197. SCHEMES[handler$1.scheme] = handler$1;
  6198. SCHEMES[handler$2.scheme] = handler$2;
  6199. SCHEMES[handler$3.scheme] = handler$3;
  6200. SCHEMES[handler$4.scheme] = handler$4;
  6201. exports.SCHEMES = SCHEMES;
  6202. exports.pctEncChar = pctEncChar;
  6203. exports.pctDecChars = pctDecChars;
  6204. exports.parse = parse;
  6205. exports.removeDotSegments = removeDotSegments;
  6206. exports.serialize = serialize;
  6207. exports.resolveComponents = resolveComponents;
  6208. exports.resolve = resolve;
  6209. exports.normalize = normalize;
  6210. exports.equal = equal;
  6211. exports.escapeComponent = escapeComponent;
  6212. exports.unescapeComponent = unescapeComponent;
  6213. Object.defineProperty(exports, '__esModule', { value: true });
  6214. })));
  6215. },{}],"ajv":[function(require,module,exports){
  6216. 'use strict';
  6217. var compileSchema = require('./compile')
  6218. , resolve = require('./compile/resolve')
  6219. , Cache = require('./cache')
  6220. , SchemaObject = require('./compile/schema_obj')
  6221. , stableStringify = require('fast-json-stable-stringify')
  6222. , formats = require('./compile/formats')
  6223. , rules = require('./compile/rules')
  6224. , $dataMetaSchema = require('./data')
  6225. , util = require('./compile/util');
  6226. module.exports = Ajv;
  6227. Ajv.prototype.validate = validate;
  6228. Ajv.prototype.compile = compile;
  6229. Ajv.prototype.addSchema = addSchema;
  6230. Ajv.prototype.addMetaSchema = addMetaSchema;
  6231. Ajv.prototype.validateSchema = validateSchema;
  6232. Ajv.prototype.getSchema = getSchema;
  6233. Ajv.prototype.removeSchema = removeSchema;
  6234. Ajv.prototype.addFormat = addFormat;
  6235. Ajv.prototype.errorsText = errorsText;
  6236. Ajv.prototype._addSchema = _addSchema;
  6237. Ajv.prototype._compile = _compile;
  6238. Ajv.prototype.compileAsync = require('./compile/async');
  6239. var customKeyword = require('./keyword');
  6240. Ajv.prototype.addKeyword = customKeyword.add;
  6241. Ajv.prototype.getKeyword = customKeyword.get;
  6242. Ajv.prototype.removeKeyword = customKeyword.remove;
  6243. Ajv.prototype.validateKeyword = customKeyword.validate;
  6244. var errorClasses = require('./compile/error_classes');
  6245. Ajv.ValidationError = errorClasses.Validation;
  6246. Ajv.MissingRefError = errorClasses.MissingRef;
  6247. Ajv.$dataMetaSchema = $dataMetaSchema;
  6248. var META_SCHEMA_ID = 'http://json-schema.org/draft-07/schema';
  6249. var META_IGNORE_OPTIONS = [ 'removeAdditional', 'useDefaults', 'coerceTypes', 'strictDefaults' ];
  6250. var META_SUPPORT_DATA = ['/properties'];
  6251. /**
  6252. * Creates validator instance.
  6253. * Usage: `Ajv(opts)`
  6254. * @param {Object} opts optional options
  6255. * @return {Object} ajv instance
  6256. */
  6257. function Ajv(opts) {
  6258. if (!(this instanceof Ajv)) return new Ajv(opts);
  6259. opts = this._opts = util.copy(opts) || {};
  6260. setLogger(this);
  6261. this._schemas = {};
  6262. this._refs = {};
  6263. this._fragments = {};
  6264. this._formats = formats(opts.format);
  6265. this._cache = opts.cache || new Cache;
  6266. this._loadingSchemas = {};
  6267. this._compilations = [];
  6268. this.RULES = rules();
  6269. this._getId = chooseGetId(opts);
  6270. opts.loopRequired = opts.loopRequired || Infinity;
  6271. if (opts.errorDataPath == 'property') opts._errorDataPathProperty = true;
  6272. if (opts.serialize === undefined) opts.serialize = stableStringify;
  6273. this._metaOpts = getMetaSchemaOptions(this);
  6274. if (opts.formats) addInitialFormats(this);
  6275. if (opts.keywords) addInitialKeywords(this);
  6276. addDefaultMetaSchema(this);
  6277. if (typeof opts.meta == 'object') this.addMetaSchema(opts.meta);
  6278. if (opts.nullable) this.addKeyword('nullable', {metaSchema: {type: 'boolean'}});
  6279. addInitialSchemas(this);
  6280. }
  6281. /**
  6282. * Validate data using schema
  6283. * Schema will be compiled and cached (using serialized JSON as key. [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) is used to serialize.
  6284. * @this Ajv
  6285. * @param {String|Object} schemaKeyRef key, ref or schema object
  6286. * @param {Any} data to be validated
  6287. * @return {Boolean} validation result. Errors from the last validation will be available in `ajv.errors` (and also in compiled schema: `schema.errors`).
  6288. */
  6289. function validate(schemaKeyRef, data) {
  6290. var v;
  6291. if (typeof schemaKeyRef == 'string') {
  6292. v = this.getSchema(schemaKeyRef);
  6293. if (!v) throw new Error('no schema with key or ref "' + schemaKeyRef + '"');
  6294. } else {
  6295. var schemaObj = this._addSchema(schemaKeyRef);
  6296. v = schemaObj.validate || this._compile(schemaObj);
  6297. }
  6298. var valid = v(data);
  6299. if (v.$async !== true) this.errors = v.errors;
  6300. return valid;
  6301. }
  6302. /**
  6303. * Create validating function for passed schema.
  6304. * @this Ajv
  6305. * @param {Object} schema schema object
  6306. * @param {Boolean} _meta true if schema is a meta-schema. Used internally to compile meta schemas of custom keywords.
  6307. * @return {Function} validating function
  6308. */
  6309. function compile(schema, _meta) {
  6310. var schemaObj = this._addSchema(schema, undefined, _meta);
  6311. return schemaObj.validate || this._compile(schemaObj);
  6312. }
  6313. /**
  6314. * Adds schema to the instance.
  6315. * @this Ajv
  6316. * @param {Object|Array} schema schema or array of schemas. If array is passed, `key` and other parameters will be ignored.
  6317. * @param {String} key Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`.
  6318. * @param {Boolean} _skipValidation true to skip schema validation. Used internally, option validateSchema should be used instead.
  6319. * @param {Boolean} _meta true if schema is a meta-schema. Used internally, addMetaSchema should be used instead.
  6320. * @return {Ajv} this for method chaining
  6321. */
  6322. function addSchema(schema, key, _skipValidation, _meta) {
  6323. if (Array.isArray(schema)){
  6324. for (var i=0; i<schema.length; i++) this.addSchema(schema[i], undefined, _skipValidation, _meta);
  6325. return this;
  6326. }
  6327. var id = this._getId(schema);
  6328. if (id !== undefined && typeof id != 'string')
  6329. throw new Error('schema id must be string');
  6330. key = resolve.normalizeId(key || id);
  6331. checkUnique(this, key);
  6332. this._schemas[key] = this._addSchema(schema, _skipValidation, _meta, true);
  6333. return this;
  6334. }
  6335. /**
  6336. * Add schema that will be used to validate other schemas
  6337. * options in META_IGNORE_OPTIONS are alway set to false
  6338. * @this Ajv
  6339. * @param {Object} schema schema object
  6340. * @param {String} key optional schema key
  6341. * @param {Boolean} skipValidation true to skip schema validation, can be used to override validateSchema option for meta-schema
  6342. * @return {Ajv} this for method chaining
  6343. */
  6344. function addMetaSchema(schema, key, skipValidation) {
  6345. this.addSchema(schema, key, skipValidation, true);
  6346. return this;
  6347. }
  6348. /**
  6349. * Validate schema
  6350. * @this Ajv
  6351. * @param {Object} schema schema to validate
  6352. * @param {Boolean} throwOrLogError pass true to throw (or log) an error if invalid
  6353. * @return {Boolean} true if schema is valid
  6354. */
  6355. function validateSchema(schema, throwOrLogError) {
  6356. var $schema = schema.$schema;
  6357. if ($schema !== undefined && typeof $schema != 'string')
  6358. throw new Error('$schema must be a string');
  6359. $schema = $schema || this._opts.defaultMeta || defaultMeta(this);
  6360. if (!$schema) {
  6361. this.logger.warn('meta-schema not available');
  6362. this.errors = null;
  6363. return true;
  6364. }
  6365. var valid = this.validate($schema, schema);
  6366. if (!valid && throwOrLogError) {
  6367. var message = 'schema is invalid: ' + this.errorsText();
  6368. if (this._opts.validateSchema == 'log') this.logger.error(message);
  6369. else throw new Error(message);
  6370. }
  6371. return valid;
  6372. }
  6373. function defaultMeta(self) {
  6374. var meta = self._opts.meta;
  6375. self._opts.defaultMeta = typeof meta == 'object'
  6376. ? self._getId(meta) || meta
  6377. : self.getSchema(META_SCHEMA_ID)
  6378. ? META_SCHEMA_ID
  6379. : undefined;
  6380. return self._opts.defaultMeta;
  6381. }
  6382. /**
  6383. * Get compiled schema from the instance by `key` or `ref`.
  6384. * @this Ajv
  6385. * @param {String} keyRef `key` that was passed to `addSchema` or full schema reference (`schema.id` or resolved id).
  6386. * @return {Function} schema validating function (with property `schema`).
  6387. */
  6388. function getSchema(keyRef) {
  6389. var schemaObj = _getSchemaObj(this, keyRef);
  6390. switch (typeof schemaObj) {
  6391. case 'object': return schemaObj.validate || this._compile(schemaObj);
  6392. case 'string': return this.getSchema(schemaObj);
  6393. case 'undefined': return _getSchemaFragment(this, keyRef);
  6394. }
  6395. }
  6396. function _getSchemaFragment(self, ref) {
  6397. var res = resolve.schema.call(self, { schema: {} }, ref);
  6398. if (res) {
  6399. var schema = res.schema
  6400. , root = res.root
  6401. , baseId = res.baseId;
  6402. var v = compileSchema.call(self, schema, root, undefined, baseId);
  6403. self._fragments[ref] = new SchemaObject({
  6404. ref: ref,
  6405. fragment: true,
  6406. schema: schema,
  6407. root: root,
  6408. baseId: baseId,
  6409. validate: v
  6410. });
  6411. return v;
  6412. }
  6413. }
  6414. function _getSchemaObj(self, keyRef) {
  6415. keyRef = resolve.normalizeId(keyRef);
  6416. return self._schemas[keyRef] || self._refs[keyRef] || self._fragments[keyRef];
  6417. }
  6418. /**
  6419. * Remove cached schema(s).
  6420. * If no parameter is passed all schemas but meta-schemas are removed.
  6421. * If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed.
  6422. * Even if schema is referenced by other schemas it still can be removed as other schemas have local references.
  6423. * @this Ajv
  6424. * @param {String|Object|RegExp} schemaKeyRef key, ref, pattern to match key/ref or schema object
  6425. * @return {Ajv} this for method chaining
  6426. */
  6427. function removeSchema(schemaKeyRef) {
  6428. if (schemaKeyRef instanceof RegExp) {
  6429. _removeAllSchemas(this, this._schemas, schemaKeyRef);
  6430. _removeAllSchemas(this, this._refs, schemaKeyRef);
  6431. return this;
  6432. }
  6433. switch (typeof schemaKeyRef) {
  6434. case 'undefined':
  6435. _removeAllSchemas(this, this._schemas);
  6436. _removeAllSchemas(this, this._refs);
  6437. this._cache.clear();
  6438. return this;
  6439. case 'string':
  6440. var schemaObj = _getSchemaObj(this, schemaKeyRef);
  6441. if (schemaObj) this._cache.del(schemaObj.cacheKey);
  6442. delete this._schemas[schemaKeyRef];
  6443. delete this._refs[schemaKeyRef];
  6444. return this;
  6445. case 'object':
  6446. var serialize = this._opts.serialize;
  6447. var cacheKey = serialize ? serialize(schemaKeyRef) : schemaKeyRef;
  6448. this._cache.del(cacheKey);
  6449. var id = this._getId(schemaKeyRef);
  6450. if (id) {
  6451. id = resolve.normalizeId(id);
  6452. delete this._schemas[id];
  6453. delete this._refs[id];
  6454. }
  6455. }
  6456. return this;
  6457. }
  6458. function _removeAllSchemas(self, schemas, regex) {
  6459. for (var keyRef in schemas) {
  6460. var schemaObj = schemas[keyRef];
  6461. if (!schemaObj.meta && (!regex || regex.test(keyRef))) {
  6462. self._cache.del(schemaObj.cacheKey);
  6463. delete schemas[keyRef];
  6464. }
  6465. }
  6466. }
  6467. /* @this Ajv */
  6468. function _addSchema(schema, skipValidation, meta, shouldAddSchema) {
  6469. if (typeof schema != 'object' && typeof schema != 'boolean')
  6470. throw new Error('schema should be object or boolean');
  6471. var serialize = this._opts.serialize;
  6472. var cacheKey = serialize ? serialize(schema) : schema;
  6473. var cached = this._cache.get(cacheKey);
  6474. if (cached) return cached;
  6475. shouldAddSchema = shouldAddSchema || this._opts.addUsedSchema !== false;
  6476. var id = resolve.normalizeId(this._getId(schema));
  6477. if (id && shouldAddSchema) checkUnique(this, id);
  6478. var willValidate = this._opts.validateSchema !== false && !skipValidation;
  6479. var recursiveMeta;
  6480. if (willValidate && !(recursiveMeta = id && id == resolve.normalizeId(schema.$schema)))
  6481. this.validateSchema(schema, true);
  6482. var localRefs = resolve.ids.call(this, schema);
  6483. var schemaObj = new SchemaObject({
  6484. id: id,
  6485. schema: schema,
  6486. localRefs: localRefs,
  6487. cacheKey: cacheKey,
  6488. meta: meta
  6489. });
  6490. if (id[0] != '#' && shouldAddSchema) this._refs[id] = schemaObj;
  6491. this._cache.put(cacheKey, schemaObj);
  6492. if (willValidate && recursiveMeta) this.validateSchema(schema, true);
  6493. return schemaObj;
  6494. }
  6495. /* @this Ajv */
  6496. function _compile(schemaObj, root) {
  6497. if (schemaObj.compiling) {
  6498. schemaObj.validate = callValidate;
  6499. callValidate.schema = schemaObj.schema;
  6500. callValidate.errors = null;
  6501. callValidate.root = root ? root : callValidate;
  6502. if (schemaObj.schema.$async === true)
  6503. callValidate.$async = true;
  6504. return callValidate;
  6505. }
  6506. schemaObj.compiling = true;
  6507. var currentOpts;
  6508. if (schemaObj.meta) {
  6509. currentOpts = this._opts;
  6510. this._opts = this._metaOpts;
  6511. }
  6512. var v;
  6513. try { v = compileSchema.call(this, schemaObj.schema, root, schemaObj.localRefs); }
  6514. catch(e) {
  6515. delete schemaObj.validate;
  6516. throw e;
  6517. }
  6518. finally {
  6519. schemaObj.compiling = false;
  6520. if (schemaObj.meta) this._opts = currentOpts;
  6521. }
  6522. schemaObj.validate = v;
  6523. schemaObj.refs = v.refs;
  6524. schemaObj.refVal = v.refVal;
  6525. schemaObj.root = v.root;
  6526. return v;
  6527. /* @this {*} - custom context, see passContext option */
  6528. function callValidate() {
  6529. /* jshint validthis: true */
  6530. var _validate = schemaObj.validate;
  6531. var result = _validate.apply(this, arguments);
  6532. callValidate.errors = _validate.errors;
  6533. return result;
  6534. }
  6535. }
  6536. function chooseGetId(opts) {
  6537. switch (opts.schemaId) {
  6538. case 'auto': return _get$IdOrId;
  6539. case 'id': return _getId;
  6540. default: return _get$Id;
  6541. }
  6542. }
  6543. /* @this Ajv */
  6544. function _getId(schema) {
  6545. if (schema.$id) this.logger.warn('schema $id ignored', schema.$id);
  6546. return schema.id;
  6547. }
  6548. /* @this Ajv */
  6549. function _get$Id(schema) {
  6550. if (schema.id) this.logger.warn('schema id ignored', schema.id);
  6551. return schema.$id;
  6552. }
  6553. function _get$IdOrId(schema) {
  6554. if (schema.$id && schema.id && schema.$id != schema.id)
  6555. throw new Error('schema $id is different from id');
  6556. return schema.$id || schema.id;
  6557. }
  6558. /**
  6559. * Convert array of error message objects to string
  6560. * @this Ajv
  6561. * @param {Array<Object>} errors optional array of validation errors, if not passed errors from the instance are used.
  6562. * @param {Object} options optional options with properties `separator` and `dataVar`.
  6563. * @return {String} human readable string with all errors descriptions
  6564. */
  6565. function errorsText(errors, options) {
  6566. errors = errors || this.errors;
  6567. if (!errors) return 'No errors';
  6568. options = options || {};
  6569. var separator = options.separator === undefined ? ', ' : options.separator;
  6570. var dataVar = options.dataVar === undefined ? 'data' : options.dataVar;
  6571. var text = '';
  6572. for (var i=0; i<errors.length; i++) {
  6573. var e = errors[i];
  6574. if (e) text += dataVar + e.dataPath + ' ' + e.message + separator;
  6575. }
  6576. return text.slice(0, -separator.length);
  6577. }
  6578. /**
  6579. * Add custom format
  6580. * @this Ajv
  6581. * @param {String} name format name
  6582. * @param {String|RegExp|Function} format string is converted to RegExp; function should return boolean (true when valid)
  6583. * @return {Ajv} this for method chaining
  6584. */
  6585. function addFormat(name, format) {
  6586. if (typeof format == 'string') format = new RegExp(format);
  6587. this._formats[name] = format;
  6588. return this;
  6589. }
  6590. function addDefaultMetaSchema(self) {
  6591. var $dataSchema;
  6592. if (self._opts.$data) {
  6593. $dataSchema = require('./refs/data.json');
  6594. self.addMetaSchema($dataSchema, $dataSchema.$id, true);
  6595. }
  6596. if (self._opts.meta === false) return;
  6597. var metaSchema = require('./refs/json-schema-draft-07.json');
  6598. if (self._opts.$data) metaSchema = $dataMetaSchema(metaSchema, META_SUPPORT_DATA);
  6599. self.addMetaSchema(metaSchema, META_SCHEMA_ID, true);
  6600. self._refs['http://json-schema.org/schema'] = META_SCHEMA_ID;
  6601. }
  6602. function addInitialSchemas(self) {
  6603. var optsSchemas = self._opts.schemas;
  6604. if (!optsSchemas) return;
  6605. if (Array.isArray(optsSchemas)) self.addSchema(optsSchemas);
  6606. else for (var key in optsSchemas) self.addSchema(optsSchemas[key], key);
  6607. }
  6608. function addInitialFormats(self) {
  6609. for (var name in self._opts.formats) {
  6610. var format = self._opts.formats[name];
  6611. self.addFormat(name, format);
  6612. }
  6613. }
  6614. function addInitialKeywords(self) {
  6615. for (var name in self._opts.keywords) {
  6616. var keyword = self._opts.keywords[name];
  6617. self.addKeyword(name, keyword);
  6618. }
  6619. }
  6620. function checkUnique(self, id) {
  6621. if (self._schemas[id] || self._refs[id])
  6622. throw new Error('schema with key or id "' + id + '" already exists');
  6623. }
  6624. function getMetaSchemaOptions(self) {
  6625. var metaOpts = util.copy(self._opts);
  6626. for (var i=0; i<META_IGNORE_OPTIONS.length; i++)
  6627. delete metaOpts[META_IGNORE_OPTIONS[i]];
  6628. return metaOpts;
  6629. }
  6630. function setLogger(self) {
  6631. var logger = self._opts.logger;
  6632. if (logger === false) {
  6633. self.logger = {log: noop, warn: noop, error: noop};
  6634. } else {
  6635. if (logger === undefined) logger = console;
  6636. if (!(typeof logger == 'object' && logger.log && logger.warn && logger.error))
  6637. throw new Error('logger must implement log, warn and error methods');
  6638. self.logger = logger;
  6639. }
  6640. }
  6641. function noop() {}
  6642. },{"./cache":1,"./compile":5,"./compile/async":2,"./compile/error_classes":3,"./compile/formats":4,"./compile/resolve":6,"./compile/rules":7,"./compile/schema_obj":8,"./compile/util":10,"./data":11,"./keyword":39,"./refs/data.json":40,"./refs/json-schema-draft-07.json":41,"fast-json-stable-stringify":43}]},{},[])("ajv")
  6643. });