You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ajv.bundle.js 265KB

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