validate.proto 199 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145
  1. // Copyright 2023-2026 Buf Technologies, Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto2";
  15. // [Protovalidate](https://protovalidate.com/) is the semantic validation library for Protobuf.
  16. // It provides standard annotations to validate common rules on messages and fields, as well as the ability to use [CEL](https://cel.dev) to write custom rules.
  17. // It's the next generation of [protoc-gen-validate](https://github.com/bufbuild/protoc-gen-validate).
  18. //
  19. // This package provides the options, messages, and enums that power Protovalidate.
  20. // Apply its options to messages, fields, and oneofs in your Protobuf schemas to add validation rules:
  21. //
  22. // ```proto
  23. // message User {
  24. // string id = 1 [(buf.validate.field).string.uuid = true];
  25. // string first_name = 2 [(buf.validate.field).string.max_len = 64];
  26. // string last_name = 3 [(buf.validate.field).string.max_len = 64];
  27. //
  28. // option (buf.validate.message).cel = {
  29. // id: "first_name_requires_last_name"
  30. // message: "last_name must be present if first_name is present"
  31. // expression: "!has(this.first_name) || has(this.last_name)"
  32. // };
  33. // }
  34. // ```
  35. //
  36. // These rules are enforced at runtime by language-specific libraries.
  37. // See the [developer quickstart](https://protovalidate.com/quickstart/) to get started, or go directly to the runtime library for your language:
  38. // [Go](https://github.com/bufbuild/protovalidate-go),
  39. // [JavaScript/TypeScript](https://github.com/bufbuild/protovalidate-es),
  40. // [Java](https://github.com/bufbuild/protovalidate-java),
  41. // [Python](https://github.com/bufbuild/protovalidate-py),
  42. // or [C++](https://github.com/bufbuild/protovalidate-cc).
  43. package buf.validate;
  44. import "google/protobuf/descriptor.proto";
  45. import "google/protobuf/duration.proto";
  46. import "google/protobuf/field_mask.proto";
  47. import "google/protobuf/timestamp.proto";
  48. option go_package = "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate";
  49. option java_multiple_files = true;
  50. option java_outer_classname = "ValidateProto";
  51. option java_package = "build.buf.validate";
  52. // MessageOptions is an extension to google.protobuf.MessageOptions. It allows
  53. // the addition of validation rules at the message level. These rules can be
  54. // applied to incoming messages to ensure they meet certain criteria before
  55. // being processed.
  56. extend google.protobuf.MessageOptions {
  57. // Rules specify the validations to be performed on this message. By default,
  58. // no validation is performed against a message.
  59. optional MessageRules message = 1159;
  60. }
  61. // OneofOptions is an extension to google.protobuf.OneofOptions. It allows
  62. // the addition of validation rules on a oneof. These rules can be
  63. // applied to incoming messages to ensure they meet certain criteria before
  64. // being processed.
  65. extend google.protobuf.OneofOptions {
  66. // Rules specify the validations to be performed on this oneof. By default,
  67. // no validation is performed against a oneof.
  68. optional OneofRules oneof = 1159;
  69. }
  70. // FieldOptions is an extension to google.protobuf.FieldOptions. It allows
  71. // the addition of validation rules at the field level. These rules can be
  72. // applied to incoming messages to ensure they meet certain criteria before
  73. // being processed.
  74. extend google.protobuf.FieldOptions {
  75. // Rules specify the validations to be performed on this field. By default,
  76. // no validation is performed against a field.
  77. optional FieldRules field = 1159;
  78. // Specifies predefined rules. When extending a standard rule message,
  79. // this adds additional CEL expressions that apply when the extension is used.
  80. //
  81. // ```proto
  82. // extend buf.validate.Int32Rules {
  83. // bool is_zero = 1001 [(buf.validate.predefined).cel = {
  84. // id: "int32.is_zero",
  85. // message: "must be zero",
  86. // expression: "!rule || this == 0",
  87. // }];
  88. // }
  89. //
  90. // message Foo {
  91. // int32 reserved = 1 [(buf.validate.field).int32.(is_zero) = true];
  92. // }
  93. // ```
  94. optional PredefinedRules predefined = 1160;
  95. }
  96. // `Rule` represents a validation rule written in the Common Expression
  97. // Language (CEL) syntax. Each Rule includes a unique identifier, an
  98. // optional error message, and the CEL expression to evaluate. For more
  99. // information, [see our documentation](https://protovalidate.com/schemas/custom-rules/).
  100. //
  101. // ```proto
  102. // message Foo {
  103. // option (buf.validate.message).cel = {
  104. // id: "foo.bar"
  105. // message: "bar must be greater than 0"
  106. // expression: "this.bar > 0"
  107. // };
  108. // int32 bar = 1;
  109. // }
  110. // ```
  111. message Rule {
  112. // `id` is a string that serves as a machine-readable name for this Rule.
  113. // It should be unique within its scope, which could be either a message or a field.
  114. optional string id = 1;
  115. // `message` is an optional field that provides a human-readable error message
  116. // for this Rule when the CEL expression evaluates to false. If a
  117. // non-empty message is provided, any strings resulting from the CEL
  118. // expression evaluation are ignored.
  119. optional string message = 2;
  120. // `expression` is the actual CEL expression that will be evaluated for
  121. // validation. This string must resolve to either a boolean or a string
  122. // value. If the expression evaluates to false or a non-empty string, the
  123. // validation is considered failed, and the message is rejected.
  124. optional string expression = 3;
  125. }
  126. // MessageRules represents validation rules that are applied to the entire message.
  127. // It includes disabling options and a list of Rule messages representing Common Expression Language (CEL) validation rules.
  128. message MessageRules {
  129. // `cel_expression` is a repeated field CEL expressions. Each expression specifies a validation
  130. // rule to be applied to this message. These rules are written in Common Expression Language (CEL) syntax.
  131. //
  132. // This is a simplified form of the `cel` Rule field, where only `expression` is set. This allows for
  133. // simpler syntax when defining CEL Rules where `id` and `message` derived from the `expression`. `id` will
  134. // be same as the `expression`.
  135. //
  136. // For more information, [see our documentation](https://protovalidate.com/schemas/custom-rules/).
  137. //
  138. // ```proto
  139. // message MyMessage {
  140. // // The field `foo` must be greater than 42.
  141. // option (buf.validate.message).cel_expression = "this.foo > 42";
  142. // // The field `foo` must be less than 84.
  143. // option (buf.validate.message).cel_expression = "this.foo < 84";
  144. // optional int32 foo = 1;
  145. // }
  146. // ```
  147. repeated string cel_expression = 5;
  148. // `cel` is a repeated field of type Rule. Each Rule specifies a validation rule to be applied to this message.
  149. // These rules are written in Common Expression Language (CEL) syntax. For more information,
  150. // [see our documentation](https://protovalidate.com/schemas/custom-rules/).
  151. //
  152. //
  153. // ```proto
  154. // message MyMessage {
  155. // // The field `foo` must be greater than 42.
  156. // option (buf.validate.message).cel = {
  157. // id: "my_message.value",
  158. // message: "must be greater than 42",
  159. // expression: "this.foo > 42",
  160. // };
  161. // optional int32 foo = 1;
  162. // }
  163. // ```
  164. repeated Rule cel = 3;
  165. // `oneof` is a repeated field of type MessageOneofRule that specifies a list of fields
  166. // of which at most one can be present. If `required` is also specified, then exactly one
  167. // of the specified fields _must_ be present.
  168. //
  169. // This will enforce oneof-like constraints with a few features not provided by
  170. // actual Protobuf oneof declarations:
  171. // 1. Repeated and map fields are allowed in this validation. In a Protobuf oneof,
  172. // only scalar fields are allowed.
  173. // 2. Fields with implicit presence are allowed. In a Protobuf oneof, all member
  174. // fields have explicit presence. This means that, for the purpose of determining
  175. // how many fields are set, explicitly setting such a field to its zero value is
  176. // effectively the same as not setting it at all.
  177. // 3. This will always generate validation errors for a message unmarshalled from
  178. // serialized data that sets more than one field. With a Protobuf oneof, when
  179. // multiple fields are present in the serialized form, earlier values are usually
  180. // silently ignored when unmarshalling, with only the last field being set when
  181. // unmarshalling completes.
  182. //
  183. // Note that adding a field to a `oneof` will also set the IGNORE_IF_ZERO_VALUE on the fields. This means
  184. // only the field that is set will be validated and the unset fields are not validated according to the field rules.
  185. // This behavior can be overridden by setting `ignore` against a field.
  186. //
  187. // ```proto
  188. // message MyMessage {
  189. // // Only one of `field1` or `field2` _can_ be present in this message.
  190. // option (buf.validate.message).oneof = { fields: ["field1", "field2"] };
  191. // // Exactly one of `field3` or `field4` _must_ be present in this message.
  192. // option (buf.validate.message).oneof = { fields: ["field3", "field4"], required: true };
  193. // string field1 = 1;
  194. // bytes field2 = 2;
  195. // bool field3 = 3;
  196. // int32 field4 = 4;
  197. // }
  198. // ```
  199. repeated MessageOneofRule oneof = 4;
  200. reserved 1;
  201. reserved "disabled";
  202. }
  203. message MessageOneofRule {
  204. // A list of field names to include in the oneof. All field names must be
  205. // defined in the message. At least one field must be specified, and
  206. // duplicates are not permitted.
  207. repeated string fields = 1;
  208. // If true, one of the fields specified _must_ be set.
  209. optional bool required = 2;
  210. }
  211. // The `OneofRules` message type enables you to manage rules for
  212. // oneof fields in your protobuf messages.
  213. message OneofRules {
  214. // If `required` is true, exactly one field of the oneof must be set. A
  215. // validation error is returned if no fields in the oneof are set. Further rules
  216. // should be placed on the fields themselves to ensure they are valid values,
  217. // such as `min_len` or `gt`.
  218. //
  219. // ```proto
  220. // message MyMessage {
  221. // oneof value {
  222. // // Either `a` or `b` must be set. If `a` is set, it must also be
  223. // // non-empty; whereas if `b` is set, it can still be an empty string.
  224. // option (buf.validate.oneof).required = true;
  225. // string a = 1 [(buf.validate.field).string.min_len = 1];
  226. // string b = 2;
  227. // }
  228. // }
  229. // ```
  230. optional bool required = 1;
  231. }
  232. // FieldRules encapsulates the rules for each type of field. Depending on
  233. // the field, the correct set should be used to ensure proper validations.
  234. message FieldRules {
  235. // `cel_expression` is a repeated field CEL expressions. Each expression specifies a validation
  236. // rule to be applied to this message. These rules are written in Common Expression Language (CEL) syntax.
  237. //
  238. // This is a simplified form of the `cel` Rule field, where only `expression` is set. This allows for
  239. // simpler syntax when defining CEL Rules where `id` and `message` derived from the `expression`. `id` will
  240. // be same as the `expression`.
  241. //
  242. // For more information, [see our documentation](https://protovalidate.com/schemas/custom-rules/).
  243. //
  244. // ```proto
  245. // message MyMessage {
  246. // // The field `value` must be greater than 42.
  247. // optional int32 value = 1 [(buf.validate.field).cel_expression = "this > 42"];
  248. // }
  249. // ```
  250. repeated string cel_expression = 29;
  251. // `cel` is a repeated field used to represent a textual expression
  252. // in the Common Expression Language (CEL) syntax. For more information,
  253. // [see our documentation](https://protovalidate.com/schemas/custom-rules/).
  254. //
  255. // ```proto
  256. // message MyMessage {
  257. // // The field `value` must be greater than 42.
  258. // optional int32 value = 1 [(buf.validate.field).cel = {
  259. // id: "my_message.value",
  260. // message: "must be greater than 42",
  261. // expression: "this > 42",
  262. // }];
  263. // }
  264. // ```
  265. repeated Rule cel = 23;
  266. // If `required` is true, the field must be set. A validation error is returned
  267. // if the field is not set.
  268. //
  269. // ```proto
  270. // syntax="proto3";
  271. //
  272. // message FieldsWithPresence {
  273. // // Requires any string to be set, including the empty string.
  274. // optional string link = 1 [
  275. // (buf.validate.field).required = true
  276. // ];
  277. // // Requires true or false to be set.
  278. // optional bool disabled = 2 [
  279. // (buf.validate.field).required = true
  280. // ];
  281. // // Requires a message to be set, including the empty message.
  282. // SomeMessage msg = 4 [
  283. // (buf.validate.field).required = true
  284. // ];
  285. // }
  286. // ```
  287. //
  288. // All fields in the example above track presence. By default, Protovalidate
  289. // ignores rules on those fields if no value is set. `required` ensures that
  290. // the fields are set and valid.
  291. //
  292. // Fields that don't track presence are always validated by Protovalidate,
  293. // whether they are set or not. It is not necessary to add `required`. It
  294. // can be added to indicate that the field cannot be the zero value.
  295. //
  296. // ```proto
  297. // syntax="proto3";
  298. //
  299. // message FieldsWithoutPresence {
  300. // // `string.email` always applies, even to an empty string.
  301. // string link = 1 [
  302. // (buf.validate.field).string.email = true
  303. // ];
  304. // // `repeated.min_items` always applies, even to an empty list.
  305. // repeated string labels = 2 [
  306. // (buf.validate.field).repeated.min_items = 1
  307. // ];
  308. // // `required`, for fields that don't track presence, indicates
  309. // // the value of the field can't be the zero value.
  310. // int32 zero_value_not_allowed = 3 [
  311. // (buf.validate.field).required = true
  312. // ];
  313. // }
  314. // ```
  315. //
  316. // To learn which fields track presence, see the
  317. // [Field Presence cheat sheet](https://protobuf.dev/programming-guides/field_presence/#cheat).
  318. //
  319. // Note: While field rules can be applied to repeated items, map keys, and map
  320. // values, the elements are always considered to be set. Consequently,
  321. // specifying `repeated.items.required` is redundant.
  322. optional bool required = 25;
  323. // Ignore validation rules on the field if its value matches the specified
  324. // criteria. See the `Ignore` enum for details.
  325. //
  326. // ```proto
  327. // message UpdateRequest {
  328. // // The uri rule only applies if the field is not an empty string.
  329. // string url = 1 [
  330. // (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE,
  331. // (buf.validate.field).string.uri = true
  332. // ];
  333. // }
  334. // ```
  335. optional Ignore ignore = 27;
  336. oneof type {
  337. // Scalar Field Types
  338. FloatRules float = 1;
  339. DoubleRules double = 2;
  340. Int32Rules int32 = 3;
  341. Int64Rules int64 = 4;
  342. UInt32Rules uint32 = 5;
  343. UInt64Rules uint64 = 6;
  344. SInt32Rules sint32 = 7;
  345. SInt64Rules sint64 = 8;
  346. Fixed32Rules fixed32 = 9;
  347. Fixed64Rules fixed64 = 10;
  348. SFixed32Rules sfixed32 = 11;
  349. SFixed64Rules sfixed64 = 12;
  350. BoolRules bool = 13;
  351. StringRules string = 14;
  352. BytesRules bytes = 15;
  353. // Complex Field Types
  354. EnumRules enum = 16;
  355. RepeatedRules repeated = 18;
  356. MapRules map = 19;
  357. // Well-Known Field Types
  358. AnyRules any = 20;
  359. DurationRules duration = 21;
  360. FieldMaskRules field_mask = 28;
  361. TimestampRules timestamp = 22;
  362. }
  363. reserved 24, 26;
  364. reserved "skipped", "ignore_empty";
  365. }
  366. // PredefinedRules are custom rules that can be re-used with
  367. // multiple fields.
  368. message PredefinedRules {
  369. // `cel` is a repeated field used to represent a textual expression
  370. // in the Common Expression Language (CEL) syntax. For more information,
  371. // [see our documentation](https://protovalidate.com/schemas/predefined-rules/).
  372. //
  373. // ```proto
  374. // message MyMessage {
  375. // // The field `value` must be greater than 42.
  376. // optional int32 value = 1 [(buf.validate.predefined).cel = {
  377. // id: "my_message.value",
  378. // message: "must be greater than 42",
  379. // expression: "this > 42",
  380. // }];
  381. // }
  382. // ```
  383. repeated Rule cel = 1;
  384. reserved 24, 26;
  385. reserved "skipped", "ignore_empty";
  386. }
  387. // Specifies how `FieldRules.ignore` behaves, depending on the field's value, and
  388. // whether the field tracks presence.
  389. enum Ignore {
  390. // Ignore rules if the field tracks presence and is unset. This is the default
  391. // behavior.
  392. //
  393. // In proto3, only message fields, members of a Protobuf `oneof`, and fields
  394. // with the `optional` label track presence. Consequently, the following fields
  395. // are always validated, whether a value is set or not:
  396. //
  397. // ```proto
  398. // syntax="proto3";
  399. //
  400. // message RulesApply {
  401. // string email = 1 [
  402. // (buf.validate.field).string.email = true
  403. // ];
  404. // int32 age = 2 [
  405. // (buf.validate.field).int32.gt = 0
  406. // ];
  407. // repeated string labels = 3 [
  408. // (buf.validate.field).repeated.min_items = 1
  409. // ];
  410. // }
  411. // ```
  412. //
  413. // In contrast, the following fields track presence, and are only validated if
  414. // a value is set:
  415. //
  416. // ```proto
  417. // syntax="proto3";
  418. //
  419. // message RulesApplyIfSet {
  420. // optional string email = 1 [
  421. // (buf.validate.field).string.email = true
  422. // ];
  423. // oneof ref {
  424. // string reference = 2 [
  425. // (buf.validate.field).string.uuid = true
  426. // ];
  427. // string name = 3 [
  428. // (buf.validate.field).string.min_len = 4
  429. // ];
  430. // }
  431. // SomeMessage msg = 4 [
  432. // (buf.validate.field).cel = {/* ... */}
  433. // ];
  434. // }
  435. // ```
  436. //
  437. // To ensure that such a field is set, add the `required` rule.
  438. //
  439. // To learn which fields track presence, see the
  440. // [Field Presence cheat sheet](https://protobuf.dev/programming-guides/field_presence/#cheat).
  441. IGNORE_UNSPECIFIED = 0;
  442. // Ignore rules if the field is unset, or set to the zero value.
  443. //
  444. // The zero value depends on the field type:
  445. // - For strings, the zero value is the empty string.
  446. // - For bytes, the zero value is empty bytes.
  447. // - For bool, the zero value is false.
  448. // - For numeric types, the zero value is zero.
  449. // - For enums, the zero value is the first defined enum value.
  450. // - For repeated fields, the zero is an empty list.
  451. // - For map fields, the zero is an empty map.
  452. // - For message fields, absence of the message (typically a null-value) is considered zero value.
  453. //
  454. // For fields that track presence (e.g. adding the `optional` label in proto3),
  455. // this a no-op and behavior is the same as the default `IGNORE_UNSPECIFIED`.
  456. IGNORE_IF_ZERO_VALUE = 1;
  457. // Always ignore rules, including the `required` rule.
  458. //
  459. // This is useful for ignoring the rules of a referenced message, or to
  460. // temporarily ignore rules during development.
  461. //
  462. // ```proto
  463. // message MyMessage {
  464. // // The field's rules will always be ignored, including any validations
  465. // // on value's fields.
  466. // MyOtherMessage value = 1 [
  467. // (buf.validate.field).ignore = IGNORE_ALWAYS
  468. // ];
  469. // }
  470. // ```
  471. IGNORE_ALWAYS = 3;
  472. reserved 2;
  473. reserved "IGNORE_EMPTY", "IGNORE_DEFAULT", "IGNORE_IF_DEFAULT_VALUE", "IGNORE_IF_UNPOPULATED";
  474. }
  475. // FloatRules describes the rules applied to `float` values. These
  476. // rules may also be applied to the `google.protobuf.FloatValue` Well-Known-Type.
  477. message FloatRules {
  478. // `const` requires the field value to exactly match the specified value. If
  479. // the field value doesn't match, an error message is generated.
  480. //
  481. // ```proto
  482. // message MyFloat {
  483. // // value must equal 42.0
  484. // float value = 1 [(buf.validate.field).float.const = 42.0];
  485. // }
  486. // ```
  487. optional float const = 1 [(predefined).cel = {
  488. id: "float.const"
  489. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  490. }];
  491. oneof less_than {
  492. // `lt` requires the field value to be less than the specified value (field <
  493. // value). If the field value is equal to or greater than the specified value,
  494. // an error message is generated.
  495. //
  496. // ```proto
  497. // message MyFloat {
  498. // // must be less than 10.0
  499. // float value = 1 [(buf.validate.field).float.lt = 10.0];
  500. // }
  501. // ```
  502. float lt = 2 [(predefined).cel = {
  503. id: "float.lt"
  504. expression:
  505. "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this >= rules.lt)"
  506. "? 'must be less than %s'.format([rules.lt]) : ''"
  507. }];
  508. // `lte` requires the field value to be less than or equal to the specified
  509. // value (field <= value). If the field value is greater than the specified
  510. // value, an error message is generated.
  511. //
  512. // ```proto
  513. // message MyFloat {
  514. // // must be less than or equal to 10.0
  515. // float value = 1 [(buf.validate.field).float.lte = 10.0];
  516. // }
  517. // ```
  518. float lte = 3 [(predefined).cel = {
  519. id: "float.lte"
  520. expression:
  521. "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this > rules.lte)"
  522. "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
  523. }];
  524. }
  525. oneof greater_than {
  526. // `gt` requires the field value to be greater than the specified value
  527. // (exclusive). If the value of `gt` is larger than a specified `lt` or
  528. // `lte`, the range is reversed, and the field value must be outside the
  529. // specified range. If the field value doesn't meet the required conditions,
  530. // an error message is generated.
  531. //
  532. // ```proto
  533. // message MyFloat {
  534. // // must be greater than 5.0 [float.gt]
  535. // float value = 1 [(buf.validate.field).float.gt = 5.0];
  536. //
  537. // // must be greater than 5 and less than 10.0 [float.gt_lt]
  538. // float other_value = 2 [(buf.validate.field).float = { gt: 5.0, lt: 10.0 }];
  539. //
  540. // // must be greater than 10 or less than 5.0 [float.gt_lt_exclusive]
  541. // float another_value = 3 [(buf.validate.field).float = { gt: 10.0, lt: 5.0 }];
  542. // }
  543. // ```
  544. float gt = 4 [
  545. (predefined).cel = {
  546. id: "float.gt"
  547. expression:
  548. "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this <= rules.gt)"
  549. "? 'must be greater than %s'.format([rules.gt]) : ''"
  550. },
  551. (predefined).cel = {
  552. id: "float.gt_lt"
  553. expression:
  554. "has(rules.lt) && rules.lt >= rules.gt && (this.isNan() || this >= rules.lt || this <= rules.gt)"
  555. "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
  556. },
  557. (predefined).cel = {
  558. id: "float.gt_lt_exclusive"
  559. expression:
  560. "has(rules.lt) && rules.lt < rules.gt && (this.isNan() || (rules.lt <= this && this <= rules.gt))"
  561. "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
  562. },
  563. (predefined).cel = {
  564. id: "float.gt_lte"
  565. expression:
  566. "has(rules.lte) && rules.lte >= rules.gt && (this.isNan() || this > rules.lte || this <= rules.gt)"
  567. "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  568. },
  569. (predefined).cel = {
  570. id: "float.gt_lte_exclusive"
  571. expression:
  572. "has(rules.lte) && rules.lte < rules.gt && (this.isNan() || (rules.lte < this && this <= rules.gt))"
  573. "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  574. }
  575. ];
  576. // `gte` requires the field value to be greater than or equal to the specified
  577. // value (exclusive). If the value of `gte` is larger than a specified `lt`
  578. // or `lte`, the range is reversed, and the field value must be outside the
  579. // specified range. If the field value doesn't meet the required conditions,
  580. // an error message is generated.
  581. //
  582. // ```proto
  583. // message MyFloat {
  584. // // must be greater than or equal to 5.0 [float.gte]
  585. // float value = 1 [(buf.validate.field).float.gte = 5.0];
  586. //
  587. // // must be greater than or equal to 5.0 and less than 10.0 [float.gte_lt]
  588. // float other_value = 2 [(buf.validate.field).float = { gte: 5.0, lt: 10.0 }];
  589. //
  590. // // must be greater than or equal to 10.0 or less than 5.0 [float.gte_lt_exclusive]
  591. // float another_value = 3 [(buf.validate.field).float = { gte: 10.0, lt: 5.0 }];
  592. // }
  593. // ```
  594. float gte = 5 [
  595. (predefined).cel = {
  596. id: "float.gte"
  597. expression:
  598. "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this < rules.gte)"
  599. "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
  600. },
  601. (predefined).cel = {
  602. id: "float.gte_lt"
  603. expression:
  604. "has(rules.lt) && rules.lt >= rules.gte && (this.isNan() || this >= rules.lt || this < rules.gte)"
  605. "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
  606. },
  607. (predefined).cel = {
  608. id: "float.gte_lt_exclusive"
  609. expression:
  610. "has(rules.lt) && rules.lt < rules.gte && (this.isNan() || (rules.lt <= this && this < rules.gte))"
  611. "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
  612. },
  613. (predefined).cel = {
  614. id: "float.gte_lte"
  615. expression:
  616. "has(rules.lte) && rules.lte >= rules.gte && (this.isNan() || this > rules.lte || this < rules.gte)"
  617. "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  618. },
  619. (predefined).cel = {
  620. id: "float.gte_lte_exclusive"
  621. expression:
  622. "has(rules.lte) && rules.lte < rules.gte && (this.isNan() || (rules.lte < this && this < rules.gte))"
  623. "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  624. }
  625. ];
  626. }
  627. // `in` requires the field value to be equal to one of the specified values.
  628. // If the field value isn't one of the specified values, an error message
  629. // is generated.
  630. //
  631. // ```proto
  632. // message MyFloat {
  633. // // must be in list [1.0, 2.0, 3.0]
  634. // float value = 1 [(buf.validate.field).float = { in: [1.0, 2.0, 3.0] }];
  635. // }
  636. // ```
  637. repeated float in = 6 [(predefined).cel = {
  638. id: "float.in"
  639. expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  640. }];
  641. // `not_in` requires the field value to not be equal to any of the specified
  642. // values. If the field value is one of the specified values, an error
  643. // message is generated.
  644. //
  645. // ```proto
  646. // message MyFloat {
  647. // // value must not be in list [1.0, 2.0, 3.0]
  648. // float value = 1 [(buf.validate.field).float = { not_in: [1.0, 2.0, 3.0] }];
  649. // }
  650. // ```
  651. repeated float not_in = 7 [(predefined).cel = {
  652. id: "float.not_in"
  653. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  654. }];
  655. // `finite` requires the field value to be finite. If the field value is
  656. // infinite or NaN, an error message is generated.
  657. optional bool finite = 8 [(predefined).cel = {
  658. id: "float.finite"
  659. expression: "rules.finite ? (this.isNan() || this.isInf() ? 'must be finite' : '') : ''"
  660. }];
  661. // `example` specifies values that the field may have. These values SHOULD
  662. // conform to other rules. `example` values will not impact validation
  663. // but may be used as helpful guidance on how to populate the given field.
  664. //
  665. // ```proto
  666. // message MyFloat {
  667. // float value = 1 [
  668. // (buf.validate.field).float.example = 1.0,
  669. // (buf.validate.field).float.example = inf
  670. // ];
  671. // }
  672. // ```
  673. repeated float example = 9 [(predefined).cel = {
  674. id: "float.example"
  675. expression: "true"
  676. }];
  677. // Extension fields that have the (buf.validate.predefined) option set
  678. // will be treated as predefined field rules.
  679. // See https://protovalidate.com/schemas/predefined-rules/
  680. extensions 1000 to max;
  681. }
  682. // DoubleRules describes the rules applied to `double` values. These
  683. // rules may also be applied to the `google.protobuf.DoubleValue` Well-Known-Type.
  684. message DoubleRules {
  685. // `const` requires the field value to exactly match the specified value. If
  686. // the field value doesn't match, an error message is generated.
  687. //
  688. // ```proto
  689. // message MyDouble {
  690. // // value must equal 42.0
  691. // double value = 1 [(buf.validate.field).double.const = 42.0];
  692. // }
  693. // ```
  694. optional double const = 1 [(predefined).cel = {
  695. id: "double.const"
  696. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  697. }];
  698. oneof less_than {
  699. // `lt` requires the field value to be less than the specified value (field <
  700. // value). If the field value is equal to or greater than the specified
  701. // value, an error message is generated.
  702. //
  703. // ```proto
  704. // message MyDouble {
  705. // // must be less than 10.0
  706. // double value = 1 [(buf.validate.field).double.lt = 10.0];
  707. // }
  708. // ```
  709. double lt = 2 [(predefined).cel = {
  710. id: "double.lt"
  711. expression:
  712. "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this >= rules.lt)"
  713. "? 'must be less than %s'.format([rules.lt]) : ''"
  714. }];
  715. // `lte` requires the field value to be less than or equal to the specified value
  716. // (field <= value). If the field value is greater than the specified value,
  717. // an error message is generated.
  718. //
  719. // ```proto
  720. // message MyDouble {
  721. // // must be less than or equal to 10.0
  722. // double value = 1 [(buf.validate.field).double.lte = 10.0];
  723. // }
  724. // ```
  725. double lte = 3 [(predefined).cel = {
  726. id: "double.lte"
  727. expression:
  728. "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this > rules.lte)"
  729. "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
  730. }];
  731. }
  732. oneof greater_than {
  733. // `gt` requires the field value to be greater than the specified value
  734. // (exclusive). If the value of `gt` is larger than a specified `lt` or `lte`,
  735. // the range is reversed, and the field value must be outside the specified
  736. // range. If the field value doesn't meet the required conditions, an error
  737. // message is generated.
  738. //
  739. // ```proto
  740. // message MyDouble {
  741. // // must be greater than 5.0 [double.gt]
  742. // double value = 1 [(buf.validate.field).double.gt = 5.0];
  743. //
  744. // // must be greater than 5 and less than 10.0 [double.gt_lt]
  745. // double other_value = 2 [(buf.validate.field).double = { gt: 5.0, lt: 10.0 }];
  746. //
  747. // // must be greater than 10 or less than 5.0 [double.gt_lt_exclusive]
  748. // double another_value = 3 [(buf.validate.field).double = { gt: 10.0, lt: 5.0 }];
  749. // }
  750. // ```
  751. double gt = 4 [
  752. (predefined).cel = {
  753. id: "double.gt"
  754. expression:
  755. "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this <= rules.gt)"
  756. "? 'must be greater than %s'.format([rules.gt]) : ''"
  757. },
  758. (predefined).cel = {
  759. id: "double.gt_lt"
  760. expression:
  761. "has(rules.lt) && rules.lt >= rules.gt && (this.isNan() || this >= rules.lt || this <= rules.gt)"
  762. "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
  763. },
  764. (predefined).cel = {
  765. id: "double.gt_lt_exclusive"
  766. expression:
  767. "has(rules.lt) && rules.lt < rules.gt && (this.isNan() || (rules.lt <= this && this <= rules.gt))"
  768. "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
  769. },
  770. (predefined).cel = {
  771. id: "double.gt_lte"
  772. expression:
  773. "has(rules.lte) && rules.lte >= rules.gt && (this.isNan() || this > rules.lte || this <= rules.gt)"
  774. "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  775. },
  776. (predefined).cel = {
  777. id: "double.gt_lte_exclusive"
  778. expression:
  779. "has(rules.lte) && rules.lte < rules.gt && (this.isNan() || (rules.lte < this && this <= rules.gt))"
  780. "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  781. }
  782. ];
  783. // `gte` requires the field value to be greater than or equal to the specified
  784. // value (exclusive). If the value of `gte` is larger than a specified `lt` or
  785. // `lte`, the range is reversed, and the field value must be outside the
  786. // specified range. If the field value doesn't meet the required conditions,
  787. // an error message is generated.
  788. //
  789. // ```proto
  790. // message MyDouble {
  791. // // must be greater than or equal to 5.0 [double.gte]
  792. // double value = 1 [(buf.validate.field).double.gte = 5.0];
  793. //
  794. // // must be greater than or equal to 5.0 and less than 10.0 [double.gte_lt]
  795. // double other_value = 2 [(buf.validate.field).double = { gte: 5.0, lt: 10.0 }];
  796. //
  797. // // must be greater than or equal to 10.0 or less than 5.0 [double.gte_lt_exclusive]
  798. // double another_value = 3 [(buf.validate.field).double = { gte: 10.0, lt: 5.0 }];
  799. // }
  800. // ```
  801. double gte = 5 [
  802. (predefined).cel = {
  803. id: "double.gte"
  804. expression:
  805. "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this < rules.gte)"
  806. "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
  807. },
  808. (predefined).cel = {
  809. id: "double.gte_lt"
  810. expression:
  811. "has(rules.lt) && rules.lt >= rules.gte && (this.isNan() || this >= rules.lt || this < rules.gte)"
  812. "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
  813. },
  814. (predefined).cel = {
  815. id: "double.gte_lt_exclusive"
  816. expression:
  817. "has(rules.lt) && rules.lt < rules.gte && (this.isNan() || (rules.lt <= this && this < rules.gte))"
  818. "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
  819. },
  820. (predefined).cel = {
  821. id: "double.gte_lte"
  822. expression:
  823. "has(rules.lte) && rules.lte >= rules.gte && (this.isNan() || this > rules.lte || this < rules.gte)"
  824. "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  825. },
  826. (predefined).cel = {
  827. id: "double.gte_lte_exclusive"
  828. expression:
  829. "has(rules.lte) && rules.lte < rules.gte && (this.isNan() || (rules.lte < this && this < rules.gte))"
  830. "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  831. }
  832. ];
  833. }
  834. // `in` requires the field value to be equal to one of the specified values.
  835. // If the field value isn't one of the specified values, an error message is
  836. // generated.
  837. //
  838. // ```proto
  839. // message MyDouble {
  840. // // must be in list [1.0, 2.0, 3.0]
  841. // double value = 1 [(buf.validate.field).double = { in: [1.0, 2.0, 3.0] }];
  842. // }
  843. // ```
  844. repeated double in = 6 [(predefined).cel = {
  845. id: "double.in"
  846. expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  847. }];
  848. // `not_in` requires the field value to not be equal to any of the specified
  849. // values. If the field value is one of the specified values, an error
  850. // message is generated.
  851. //
  852. // ```proto
  853. // message MyDouble {
  854. // // value must not be in list [1.0, 2.0, 3.0]
  855. // double value = 1 [(buf.validate.field).double = { not_in: [1.0, 2.0, 3.0] }];
  856. // }
  857. // ```
  858. repeated double not_in = 7 [(predefined).cel = {
  859. id: "double.not_in"
  860. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  861. }];
  862. // `finite` requires the field value to be finite. If the field value is
  863. // infinite or NaN, an error message is generated.
  864. optional bool finite = 8 [(predefined).cel = {
  865. id: "double.finite"
  866. expression: "rules.finite ? (this.isNan() || this.isInf() ? 'must be finite' : '') : ''"
  867. }];
  868. // `example` specifies values that the field may have. These values SHOULD
  869. // conform to other rules. `example` values will not impact validation
  870. // but may be used as helpful guidance on how to populate the given field.
  871. //
  872. // ```proto
  873. // message MyDouble {
  874. // double value = 1 [
  875. // (buf.validate.field).double.example = 1.0,
  876. // (buf.validate.field).double.example = inf
  877. // ];
  878. // }
  879. // ```
  880. repeated double example = 9 [(predefined).cel = {
  881. id: "double.example"
  882. expression: "true"
  883. }];
  884. // Extension fields that have the (buf.validate.predefined) option set
  885. // will be treated as predefined field rules.
  886. // See https://protovalidate.com/schemas/predefined-rules/
  887. extensions 1000 to max;
  888. }
  889. // Int32Rules describes the rules applied to `int32` values. These
  890. // rules may also be applied to the `google.protobuf.Int32Value` Well-Known-Type.
  891. message Int32Rules {
  892. // `const` requires the field value to exactly match the specified value. If
  893. // the field value doesn't match, an error message is generated.
  894. //
  895. // ```proto
  896. // message MyInt32 {
  897. // // value must equal 42
  898. // int32 value = 1 [(buf.validate.field).int32.const = 42];
  899. // }
  900. // ```
  901. optional int32 const = 1 [(predefined).cel = {
  902. id: "int32.const"
  903. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  904. }];
  905. oneof less_than {
  906. // `lt` requires the field value to be less than the specified value (field
  907. // < value). If the field value is equal to or greater than the specified
  908. // value, an error message is generated.
  909. //
  910. // ```proto
  911. // message MyInt32 {
  912. // // must be less than 10
  913. // int32 value = 1 [(buf.validate.field).int32.lt = 10];
  914. // }
  915. // ```
  916. int32 lt = 2 [(predefined).cel = {
  917. id: "int32.lt"
  918. expression:
  919. "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
  920. "? 'must be less than %s'.format([rules.lt]) : ''"
  921. }];
  922. // `lte` requires the field value to be less than or equal to the specified
  923. // value (field <= value). If the field value is greater than the specified
  924. // value, an error message is generated.
  925. //
  926. // ```proto
  927. // message MyInt32 {
  928. // // must be less than or equal to 10
  929. // int32 value = 1 [(buf.validate.field).int32.lte = 10];
  930. // }
  931. // ```
  932. int32 lte = 3 [(predefined).cel = {
  933. id: "int32.lte"
  934. expression:
  935. "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
  936. "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
  937. }];
  938. }
  939. oneof greater_than {
  940. // `gt` requires the field value to be greater than the specified value
  941. // (exclusive). If the value of `gt` is larger than a specified `lt` or
  942. // `lte`, the range is reversed, and the field value must be outside the
  943. // specified range. If the field value doesn't meet the required conditions,
  944. // an error message is generated.
  945. //
  946. // ```proto
  947. // message MyInt32 {
  948. // // must be greater than 5 [int32.gt]
  949. // int32 value = 1 [(buf.validate.field).int32.gt = 5];
  950. //
  951. // // must be greater than 5 and less than 10 [int32.gt_lt]
  952. // int32 other_value = 2 [(buf.validate.field).int32 = { gt: 5, lt: 10 }];
  953. //
  954. // // must be greater than 10 or less than 5 [int32.gt_lt_exclusive]
  955. // int32 another_value = 3 [(buf.validate.field).int32 = { gt: 10, lt: 5 }];
  956. // }
  957. // ```
  958. int32 gt = 4 [
  959. (predefined).cel = {
  960. id: "int32.gt"
  961. expression:
  962. "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
  963. "? 'must be greater than %s'.format([rules.gt]) : ''"
  964. },
  965. (predefined).cel = {
  966. id: "int32.gt_lt"
  967. expression:
  968. "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
  969. "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
  970. },
  971. (predefined).cel = {
  972. id: "int32.gt_lt_exclusive"
  973. expression:
  974. "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
  975. "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
  976. },
  977. (predefined).cel = {
  978. id: "int32.gt_lte"
  979. expression:
  980. "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
  981. "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  982. },
  983. (predefined).cel = {
  984. id: "int32.gt_lte_exclusive"
  985. expression:
  986. "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
  987. "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  988. }
  989. ];
  990. // `gte` requires the field value to be greater than or equal to the specified value
  991. // (exclusive). If the value of `gte` is larger than a specified `lt` or
  992. // `lte`, the range is reversed, and the field value must be outside the
  993. // specified range. If the field value doesn't meet the required conditions,
  994. // an error message is generated.
  995. //
  996. // ```proto
  997. // message MyInt32 {
  998. // // must be greater than or equal to 5 [int32.gte]
  999. // int32 value = 1 [(buf.validate.field).int32.gte = 5];
  1000. //
  1001. // // must be greater than or equal to 5 and less than 10 [int32.gte_lt]
  1002. // int32 other_value = 2 [(buf.validate.field).int32 = { gte: 5, lt: 10 }];
  1003. //
  1004. // // must be greater than or equal to 10 or less than 5 [int32.gte_lt_exclusive]
  1005. // int32 another_value = 3 [(buf.validate.field).int32 = { gte: 10, lt: 5 }];
  1006. // }
  1007. // ```
  1008. int32 gte = 5 [
  1009. (predefined).cel = {
  1010. id: "int32.gte"
  1011. expression:
  1012. "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
  1013. "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
  1014. },
  1015. (predefined).cel = {
  1016. id: "int32.gte_lt"
  1017. expression:
  1018. "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
  1019. "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
  1020. },
  1021. (predefined).cel = {
  1022. id: "int32.gte_lt_exclusive"
  1023. expression:
  1024. "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
  1025. "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
  1026. },
  1027. (predefined).cel = {
  1028. id: "int32.gte_lte"
  1029. expression:
  1030. "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
  1031. "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  1032. },
  1033. (predefined).cel = {
  1034. id: "int32.gte_lte_exclusive"
  1035. expression:
  1036. "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
  1037. "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  1038. }
  1039. ];
  1040. }
  1041. // `in` requires the field value to be equal to one of the specified values.
  1042. // If the field value isn't one of the specified values, an error message is
  1043. // generated.
  1044. //
  1045. // ```proto
  1046. // message MyInt32 {
  1047. // // must be in list [1, 2, 3]
  1048. // int32 value = 1 [(buf.validate.field).int32 = { in: [1, 2, 3] }];
  1049. // }
  1050. // ```
  1051. repeated int32 in = 6 [(predefined).cel = {
  1052. id: "int32.in"
  1053. expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  1054. }];
  1055. // `not_in` requires the field value to not be equal to any of the specified
  1056. // values. If the field value is one of the specified values, an error message
  1057. // is generated.
  1058. //
  1059. // ```proto
  1060. // message MyInt32 {
  1061. // // value must not be in list [1, 2, 3]
  1062. // int32 value = 1 [(buf.validate.field).int32 = { not_in: [1, 2, 3] }];
  1063. // }
  1064. // ```
  1065. repeated int32 not_in = 7 [(predefined).cel = {
  1066. id: "int32.not_in"
  1067. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  1068. }];
  1069. // `example` specifies values that the field may have. These values SHOULD
  1070. // conform to other rules. `example` values will not impact validation
  1071. // but may be used as helpful guidance on how to populate the given field.
  1072. //
  1073. // ```proto
  1074. // message MyInt32 {
  1075. // int32 value = 1 [
  1076. // (buf.validate.field).int32.example = 1,
  1077. // (buf.validate.field).int32.example = -10
  1078. // ];
  1079. // }
  1080. // ```
  1081. repeated int32 example = 8 [(predefined).cel = {
  1082. id: "int32.example"
  1083. expression: "true"
  1084. }];
  1085. // Extension fields that have the (buf.validate.predefined) option set
  1086. // will be treated as predefined field rules.
  1087. // See https://protovalidate.com/schemas/predefined-rules/
  1088. extensions 1000 to max;
  1089. }
  1090. // Int64Rules describes the rules applied to `int64` values. These
  1091. // rules may also be applied to the `google.protobuf.Int64Value` Well-Known-Type.
  1092. message Int64Rules {
  1093. // `const` requires the field value to exactly match the specified value. If
  1094. // the field value doesn't match, an error message is generated.
  1095. //
  1096. // ```proto
  1097. // message MyInt64 {
  1098. // // value must equal 42
  1099. // int64 value = 1 [(buf.validate.field).int64.const = 42];
  1100. // }
  1101. // ```
  1102. optional int64 const = 1 [(predefined).cel = {
  1103. id: "int64.const"
  1104. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  1105. }];
  1106. oneof less_than {
  1107. // `lt` requires the field value to be less than the specified value (field <
  1108. // value). If the field value is equal to or greater than the specified value,
  1109. // an error message is generated.
  1110. //
  1111. // ```proto
  1112. // message MyInt64 {
  1113. // // must be less than 10
  1114. // int64 value = 1 [(buf.validate.field).int64.lt = 10];
  1115. // }
  1116. // ```
  1117. int64 lt = 2 [(predefined).cel = {
  1118. id: "int64.lt"
  1119. expression:
  1120. "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
  1121. "? 'must be less than %s'.format([rules.lt]) : ''"
  1122. }];
  1123. // `lte` requires the field value to be less than or equal to the specified
  1124. // value (field <= value). If the field value is greater than the specified
  1125. // value, an error message is generated.
  1126. //
  1127. // ```proto
  1128. // message MyInt64 {
  1129. // // must be less than or equal to 10
  1130. // int64 value = 1 [(buf.validate.field).int64.lte = 10];
  1131. // }
  1132. // ```
  1133. int64 lte = 3 [(predefined).cel = {
  1134. id: "int64.lte"
  1135. expression:
  1136. "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
  1137. "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
  1138. }];
  1139. }
  1140. oneof greater_than {
  1141. // `gt` requires the field value to be greater than the specified value
  1142. // (exclusive). If the value of `gt` is larger than a specified `lt` or
  1143. // `lte`, the range is reversed, and the field value must be outside the
  1144. // specified range. If the field value doesn't meet the required conditions,
  1145. // an error message is generated.
  1146. //
  1147. // ```proto
  1148. // message MyInt64 {
  1149. // // must be greater than 5 [int64.gt]
  1150. // int64 value = 1 [(buf.validate.field).int64.gt = 5];
  1151. //
  1152. // // must be greater than 5 and less than 10 [int64.gt_lt]
  1153. // int64 other_value = 2 [(buf.validate.field).int64 = { gt: 5, lt: 10 }];
  1154. //
  1155. // // must be greater than 10 or less than 5 [int64.gt_lt_exclusive]
  1156. // int64 another_value = 3 [(buf.validate.field).int64 = { gt: 10, lt: 5 }];
  1157. // }
  1158. // ```
  1159. int64 gt = 4 [
  1160. (predefined).cel = {
  1161. id: "int64.gt"
  1162. expression:
  1163. "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
  1164. "? 'must be greater than %s'.format([rules.gt]) : ''"
  1165. },
  1166. (predefined).cel = {
  1167. id: "int64.gt_lt"
  1168. expression:
  1169. "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
  1170. "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
  1171. },
  1172. (predefined).cel = {
  1173. id: "int64.gt_lt_exclusive"
  1174. expression:
  1175. "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
  1176. "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
  1177. },
  1178. (predefined).cel = {
  1179. id: "int64.gt_lte"
  1180. expression:
  1181. "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
  1182. "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  1183. },
  1184. (predefined).cel = {
  1185. id: "int64.gt_lte_exclusive"
  1186. expression:
  1187. "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
  1188. "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  1189. }
  1190. ];
  1191. // `gte` requires the field value to be greater than or equal to the specified
  1192. // value (exclusive). If the value of `gte` is larger than a specified `lt`
  1193. // or `lte`, the range is reversed, and the field value must be outside the
  1194. // specified range. If the field value doesn't meet the required conditions,
  1195. // an error message is generated.
  1196. //
  1197. // ```proto
  1198. // message MyInt64 {
  1199. // // must be greater than or equal to 5 [int64.gte]
  1200. // int64 value = 1 [(buf.validate.field).int64.gte = 5];
  1201. //
  1202. // // must be greater than or equal to 5 and less than 10 [int64.gte_lt]
  1203. // int64 other_value = 2 [(buf.validate.field).int64 = { gte: 5, lt: 10 }];
  1204. //
  1205. // // must be greater than or equal to 10 or less than 5 [int64.gte_lt_exclusive]
  1206. // int64 another_value = 3 [(buf.validate.field).int64 = { gte: 10, lt: 5 }];
  1207. // }
  1208. // ```
  1209. int64 gte = 5 [
  1210. (predefined).cel = {
  1211. id: "int64.gte"
  1212. expression:
  1213. "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
  1214. "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
  1215. },
  1216. (predefined).cel = {
  1217. id: "int64.gte_lt"
  1218. expression:
  1219. "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
  1220. "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
  1221. },
  1222. (predefined).cel = {
  1223. id: "int64.gte_lt_exclusive"
  1224. expression:
  1225. "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
  1226. "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
  1227. },
  1228. (predefined).cel = {
  1229. id: "int64.gte_lte"
  1230. expression:
  1231. "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
  1232. "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  1233. },
  1234. (predefined).cel = {
  1235. id: "int64.gte_lte_exclusive"
  1236. expression:
  1237. "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
  1238. "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  1239. }
  1240. ];
  1241. }
  1242. // `in` requires the field value to be equal to one of the specified values.
  1243. // If the field value isn't one of the specified values, an error message is
  1244. // generated.
  1245. //
  1246. // ```proto
  1247. // message MyInt64 {
  1248. // // must be in list [1, 2, 3]
  1249. // int64 value = 1 [(buf.validate.field).int64 = { in: [1, 2, 3] }];
  1250. // }
  1251. // ```
  1252. repeated int64 in = 6 [(predefined).cel = {
  1253. id: "int64.in"
  1254. expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  1255. }];
  1256. // `not_in` requires the field value to not be equal to any of the specified
  1257. // values. If the field value is one of the specified values, an error
  1258. // message is generated.
  1259. //
  1260. // ```proto
  1261. // message MyInt64 {
  1262. // // value must not be in list [1, 2, 3]
  1263. // int64 value = 1 [(buf.validate.field).int64 = { not_in: [1, 2, 3] }];
  1264. // }
  1265. // ```
  1266. repeated int64 not_in = 7 [(predefined).cel = {
  1267. id: "int64.not_in"
  1268. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  1269. }];
  1270. // `example` specifies values that the field may have. These values SHOULD
  1271. // conform to other rules. `example` values will not impact validation
  1272. // but may be used as helpful guidance on how to populate the given field.
  1273. //
  1274. // ```proto
  1275. // message MyInt64 {
  1276. // int64 value = 1 [
  1277. // (buf.validate.field).int64.example = 1,
  1278. // (buf.validate.field).int64.example = -10
  1279. // ];
  1280. // }
  1281. // ```
  1282. repeated int64 example = 9 [(predefined).cel = {
  1283. id: "int64.example"
  1284. expression: "true"
  1285. }];
  1286. // Extension fields that have the (buf.validate.predefined) option set
  1287. // will be treated as predefined field rules.
  1288. // See https://protovalidate.com/schemas/predefined-rules/
  1289. extensions 1000 to max;
  1290. }
  1291. // UInt32Rules describes the rules applied to `uint32` values. These
  1292. // rules may also be applied to the `google.protobuf.UInt32Value` Well-Known-Type.
  1293. message UInt32Rules {
  1294. // `const` requires the field value to exactly match the specified value. If
  1295. // the field value doesn't match, an error message is generated.
  1296. //
  1297. // ```proto
  1298. // message MyUInt32 {
  1299. // // value must equal 42
  1300. // uint32 value = 1 [(buf.validate.field).uint32.const = 42];
  1301. // }
  1302. // ```
  1303. optional uint32 const = 1 [(predefined).cel = {
  1304. id: "uint32.const"
  1305. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  1306. }];
  1307. oneof less_than {
  1308. // `lt` requires the field value to be less than the specified value (field <
  1309. // value). If the field value is equal to or greater than the specified value,
  1310. // an error message is generated.
  1311. //
  1312. // ```proto
  1313. // message MyUInt32 {
  1314. // // must be less than 10
  1315. // uint32 value = 1 [(buf.validate.field).uint32.lt = 10];
  1316. // }
  1317. // ```
  1318. uint32 lt = 2 [(predefined).cel = {
  1319. id: "uint32.lt"
  1320. expression:
  1321. "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
  1322. "? 'must be less than %s'.format([rules.lt]) : ''"
  1323. }];
  1324. // `lte` requires the field value to be less than or equal to the specified
  1325. // value (field <= value). If the field value is greater than the specified
  1326. // value, an error message is generated.
  1327. //
  1328. // ```proto
  1329. // message MyUInt32 {
  1330. // // must be less than or equal to 10
  1331. // uint32 value = 1 [(buf.validate.field).uint32.lte = 10];
  1332. // }
  1333. // ```
  1334. uint32 lte = 3 [(predefined).cel = {
  1335. id: "uint32.lte"
  1336. expression:
  1337. "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
  1338. "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
  1339. }];
  1340. }
  1341. oneof greater_than {
  1342. // `gt` requires the field value to be greater than the specified value
  1343. // (exclusive). If the value of `gt` is larger than a specified `lt` or
  1344. // `lte`, the range is reversed, and the field value must be outside the
  1345. // specified range. If the field value doesn't meet the required conditions,
  1346. // an error message is generated.
  1347. //
  1348. // ```proto
  1349. // message MyUInt32 {
  1350. // // must be greater than 5 [uint32.gt]
  1351. // uint32 value = 1 [(buf.validate.field).uint32.gt = 5];
  1352. //
  1353. // // must be greater than 5 and less than 10 [uint32.gt_lt]
  1354. // uint32 other_value = 2 [(buf.validate.field).uint32 = { gt: 5, lt: 10 }];
  1355. //
  1356. // // must be greater than 10 or less than 5 [uint32.gt_lt_exclusive]
  1357. // uint32 another_value = 3 [(buf.validate.field).uint32 = { gt: 10, lt: 5 }];
  1358. // }
  1359. // ```
  1360. uint32 gt = 4 [
  1361. (predefined).cel = {
  1362. id: "uint32.gt"
  1363. expression:
  1364. "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
  1365. "? 'must be greater than %s'.format([rules.gt]) : ''"
  1366. },
  1367. (predefined).cel = {
  1368. id: "uint32.gt_lt"
  1369. expression:
  1370. "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
  1371. "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
  1372. },
  1373. (predefined).cel = {
  1374. id: "uint32.gt_lt_exclusive"
  1375. expression:
  1376. "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
  1377. "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
  1378. },
  1379. (predefined).cel = {
  1380. id: "uint32.gt_lte"
  1381. expression:
  1382. "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
  1383. "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  1384. },
  1385. (predefined).cel = {
  1386. id: "uint32.gt_lte_exclusive"
  1387. expression:
  1388. "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
  1389. "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  1390. }
  1391. ];
  1392. // `gte` requires the field value to be greater than or equal to the specified
  1393. // value (exclusive). If the value of `gte` is larger than a specified `lt`
  1394. // or `lte`, the range is reversed, and the field value must be outside the
  1395. // specified range. If the field value doesn't meet the required conditions,
  1396. // an error message is generated.
  1397. //
  1398. // ```proto
  1399. // message MyUInt32 {
  1400. // // must be greater than or equal to 5 [uint32.gte]
  1401. // uint32 value = 1 [(buf.validate.field).uint32.gte = 5];
  1402. //
  1403. // // must be greater than or equal to 5 and less than 10 [uint32.gte_lt]
  1404. // uint32 other_value = 2 [(buf.validate.field).uint32 = { gte: 5, lt: 10 }];
  1405. //
  1406. // // must be greater than or equal to 10 or less than 5 [uint32.gte_lt_exclusive]
  1407. // uint32 another_value = 3 [(buf.validate.field).uint32 = { gte: 10, lt: 5 }];
  1408. // }
  1409. // ```
  1410. uint32 gte = 5 [
  1411. (predefined).cel = {
  1412. id: "uint32.gte"
  1413. expression:
  1414. "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
  1415. "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
  1416. },
  1417. (predefined).cel = {
  1418. id: "uint32.gte_lt"
  1419. expression:
  1420. "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
  1421. "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
  1422. },
  1423. (predefined).cel = {
  1424. id: "uint32.gte_lt_exclusive"
  1425. expression:
  1426. "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
  1427. "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
  1428. },
  1429. (predefined).cel = {
  1430. id: "uint32.gte_lte"
  1431. expression:
  1432. "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
  1433. "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  1434. },
  1435. (predefined).cel = {
  1436. id: "uint32.gte_lte_exclusive"
  1437. expression:
  1438. "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
  1439. "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  1440. }
  1441. ];
  1442. }
  1443. // `in` requires the field value to be equal to one of the specified values.
  1444. // If the field value isn't one of the specified values, an error message is
  1445. // generated.
  1446. //
  1447. // ```proto
  1448. // message MyUInt32 {
  1449. // // must be in list [1, 2, 3]
  1450. // uint32 value = 1 [(buf.validate.field).uint32 = { in: [1, 2, 3] }];
  1451. // }
  1452. // ```
  1453. repeated uint32 in = 6 [(predefined).cel = {
  1454. id: "uint32.in"
  1455. expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  1456. }];
  1457. // `not_in` requires the field value to not be equal to any of the specified
  1458. // values. If the field value is one of the specified values, an error
  1459. // message is generated.
  1460. //
  1461. // ```proto
  1462. // message MyUInt32 {
  1463. // // value must not be in list [1, 2, 3]
  1464. // uint32 value = 1 [(buf.validate.field).uint32 = { not_in: [1, 2, 3] }];
  1465. // }
  1466. // ```
  1467. repeated uint32 not_in = 7 [(predefined).cel = {
  1468. id: "uint32.not_in"
  1469. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  1470. }];
  1471. // `example` specifies values that the field may have. These values SHOULD
  1472. // conform to other rules. `example` values will not impact validation
  1473. // but may be used as helpful guidance on how to populate the given field.
  1474. //
  1475. // ```proto
  1476. // message MyUInt32 {
  1477. // uint32 value = 1 [
  1478. // (buf.validate.field).uint32.example = 1,
  1479. // (buf.validate.field).uint32.example = 10
  1480. // ];
  1481. // }
  1482. // ```
  1483. repeated uint32 example = 8 [(predefined).cel = {
  1484. id: "uint32.example"
  1485. expression: "true"
  1486. }];
  1487. // Extension fields that have the (buf.validate.predefined) option set
  1488. // will be treated as predefined field rules.
  1489. // See https://protovalidate.com/schemas/predefined-rules/
  1490. extensions 1000 to max;
  1491. }
  1492. // UInt64Rules describes the rules applied to `uint64` values. These
  1493. // rules may also be applied to the `google.protobuf.UInt64Value` Well-Known-Type.
  1494. message UInt64Rules {
  1495. // `const` requires the field value to exactly match the specified value. If
  1496. // the field value doesn't match, an error message is generated.
  1497. //
  1498. // ```proto
  1499. // message MyUInt64 {
  1500. // // value must equal 42
  1501. // uint64 value = 1 [(buf.validate.field).uint64.const = 42];
  1502. // }
  1503. // ```
  1504. optional uint64 const = 1 [(predefined).cel = {
  1505. id: "uint64.const"
  1506. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  1507. }];
  1508. oneof less_than {
  1509. // `lt` requires the field value to be less than the specified value (field <
  1510. // value). If the field value is equal to or greater than the specified value,
  1511. // an error message is generated.
  1512. //
  1513. // ```proto
  1514. // message MyUInt64 {
  1515. // // must be less than 10
  1516. // uint64 value = 1 [(buf.validate.field).uint64.lt = 10];
  1517. // }
  1518. // ```
  1519. uint64 lt = 2 [(predefined).cel = {
  1520. id: "uint64.lt"
  1521. expression:
  1522. "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
  1523. "? 'must be less than %s'.format([rules.lt]) : ''"
  1524. }];
  1525. // `lte` requires the field value to be less than or equal to the specified
  1526. // value (field <= value). If the field value is greater than the specified
  1527. // value, an error message is generated.
  1528. //
  1529. // ```proto
  1530. // message MyUInt64 {
  1531. // // must be less than or equal to 10
  1532. // uint64 value = 1 [(buf.validate.field).uint64.lte = 10];
  1533. // }
  1534. // ```
  1535. uint64 lte = 3 [(predefined).cel = {
  1536. id: "uint64.lte"
  1537. expression:
  1538. "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
  1539. "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
  1540. }];
  1541. }
  1542. oneof greater_than {
  1543. // `gt` requires the field value to be greater than the specified value
  1544. // (exclusive). If the value of `gt` is larger than a specified `lt` or
  1545. // `lte`, the range is reversed, and the field value must be outside the
  1546. // specified range. If the field value doesn't meet the required conditions,
  1547. // an error message is generated.
  1548. //
  1549. // ```proto
  1550. // message MyUInt64 {
  1551. // // must be greater than 5 [uint64.gt]
  1552. // uint64 value = 1 [(buf.validate.field).uint64.gt = 5];
  1553. //
  1554. // // must be greater than 5 and less than 10 [uint64.gt_lt]
  1555. // uint64 other_value = 2 [(buf.validate.field).uint64 = { gt: 5, lt: 10 }];
  1556. //
  1557. // // must be greater than 10 or less than 5 [uint64.gt_lt_exclusive]
  1558. // uint64 another_value = 3 [(buf.validate.field).uint64 = { gt: 10, lt: 5 }];
  1559. // }
  1560. // ```
  1561. uint64 gt = 4 [
  1562. (predefined).cel = {
  1563. id: "uint64.gt"
  1564. expression:
  1565. "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
  1566. "? 'must be greater than %s'.format([rules.gt]) : ''"
  1567. },
  1568. (predefined).cel = {
  1569. id: "uint64.gt_lt"
  1570. expression:
  1571. "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
  1572. "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
  1573. },
  1574. (predefined).cel = {
  1575. id: "uint64.gt_lt_exclusive"
  1576. expression:
  1577. "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
  1578. "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
  1579. },
  1580. (predefined).cel = {
  1581. id: "uint64.gt_lte"
  1582. expression:
  1583. "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
  1584. "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  1585. },
  1586. (predefined).cel = {
  1587. id: "uint64.gt_lte_exclusive"
  1588. expression:
  1589. "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
  1590. "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  1591. }
  1592. ];
  1593. // `gte` requires the field value to be greater than or equal to the specified
  1594. // value (exclusive). If the value of `gte` is larger than a specified `lt`
  1595. // or `lte`, the range is reversed, and the field value must be outside the
  1596. // specified range. If the field value doesn't meet the required conditions,
  1597. // an error message is generated.
  1598. //
  1599. // ```proto
  1600. // message MyUInt64 {
  1601. // // must be greater than or equal to 5 [uint64.gte]
  1602. // uint64 value = 1 [(buf.validate.field).uint64.gte = 5];
  1603. //
  1604. // // must be greater than or equal to 5 and less than 10 [uint64.gte_lt]
  1605. // uint64 other_value = 2 [(buf.validate.field).uint64 = { gte: 5, lt: 10 }];
  1606. //
  1607. // // must be greater than or equal to 10 or less than 5 [uint64.gte_lt_exclusive]
  1608. // uint64 another_value = 3 [(buf.validate.field).uint64 = { gte: 10, lt: 5 }];
  1609. // }
  1610. // ```
  1611. uint64 gte = 5 [
  1612. (predefined).cel = {
  1613. id: "uint64.gte"
  1614. expression:
  1615. "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
  1616. "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
  1617. },
  1618. (predefined).cel = {
  1619. id: "uint64.gte_lt"
  1620. expression:
  1621. "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
  1622. "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
  1623. },
  1624. (predefined).cel = {
  1625. id: "uint64.gte_lt_exclusive"
  1626. expression:
  1627. "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
  1628. "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
  1629. },
  1630. (predefined).cel = {
  1631. id: "uint64.gte_lte"
  1632. expression:
  1633. "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
  1634. "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  1635. },
  1636. (predefined).cel = {
  1637. id: "uint64.gte_lte_exclusive"
  1638. expression:
  1639. "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
  1640. "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  1641. }
  1642. ];
  1643. }
  1644. // `in` requires the field value to be equal to one of the specified values.
  1645. // If the field value isn't one of the specified values, an error message is
  1646. // generated.
  1647. //
  1648. // ```proto
  1649. // message MyUInt64 {
  1650. // // must be in list [1, 2, 3]
  1651. // uint64 value = 1 [(buf.validate.field).uint64 = { in: [1, 2, 3] }];
  1652. // }
  1653. // ```
  1654. repeated uint64 in = 6 [(predefined).cel = {
  1655. id: "uint64.in"
  1656. expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  1657. }];
  1658. // `not_in` requires the field value to not be equal to any of the specified
  1659. // values. If the field value is one of the specified values, an error
  1660. // message is generated.
  1661. //
  1662. // ```proto
  1663. // message MyUInt64 {
  1664. // // value must not be in list [1, 2, 3]
  1665. // uint64 value = 1 [(buf.validate.field).uint64 = { not_in: [1, 2, 3] }];
  1666. // }
  1667. // ```
  1668. repeated uint64 not_in = 7 [(predefined).cel = {
  1669. id: "uint64.not_in"
  1670. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  1671. }];
  1672. // `example` specifies values that the field may have. These values SHOULD
  1673. // conform to other rules. `example` values will not impact validation
  1674. // but may be used as helpful guidance on how to populate the given field.
  1675. //
  1676. // ```proto
  1677. // message MyUInt64 {
  1678. // uint64 value = 1 [
  1679. // (buf.validate.field).uint64.example = 1,
  1680. // (buf.validate.field).uint64.example = 10
  1681. // ];
  1682. // }
  1683. // ```
  1684. repeated uint64 example = 8 [(predefined).cel = {
  1685. id: "uint64.example"
  1686. expression: "true"
  1687. }];
  1688. // Extension fields that have the (buf.validate.predefined) option set
  1689. // will be treated as predefined field rules.
  1690. // See https://protovalidate.com/schemas/predefined-rules/
  1691. extensions 1000 to max;
  1692. }
  1693. // SInt32Rules describes the rules applied to `sint32` values.
  1694. message SInt32Rules {
  1695. // `const` requires the field value to exactly match the specified value. If
  1696. // the field value doesn't match, an error message is generated.
  1697. //
  1698. // ```proto
  1699. // message MySInt32 {
  1700. // // value must equal 42
  1701. // sint32 value = 1 [(buf.validate.field).sint32.const = 42];
  1702. // }
  1703. // ```
  1704. optional sint32 const = 1 [(predefined).cel = {
  1705. id: "sint32.const"
  1706. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  1707. }];
  1708. oneof less_than {
  1709. // `lt` requires the field value to be less than the specified value (field
  1710. // < value). If the field value is equal to or greater than the specified
  1711. // value, an error message is generated.
  1712. //
  1713. // ```proto
  1714. // message MySInt32 {
  1715. // // must be less than 10
  1716. // sint32 value = 1 [(buf.validate.field).sint32.lt = 10];
  1717. // }
  1718. // ```
  1719. sint32 lt = 2 [(predefined).cel = {
  1720. id: "sint32.lt"
  1721. expression:
  1722. "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
  1723. "? 'must be less than %s'.format([rules.lt]) : ''"
  1724. }];
  1725. // `lte` requires the field value to be less than or equal to the specified
  1726. // value (field <= value). If the field value is greater than the specified
  1727. // value, an error message is generated.
  1728. //
  1729. // ```proto
  1730. // message MySInt32 {
  1731. // // must be less than or equal to 10
  1732. // sint32 value = 1 [(buf.validate.field).sint32.lte = 10];
  1733. // }
  1734. // ```
  1735. sint32 lte = 3 [(predefined).cel = {
  1736. id: "sint32.lte"
  1737. expression:
  1738. "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
  1739. "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
  1740. }];
  1741. }
  1742. oneof greater_than {
  1743. // `gt` requires the field value to be greater than the specified value
  1744. // (exclusive). If the value of `gt` is larger than a specified `lt` or
  1745. // `lte`, the range is reversed, and the field value must be outside the
  1746. // specified range. If the field value doesn't meet the required conditions,
  1747. // an error message is generated.
  1748. //
  1749. // ```proto
  1750. // message MySInt32 {
  1751. // // must be greater than 5 [sint32.gt]
  1752. // sint32 value = 1 [(buf.validate.field).sint32.gt = 5];
  1753. //
  1754. // // must be greater than 5 and less than 10 [sint32.gt_lt]
  1755. // sint32 other_value = 2 [(buf.validate.field).sint32 = { gt: 5, lt: 10 }];
  1756. //
  1757. // // must be greater than 10 or less than 5 [sint32.gt_lt_exclusive]
  1758. // sint32 another_value = 3 [(buf.validate.field).sint32 = { gt: 10, lt: 5 }];
  1759. // }
  1760. // ```
  1761. sint32 gt = 4 [
  1762. (predefined).cel = {
  1763. id: "sint32.gt"
  1764. expression:
  1765. "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
  1766. "? 'must be greater than %s'.format([rules.gt]) : ''"
  1767. },
  1768. (predefined).cel = {
  1769. id: "sint32.gt_lt"
  1770. expression:
  1771. "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
  1772. "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
  1773. },
  1774. (predefined).cel = {
  1775. id: "sint32.gt_lt_exclusive"
  1776. expression:
  1777. "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
  1778. "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
  1779. },
  1780. (predefined).cel = {
  1781. id: "sint32.gt_lte"
  1782. expression:
  1783. "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
  1784. "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  1785. },
  1786. (predefined).cel = {
  1787. id: "sint32.gt_lte_exclusive"
  1788. expression:
  1789. "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
  1790. "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  1791. }
  1792. ];
  1793. // `gte` requires the field value to be greater than or equal to the specified
  1794. // value (exclusive). If the value of `gte` is larger than a specified `lt`
  1795. // or `lte`, the range is reversed, and the field value must be outside the
  1796. // specified range. If the field value doesn't meet the required conditions,
  1797. // an error message is generated.
  1798. //
  1799. // ```proto
  1800. // message MySInt32 {
  1801. // // must be greater than or equal to 5 [sint32.gte]
  1802. // sint32 value = 1 [(buf.validate.field).sint32.gte = 5];
  1803. //
  1804. // // must be greater than or equal to 5 and less than 10 [sint32.gte_lt]
  1805. // sint32 other_value = 2 [(buf.validate.field).sint32 = { gte: 5, lt: 10 }];
  1806. //
  1807. // // must be greater than or equal to 10 or less than 5 [sint32.gte_lt_exclusive]
  1808. // sint32 another_value = 3 [(buf.validate.field).sint32 = { gte: 10, lt: 5 }];
  1809. // }
  1810. // ```
  1811. sint32 gte = 5 [
  1812. (predefined).cel = {
  1813. id: "sint32.gte"
  1814. expression:
  1815. "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
  1816. "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
  1817. },
  1818. (predefined).cel = {
  1819. id: "sint32.gte_lt"
  1820. expression:
  1821. "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
  1822. "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
  1823. },
  1824. (predefined).cel = {
  1825. id: "sint32.gte_lt_exclusive"
  1826. expression:
  1827. "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
  1828. "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
  1829. },
  1830. (predefined).cel = {
  1831. id: "sint32.gte_lte"
  1832. expression:
  1833. "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
  1834. "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  1835. },
  1836. (predefined).cel = {
  1837. id: "sint32.gte_lte_exclusive"
  1838. expression:
  1839. "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
  1840. "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  1841. }
  1842. ];
  1843. }
  1844. // `in` requires the field value to be equal to one of the specified values.
  1845. // If the field value isn't one of the specified values, an error message is
  1846. // generated.
  1847. //
  1848. // ```proto
  1849. // message MySInt32 {
  1850. // // must be in list [1, 2, 3]
  1851. // sint32 value = 1 [(buf.validate.field).sint32 = { in: [1, 2, 3] }];
  1852. // }
  1853. // ```
  1854. repeated sint32 in = 6 [(predefined).cel = {
  1855. id: "sint32.in"
  1856. expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  1857. }];
  1858. // `not_in` requires the field value to not be equal to any of the specified
  1859. // values. If the field value is one of the specified values, an error
  1860. // message is generated.
  1861. //
  1862. // ```proto
  1863. // message MySInt32 {
  1864. // // value must not be in list [1, 2, 3]
  1865. // sint32 value = 1 [(buf.validate.field).sint32 = { not_in: [1, 2, 3] }];
  1866. // }
  1867. // ```
  1868. repeated sint32 not_in = 7 [(predefined).cel = {
  1869. id: "sint32.not_in"
  1870. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  1871. }];
  1872. // `example` specifies values that the field may have. These values SHOULD
  1873. // conform to other rules. `example` values will not impact validation
  1874. // but may be used as helpful guidance on how to populate the given field.
  1875. //
  1876. // ```proto
  1877. // message MySInt32 {
  1878. // sint32 value = 1 [
  1879. // (buf.validate.field).sint32.example = 1,
  1880. // (buf.validate.field).sint32.example = -10
  1881. // ];
  1882. // }
  1883. // ```
  1884. repeated sint32 example = 8 [(predefined).cel = {
  1885. id: "sint32.example"
  1886. expression: "true"
  1887. }];
  1888. // Extension fields that have the (buf.validate.predefined) option set
  1889. // will be treated as predefined field rules.
  1890. // See https://protovalidate.com/schemas/predefined-rules/
  1891. extensions 1000 to max;
  1892. }
  1893. // SInt64Rules describes the rules applied to `sint64` values.
  1894. message SInt64Rules {
  1895. // `const` requires the field value to exactly match the specified value. If
  1896. // the field value doesn't match, an error message is generated.
  1897. //
  1898. // ```proto
  1899. // message MySInt64 {
  1900. // // value must equal 42
  1901. // sint64 value = 1 [(buf.validate.field).sint64.const = 42];
  1902. // }
  1903. // ```
  1904. optional sint64 const = 1 [(predefined).cel = {
  1905. id: "sint64.const"
  1906. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  1907. }];
  1908. oneof less_than {
  1909. // `lt` requires the field value to be less than the specified value (field
  1910. // < value). If the field value is equal to or greater than the specified
  1911. // value, an error message is generated.
  1912. //
  1913. // ```proto
  1914. // message MySInt64 {
  1915. // // must be less than 10
  1916. // sint64 value = 1 [(buf.validate.field).sint64.lt = 10];
  1917. // }
  1918. // ```
  1919. sint64 lt = 2 [(predefined).cel = {
  1920. id: "sint64.lt"
  1921. expression:
  1922. "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
  1923. "? 'must be less than %s'.format([rules.lt]) : ''"
  1924. }];
  1925. // `lte` requires the field value to be less than or equal to the specified
  1926. // value (field <= value). If the field value is greater than the specified
  1927. // value, an error message is generated.
  1928. //
  1929. // ```proto
  1930. // message MySInt64 {
  1931. // // must be less than or equal to 10
  1932. // sint64 value = 1 [(buf.validate.field).sint64.lte = 10];
  1933. // }
  1934. // ```
  1935. sint64 lte = 3 [(predefined).cel = {
  1936. id: "sint64.lte"
  1937. expression:
  1938. "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
  1939. "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
  1940. }];
  1941. }
  1942. oneof greater_than {
  1943. // `gt` requires the field value to be greater than the specified value
  1944. // (exclusive). If the value of `gt` is larger than a specified `lt` or
  1945. // `lte`, the range is reversed, and the field value must be outside the
  1946. // specified range. If the field value doesn't meet the required conditions,
  1947. // an error message is generated.
  1948. //
  1949. // ```proto
  1950. // message MySInt64 {
  1951. // // must be greater than 5 [sint64.gt]
  1952. // sint64 value = 1 [(buf.validate.field).sint64.gt = 5];
  1953. //
  1954. // // must be greater than 5 and less than 10 [sint64.gt_lt]
  1955. // sint64 other_value = 2 [(buf.validate.field).sint64 = { gt: 5, lt: 10 }];
  1956. //
  1957. // // must be greater than 10 or less than 5 [sint64.gt_lt_exclusive]
  1958. // sint64 another_value = 3 [(buf.validate.field).sint64 = { gt: 10, lt: 5 }];
  1959. // }
  1960. // ```
  1961. sint64 gt = 4 [
  1962. (predefined).cel = {
  1963. id: "sint64.gt"
  1964. expression:
  1965. "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
  1966. "? 'must be greater than %s'.format([rules.gt]) : ''"
  1967. },
  1968. (predefined).cel = {
  1969. id: "sint64.gt_lt"
  1970. expression:
  1971. "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
  1972. "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
  1973. },
  1974. (predefined).cel = {
  1975. id: "sint64.gt_lt_exclusive"
  1976. expression:
  1977. "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
  1978. "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
  1979. },
  1980. (predefined).cel = {
  1981. id: "sint64.gt_lte"
  1982. expression:
  1983. "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
  1984. "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  1985. },
  1986. (predefined).cel = {
  1987. id: "sint64.gt_lte_exclusive"
  1988. expression:
  1989. "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
  1990. "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  1991. }
  1992. ];
  1993. // `gte` requires the field value to be greater than or equal to the specified
  1994. // value (exclusive). If the value of `gte` is larger than a specified `lt`
  1995. // or `lte`, the range is reversed, and the field value must be outside the
  1996. // specified range. If the field value doesn't meet the required conditions,
  1997. // an error message is generated.
  1998. //
  1999. // ```proto
  2000. // message MySInt64 {
  2001. // // must be greater than or equal to 5 [sint64.gte]
  2002. // sint64 value = 1 [(buf.validate.field).sint64.gte = 5];
  2003. //
  2004. // // must be greater than or equal to 5 and less than 10 [sint64.gte_lt]
  2005. // sint64 other_value = 2 [(buf.validate.field).sint64 = { gte: 5, lt: 10 }];
  2006. //
  2007. // // must be greater than or equal to 10 or less than 5 [sint64.gte_lt_exclusive]
  2008. // sint64 another_value = 3 [(buf.validate.field).sint64 = { gte: 10, lt: 5 }];
  2009. // }
  2010. // ```
  2011. sint64 gte = 5 [
  2012. (predefined).cel = {
  2013. id: "sint64.gte"
  2014. expression:
  2015. "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
  2016. "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
  2017. },
  2018. (predefined).cel = {
  2019. id: "sint64.gte_lt"
  2020. expression:
  2021. "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
  2022. "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
  2023. },
  2024. (predefined).cel = {
  2025. id: "sint64.gte_lt_exclusive"
  2026. expression:
  2027. "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
  2028. "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
  2029. },
  2030. (predefined).cel = {
  2031. id: "sint64.gte_lte"
  2032. expression:
  2033. "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
  2034. "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  2035. },
  2036. (predefined).cel = {
  2037. id: "sint64.gte_lte_exclusive"
  2038. expression:
  2039. "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
  2040. "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  2041. }
  2042. ];
  2043. }
  2044. // `in` requires the field value to be equal to one of the specified values.
  2045. // If the field value isn't one of the specified values, an error message
  2046. // is generated.
  2047. //
  2048. // ```proto
  2049. // message MySInt64 {
  2050. // // must be in list [1, 2, 3]
  2051. // sint64 value = 1 [(buf.validate.field).sint64 = { in: [1, 2, 3] }];
  2052. // }
  2053. // ```
  2054. repeated sint64 in = 6 [(predefined).cel = {
  2055. id: "sint64.in"
  2056. expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  2057. }];
  2058. // `not_in` requires the field value to not be equal to any of the specified
  2059. // values. If the field value is one of the specified values, an error
  2060. // message is generated.
  2061. //
  2062. // ```proto
  2063. // message MySInt64 {
  2064. // // value must not be in list [1, 2, 3]
  2065. // sint64 value = 1 [(buf.validate.field).sint64 = { not_in: [1, 2, 3] }];
  2066. // }
  2067. // ```
  2068. repeated sint64 not_in = 7 [(predefined).cel = {
  2069. id: "sint64.not_in"
  2070. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  2071. }];
  2072. // `example` specifies values that the field may have. These values SHOULD
  2073. // conform to other rules. `example` values will not impact validation
  2074. // but may be used as helpful guidance on how to populate the given field.
  2075. //
  2076. // ```proto
  2077. // message MySInt64 {
  2078. // sint64 value = 1 [
  2079. // (buf.validate.field).sint64.example = 1,
  2080. // (buf.validate.field).sint64.example = -10
  2081. // ];
  2082. // }
  2083. // ```
  2084. repeated sint64 example = 8 [(predefined).cel = {
  2085. id: "sint64.example"
  2086. expression: "true"
  2087. }];
  2088. // Extension fields that have the (buf.validate.predefined) option set
  2089. // will be treated as predefined field rules.
  2090. // See https://protovalidate.com/schemas/predefined-rules/
  2091. extensions 1000 to max;
  2092. }
  2093. // Fixed32Rules describes the rules applied to `fixed32` values.
  2094. message Fixed32Rules {
  2095. // `const` requires the field value to exactly match the specified value.
  2096. // If the field value doesn't match, an error message is generated.
  2097. //
  2098. // ```proto
  2099. // message MyFixed32 {
  2100. // // value must equal 42
  2101. // fixed32 value = 1 [(buf.validate.field).fixed32.const = 42];
  2102. // }
  2103. // ```
  2104. optional fixed32 const = 1 [(predefined).cel = {
  2105. id: "fixed32.const"
  2106. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  2107. }];
  2108. oneof less_than {
  2109. // `lt` requires the field value to be less than the specified value (field <
  2110. // value). If the field value is equal to or greater than the specified value,
  2111. // an error message is generated.
  2112. //
  2113. // ```proto
  2114. // message MyFixed32 {
  2115. // // must be less than 10
  2116. // fixed32 value = 1 [(buf.validate.field).fixed32.lt = 10];
  2117. // }
  2118. // ```
  2119. fixed32 lt = 2 [(predefined).cel = {
  2120. id: "fixed32.lt"
  2121. expression:
  2122. "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
  2123. "? 'must be less than %s'.format([rules.lt]) : ''"
  2124. }];
  2125. // `lte` requires the field value to be less than or equal to the specified
  2126. // value (field <= value). If the field value is greater than the specified
  2127. // value, an error message is generated.
  2128. //
  2129. // ```proto
  2130. // message MyFixed32 {
  2131. // // must be less than or equal to 10
  2132. // fixed32 value = 1 [(buf.validate.field).fixed32.lte = 10];
  2133. // }
  2134. // ```
  2135. fixed32 lte = 3 [(predefined).cel = {
  2136. id: "fixed32.lte"
  2137. expression:
  2138. "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
  2139. "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
  2140. }];
  2141. }
  2142. oneof greater_than {
  2143. // `gt` requires the field value to be greater than the specified value
  2144. // (exclusive). If the value of `gt` is larger than a specified `lt` or
  2145. // `lte`, the range is reversed, and the field value must be outside the
  2146. // specified range. If the field value doesn't meet the required conditions,
  2147. // an error message is generated.
  2148. //
  2149. // ```proto
  2150. // message MyFixed32 {
  2151. // // must be greater than 5 [fixed32.gt]
  2152. // fixed32 value = 1 [(buf.validate.field).fixed32.gt = 5];
  2153. //
  2154. // // must be greater than 5 and less than 10 [fixed32.gt_lt]
  2155. // fixed32 other_value = 2 [(buf.validate.field).fixed32 = { gt: 5, lt: 10 }];
  2156. //
  2157. // // must be greater than 10 or less than 5 [fixed32.gt_lt_exclusive]
  2158. // fixed32 another_value = 3 [(buf.validate.field).fixed32 = { gt: 10, lt: 5 }];
  2159. // }
  2160. // ```
  2161. fixed32 gt = 4 [
  2162. (predefined).cel = {
  2163. id: "fixed32.gt"
  2164. expression:
  2165. "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
  2166. "? 'must be greater than %s'.format([rules.gt]) : ''"
  2167. },
  2168. (predefined).cel = {
  2169. id: "fixed32.gt_lt"
  2170. expression:
  2171. "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
  2172. "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
  2173. },
  2174. (predefined).cel = {
  2175. id: "fixed32.gt_lt_exclusive"
  2176. expression:
  2177. "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
  2178. "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
  2179. },
  2180. (predefined).cel = {
  2181. id: "fixed32.gt_lte"
  2182. expression:
  2183. "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
  2184. "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  2185. },
  2186. (predefined).cel = {
  2187. id: "fixed32.gt_lte_exclusive"
  2188. expression:
  2189. "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
  2190. "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  2191. }
  2192. ];
  2193. // `gte` requires the field value to be greater than or equal to the specified
  2194. // value (exclusive). If the value of `gte` is larger than a specified `lt`
  2195. // or `lte`, the range is reversed, and the field value must be outside the
  2196. // specified range. If the field value doesn't meet the required conditions,
  2197. // an error message is generated.
  2198. //
  2199. // ```proto
  2200. // message MyFixed32 {
  2201. // // must be greater than or equal to 5 [fixed32.gte]
  2202. // fixed32 value = 1 [(buf.validate.field).fixed32.gte = 5];
  2203. //
  2204. // // must be greater than or equal to 5 and less than 10 [fixed32.gte_lt]
  2205. // fixed32 other_value = 2 [(buf.validate.field).fixed32 = { gte: 5, lt: 10 }];
  2206. //
  2207. // // must be greater than or equal to 10 or less than 5 [fixed32.gte_lt_exclusive]
  2208. // fixed32 another_value = 3 [(buf.validate.field).fixed32 = { gte: 10, lt: 5 }];
  2209. // }
  2210. // ```
  2211. fixed32 gte = 5 [
  2212. (predefined).cel = {
  2213. id: "fixed32.gte"
  2214. expression:
  2215. "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
  2216. "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
  2217. },
  2218. (predefined).cel = {
  2219. id: "fixed32.gte_lt"
  2220. expression:
  2221. "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
  2222. "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
  2223. },
  2224. (predefined).cel = {
  2225. id: "fixed32.gte_lt_exclusive"
  2226. expression:
  2227. "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
  2228. "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
  2229. },
  2230. (predefined).cel = {
  2231. id: "fixed32.gte_lte"
  2232. expression:
  2233. "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
  2234. "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  2235. },
  2236. (predefined).cel = {
  2237. id: "fixed32.gte_lte_exclusive"
  2238. expression:
  2239. "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
  2240. "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  2241. }
  2242. ];
  2243. }
  2244. // `in` requires the field value to be equal to one of the specified values.
  2245. // If the field value isn't one of the specified values, an error message
  2246. // is generated.
  2247. //
  2248. // ```proto
  2249. // message MyFixed32 {
  2250. // // must be in list [1, 2, 3]
  2251. // fixed32 value = 1 [(buf.validate.field).fixed32 = { in: [1, 2, 3] }];
  2252. // }
  2253. // ```
  2254. repeated fixed32 in = 6 [(predefined).cel = {
  2255. id: "fixed32.in"
  2256. expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  2257. }];
  2258. // `not_in` requires the field value to not be equal to any of the specified
  2259. // values. If the field value is one of the specified values, an error
  2260. // message is generated.
  2261. //
  2262. // ```proto
  2263. // message MyFixed32 {
  2264. // // value must not be in list [1, 2, 3]
  2265. // fixed32 value = 1 [(buf.validate.field).fixed32 = { not_in: [1, 2, 3] }];
  2266. // }
  2267. // ```
  2268. repeated fixed32 not_in = 7 [(predefined).cel = {
  2269. id: "fixed32.not_in"
  2270. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  2271. }];
  2272. // `example` specifies values that the field may have. These values SHOULD
  2273. // conform to other rules. `example` values will not impact validation
  2274. // but may be used as helpful guidance on how to populate the given field.
  2275. //
  2276. // ```proto
  2277. // message MyFixed32 {
  2278. // fixed32 value = 1 [
  2279. // (buf.validate.field).fixed32.example = 1,
  2280. // (buf.validate.field).fixed32.example = 2
  2281. // ];
  2282. // }
  2283. // ```
  2284. repeated fixed32 example = 8 [(predefined).cel = {
  2285. id: "fixed32.example"
  2286. expression: "true"
  2287. }];
  2288. // Extension fields that have the (buf.validate.predefined) option set
  2289. // will be treated as predefined field rules.
  2290. // See https://protovalidate.com/schemas/predefined-rules/
  2291. extensions 1000 to max;
  2292. }
  2293. // Fixed64Rules describes the rules applied to `fixed64` values.
  2294. message Fixed64Rules {
  2295. // `const` requires the field value to exactly match the specified value. If
  2296. // the field value doesn't match, an error message is generated.
  2297. //
  2298. // ```proto
  2299. // message MyFixed64 {
  2300. // // value must equal 42
  2301. // fixed64 value = 1 [(buf.validate.field).fixed64.const = 42];
  2302. // }
  2303. // ```
  2304. optional fixed64 const = 1 [(predefined).cel = {
  2305. id: "fixed64.const"
  2306. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  2307. }];
  2308. oneof less_than {
  2309. // `lt` requires the field value to be less than the specified value (field <
  2310. // value). If the field value is equal to or greater than the specified value,
  2311. // an error message is generated.
  2312. //
  2313. // ```proto
  2314. // message MyFixed64 {
  2315. // // must be less than 10
  2316. // fixed64 value = 1 [(buf.validate.field).fixed64.lt = 10];
  2317. // }
  2318. // ```
  2319. fixed64 lt = 2 [(predefined).cel = {
  2320. id: "fixed64.lt"
  2321. expression:
  2322. "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
  2323. "? 'must be less than %s'.format([rules.lt]) : ''"
  2324. }];
  2325. // `lte` requires the field value to be less than or equal to the specified
  2326. // value (field <= value). If the field value is greater than the specified
  2327. // value, an error message is generated.
  2328. //
  2329. // ```proto
  2330. // message MyFixed64 {
  2331. // // must be less than or equal to 10
  2332. // fixed64 value = 1 [(buf.validate.field).fixed64.lte = 10];
  2333. // }
  2334. // ```
  2335. fixed64 lte = 3 [(predefined).cel = {
  2336. id: "fixed64.lte"
  2337. expression:
  2338. "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
  2339. "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
  2340. }];
  2341. }
  2342. oneof greater_than {
  2343. // `gt` requires the field value to be greater than the specified value
  2344. // (exclusive). If the value of `gt` is larger than a specified `lt` or
  2345. // `lte`, the range is reversed, and the field value must be outside the
  2346. // specified range. If the field value doesn't meet the required conditions,
  2347. // an error message is generated.
  2348. //
  2349. // ```proto
  2350. // message MyFixed64 {
  2351. // // must be greater than 5 [fixed64.gt]
  2352. // fixed64 value = 1 [(buf.validate.field).fixed64.gt = 5];
  2353. //
  2354. // // must be greater than 5 and less than 10 [fixed64.gt_lt]
  2355. // fixed64 other_value = 2 [(buf.validate.field).fixed64 = { gt: 5, lt: 10 }];
  2356. //
  2357. // // must be greater than 10 or less than 5 [fixed64.gt_lt_exclusive]
  2358. // fixed64 another_value = 3 [(buf.validate.field).fixed64 = { gt: 10, lt: 5 }];
  2359. // }
  2360. // ```
  2361. fixed64 gt = 4 [
  2362. (predefined).cel = {
  2363. id: "fixed64.gt"
  2364. expression:
  2365. "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
  2366. "? 'must be greater than %s'.format([rules.gt]) : ''"
  2367. },
  2368. (predefined).cel = {
  2369. id: "fixed64.gt_lt"
  2370. expression:
  2371. "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
  2372. "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
  2373. },
  2374. (predefined).cel = {
  2375. id: "fixed64.gt_lt_exclusive"
  2376. expression:
  2377. "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
  2378. "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
  2379. },
  2380. (predefined).cel = {
  2381. id: "fixed64.gt_lte"
  2382. expression:
  2383. "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
  2384. "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  2385. },
  2386. (predefined).cel = {
  2387. id: "fixed64.gt_lte_exclusive"
  2388. expression:
  2389. "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
  2390. "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  2391. }
  2392. ];
  2393. // `gte` requires the field value to be greater than or equal to the specified
  2394. // value (exclusive). If the value of `gte` is larger than a specified `lt`
  2395. // or `lte`, the range is reversed, and the field value must be outside the
  2396. // specified range. If the field value doesn't meet the required conditions,
  2397. // an error message is generated.
  2398. //
  2399. // ```proto
  2400. // message MyFixed64 {
  2401. // // must be greater than or equal to 5 [fixed64.gte]
  2402. // fixed64 value = 1 [(buf.validate.field).fixed64.gte = 5];
  2403. //
  2404. // // must be greater than or equal to 5 and less than 10 [fixed64.gte_lt]
  2405. // fixed64 other_value = 2 [(buf.validate.field).fixed64 = { gte: 5, lt: 10 }];
  2406. //
  2407. // // must be greater than or equal to 10 or less than 5 [fixed64.gte_lt_exclusive]
  2408. // fixed64 another_value = 3 [(buf.validate.field).fixed64 = { gte: 10, lt: 5 }];
  2409. // }
  2410. // ```
  2411. fixed64 gte = 5 [
  2412. (predefined).cel = {
  2413. id: "fixed64.gte"
  2414. expression:
  2415. "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
  2416. "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
  2417. },
  2418. (predefined).cel = {
  2419. id: "fixed64.gte_lt"
  2420. expression:
  2421. "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
  2422. "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
  2423. },
  2424. (predefined).cel = {
  2425. id: "fixed64.gte_lt_exclusive"
  2426. expression:
  2427. "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
  2428. "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
  2429. },
  2430. (predefined).cel = {
  2431. id: "fixed64.gte_lte"
  2432. expression:
  2433. "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
  2434. "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  2435. },
  2436. (predefined).cel = {
  2437. id: "fixed64.gte_lte_exclusive"
  2438. expression:
  2439. "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
  2440. "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  2441. }
  2442. ];
  2443. }
  2444. // `in` requires the field value to be equal to one of the specified values.
  2445. // If the field value isn't one of the specified values, an error message is
  2446. // generated.
  2447. //
  2448. // ```proto
  2449. // message MyFixed64 {
  2450. // // must be in list [1, 2, 3]
  2451. // fixed64 value = 1 [(buf.validate.field).fixed64 = { in: [1, 2, 3] }];
  2452. // }
  2453. // ```
  2454. repeated fixed64 in = 6 [(predefined).cel = {
  2455. id: "fixed64.in"
  2456. expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  2457. }];
  2458. // `not_in` requires the field value to not be equal to any of the specified
  2459. // values. If the field value is one of the specified values, an error
  2460. // message is generated.
  2461. //
  2462. // ```proto
  2463. // message MyFixed64 {
  2464. // // value must not be in list [1, 2, 3]
  2465. // fixed64 value = 1 [(buf.validate.field).fixed64 = { not_in: [1, 2, 3] }];
  2466. // }
  2467. // ```
  2468. repeated fixed64 not_in = 7 [(predefined).cel = {
  2469. id: "fixed64.not_in"
  2470. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  2471. }];
  2472. // `example` specifies values that the field may have. These values SHOULD
  2473. // conform to other rules. `example` values will not impact validation
  2474. // but may be used as helpful guidance on how to populate the given field.
  2475. //
  2476. // ```proto
  2477. // message MyFixed64 {
  2478. // fixed64 value = 1 [
  2479. // (buf.validate.field).fixed64.example = 1,
  2480. // (buf.validate.field).fixed64.example = 2
  2481. // ];
  2482. // }
  2483. // ```
  2484. repeated fixed64 example = 8 [(predefined).cel = {
  2485. id: "fixed64.example"
  2486. expression: "true"
  2487. }];
  2488. // Extension fields that have the (buf.validate.predefined) option set
  2489. // will be treated as predefined field rules.
  2490. // See https://protovalidate.com/schemas/predefined-rules/
  2491. extensions 1000 to max;
  2492. }
  2493. // SFixed32Rules describes the rules applied to `fixed32` values.
  2494. message SFixed32Rules {
  2495. // `const` requires the field value to exactly match the specified value. If
  2496. // the field value doesn't match, an error message is generated.
  2497. //
  2498. // ```proto
  2499. // message MySFixed32 {
  2500. // // value must equal 42
  2501. // sfixed32 value = 1 [(buf.validate.field).sfixed32.const = 42];
  2502. // }
  2503. // ```
  2504. optional sfixed32 const = 1 [(predefined).cel = {
  2505. id: "sfixed32.const"
  2506. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  2507. }];
  2508. oneof less_than {
  2509. // `lt` requires the field value to be less than the specified value (field <
  2510. // value). If the field value is equal to or greater than the specified value,
  2511. // an error message is generated.
  2512. //
  2513. // ```proto
  2514. // message MySFixed32 {
  2515. // // must be less than 10
  2516. // sfixed32 value = 1 [(buf.validate.field).sfixed32.lt = 10];
  2517. // }
  2518. // ```
  2519. sfixed32 lt = 2 [(predefined).cel = {
  2520. id: "sfixed32.lt"
  2521. expression:
  2522. "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
  2523. "? 'must be less than %s'.format([rules.lt]) : ''"
  2524. }];
  2525. // `lte` requires the field value to be less than or equal to the specified
  2526. // value (field <= value). If the field value is greater than the specified
  2527. // value, an error message is generated.
  2528. //
  2529. // ```proto
  2530. // message MySFixed32 {
  2531. // // must be less than or equal to 10
  2532. // sfixed32 value = 1 [(buf.validate.field).sfixed32.lte = 10];
  2533. // }
  2534. // ```
  2535. sfixed32 lte = 3 [(predefined).cel = {
  2536. id: "sfixed32.lte"
  2537. expression:
  2538. "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
  2539. "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
  2540. }];
  2541. }
  2542. oneof greater_than {
  2543. // `gt` requires the field value to be greater than the specified value
  2544. // (exclusive). If the value of `gt` is larger than a specified `lt` or
  2545. // `lte`, the range is reversed, and the field value must be outside the
  2546. // specified range. If the field value doesn't meet the required conditions,
  2547. // an error message is generated.
  2548. //
  2549. // ```proto
  2550. // message MySFixed32 {
  2551. // // must be greater than 5 [sfixed32.gt]
  2552. // sfixed32 value = 1 [(buf.validate.field).sfixed32.gt = 5];
  2553. //
  2554. // // must be greater than 5 and less than 10 [sfixed32.gt_lt]
  2555. // sfixed32 other_value = 2 [(buf.validate.field).sfixed32 = { gt: 5, lt: 10 }];
  2556. //
  2557. // // must be greater than 10 or less than 5 [sfixed32.gt_lt_exclusive]
  2558. // sfixed32 another_value = 3 [(buf.validate.field).sfixed32 = { gt: 10, lt: 5 }];
  2559. // }
  2560. // ```
  2561. sfixed32 gt = 4 [
  2562. (predefined).cel = {
  2563. id: "sfixed32.gt"
  2564. expression:
  2565. "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
  2566. "? 'must be greater than %s'.format([rules.gt]) : ''"
  2567. },
  2568. (predefined).cel = {
  2569. id: "sfixed32.gt_lt"
  2570. expression:
  2571. "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
  2572. "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
  2573. },
  2574. (predefined).cel = {
  2575. id: "sfixed32.gt_lt_exclusive"
  2576. expression:
  2577. "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
  2578. "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
  2579. },
  2580. (predefined).cel = {
  2581. id: "sfixed32.gt_lte"
  2582. expression:
  2583. "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
  2584. "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  2585. },
  2586. (predefined).cel = {
  2587. id: "sfixed32.gt_lte_exclusive"
  2588. expression:
  2589. "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
  2590. "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  2591. }
  2592. ];
  2593. // `gte` requires the field value to be greater than or equal to the specified
  2594. // value (exclusive). If the value of `gte` is larger than a specified `lt`
  2595. // or `lte`, the range is reversed, and the field value must be outside the
  2596. // specified range. If the field value doesn't meet the required conditions,
  2597. // an error message is generated.
  2598. //
  2599. // ```proto
  2600. // message MySFixed32 {
  2601. // // must be greater than or equal to 5 [sfixed32.gte]
  2602. // sfixed32 value = 1 [(buf.validate.field).sfixed32.gte = 5];
  2603. //
  2604. // // must be greater than or equal to 5 and less than 10 [sfixed32.gte_lt]
  2605. // sfixed32 other_value = 2 [(buf.validate.field).sfixed32 = { gte: 5, lt: 10 }];
  2606. //
  2607. // // must be greater than or equal to 10 or less than 5 [sfixed32.gte_lt_exclusive]
  2608. // sfixed32 another_value = 3 [(buf.validate.field).sfixed32 = { gte: 10, lt: 5 }];
  2609. // }
  2610. // ```
  2611. sfixed32 gte = 5 [
  2612. (predefined).cel = {
  2613. id: "sfixed32.gte"
  2614. expression:
  2615. "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
  2616. "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
  2617. },
  2618. (predefined).cel = {
  2619. id: "sfixed32.gte_lt"
  2620. expression:
  2621. "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
  2622. "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
  2623. },
  2624. (predefined).cel = {
  2625. id: "sfixed32.gte_lt_exclusive"
  2626. expression:
  2627. "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
  2628. "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
  2629. },
  2630. (predefined).cel = {
  2631. id: "sfixed32.gte_lte"
  2632. expression:
  2633. "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
  2634. "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  2635. },
  2636. (predefined).cel = {
  2637. id: "sfixed32.gte_lte_exclusive"
  2638. expression:
  2639. "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
  2640. "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  2641. }
  2642. ];
  2643. }
  2644. // `in` requires the field value to be equal to one of the specified values.
  2645. // If the field value isn't one of the specified values, an error message is
  2646. // generated.
  2647. //
  2648. // ```proto
  2649. // message MySFixed32 {
  2650. // // must be in list [1, 2, 3]
  2651. // sfixed32 value = 1 [(buf.validate.field).sfixed32 = { in: [1, 2, 3] }];
  2652. // }
  2653. // ```
  2654. repeated sfixed32 in = 6 [(predefined).cel = {
  2655. id: "sfixed32.in"
  2656. expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  2657. }];
  2658. // `not_in` requires the field value to not be equal to any of the specified
  2659. // values. If the field value is one of the specified values, an error
  2660. // message is generated.
  2661. //
  2662. // ```proto
  2663. // message MySFixed32 {
  2664. // // value must not be in list [1, 2, 3]
  2665. // sfixed32 value = 1 [(buf.validate.field).sfixed32 = { not_in: [1, 2, 3] }];
  2666. // }
  2667. // ```
  2668. repeated sfixed32 not_in = 7 [(predefined).cel = {
  2669. id: "sfixed32.not_in"
  2670. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  2671. }];
  2672. // `example` specifies values that the field may have. These values SHOULD
  2673. // conform to other rules. `example` values will not impact validation
  2674. // but may be used as helpful guidance on how to populate the given field.
  2675. //
  2676. // ```proto
  2677. // message MySFixed32 {
  2678. // sfixed32 value = 1 [
  2679. // (buf.validate.field).sfixed32.example = 1,
  2680. // (buf.validate.field).sfixed32.example = 2
  2681. // ];
  2682. // }
  2683. // ```
  2684. repeated sfixed32 example = 8 [(predefined).cel = {
  2685. id: "sfixed32.example"
  2686. expression: "true"
  2687. }];
  2688. // Extension fields that have the (buf.validate.predefined) option set
  2689. // will be treated as predefined field rules.
  2690. // See https://protovalidate.com/schemas/predefined-rules/
  2691. extensions 1000 to max;
  2692. }
  2693. // SFixed64Rules describes the rules applied to `fixed64` values.
  2694. message SFixed64Rules {
  2695. // `const` requires the field value to exactly match the specified value. If
  2696. // the field value doesn't match, an error message is generated.
  2697. //
  2698. // ```proto
  2699. // message MySFixed64 {
  2700. // // value must equal 42
  2701. // sfixed64 value = 1 [(buf.validate.field).sfixed64.const = 42];
  2702. // }
  2703. // ```
  2704. optional sfixed64 const = 1 [(predefined).cel = {
  2705. id: "sfixed64.const"
  2706. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  2707. }];
  2708. oneof less_than {
  2709. // `lt` requires the field value to be less than the specified value (field <
  2710. // value). If the field value is equal to or greater than the specified value,
  2711. // an error message is generated.
  2712. //
  2713. // ```proto
  2714. // message MySFixed64 {
  2715. // // must be less than 10
  2716. // sfixed64 value = 1 [(buf.validate.field).sfixed64.lt = 10];
  2717. // }
  2718. // ```
  2719. sfixed64 lt = 2 [(predefined).cel = {
  2720. id: "sfixed64.lt"
  2721. expression:
  2722. "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
  2723. "? 'must be less than %s'.format([rules.lt]) : ''"
  2724. }];
  2725. // `lte` requires the field value to be less than or equal to the specified
  2726. // value (field <= value). If the field value is greater than the specified
  2727. // value, an error message is generated.
  2728. //
  2729. // ```proto
  2730. // message MySFixed64 {
  2731. // // must be less than or equal to 10
  2732. // sfixed64 value = 1 [(buf.validate.field).sfixed64.lte = 10];
  2733. // }
  2734. // ```
  2735. sfixed64 lte = 3 [(predefined).cel = {
  2736. id: "sfixed64.lte"
  2737. expression:
  2738. "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
  2739. "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
  2740. }];
  2741. }
  2742. oneof greater_than {
  2743. // `gt` requires the field value to be greater than the specified value
  2744. // (exclusive). If the value of `gt` is larger than a specified `lt` or
  2745. // `lte`, the range is reversed, and the field value must be outside the
  2746. // specified range. If the field value doesn't meet the required conditions,
  2747. // an error message is generated.
  2748. //
  2749. // ```proto
  2750. // message MySFixed64 {
  2751. // // must be greater than 5 [sfixed64.gt]
  2752. // sfixed64 value = 1 [(buf.validate.field).sfixed64.gt = 5];
  2753. //
  2754. // // must be greater than 5 and less than 10 [sfixed64.gt_lt]
  2755. // sfixed64 other_value = 2 [(buf.validate.field).sfixed64 = { gt: 5, lt: 10 }];
  2756. //
  2757. // // must be greater than 10 or less than 5 [sfixed64.gt_lt_exclusive]
  2758. // sfixed64 another_value = 3 [(buf.validate.field).sfixed64 = { gt: 10, lt: 5 }];
  2759. // }
  2760. // ```
  2761. sfixed64 gt = 4 [
  2762. (predefined).cel = {
  2763. id: "sfixed64.gt"
  2764. expression:
  2765. "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
  2766. "? 'must be greater than %s'.format([rules.gt]) : ''"
  2767. },
  2768. (predefined).cel = {
  2769. id: "sfixed64.gt_lt"
  2770. expression:
  2771. "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
  2772. "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
  2773. },
  2774. (predefined).cel = {
  2775. id: "sfixed64.gt_lt_exclusive"
  2776. expression:
  2777. "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
  2778. "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
  2779. },
  2780. (predefined).cel = {
  2781. id: "sfixed64.gt_lte"
  2782. expression:
  2783. "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
  2784. "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  2785. },
  2786. (predefined).cel = {
  2787. id: "sfixed64.gt_lte_exclusive"
  2788. expression:
  2789. "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
  2790. "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  2791. }
  2792. ];
  2793. // `gte` requires the field value to be greater than or equal to the specified
  2794. // value (exclusive). If the value of `gte` is larger than a specified `lt`
  2795. // or `lte`, the range is reversed, and the field value must be outside the
  2796. // specified range. If the field value doesn't meet the required conditions,
  2797. // an error message is generated.
  2798. //
  2799. // ```proto
  2800. // message MySFixed64 {
  2801. // // must be greater than or equal to 5 [sfixed64.gte]
  2802. // sfixed64 value = 1 [(buf.validate.field).sfixed64.gte = 5];
  2803. //
  2804. // // must be greater than or equal to 5 and less than 10 [sfixed64.gte_lt]
  2805. // sfixed64 other_value = 2 [(buf.validate.field).sfixed64 = { gte: 5, lt: 10 }];
  2806. //
  2807. // // must be greater than or equal to 10 or less than 5 [sfixed64.gte_lt_exclusive]
  2808. // sfixed64 another_value = 3 [(buf.validate.field).sfixed64 = { gte: 10, lt: 5 }];
  2809. // }
  2810. // ```
  2811. sfixed64 gte = 5 [
  2812. (predefined).cel = {
  2813. id: "sfixed64.gte"
  2814. expression:
  2815. "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
  2816. "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
  2817. },
  2818. (predefined).cel = {
  2819. id: "sfixed64.gte_lt"
  2820. expression:
  2821. "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
  2822. "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
  2823. },
  2824. (predefined).cel = {
  2825. id: "sfixed64.gte_lt_exclusive"
  2826. expression:
  2827. "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
  2828. "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
  2829. },
  2830. (predefined).cel = {
  2831. id: "sfixed64.gte_lte"
  2832. expression:
  2833. "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
  2834. "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  2835. },
  2836. (predefined).cel = {
  2837. id: "sfixed64.gte_lte_exclusive"
  2838. expression:
  2839. "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
  2840. "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  2841. }
  2842. ];
  2843. }
  2844. // `in` requires the field value to be equal to one of the specified values.
  2845. // If the field value isn't one of the specified values, an error message is
  2846. // generated.
  2847. //
  2848. // ```proto
  2849. // message MySFixed64 {
  2850. // // must be in list [1, 2, 3]
  2851. // sfixed64 value = 1 [(buf.validate.field).sfixed64 = { in: [1, 2, 3] }];
  2852. // }
  2853. // ```
  2854. repeated sfixed64 in = 6 [(predefined).cel = {
  2855. id: "sfixed64.in"
  2856. expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  2857. }];
  2858. // `not_in` requires the field value to not be equal to any of the specified
  2859. // values. If the field value is one of the specified values, an error
  2860. // message is generated.
  2861. //
  2862. // ```proto
  2863. // message MySFixed64 {
  2864. // // value must not be in list [1, 2, 3]
  2865. // sfixed64 value = 1 [(buf.validate.field).sfixed64 = { not_in: [1, 2, 3] }];
  2866. // }
  2867. // ```
  2868. repeated sfixed64 not_in = 7 [(predefined).cel = {
  2869. id: "sfixed64.not_in"
  2870. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  2871. }];
  2872. // `example` specifies values that the field may have. These values SHOULD
  2873. // conform to other rules. `example` values will not impact validation
  2874. // but may be used as helpful guidance on how to populate the given field.
  2875. //
  2876. // ```proto
  2877. // message MySFixed64 {
  2878. // sfixed64 value = 1 [
  2879. // (buf.validate.field).sfixed64.example = 1,
  2880. // (buf.validate.field).sfixed64.example = 2
  2881. // ];
  2882. // }
  2883. // ```
  2884. repeated sfixed64 example = 8 [(predefined).cel = {
  2885. id: "sfixed64.example"
  2886. expression: "true"
  2887. }];
  2888. // Extension fields that have the (buf.validate.predefined) option set
  2889. // will be treated as predefined field rules.
  2890. // See https://protovalidate.com/schemas/predefined-rules/
  2891. extensions 1000 to max;
  2892. }
  2893. // BoolRules describes the rules applied to `bool` values. These rules
  2894. // may also be applied to the `google.protobuf.BoolValue` Well-Known-Type.
  2895. message BoolRules {
  2896. // `const` requires the field value to exactly match the specified boolean value.
  2897. // If the field value doesn't match, an error message is generated.
  2898. //
  2899. // ```proto
  2900. // message MyBool {
  2901. // // value must equal true
  2902. // bool value = 1 [(buf.validate.field).bool.const = true];
  2903. // }
  2904. // ```
  2905. optional bool const = 1 [(predefined).cel = {
  2906. id: "bool.const"
  2907. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  2908. }];
  2909. // `example` specifies values that the field may have. These values SHOULD
  2910. // conform to other rules. `example` values will not impact validation
  2911. // but may be used as helpful guidance on how to populate the given field.
  2912. //
  2913. // ```proto
  2914. // message MyBool {
  2915. // bool value = 1 [
  2916. // (buf.validate.field).bool.example = true,
  2917. // (buf.validate.field).bool.example = false
  2918. // ];
  2919. // }
  2920. // ```
  2921. repeated bool example = 2 [(predefined).cel = {
  2922. id: "bool.example"
  2923. expression: "true"
  2924. }];
  2925. // Extension fields that have the (buf.validate.predefined) option set
  2926. // will be treated as predefined field rules.
  2927. // See https://protovalidate.com/schemas/predefined-rules/
  2928. extensions 1000 to max;
  2929. }
  2930. // StringRules describes the rules applied to `string` values These
  2931. // rules may also be applied to the `google.protobuf.StringValue` Well-Known-Type.
  2932. message StringRules {
  2933. // `const` requires the field value to exactly match the specified value. If
  2934. // the field value doesn't match, an error message is generated.
  2935. //
  2936. // ```proto
  2937. // message MyString {
  2938. // // value must equal `hello`
  2939. // string value = 1 [(buf.validate.field).string.const = "hello"];
  2940. // }
  2941. // ```
  2942. optional string const = 1 [(predefined).cel = {
  2943. id: "string.const"
  2944. expression: "this != getField(rules, 'const') ? 'must equal `%s`'.format([getField(rules, 'const')]) : ''"
  2945. }];
  2946. // `len` dictates that the field value must have the specified
  2947. // number of characters (Unicode code points), which may differ from the number
  2948. // of bytes in the string. If the field value does not meet the specified
  2949. // length, an error message will be generated.
  2950. //
  2951. // ```proto
  2952. // message MyString {
  2953. // // value length must be 5 characters
  2954. // string value = 1 [(buf.validate.field).string.len = 5];
  2955. // }
  2956. // ```
  2957. optional uint64 len = 19 [(predefined).cel = {
  2958. id: "string.len"
  2959. expression: "uint(this.size()) != rules.len ? 'must be %s characters'.format([rules.len]) : ''"
  2960. }];
  2961. // `min_len` specifies that the field value must have at least the specified
  2962. // number of characters (Unicode code points), which may differ from the number
  2963. // of bytes in the string. If the field value contains fewer characters, an error
  2964. // message will be generated.
  2965. //
  2966. // ```proto
  2967. // message MyString {
  2968. // // value length must be at least 3 characters
  2969. // string value = 1 [(buf.validate.field).string.min_len = 3];
  2970. // }
  2971. // ```
  2972. optional uint64 min_len = 2 [(predefined).cel = {
  2973. id: "string.min_len"
  2974. expression: "uint(this.size()) < rules.min_len ? 'must be at least %s characters'.format([rules.min_len]) : ''"
  2975. }];
  2976. // `max_len` specifies that the field value must have no more than the specified
  2977. // number of characters (Unicode code points), which may differ from the
  2978. // number of bytes in the string. If the field value contains more characters,
  2979. // an error message will be generated.
  2980. //
  2981. // ```proto
  2982. // message MyString {
  2983. // // value length must be at most 10 characters
  2984. // string value = 1 [(buf.validate.field).string.max_len = 10];
  2985. // }
  2986. // ```
  2987. optional uint64 max_len = 3 [(predefined).cel = {
  2988. id: "string.max_len"
  2989. expression: "uint(this.size()) > rules.max_len ? 'must be at most %s characters'.format([rules.max_len]) : ''"
  2990. }];
  2991. // `len_bytes` dictates that the field value must have the specified number of
  2992. // bytes. If the field value does not match the specified length in bytes,
  2993. // an error message will be generated.
  2994. //
  2995. // ```proto
  2996. // message MyString {
  2997. // // value length must be 6 bytes
  2998. // string value = 1 [(buf.validate.field).string.len_bytes = 6];
  2999. // }
  3000. // ```
  3001. optional uint64 len_bytes = 20 [(predefined).cel = {
  3002. id: "string.len_bytes"
  3003. expression: "uint(bytes(this).size()) != rules.len_bytes ? 'must be %s bytes'.format([rules.len_bytes]) : ''"
  3004. }];
  3005. // `min_bytes` specifies that the field value must have at least the specified
  3006. // number of bytes. If the field value contains fewer bytes, an error message
  3007. // will be generated.
  3008. //
  3009. // ```proto
  3010. // message MyString {
  3011. // // value length must be at least 4 bytes
  3012. // string value = 1 [(buf.validate.field).string.min_bytes = 4];
  3013. // }
  3014. //
  3015. // ```
  3016. optional uint64 min_bytes = 4 [(predefined).cel = {
  3017. id: "string.min_bytes"
  3018. expression: "uint(bytes(this).size()) < rules.min_bytes ? 'must be at least %s bytes'.format([rules.min_bytes]) : ''"
  3019. }];
  3020. // `max_bytes` specifies that the field value must have no more than the
  3021. // specified number of bytes. If the field value contains more bytes, an
  3022. // error message will be generated.
  3023. //
  3024. // ```proto
  3025. // message MyString {
  3026. // // value length must be at most 8 bytes
  3027. // string value = 1 [(buf.validate.field).string.max_bytes = 8];
  3028. // }
  3029. // ```
  3030. optional uint64 max_bytes = 5 [(predefined).cel = {
  3031. id: "string.max_bytes"
  3032. expression: "uint(bytes(this).size()) > rules.max_bytes ? 'must be at most %s bytes'.format([rules.max_bytes]) : ''"
  3033. }];
  3034. // `pattern` specifies that the field value must match the specified
  3035. // regular expression (RE2 syntax), with the expression provided without any
  3036. // delimiters. If the field value doesn't match the regular expression, an
  3037. // error message will be generated.
  3038. //
  3039. // ```proto
  3040. // message MyString {
  3041. // // value does not match regex pattern `^[a-zA-Z]//$`
  3042. // string value = 1 [(buf.validate.field).string.pattern = "^[a-zA-Z]//$"];
  3043. // }
  3044. // ```
  3045. optional string pattern = 6 [(predefined).cel = {
  3046. id: "string.pattern"
  3047. expression: "!this.matches(rules.pattern) ? 'does not match regex pattern `%s`'.format([rules.pattern]) : ''"
  3048. }];
  3049. // `prefix` specifies that the field value must have the
  3050. // specified substring at the beginning of the string. If the field value
  3051. // doesn't start with the specified prefix, an error message will be
  3052. // generated.
  3053. //
  3054. // ```proto
  3055. // message MyString {
  3056. // // value does not have prefix `pre`
  3057. // string value = 1 [(buf.validate.field).string.prefix = "pre"];
  3058. // }
  3059. // ```
  3060. optional string prefix = 7 [(predefined).cel = {
  3061. id: "string.prefix"
  3062. expression: "!this.startsWith(rules.prefix) ? 'does not have prefix `%s`'.format([rules.prefix]) : ''"
  3063. }];
  3064. // `suffix` specifies that the field value must have the
  3065. // specified substring at the end of the string. If the field value doesn't
  3066. // end with the specified suffix, an error message will be generated.
  3067. //
  3068. // ```proto
  3069. // message MyString {
  3070. // // value does not have suffix `post`
  3071. // string value = 1 [(buf.validate.field).string.suffix = "post"];
  3072. // }
  3073. // ```
  3074. optional string suffix = 8 [(predefined).cel = {
  3075. id: "string.suffix"
  3076. expression: "!this.endsWith(rules.suffix) ? 'does not have suffix `%s`'.format([rules.suffix]) : ''"
  3077. }];
  3078. // `contains` specifies that the field value must have the
  3079. // specified substring anywhere in the string. If the field value doesn't
  3080. // contain the specified substring, an error message will be generated.
  3081. //
  3082. // ```proto
  3083. // message MyString {
  3084. // // value does not contain substring `inside`.
  3085. // string value = 1 [(buf.validate.field).string.contains = "inside"];
  3086. // }
  3087. // ```
  3088. optional string contains = 9 [(predefined).cel = {
  3089. id: "string.contains"
  3090. expression: "!this.contains(rules.contains) ? 'does not contain substring `%s`'.format([rules.contains]) : ''"
  3091. }];
  3092. // `not_contains` specifies that the field value must not have the
  3093. // specified substring anywhere in the string. If the field value contains
  3094. // the specified substring, an error message will be generated.
  3095. //
  3096. // ```proto
  3097. // message MyString {
  3098. // // value contains substring `inside`.
  3099. // string value = 1 [(buf.validate.field).string.not_contains = "inside"];
  3100. // }
  3101. // ```
  3102. optional string not_contains = 23 [(predefined).cel = {
  3103. id: "string.not_contains"
  3104. expression: "this.contains(rules.not_contains) ? 'contains substring `%s`'.format([rules.not_contains]) : ''"
  3105. }];
  3106. // `in` specifies that the field value must be equal to one of the specified
  3107. // values. If the field value isn't one of the specified values, an error
  3108. // message will be generated.
  3109. //
  3110. // ```proto
  3111. // message MyString {
  3112. // // must be in list ["apple", "banana"]
  3113. // string value = 1 [(buf.validate.field).string = { in: ["apple", "banana"] }];
  3114. // }
  3115. // ```
  3116. repeated string in = 10 [(predefined).cel = {
  3117. id: "string.in"
  3118. expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  3119. }];
  3120. // `not_in` specifies that the field value cannot be equal to any
  3121. // of the specified values. If the field value is one of the specified values,
  3122. // an error message will be generated.
  3123. // ```proto
  3124. // message MyString {
  3125. // // value must not be in list ["orange", "grape"]
  3126. // string value = 1 [(buf.validate.field).string = { not_in: ["orange", "grape"] }];
  3127. // }
  3128. // ```
  3129. repeated string not_in = 11 [(predefined).cel = {
  3130. id: "string.not_in"
  3131. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  3132. }];
  3133. // `WellKnown` rules provide advanced rules against common string
  3134. // patterns.
  3135. oneof well_known {
  3136. // `email` specifies that the field value must be a valid email address, for
  3137. // example "foo@example.com".
  3138. //
  3139. // Conforms to the definition for a valid email address from the [HTML standard](https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address).
  3140. // Note that this standard willfully deviates from [RFC 5322](https://datatracker.ietf.org/doc/html/rfc5322),
  3141. // which allows many unexpected forms of email addresses and will easily match
  3142. // a typographical error.
  3143. //
  3144. // If the field value isn't a valid email address, an error message will be generated.
  3145. //
  3146. // ```proto
  3147. // message MyString {
  3148. // // must be a valid email address
  3149. // string value = 1 [(buf.validate.field).string.email = true];
  3150. // }
  3151. // ```
  3152. bool email = 12 [
  3153. (predefined).cel = {
  3154. id: "string.email"
  3155. message: "must be a valid email address"
  3156. expression: "!rules.email || this == '' || this.isEmail()"
  3157. },
  3158. (predefined).cel = {
  3159. id: "string.email_empty"
  3160. message: "value is empty, which is not a valid email address"
  3161. expression: "!rules.email || this != ''"
  3162. }
  3163. ];
  3164. // `hostname` specifies that the field value must be a valid hostname, for
  3165. // example "foo.example.com".
  3166. //
  3167. // A valid hostname follows the rules below:
  3168. // - The name consists of one or more labels, separated by a dot (".").
  3169. // - Each label can be 1 to 63 alphanumeric characters.
  3170. // - A label can contain hyphens ("-"), but must not start or end with a hyphen.
  3171. // - The right-most label must not be digits only.
  3172. // - The name can have a trailing dot—for example, "foo.example.com.".
  3173. // - The name can be 253 characters at most, excluding the optional trailing dot.
  3174. //
  3175. // If the field value isn't a valid hostname, an error message will be generated.
  3176. //
  3177. // ```proto
  3178. // message MyString {
  3179. // // must be a valid hostname
  3180. // string value = 1 [(buf.validate.field).string.hostname = true];
  3181. // }
  3182. // ```
  3183. bool hostname = 13 [
  3184. (predefined).cel = {
  3185. id: "string.hostname"
  3186. message: "must be a valid hostname"
  3187. expression: "!rules.hostname || this == '' || this.isHostname()"
  3188. },
  3189. (predefined).cel = {
  3190. id: "string.hostname_empty"
  3191. message: "value is empty, which is not a valid hostname"
  3192. expression: "!rules.hostname || this != ''"
  3193. }
  3194. ];
  3195. // `ip` specifies that the field value must be a valid IP (v4 or v6) address.
  3196. //
  3197. // IPv4 addresses are expected in the dotted decimal format—for example, "192.168.5.21".
  3198. // IPv6 addresses are expected in their text representation—for example, "::1",
  3199. // or "2001:0DB8:ABCD:0012::0".
  3200. //
  3201. // Both formats are well-defined in the internet standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986).
  3202. // Zone identifiers for IPv6 addresses (for example, "fe80::a%en1") are supported.
  3203. //
  3204. // If the field value isn't a valid IP address, an error message will be
  3205. // generated.
  3206. //
  3207. // ```proto
  3208. // message MyString {
  3209. // // must be a valid IP address
  3210. // string value = 1 [(buf.validate.field).string.ip = true];
  3211. // }
  3212. // ```
  3213. bool ip = 14 [
  3214. (predefined).cel = {
  3215. id: "string.ip"
  3216. message: "must be a valid IP address"
  3217. expression: "!rules.ip || this == '' || this.isIp()"
  3218. },
  3219. (predefined).cel = {
  3220. id: "string.ip_empty"
  3221. message: "value is empty, which is not a valid IP address"
  3222. expression: "!rules.ip || this != ''"
  3223. }
  3224. ];
  3225. // `ipv4` specifies that the field value must be a valid IPv4 address—for
  3226. // example "192.168.5.21". If the field value isn't a valid IPv4 address, an
  3227. // error message will be generated.
  3228. //
  3229. // ```proto
  3230. // message MyString {
  3231. // // must be a valid IPv4 address
  3232. // string value = 1 [(buf.validate.field).string.ipv4 = true];
  3233. // }
  3234. // ```
  3235. bool ipv4 = 15 [
  3236. (predefined).cel = {
  3237. id: "string.ipv4"
  3238. message: "must be a valid IPv4 address"
  3239. expression: "!rules.ipv4 || this == '' || this.isIp(4)"
  3240. },
  3241. (predefined).cel = {
  3242. id: "string.ipv4_empty"
  3243. message: "value is empty, which is not a valid IPv4 address"
  3244. expression: "!rules.ipv4 || this != ''"
  3245. }
  3246. ];
  3247. // `ipv6` specifies that the field value must be a valid IPv6 address—for
  3248. // example "::1", or "d7a:115c:a1e0:ab12:4843:cd96:626b:430b". If the field
  3249. // value is not a valid IPv6 address, an error message will be generated.
  3250. //
  3251. // ```proto
  3252. // message MyString {
  3253. // // must be a valid IPv6 address
  3254. // string value = 1 [(buf.validate.field).string.ipv6 = true];
  3255. // }
  3256. // ```
  3257. bool ipv6 = 16 [
  3258. (predefined).cel = {
  3259. id: "string.ipv6"
  3260. message: "must be a valid IPv6 address"
  3261. expression: "!rules.ipv6 || this == '' || this.isIp(6)"
  3262. },
  3263. (predefined).cel = {
  3264. id: "string.ipv6_empty"
  3265. message: "value is empty, which is not a valid IPv6 address"
  3266. expression: "!rules.ipv6 || this != ''"
  3267. }
  3268. ];
  3269. // `uri` specifies that the field value must be a valid URI, for example
  3270. // "https://example.com/foo/bar?baz=quux#frag".
  3271. //
  3272. // URI is defined in the internet standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986).
  3273. // Zone Identifiers in IPv6 address literals are supported ([RFC 6874](https://datatracker.ietf.org/doc/html/rfc6874)).
  3274. //
  3275. // If the field value isn't a valid URI, an error message will be generated.
  3276. //
  3277. // ```proto
  3278. // message MyString {
  3279. // // must be a valid URI
  3280. // string value = 1 [(buf.validate.field).string.uri = true];
  3281. // }
  3282. // ```
  3283. bool uri = 17 [
  3284. (predefined).cel = {
  3285. id: "string.uri"
  3286. message: "must be a valid URI"
  3287. expression: "!rules.uri || this == '' || this.isUri()"
  3288. },
  3289. (predefined).cel = {
  3290. id: "string.uri_empty"
  3291. message: "value is empty, which is not a valid URI"
  3292. expression: "!rules.uri || this != ''"
  3293. }
  3294. ];
  3295. // `uri_ref` specifies that the field value must be a valid URI Reference—either
  3296. // a URI such as "https://example.com/foo/bar?baz=quux#frag", or a Relative
  3297. // Reference such as "./foo/bar?query".
  3298. //
  3299. // URI, URI Reference, and Relative Reference are defined in the internet
  3300. // standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). Zone
  3301. // Identifiers in IPv6 address literals are supported ([RFC 6874](https://datatracker.ietf.org/doc/html/rfc6874)).
  3302. //
  3303. // If the field value isn't a valid URI Reference, an error message will be
  3304. // generated.
  3305. //
  3306. // ```proto
  3307. // message MyString {
  3308. // // must be a valid URI Reference
  3309. // string value = 1 [(buf.validate.field).string.uri_ref = true];
  3310. // }
  3311. // ```
  3312. bool uri_ref = 18 [(predefined).cel = {
  3313. id: "string.uri_ref"
  3314. message: "must be a valid URI Reference"
  3315. expression: "!rules.uri_ref || this.isUriRef()"
  3316. }];
  3317. // `address` specifies that the field value must be either a valid hostname
  3318. // (for example, "example.com"), or a valid IP (v4 or v6) address (for example,
  3319. // "192.168.0.1", or "::1"). If the field value isn't a valid hostname or IP,
  3320. // an error message will be generated.
  3321. //
  3322. // ```proto
  3323. // message MyString {
  3324. // // must be a valid hostname, or ip address
  3325. // string value = 1 [(buf.validate.field).string.address = true];
  3326. // }
  3327. // ```
  3328. bool address = 21 [
  3329. (predefined).cel = {
  3330. id: "string.address"
  3331. message: "must be a valid hostname, or ip address"
  3332. expression: "!rules.address || this == '' || this.isHostname() || this.isIp()"
  3333. },
  3334. (predefined).cel = {
  3335. id: "string.address_empty"
  3336. message: "value is empty, which is not a valid hostname, or ip address"
  3337. expression: "!rules.address || this != ''"
  3338. }
  3339. ];
  3340. // `uuid` specifies that the field value must have the textual shape of a
  3341. // UUID as defined by
  3342. // [RFC 9562](https://datatracker.ietf.org/doc/html/rfc9562#section-4): 32
  3343. // hexadecimal digits in five dash-separated groups. Only the shape is
  3344. // enforced, so that UUID versions defined in the future are not rejected:
  3345. // the version and variant fields are not checked. If the field value isn't
  3346. // shaped like a UUID, an error message will be generated.
  3347. //
  3348. // ```proto
  3349. // message MyString {
  3350. // // must be a valid UUID
  3351. // string value = 1 [(buf.validate.field).string.uuid = true];
  3352. // }
  3353. // ```
  3354. bool uuid = 22 [
  3355. (predefined).cel = {
  3356. id: "string.uuid"
  3357. message: "must be a valid UUID"
  3358. expression: "!rules.uuid || this == '' || this.matches('^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$')"
  3359. },
  3360. (predefined).cel = {
  3361. id: "string.uuid_empty"
  3362. message: "value is empty, which is not a valid UUID"
  3363. expression: "!rules.uuid || this != ''"
  3364. }
  3365. ];
  3366. // `tuuid` (trimmed UUID) specifies that the field value must have the
  3367. // textual shape of a UUID as defined by
  3368. // [RFC 9562](https://datatracker.ietf.org/doc/html/rfc9562#section-4) with all
  3369. // dashes omitted: 32 hexadecimal digits. Only the shape is enforced, so
  3370. // that UUID versions defined in the future are not rejected: the version
  3371. // and variant fields are not checked. If the field value isn't shaped like
  3372. // a UUID without dashes, an error message will be generated.
  3373. //
  3374. // ```proto
  3375. // message MyString {
  3376. // // must be a valid trimmed UUID
  3377. // string value = 1 [(buf.validate.field).string.tuuid = true];
  3378. // }
  3379. // ```
  3380. bool tuuid = 33 [
  3381. (predefined).cel = {
  3382. id: "string.tuuid"
  3383. message: "must be a valid trimmed UUID"
  3384. expression: "!rules.tuuid || this == '' || this.matches('^[0-9a-fA-F]{32}$')"
  3385. },
  3386. (predefined).cel = {
  3387. id: "string.tuuid_empty"
  3388. message: "value is empty, which is not a valid trimmed UUID"
  3389. expression: "!rules.tuuid || this != ''"
  3390. }
  3391. ];
  3392. // `ip_with_prefixlen` specifies that the field value must be a valid IP
  3393. // (v4 or v6) address with prefix length—for example, "192.168.5.21/16" or
  3394. // "2001:0DB8:ABCD:0012::F1/64". If the field value isn't a valid IP with
  3395. // prefix length, an error message will be generated.
  3396. //
  3397. // ```proto
  3398. // message MyString {
  3399. // // must be a valid IP with prefix length
  3400. // string value = 1 [(buf.validate.field).string.ip_with_prefixlen = true];
  3401. // }
  3402. // ```
  3403. bool ip_with_prefixlen = 26 [
  3404. (predefined).cel = {
  3405. id: "string.ip_with_prefixlen"
  3406. message: "must be a valid IP prefix"
  3407. expression: "!rules.ip_with_prefixlen || this == '' || this.isIpPrefix()"
  3408. },
  3409. (predefined).cel = {
  3410. id: "string.ip_with_prefixlen_empty"
  3411. message: "value is empty, which is not a valid IP prefix"
  3412. expression: "!rules.ip_with_prefixlen || this != ''"
  3413. }
  3414. ];
  3415. // `ipv4_with_prefixlen` specifies that the field value must be a valid
  3416. // IPv4 address with prefix length—for example, "192.168.5.21/16". If the
  3417. // field value isn't a valid IPv4 address with prefix length, an error
  3418. // message will be generated.
  3419. //
  3420. // ```proto
  3421. // message MyString {
  3422. // // must be a valid IPv4 address with prefix length
  3423. // string value = 1 [(buf.validate.field).string.ipv4_with_prefixlen = true];
  3424. // }
  3425. // ```
  3426. bool ipv4_with_prefixlen = 27 [
  3427. (predefined).cel = {
  3428. id: "string.ipv4_with_prefixlen"
  3429. message: "must be a valid IPv4 address with prefix length"
  3430. expression: "!rules.ipv4_with_prefixlen || this == '' || this.isIpPrefix(4)"
  3431. },
  3432. (predefined).cel = {
  3433. id: "string.ipv4_with_prefixlen_empty"
  3434. message: "value is empty, which is not a valid IPv4 address with prefix length"
  3435. expression: "!rules.ipv4_with_prefixlen || this != ''"
  3436. }
  3437. ];
  3438. // `ipv6_with_prefixlen` specifies that the field value must be a valid
  3439. // IPv6 address with prefix length—for example, "2001:0DB8:ABCD:0012::F1/64".
  3440. // If the field value is not a valid IPv6 address with prefix length,
  3441. // an error message will be generated.
  3442. //
  3443. // ```proto
  3444. // message MyString {
  3445. // // must be a valid IPv6 address prefix length
  3446. // string value = 1 [(buf.validate.field).string.ipv6_with_prefixlen = true];
  3447. // }
  3448. // ```
  3449. bool ipv6_with_prefixlen = 28 [
  3450. (predefined).cel = {
  3451. id: "string.ipv6_with_prefixlen"
  3452. message: "must be a valid IPv6 address with prefix length"
  3453. expression: "!rules.ipv6_with_prefixlen || this == '' || this.isIpPrefix(6)"
  3454. },
  3455. (predefined).cel = {
  3456. id: "string.ipv6_with_prefixlen_empty"
  3457. message: "value is empty, which is not a valid IPv6 address with prefix length"
  3458. expression: "!rules.ipv6_with_prefixlen || this != ''"
  3459. }
  3460. ];
  3461. // `ip_prefix` specifies that the field value must be a valid IP (v4 or v6)
  3462. // prefix—for example, "192.168.0.0/16" or "2001:0DB8:ABCD:0012::0/64".
  3463. //
  3464. // The prefix must have all zeros for the unmasked bits. For example,
  3465. // "2001:0DB8:ABCD:0012::0/64" designates the left-most 64 bits for the
  3466. // prefix, and the remaining 64 bits must be zero.
  3467. //
  3468. // If the field value isn't a valid IP prefix, an error message will be
  3469. // generated.
  3470. //
  3471. // ```proto
  3472. // message MyString {
  3473. // // must be a valid IP prefix
  3474. // string value = 1 [(buf.validate.field).string.ip_prefix = true];
  3475. // }
  3476. // ```
  3477. bool ip_prefix = 29 [
  3478. (predefined).cel = {
  3479. id: "string.ip_prefix"
  3480. message: "must be a valid IP prefix"
  3481. expression: "!rules.ip_prefix || this == '' || this.isIpPrefix(true)"
  3482. },
  3483. (predefined).cel = {
  3484. id: "string.ip_prefix_empty"
  3485. message: "value is empty, which is not a valid IP prefix"
  3486. expression: "!rules.ip_prefix || this != ''"
  3487. }
  3488. ];
  3489. // `ipv4_prefix` specifies that the field value must be a valid IPv4
  3490. // prefix, for example "192.168.0.0/16".
  3491. //
  3492. // The prefix must have all zeros for the unmasked bits. For example,
  3493. // "192.168.0.0/16" designates the left-most 16 bits for the prefix,
  3494. // and the remaining 16 bits must be zero.
  3495. //
  3496. // If the field value isn't a valid IPv4 prefix, an error message
  3497. // will be generated.
  3498. //
  3499. // ```proto
  3500. // message MyString {
  3501. // // must be a valid IPv4 prefix
  3502. // string value = 1 [(buf.validate.field).string.ipv4_prefix = true];
  3503. // }
  3504. // ```
  3505. bool ipv4_prefix = 30 [
  3506. (predefined).cel = {
  3507. id: "string.ipv4_prefix"
  3508. message: "must be a valid IPv4 prefix"
  3509. expression: "!rules.ipv4_prefix || this == '' || this.isIpPrefix(4, true)"
  3510. },
  3511. (predefined).cel = {
  3512. id: "string.ipv4_prefix_empty"
  3513. message: "value is empty, which is not a valid IPv4 prefix"
  3514. expression: "!rules.ipv4_prefix || this != ''"
  3515. }
  3516. ];
  3517. // `ipv6_prefix` specifies that the field value must be a valid IPv6 prefix—for
  3518. // example, "2001:0DB8:ABCD:0012::0/64".
  3519. //
  3520. // The prefix must have all zeros for the unmasked bits. For example,
  3521. // "2001:0DB8:ABCD:0012::0/64" designates the left-most 64 bits for the
  3522. // prefix, and the remaining 64 bits must be zero.
  3523. //
  3524. // If the field value is not a valid IPv6 prefix, an error message will be
  3525. // generated.
  3526. //
  3527. // ```proto
  3528. // message MyString {
  3529. // // must be a valid IPv6 prefix
  3530. // string value = 1 [(buf.validate.field).string.ipv6_prefix = true];
  3531. // }
  3532. // ```
  3533. bool ipv6_prefix = 31 [
  3534. (predefined).cel = {
  3535. id: "string.ipv6_prefix"
  3536. message: "must be a valid IPv6 prefix"
  3537. expression: "!rules.ipv6_prefix || this == '' || this.isIpPrefix(6, true)"
  3538. },
  3539. (predefined).cel = {
  3540. id: "string.ipv6_prefix_empty"
  3541. message: "value is empty, which is not a valid IPv6 prefix"
  3542. expression: "!rules.ipv6_prefix || this != ''"
  3543. }
  3544. ];
  3545. // `host_and_port` specifies that the field value must be a valid host/port
  3546. // pair—for example, "example.com:8080".
  3547. //
  3548. // The host can be one of:
  3549. // - An IPv4 address in dotted decimal format—for example, "192.168.5.21".
  3550. // - An IPv6 address enclosed in square brackets—for example, "[2001:0DB8:ABCD:0012::F1]".
  3551. // - A hostname—for example, "example.com".
  3552. //
  3553. // The port is separated by a colon. It must be non-empty, with a decimal number
  3554. // in the range of 0-65535, inclusive.
  3555. bool host_and_port = 32 [
  3556. (predefined).cel = {
  3557. id: "string.host_and_port"
  3558. message: "must be a valid host (hostname or IP address) and port pair"
  3559. expression: "!rules.host_and_port || this == '' || this.isHostAndPort(true)"
  3560. },
  3561. (predefined).cel = {
  3562. id: "string.host_and_port_empty"
  3563. message: "value is empty, which is not a valid host and port pair"
  3564. expression: "!rules.host_and_port || this != ''"
  3565. }
  3566. ];
  3567. // `ulid` specifies that the field value must be a valid ULID (Universally Unique
  3568. // Lexicographically Sortable Identifier) as defined by the [ULID specification](https://github.com/ulid/spec).
  3569. // If the field value isn't a valid ULID, an error message will be generated.
  3570. //
  3571. // ```proto
  3572. // message MyString {
  3573. // // must be a valid ULID
  3574. // string value = 1 [(buf.validate.field).string.ulid = true];
  3575. // }
  3576. // ```
  3577. bool ulid = 35 [
  3578. (predefined).cel = {
  3579. id: "string.ulid"
  3580. message: "must be a valid ULID"
  3581. expression: "!rules.ulid || this == '' || this.matches('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$')"
  3582. },
  3583. (predefined).cel = {
  3584. id: "string.ulid_empty"
  3585. message: "value is empty, which is not a valid ULID"
  3586. expression: "!rules.ulid || this != ''"
  3587. }
  3588. ];
  3589. // `protobuf_fqn` specifies that the field value must be a valid fully-qualified
  3590. // Protobuf name as defined by the [Protobuf Language Specification](https://protobuf.com/docs/language-spec).
  3591. //
  3592. // A fully-qualified Protobuf name is a dot-separated list of Protobuf identifiers,
  3593. // where each identifier starts with a letter or underscore and is followed by zero or
  3594. // more letters, underscores, or digits.
  3595. //
  3596. // Examples: "buf.validate", "google.protobuf.Timestamp", "my_package.MyMessage".
  3597. //
  3598. // Note: historically, fully-qualified Protobuf names were represented with a leading
  3599. // dot (for example, ".buf.validate.StringRules"). Modern Protobuf does not use the
  3600. // leading dot, and most fully-qualified names are represented without it. Use
  3601. // `protobuf_dot_fqn` if a leading dot is required.
  3602. //
  3603. // If the field value isn't a valid fully-qualified Protobuf name, an error message
  3604. // will be generated.
  3605. //
  3606. // ```proto
  3607. // message MyString {
  3608. // // value must be a valid fully-qualified Protobuf name
  3609. // string value = 1 [(buf.validate.field).string.protobuf_fqn = true];
  3610. // }
  3611. // ```
  3612. bool protobuf_fqn = 37 [
  3613. (predefined).cel = {
  3614. id: "string.protobuf_fqn"
  3615. message: "must be a valid fully-qualified Protobuf name"
  3616. expression: "!rules.protobuf_fqn || this == '' || this.matches('^[A-Za-z_][A-Za-z_0-9]*(\\\\.[A-Za-z_][A-Za-z_0-9]*)*$')"
  3617. },
  3618. (predefined).cel = {
  3619. id: "string.protobuf_fqn_empty"
  3620. message: "value is empty, which is not a valid fully-qualified Protobuf name"
  3621. expression: "!rules.protobuf_fqn || this != ''"
  3622. }
  3623. ];
  3624. // `protobuf_dot_fqn` specifies that the field value must be a valid fully-qualified
  3625. // Protobuf name with a leading dot, as defined by the
  3626. // [Protobuf Language Specification](https://protobuf.com/docs/language-spec).
  3627. //
  3628. // A fully-qualified Protobuf name with a leading dot is a dot followed by a
  3629. // dot-separated list of Protobuf identifiers, where each identifier starts with a
  3630. // letter or underscore and is followed by zero or more letters, underscores, or
  3631. // digits.
  3632. //
  3633. // Examples: ".buf.validate", ".google.protobuf.Timestamp", ".my_package.MyMessage".
  3634. //
  3635. // Note: this is the historical representation of fully-qualified Protobuf names,
  3636. // where a leading dot denotes an absolute reference. Modern Protobuf does not use
  3637. // the leading dot, and most fully-qualified names are represented without it. Most
  3638. // users will want to use `protobuf_fqn` instead.
  3639. //
  3640. // If the field value isn't a valid fully-qualified Protobuf name with a leading dot,
  3641. // an error message will be generated.
  3642. //
  3643. // ```proto
  3644. // message MyString {
  3645. // // value must be a valid fully-qualified Protobuf name with a leading dot
  3646. // string value = 1 [(buf.validate.field).string.protobuf_dot_fqn = true];
  3647. // }
  3648. // ```
  3649. bool protobuf_dot_fqn = 38 [
  3650. (predefined).cel = {
  3651. id: "string.protobuf_dot_fqn"
  3652. message: "must be a valid fully-qualified Protobuf name with a leading dot"
  3653. expression: "!rules.protobuf_dot_fqn || this == '' || this.matches('^\\\\.[A-Za-z_][A-Za-z_0-9]*(\\\\.[A-Za-z_][A-Za-z_0-9]*)*$')"
  3654. },
  3655. (predefined).cel = {
  3656. id: "string.protobuf_dot_fqn_empty"
  3657. message: "value is empty, which is not a valid fully-qualified Protobuf name with a leading dot"
  3658. expression: "!rules.protobuf_dot_fqn || this != ''"
  3659. }
  3660. ];
  3661. // `well_known_regex` specifies a common well-known pattern
  3662. // defined as a regex. If the field value doesn't match the well-known
  3663. // regex, an error message will be generated.
  3664. //
  3665. // ```proto
  3666. // message MyString {
  3667. // // must be a valid HTTP header value
  3668. // string value = 1 [(buf.validate.field).string.well_known_regex = KNOWN_REGEX_HTTP_HEADER_VALUE];
  3669. // }
  3670. // ```
  3671. //
  3672. // #### KnownRegex
  3673. //
  3674. // `well_known_regex` contains some well-known patterns.
  3675. //
  3676. // | Name | Number | Description |
  3677. // |-------------------------------|--------|-------------------------------------------|
  3678. // | KNOWN_REGEX_UNSPECIFIED | 0 | |
  3679. // | KNOWN_REGEX_HTTP_HEADER_NAME | 1 | HTTP header name as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2) |
  3680. // | KNOWN_REGEX_HTTP_HEADER_VALUE | 2 | HTTP header value as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4) |
  3681. KnownRegex well_known_regex = 24 [
  3682. (predefined).cel = {
  3683. id: "string.well_known_regex.header_name"
  3684. message: "must be a valid HTTP header name"
  3685. expression:
  3686. "rules.well_known_regex != 1 || this == '' || this.matches(!has(rules.strict) || rules.strict ?"
  3687. "'^:?[0-9a-zA-Z!#$%&\\'*+.^_|~\\x60-]+$' :"
  3688. "'^[^\\u0000\\u000A\\u000D]+$')"
  3689. },
  3690. (predefined).cel = {
  3691. id: "string.well_known_regex.header_name_empty"
  3692. message: "value is empty, which is not a valid HTTP header name"
  3693. expression: "rules.well_known_regex != 1 || this != ''"
  3694. },
  3695. (predefined).cel = {
  3696. id: "string.well_known_regex.header_value"
  3697. message: "must be a valid HTTP header value"
  3698. expression:
  3699. "rules.well_known_regex != 2 || this.matches(!has(rules.strict) || rules.strict ?"
  3700. "'^[^\\u0000-\\u0008\\u000A-\\u001F\\u007F]*$' :"
  3701. "'^[^\\u0000\\u000A\\u000D]*$')"
  3702. }
  3703. ];
  3704. }
  3705. // This applies to regexes `HTTP_HEADER_NAME` and `HTTP_HEADER_VALUE` to
  3706. // enable strict header validation. By default, this is true, and HTTP header
  3707. // validations are [RFC-compliant](https://datatracker.ietf.org/doc/html/rfc7230#section-3). Setting to false will enable looser
  3708. // validations that only disallow `\r\n\0` characters, which can be used to
  3709. // bypass header matching rules.
  3710. //
  3711. // ```proto
  3712. // message MyString {
  3713. // // The field `value` must have be a valid HTTP headers, but not enforced with strict rules.
  3714. // string value = 1 [(buf.validate.field).string.strict = false];
  3715. // }
  3716. // ```
  3717. optional bool strict = 25;
  3718. // `example` specifies values that the field may have. These values SHOULD
  3719. // conform to other rules. `example` values will not impact validation
  3720. // but may be used as helpful guidance on how to populate the given field.
  3721. //
  3722. // ```proto
  3723. // message MyString {
  3724. // string value = 1 [
  3725. // (buf.validate.field).string.example = "hello",
  3726. // (buf.validate.field).string.example = "world"
  3727. // ];
  3728. // }
  3729. // ```
  3730. repeated string example = 34 [(predefined).cel = {
  3731. id: "string.example"
  3732. expression: "true"
  3733. }];
  3734. // Extension fields that have the (buf.validate.predefined) option set
  3735. // will be treated as predefined field rules.
  3736. // See https://protovalidate.com/schemas/predefined-rules/
  3737. extensions 1000 to max;
  3738. }
  3739. // KnownRegex contains some well-known patterns.
  3740. enum KnownRegex {
  3741. KNOWN_REGEX_UNSPECIFIED = 0;
  3742. // HTTP header name as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2).
  3743. KNOWN_REGEX_HTTP_HEADER_NAME = 1;
  3744. // HTTP header value as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4).
  3745. KNOWN_REGEX_HTTP_HEADER_VALUE = 2;
  3746. }
  3747. // BytesRules describe the rules applied to `bytes` values. These rules
  3748. // may also be applied to the `google.protobuf.BytesValue` Well-Known-Type.
  3749. message BytesRules {
  3750. // `const` requires the field value to exactly match the specified bytes
  3751. // value. If the field value doesn't match, an error message is generated.
  3752. //
  3753. // ```proto
  3754. // message MyBytes {
  3755. // // must be "\x01\x02\x03\x04"
  3756. // bytes value = 1 [(buf.validate.field).bytes.const = "\x01\x02\x03\x04"];
  3757. // }
  3758. // ```
  3759. optional bytes const = 1 [(predefined).cel = {
  3760. id: "bytes.const"
  3761. expression: "this != getField(rules, 'const') ? 'must be %x'.format([getField(rules, 'const')]) : ''"
  3762. }];
  3763. // `len` requires the field value to have the specified length in bytes.
  3764. // If the field value doesn't match, an error message is generated.
  3765. //
  3766. // ```proto
  3767. // message MyBytes {
  3768. // // value length must be 4 bytes.
  3769. // optional bytes value = 1 [(buf.validate.field).bytes.len = 4];
  3770. // }
  3771. // ```
  3772. optional uint64 len = 13 [(predefined).cel = {
  3773. id: "bytes.len"
  3774. expression: "uint(this.size()) != rules.len ? 'must be %s bytes'.format([rules.len]) : ''"
  3775. }];
  3776. // `min_len` requires the field value to have at least the specified minimum
  3777. // length in bytes.
  3778. // If the field value doesn't meet the requirement, an error message is generated.
  3779. //
  3780. // ```proto
  3781. // message MyBytes {
  3782. // // value length must be at least 2 bytes.
  3783. // optional bytes value = 1 [(buf.validate.field).bytes.min_len = 2];
  3784. // }
  3785. // ```
  3786. optional uint64 min_len = 2 [(predefined).cel = {
  3787. id: "bytes.min_len"
  3788. expression: "uint(this.size()) < rules.min_len ? 'must be at least %s bytes'.format([rules.min_len]) : ''"
  3789. }];
  3790. // `max_len` requires the field value to have at most the specified maximum
  3791. // length in bytes.
  3792. // If the field value exceeds the requirement, an error message is generated.
  3793. //
  3794. // ```proto
  3795. // message MyBytes {
  3796. // // must be at most 6 bytes.
  3797. // optional bytes value = 1 [(buf.validate.field).bytes.max_len = 6];
  3798. // }
  3799. // ```
  3800. optional uint64 max_len = 3 [(predefined).cel = {
  3801. id: "bytes.max_len"
  3802. expression: "uint(this.size()) > rules.max_len ? 'must be at most %s bytes'.format([rules.max_len]) : ''"
  3803. }];
  3804. // `pattern` requires the field value to match the specified regular
  3805. // expression ([RE2 syntax](https://github.com/google/re2/wiki/Syntax)).
  3806. // The value of the field must be valid UTF-8 or validation will fail with a
  3807. // runtime error.
  3808. // If the field value doesn't match the pattern, an error message is generated.
  3809. //
  3810. // ```proto
  3811. // message MyBytes {
  3812. // // value must match regex pattern "^[a-zA-Z0-9]+$".
  3813. // optional bytes value = 1 [(buf.validate.field).bytes.pattern = "^[a-zA-Z0-9]+$"];
  3814. // }
  3815. // ```
  3816. optional string pattern = 4 [(predefined).cel = {
  3817. id: "bytes.pattern"
  3818. expression: "!string(this).matches(rules.pattern) ? 'must match regex pattern `%s`'.format([rules.pattern]) : ''"
  3819. }];
  3820. // `prefix` requires the field value to have the specified bytes at the
  3821. // beginning of the string.
  3822. // If the field value doesn't meet the requirement, an error message is generated.
  3823. //
  3824. // ```proto
  3825. // message MyBytes {
  3826. // // value does not have prefix \x01\x02
  3827. // optional bytes value = 1 [(buf.validate.field).bytes.prefix = "\x01\x02"];
  3828. // }
  3829. // ```
  3830. optional bytes prefix = 5 [(predefined).cel = {
  3831. id: "bytes.prefix"
  3832. expression: "!this.startsWith(rules.prefix) ? 'does not have prefix %x'.format([rules.prefix]) : ''"
  3833. }];
  3834. // `suffix` requires the field value to have the specified bytes at the end
  3835. // of the string.
  3836. // If the field value doesn't meet the requirement, an error message is generated.
  3837. //
  3838. // ```proto
  3839. // message MyBytes {
  3840. // // value does not have suffix \x03\x04
  3841. // optional bytes value = 1 [(buf.validate.field).bytes.suffix = "\x03\x04"];
  3842. // }
  3843. // ```
  3844. optional bytes suffix = 6 [(predefined).cel = {
  3845. id: "bytes.suffix"
  3846. expression: "!this.endsWith(rules.suffix) ? 'does not have suffix %x'.format([rules.suffix]) : ''"
  3847. }];
  3848. // `contains` requires the field value to have the specified bytes anywhere in
  3849. // the string.
  3850. // If the field value doesn't meet the requirement, an error message is generated.
  3851. //
  3852. // ```proto
  3853. // message MyBytes {
  3854. // // value does not contain \x02\x03
  3855. // optional bytes value = 1 [(buf.validate.field).bytes.contains = "\x02\x03"];
  3856. // }
  3857. // ```
  3858. optional bytes contains = 7 [(predefined).cel = {
  3859. id: "bytes.contains"
  3860. expression: "!this.contains(rules.contains) ? 'does not contain %x'.format([rules.contains]) : ''"
  3861. }];
  3862. // `in` requires the field value to be equal to one of the specified
  3863. // values. If the field value doesn't match any of the specified values, an
  3864. // error message is generated.
  3865. //
  3866. // ```proto
  3867. // message MyBytes {
  3868. // // value must in ["\x01\x02", "\x02\x03", "\x03\x04"]
  3869. // optional bytes value = 1 [(buf.validate.field).bytes = { in: ["\x01\x02", "\x02\x03", "\x03\x04"] }];
  3870. // }
  3871. // ```
  3872. repeated bytes in = 8 [(predefined).cel = {
  3873. id: "bytes.in"
  3874. expression: "getField(rules, 'in').size() > 0 && !(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  3875. }];
  3876. // `not_in` requires the field value to be not equal to any of the specified
  3877. // values.
  3878. // If the field value matches any of the specified values, an error message is
  3879. // generated.
  3880. //
  3881. // ```proto
  3882. // message MyBytes {
  3883. // // value must not in ["\x01\x02", "\x02\x03", "\x03\x04"]
  3884. // optional bytes value = 1 [(buf.validate.field).bytes = { not_in: ["\x01\x02", "\x02\x03", "\x03\x04"] }];
  3885. // }
  3886. // ```
  3887. repeated bytes not_in = 9 [(predefined).cel = {
  3888. id: "bytes.not_in"
  3889. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  3890. }];
  3891. // WellKnown rules provide advanced rules against common byte
  3892. // patterns
  3893. oneof well_known {
  3894. // `ip` ensures that the field `value` is a valid IP address (v4 or v6) in byte format.
  3895. // If the field value doesn't meet this rule, an error message is generated.
  3896. //
  3897. // ```proto
  3898. // message MyBytes {
  3899. // // must be a valid IP address
  3900. // optional bytes value = 1 [(buf.validate.field).bytes.ip = true];
  3901. // }
  3902. // ```
  3903. bool ip = 10 [
  3904. (predefined).cel = {
  3905. id: "bytes.ip"
  3906. message: "must be a valid IP address"
  3907. expression: "!rules.ip || this.size() == 0 || this.size() == 4 || this.size() == 16"
  3908. },
  3909. (predefined).cel = {
  3910. id: "bytes.ip_empty"
  3911. message: "value is empty, which is not a valid IP address"
  3912. expression: "!rules.ip || this.size() != 0"
  3913. }
  3914. ];
  3915. // `ipv4` ensures that the field `value` is a valid IPv4 address in byte format.
  3916. // If the field value doesn't meet this rule, an error message is generated.
  3917. //
  3918. // ```proto
  3919. // message MyBytes {
  3920. // // must be a valid IPv4 address
  3921. // optional bytes value = 1 [(buf.validate.field).bytes.ipv4 = true];
  3922. // }
  3923. // ```
  3924. bool ipv4 = 11 [
  3925. (predefined).cel = {
  3926. id: "bytes.ipv4"
  3927. message: "must be a valid IPv4 address"
  3928. expression: "!rules.ipv4 || this.size() == 0 || this.size() == 4"
  3929. },
  3930. (predefined).cel = {
  3931. id: "bytes.ipv4_empty"
  3932. message: "value is empty, which is not a valid IPv4 address"
  3933. expression: "!rules.ipv4 || this.size() != 0"
  3934. }
  3935. ];
  3936. // `ipv6` ensures that the field `value` is a valid IPv6 address in byte format.
  3937. // If the field value doesn't meet this rule, an error message is generated.
  3938. // ```proto
  3939. // message MyBytes {
  3940. // // must be a valid IPv6 address
  3941. // optional bytes value = 1 [(buf.validate.field).bytes.ipv6 = true];
  3942. // }
  3943. // ```
  3944. bool ipv6 = 12 [
  3945. (predefined).cel = {
  3946. id: "bytes.ipv6"
  3947. message: "must be a valid IPv6 address"
  3948. expression: "!rules.ipv6 || this.size() == 0 || this.size() == 16"
  3949. },
  3950. (predefined).cel = {
  3951. id: "bytes.ipv6_empty"
  3952. message: "value is empty, which is not a valid IPv6 address"
  3953. expression: "!rules.ipv6 || this.size() != 0"
  3954. }
  3955. ];
  3956. // `uuid` ensures that the field `value` is exactly 16 bytes long,
  3957. // the size of a UUID in binary form as defined by
  3958. // [RFC 9562](https://datatracker.ietf.org/doc/html/rfc9562#section-4).
  3959. // Only the length is enforced: the version and variant fields
  3960. // are not checked, and any 16 bytes are accepted.
  3961. // If the field value doesn't meet this rule, an error message is generated.
  3962. //
  3963. // ```proto
  3964. // message MyBytes {
  3965. // // must be a valid UUID
  3966. // optional bytes value = 1 [(buf.validate.field).bytes.uuid = true];
  3967. // }
  3968. // ```
  3969. bool uuid = 15 [
  3970. (predefined).cel = {
  3971. id: "bytes.uuid"
  3972. message: "must be a valid UUID"
  3973. expression: "!rules.uuid || this.size() == 0 || this.size() == 16"
  3974. },
  3975. (predefined).cel = {
  3976. id: "bytes.uuid_empty"
  3977. message: "value is empty, which is not a valid UUID"
  3978. expression: "!rules.uuid || this.size() != 0"
  3979. }
  3980. ];
  3981. }
  3982. // `example` specifies values that the field may have. These values SHOULD
  3983. // conform to other rules. `example` values will not impact validation
  3984. // but may be used as helpful guidance on how to populate the given field.
  3985. //
  3986. // ```proto
  3987. // message MyBytes {
  3988. // bytes value = 1 [
  3989. // (buf.validate.field).bytes.example = "\x01\x02",
  3990. // (buf.validate.field).bytes.example = "\x02\x03"
  3991. // ];
  3992. // }
  3993. // ```
  3994. repeated bytes example = 14 [(predefined).cel = {
  3995. id: "bytes.example"
  3996. expression: "true"
  3997. }];
  3998. // Extension fields that have the (buf.validate.predefined) option set
  3999. // will be treated as predefined field rules.
  4000. // See https://protovalidate.com/schemas/predefined-rules/
  4001. extensions 1000 to max;
  4002. }
  4003. // EnumRules describe the rules applied to `enum` values.
  4004. message EnumRules {
  4005. // `const` requires the field value to exactly match the specified enum value.
  4006. // If the field value doesn't match, an error message is generated.
  4007. //
  4008. // ```proto
  4009. // enum MyEnum {
  4010. // MY_ENUM_UNSPECIFIED = 0;
  4011. // MY_ENUM_VALUE1 = 1;
  4012. // MY_ENUM_VALUE2 = 2;
  4013. // }
  4014. //
  4015. // message MyMessage {
  4016. // // The field `value` must be exactly MY_ENUM_VALUE1.
  4017. // MyEnum value = 1 [(buf.validate.field).enum.const = 1];
  4018. // }
  4019. // ```
  4020. optional int32 const = 1 [(predefined).cel = {
  4021. id: "enum.const"
  4022. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  4023. }];
  4024. // `defined_only` requires the field value to be one of the defined values for
  4025. // this enum, failing on any undefined value.
  4026. //
  4027. // ```proto
  4028. // enum MyEnum {
  4029. // MY_ENUM_UNSPECIFIED = 0;
  4030. // MY_ENUM_VALUE1 = 1;
  4031. // MY_ENUM_VALUE2 = 2;
  4032. // }
  4033. //
  4034. // message MyMessage {
  4035. // // The field `value` must be a defined value of MyEnum.
  4036. // MyEnum value = 1 [(buf.validate.field).enum.defined_only = true];
  4037. // }
  4038. // ```
  4039. optional bool defined_only = 2;
  4040. // `in` requires the field value to be equal to one of the
  4041. // specified enum values. If the field value doesn't match any of the
  4042. // specified values, an error message is generated.
  4043. //
  4044. // ```proto
  4045. // enum MyEnum {
  4046. // MY_ENUM_UNSPECIFIED = 0;
  4047. // MY_ENUM_VALUE1 = 1;
  4048. // MY_ENUM_VALUE2 = 2;
  4049. // }
  4050. //
  4051. // message MyMessage {
  4052. // // The field `value` must be equal to one of the specified values.
  4053. // MyEnum value = 1 [(buf.validate.field).enum = { in: [1, 2]}];
  4054. // }
  4055. // ```
  4056. repeated int32 in = 3 [(predefined).cel = {
  4057. id: "enum.in"
  4058. expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  4059. }];
  4060. // `not_in` requires the field value to be not equal to any of the
  4061. // specified enum values. If the field value matches one of the specified
  4062. // values, an error message is generated.
  4063. //
  4064. // ```proto
  4065. // enum MyEnum {
  4066. // MY_ENUM_UNSPECIFIED = 0;
  4067. // MY_ENUM_VALUE1 = 1;
  4068. // MY_ENUM_VALUE2 = 2;
  4069. // }
  4070. //
  4071. // message MyMessage {
  4072. // // The field `value` must not be equal to any of the specified values.
  4073. // MyEnum value = 1 [(buf.validate.field).enum = { not_in: [1, 2]}];
  4074. // }
  4075. // ```
  4076. repeated int32 not_in = 4 [(predefined).cel = {
  4077. id: "enum.not_in"
  4078. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  4079. }];
  4080. // `example` specifies values that the field may have. These values SHOULD
  4081. // conform to other rules. `example` values will not impact validation
  4082. // but may be used as helpful guidance on how to populate the given field.
  4083. //
  4084. // ```proto
  4085. // enum MyEnum {
  4086. // MY_ENUM_UNSPECIFIED = 0;
  4087. // MY_ENUM_VALUE1 = 1;
  4088. // MY_ENUM_VALUE2 = 2;
  4089. // }
  4090. //
  4091. // message MyMessage {
  4092. // MyEnum value = 1 [
  4093. // (buf.validate.field).enum.example = 1,
  4094. // (buf.validate.field).enum.example = 2
  4095. // ];
  4096. // }
  4097. // ```
  4098. repeated int32 example = 5 [(predefined).cel = {
  4099. id: "enum.example"
  4100. expression: "true"
  4101. }];
  4102. // Extension fields that have the (buf.validate.predefined) option set
  4103. // will be treated as predefined field rules.
  4104. // See https://protovalidate.com/schemas/predefined-rules/
  4105. extensions 1000 to max;
  4106. }
  4107. // RepeatedRules describe the rules applied to `repeated` values.
  4108. message RepeatedRules {
  4109. // `min_items` requires that this field must contain at least the specified
  4110. // minimum number of items.
  4111. //
  4112. // Note that `min_items = 1` is equivalent to setting a field as `required`.
  4113. //
  4114. // ```proto
  4115. // message MyRepeated {
  4116. // // value must contain at least 2 items
  4117. // repeated string value = 1 [(buf.validate.field).repeated.min_items = 2];
  4118. // }
  4119. // ```
  4120. optional uint64 min_items = 1 [(predefined).cel = {
  4121. id: "repeated.min_items"
  4122. expression: "uint(this.size()) < rules.min_items ? 'must contain at least %d item(s)'.format([rules.min_items]) : ''"
  4123. }];
  4124. // `max_items` denotes that this field must not exceed a
  4125. // certain number of items as the upper limit. If the field contains more
  4126. // items than specified, an error message will be generated, requiring the
  4127. // field to maintain no more than the specified number of items.
  4128. //
  4129. // ```proto
  4130. // message MyRepeated {
  4131. // // value must contain no more than 3 item(s)
  4132. // repeated string value = 1 [(buf.validate.field).repeated.max_items = 3];
  4133. // }
  4134. // ```
  4135. optional uint64 max_items = 2 [(predefined).cel = {
  4136. id: "repeated.max_items"
  4137. expression: "uint(this.size()) > rules.max_items ? 'must contain no more than %s item(s)'.format([rules.max_items]) : ''"
  4138. }];
  4139. // `unique` indicates that all elements in this field must
  4140. // be unique. This rule is strictly applicable to scalar and enum
  4141. // types, with message types not being supported.
  4142. //
  4143. // ```proto
  4144. // message MyRepeated {
  4145. // // repeated value must contain unique items
  4146. // repeated string value = 1 [(buf.validate.field).repeated.unique = true];
  4147. // }
  4148. // ```
  4149. optional bool unique = 3 [(predefined).cel = {
  4150. id: "repeated.unique"
  4151. message: "repeated value must contain unique items"
  4152. expression: "!rules.unique || this.unique()"
  4153. }];
  4154. // `items` details the rules to be applied to each item
  4155. // in the field. Even for repeated message fields, validation is executed
  4156. // against each item unless `ignore` is specified.
  4157. //
  4158. // ```proto
  4159. // message MyRepeated {
  4160. // // The items in the field `value` must follow the specified rules.
  4161. // repeated string value = 1 [(buf.validate.field).repeated.items = {
  4162. // string: {
  4163. // min_len: 3
  4164. // max_len: 10
  4165. // }
  4166. // }];
  4167. // }
  4168. // ```
  4169. //
  4170. // Note that the `required` rule does not apply. Repeated items
  4171. // cannot be unset.
  4172. optional FieldRules items = 4;
  4173. // Extension fields that have the (buf.validate.predefined) option set
  4174. // will be treated as predefined field rules.
  4175. // See https://protovalidate.com/schemas/predefined-rules/
  4176. extensions 1000 to max;
  4177. }
  4178. // MapRules describe the rules applied to `map` values.
  4179. message MapRules {
  4180. // Specifies the minimum number of key-value pairs allowed. If the field has
  4181. // fewer key-value pairs than specified, an error message is generated.
  4182. //
  4183. // ```proto
  4184. // message MyMap {
  4185. // // The field `value` must have at least 2 key-value pairs.
  4186. // map<string, string> value = 1 [(buf.validate.field).map.min_pairs = 2];
  4187. // }
  4188. // ```
  4189. optional uint64 min_pairs = 1 [(predefined).cel = {
  4190. id: "map.min_pairs"
  4191. expression: "uint(this.size()) < rules.min_pairs ? 'map must be at least %d entries'.format([rules.min_pairs]) : ''"
  4192. }];
  4193. // Specifies the maximum number of key-value pairs allowed. If the field has
  4194. // more key-value pairs than specified, an error message is generated.
  4195. //
  4196. // ```proto
  4197. // message MyMap {
  4198. // // The field `value` must have at most 3 key-value pairs.
  4199. // map<string, string> value = 1 [(buf.validate.field).map.max_pairs = 3];
  4200. // }
  4201. // ```
  4202. optional uint64 max_pairs = 2 [(predefined).cel = {
  4203. id: "map.max_pairs"
  4204. expression: "uint(this.size()) > rules.max_pairs ? 'map must be at most %d entries'.format([rules.max_pairs]) : ''"
  4205. }];
  4206. // Specifies the rules to be applied to each key in the field.
  4207. //
  4208. // ```proto
  4209. // message MyMap {
  4210. // // The keys in the field `value` must follow the specified rules.
  4211. // map<string, string> value = 1 [(buf.validate.field).map.keys = {
  4212. // string: {
  4213. // min_len: 3
  4214. // max_len: 10
  4215. // }
  4216. // }];
  4217. // }
  4218. // ```
  4219. //
  4220. // Note that the `required` rule does not apply. Map keys cannot be unset.
  4221. optional FieldRules keys = 4;
  4222. // Specifies the rules to be applied to the value of each key in the
  4223. // field. Message values will still have their validations evaluated unless
  4224. // `ignore` is specified.
  4225. //
  4226. // ```proto
  4227. // message MyMap {
  4228. // // The values in the field `value` must follow the specified rules.
  4229. // map<string, string> value = 1 [(buf.validate.field).map.values = {
  4230. // string: {
  4231. // min_len: 5
  4232. // max_len: 20
  4233. // }
  4234. // }];
  4235. // }
  4236. // ```
  4237. // Note that the `required` rule does not apply. Map values cannot be unset.
  4238. optional FieldRules values = 5;
  4239. // Extension fields that have the (buf.validate.predefined) option set
  4240. // will be treated as predefined field rules.
  4241. // See https://protovalidate.com/schemas/predefined-rules/
  4242. extensions 1000 to max;
  4243. }
  4244. // AnyRules describe rules applied exclusively to the `google.protobuf.Any` well-known type.
  4245. message AnyRules {
  4246. // `in` requires the field's `type_url` to be equal to one of the
  4247. // specified values. If it doesn't match any of the specified values, an error
  4248. // message is generated.
  4249. //
  4250. // ```proto
  4251. // message MyAny {
  4252. // // The `value` field must have a `type_url` equal to one of the specified values.
  4253. // google.protobuf.Any value = 1 [(buf.validate.field).any = {
  4254. // in: ["type.googleapis.com/MyType1", "type.googleapis.com/MyType2"]
  4255. // }];
  4256. // }
  4257. // ```
  4258. repeated string in = 2;
  4259. // `not_in` requires the field's type_url to be not equal to any of the specified values. If it matches any of the specified values, an error message is generated.
  4260. //
  4261. // ```proto
  4262. // message MyAny {
  4263. // // The `value` field must not have a `type_url` equal to any of the specified values.
  4264. // google.protobuf.Any value = 1 [(buf.validate.field).any = {
  4265. // not_in: ["type.googleapis.com/ForbiddenType1", "type.googleapis.com/ForbiddenType2"]
  4266. // }];
  4267. // }
  4268. // ```
  4269. repeated string not_in = 3;
  4270. }
  4271. // DurationRules describe the rules applied exclusively to the `google.protobuf.Duration` well-known type.
  4272. message DurationRules {
  4273. // `const` dictates that the field must match the specified value of the `google.protobuf.Duration` type exactly.
  4274. // If the field's value deviates from the specified value, an error message
  4275. // will be generated.
  4276. //
  4277. // ```proto
  4278. // message MyDuration {
  4279. // // value must equal 5s
  4280. // google.protobuf.Duration value = 1 [(buf.validate.field).duration.const = { seconds: 5 }];
  4281. // }
  4282. // ```
  4283. optional google.protobuf.Duration const = 2 [(predefined).cel = {
  4284. id: "duration.const"
  4285. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  4286. }];
  4287. oneof less_than {
  4288. // `lt` stipulates that the field must be less than the specified value of the `google.protobuf.Duration` type,
  4289. // exclusive. If the field's value is greater than or equal to the specified
  4290. // value, an error message will be generated.
  4291. //
  4292. // ```proto
  4293. // message MyDuration {
  4294. // // must be less than 5s
  4295. // google.protobuf.Duration value = 1 [(buf.validate.field).duration.lt = { seconds: 5 }];
  4296. // }
  4297. // ```
  4298. google.protobuf.Duration lt = 3 [(predefined).cel = {
  4299. id: "duration.lt"
  4300. expression:
  4301. "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
  4302. "? 'must be less than %s'.format([rules.lt]) : ''"
  4303. }];
  4304. // `lte` indicates that the field must be less than or equal to the specified
  4305. // value of the `google.protobuf.Duration` type, inclusive. If the field's value is greater than the specified value,
  4306. // an error message will be generated.
  4307. //
  4308. // ```proto
  4309. // message MyDuration {
  4310. // // must be less than or equal to 10s
  4311. // google.protobuf.Duration value = 1 [(buf.validate.field).duration.lte = { seconds: 10 }];
  4312. // }
  4313. // ```
  4314. google.protobuf.Duration lte = 4 [(predefined).cel = {
  4315. id: "duration.lte"
  4316. expression:
  4317. "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
  4318. "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
  4319. }];
  4320. }
  4321. oneof greater_than {
  4322. // `gt` requires the duration field value to be greater than the specified
  4323. // value (exclusive). If the value of `gt` is larger than a specified `lt`
  4324. // or `lte`, the range is reversed, and the field value must be outside the
  4325. // specified range. If the field value doesn't meet the required conditions,
  4326. // an error message is generated.
  4327. //
  4328. // ```proto
  4329. // message MyDuration {
  4330. // // duration must be greater than 5s [duration.gt]
  4331. // google.protobuf.Duration value = 1 [(buf.validate.field).duration.gt = { seconds: 5 }];
  4332. //
  4333. // // duration must be greater than 5s and less than 10s [duration.gt_lt]
  4334. // google.protobuf.Duration another_value = 2 [(buf.validate.field).duration = { gt: { seconds: 5 }, lt: { seconds: 10 } }];
  4335. //
  4336. // // duration must be greater than 10s or less than 5s [duration.gt_lt_exclusive]
  4337. // google.protobuf.Duration other_value = 3 [(buf.validate.field).duration = { gt: { seconds: 10 }, lt: { seconds: 5 } }];
  4338. // }
  4339. // ```
  4340. google.protobuf.Duration gt = 5 [
  4341. (predefined).cel = {
  4342. id: "duration.gt"
  4343. expression:
  4344. "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
  4345. "? 'must be greater than %s'.format([rules.gt]) : ''"
  4346. },
  4347. (predefined).cel = {
  4348. id: "duration.gt_lt"
  4349. expression:
  4350. "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
  4351. "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
  4352. },
  4353. (predefined).cel = {
  4354. id: "duration.gt_lt_exclusive"
  4355. expression:
  4356. "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
  4357. "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
  4358. },
  4359. (predefined).cel = {
  4360. id: "duration.gt_lte"
  4361. expression:
  4362. "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
  4363. "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  4364. },
  4365. (predefined).cel = {
  4366. id: "duration.gt_lte_exclusive"
  4367. expression:
  4368. "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
  4369. "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  4370. }
  4371. ];
  4372. // `gte` requires the duration field value to be greater than or equal to the
  4373. // specified value (exclusive). If the value of `gte` is larger than a
  4374. // specified `lt` or `lte`, the range is reversed, and the field value must
  4375. // be outside the specified range. If the field value doesn't meet the
  4376. // required conditions, an error message is generated.
  4377. //
  4378. // ```proto
  4379. // message MyDuration {
  4380. // // duration must be greater than or equal to 5s [duration.gte]
  4381. // google.protobuf.Duration value = 1 [(buf.validate.field).duration.gte = { seconds: 5 }];
  4382. //
  4383. // // duration must be greater than or equal to 5s and less than 10s [duration.gte_lt]
  4384. // google.protobuf.Duration another_value = 2 [(buf.validate.field).duration = { gte: { seconds: 5 }, lt: { seconds: 10 } }];
  4385. //
  4386. // // duration must be greater than or equal to 10s or less than 5s [duration.gte_lt_exclusive]
  4387. // google.protobuf.Duration other_value = 3 [(buf.validate.field).duration = { gte: { seconds: 10 }, lt: { seconds: 5 } }];
  4388. // }
  4389. // ```
  4390. google.protobuf.Duration gte = 6 [
  4391. (predefined).cel = {
  4392. id: "duration.gte"
  4393. expression:
  4394. "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
  4395. "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
  4396. },
  4397. (predefined).cel = {
  4398. id: "duration.gte_lt"
  4399. expression:
  4400. "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
  4401. "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
  4402. },
  4403. (predefined).cel = {
  4404. id: "duration.gte_lt_exclusive"
  4405. expression:
  4406. "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
  4407. "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
  4408. },
  4409. (predefined).cel = {
  4410. id: "duration.gte_lte"
  4411. expression:
  4412. "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
  4413. "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  4414. },
  4415. (predefined).cel = {
  4416. id: "duration.gte_lte_exclusive"
  4417. expression:
  4418. "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
  4419. "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  4420. }
  4421. ];
  4422. }
  4423. // `in` asserts that the field must be equal to one of the specified values of the `google.protobuf.Duration` type.
  4424. // If the field's value doesn't correspond to any of the specified values,
  4425. // an error message will be generated.
  4426. //
  4427. // ```proto
  4428. // message MyDuration {
  4429. // // must be in list [1s, 2s, 3s]
  4430. // google.protobuf.Duration value = 1 [(buf.validate.field).duration = {
  4431. // in: [{ seconds: 1 }, { seconds: 2 }, { seconds: 3 }]
  4432. // }];
  4433. // }
  4434. // ```
  4435. repeated google.protobuf.Duration in = 7 [(predefined).cel = {
  4436. id: "duration.in"
  4437. expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  4438. }];
  4439. // `not_in` denotes that the field must not be equal to
  4440. // any of the specified values of the `google.protobuf.Duration` type.
  4441. // If the field's value matches any of these values, an error message will be
  4442. // generated.
  4443. //
  4444. // ```proto
  4445. // message MyDuration {
  4446. // // value must not be in list [1s, 2s, 3s]
  4447. // google.protobuf.Duration value = 1 [(buf.validate.field).duration = {
  4448. // not_in: [{ seconds: 1 }, { seconds: 2 }, { seconds: 3 }]
  4449. // }];
  4450. // }
  4451. // ```
  4452. repeated google.protobuf.Duration not_in = 8 [(predefined).cel = {
  4453. id: "duration.not_in"
  4454. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  4455. }];
  4456. // `example` specifies values that the field may have. These values SHOULD
  4457. // conform to other rules. `example` values will not impact validation
  4458. // but may be used as helpful guidance on how to populate the given field.
  4459. //
  4460. // ```proto
  4461. // message MyDuration {
  4462. // google.protobuf.Duration value = 1 [
  4463. // (buf.validate.field).duration.example = { seconds: 1 },
  4464. // (buf.validate.field).duration.example = { seconds: 2 }
  4465. // ];
  4466. // }
  4467. // ```
  4468. repeated google.protobuf.Duration example = 9 [(predefined).cel = {
  4469. id: "duration.example"
  4470. expression: "true"
  4471. }];
  4472. // Extension fields that have the (buf.validate.predefined) option set
  4473. // will be treated as predefined field rules.
  4474. // See https://protovalidate.com/schemas/predefined-rules/
  4475. extensions 1000 to max;
  4476. }
  4477. // FieldMaskRules describe rules applied exclusively to the `google.protobuf.FieldMask` well-known type.
  4478. message FieldMaskRules {
  4479. // `const` dictates that the field must match the specified value of the `google.protobuf.FieldMask` type exactly.
  4480. // If the field's value deviates from the specified value, an error message
  4481. // will be generated.
  4482. //
  4483. // ```proto
  4484. // message MyFieldMask {
  4485. // // value must equal ["a"]
  4486. // google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask.const = {
  4487. // paths: ["a"]
  4488. // }];
  4489. // }
  4490. // ```
  4491. optional google.protobuf.FieldMask const = 1 [(predefined).cel = {
  4492. id: "field_mask.const"
  4493. expression: "this.paths != getField(rules, 'const').paths ? 'must equal paths %s'.format([getField(rules, 'const').paths]) : ''"
  4494. }];
  4495. // `in` requires the field value to only contain paths matching specified
  4496. // values or their subpaths.
  4497. // If any of the field value's paths doesn't match the rule,
  4498. // an error message is generated.
  4499. // See: https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask
  4500. //
  4501. // ```proto
  4502. // message MyFieldMask {
  4503. // // The `value` FieldMask must only contain paths listed in `in`.
  4504. // google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask = {
  4505. // in: ["a", "b", "c.a"]
  4506. // }];
  4507. // }
  4508. // ```
  4509. repeated string in = 2 [(predefined).cel = {
  4510. id: "field_mask.in"
  4511. expression: "!this.paths.all(p, p in getField(rules, 'in') || getField(rules, 'in').exists(f, p.startsWith(f+'.'))) ? 'must only contain paths in %s'.format([getField(rules, 'in')]) : ''"
  4512. }];
  4513. // `not_in` requires the field value to not contain paths matching specified
  4514. // values or their subpaths.
  4515. // If any of the field value's paths matches the rule,
  4516. // an error message is generated.
  4517. // See: https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask
  4518. //
  4519. // ```proto
  4520. // message MyFieldMask {
  4521. // // The `value` FieldMask shall not contain paths listed in `not_in`.
  4522. // google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask = {
  4523. // not_in: ["forbidden", "immutable", "c.a"]
  4524. // }];
  4525. // }
  4526. // ```
  4527. repeated string not_in = 3 [(predefined).cel = {
  4528. id: "field_mask.not_in"
  4529. expression: "!this.paths.all(p, !(p in getField(rules, 'not_in') || getField(rules, 'not_in').exists(f, p.startsWith(f+'.')))) ? 'must not contain any paths in %s'.format([getField(rules, 'not_in')]) : ''"
  4530. }];
  4531. // `example` specifies values that the field may have. These values SHOULD
  4532. // conform to other rules. `example` values will not impact validation
  4533. // but may be used as helpful guidance on how to populate the given field.
  4534. //
  4535. // ```proto
  4536. // message MyFieldMask {
  4537. // google.protobuf.FieldMask value = 1 [
  4538. // (buf.validate.field).field_mask.example = { paths: ["a", "b"] },
  4539. // (buf.validate.field).field_mask.example = { paths: ["c.a", "d"] }
  4540. // ];
  4541. // }
  4542. // ```
  4543. repeated google.protobuf.FieldMask example = 4 [(predefined).cel = {
  4544. id: "field_mask.example"
  4545. expression: "true"
  4546. }];
  4547. // Extension fields that have the (buf.validate.predefined) option set
  4548. // will be treated as predefined field rules.
  4549. // See https://protovalidate.com/schemas/predefined-rules/
  4550. extensions 1000 to max;
  4551. }
  4552. // TimestampRules describe the rules applied exclusively to the `google.protobuf.Timestamp` well-known type.
  4553. message TimestampRules {
  4554. // `const` dictates that this field, of the `google.protobuf.Timestamp` type, must exactly match the specified value. If the field value doesn't correspond to the specified timestamp, an error message will be generated.
  4555. //
  4556. // ```proto
  4557. // message MyTimestamp {
  4558. // // value must equal 2023-05-03T10:00:00Z
  4559. // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.const = {seconds: 1727998800}];
  4560. // }
  4561. // ```
  4562. optional google.protobuf.Timestamp const = 2 [(predefined).cel = {
  4563. id: "timestamp.const"
  4564. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  4565. }];
  4566. oneof less_than {
  4567. // `lt` requires the timestamp field value to be less than the specified value (field < value). If the field value doesn't meet the required conditions, an error message is generated.
  4568. //
  4569. // ```proto
  4570. // message MyTimestamp {
  4571. // // timestamp must be less than '2023-01-01T00:00:00Z' [timestamp.lt]
  4572. // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.lt = { seconds: 1672444800 }];
  4573. // }
  4574. // ```
  4575. google.protobuf.Timestamp lt = 3 [(predefined).cel = {
  4576. id: "timestamp.lt"
  4577. expression:
  4578. "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
  4579. "? 'must be less than %s'.format([rules.lt]) : ''"
  4580. }];
  4581. // `lte` requires the timestamp field value to be less than or equal to the specified value (field <= value). If the field value doesn't meet the required conditions, an error message is generated.
  4582. //
  4583. // ```proto
  4584. // message MyTimestamp {
  4585. // // timestamp must be less than or equal to '2023-05-14T00:00:00Z' [timestamp.lte]
  4586. // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.lte = { seconds: 1678867200 }];
  4587. // }
  4588. // ```
  4589. google.protobuf.Timestamp lte = 4 [(predefined).cel = {
  4590. id: "timestamp.lte"
  4591. expression:
  4592. "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
  4593. "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
  4594. }];
  4595. // `lt_now` specifies that this field, of the `google.protobuf.Timestamp` type, must be less than the current time. `lt_now` can only be used with the `within` rule.
  4596. //
  4597. // ```proto
  4598. // message MyTimestamp {
  4599. // // must be less than now
  4600. // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.lt_now = true];
  4601. // }
  4602. // ```
  4603. bool lt_now = 7 [(predefined).cel = {
  4604. id: "timestamp.lt_now"
  4605. expression: "(rules.lt_now && this > now) ? 'must be less than now' : ''"
  4606. }];
  4607. }
  4608. oneof greater_than {
  4609. // `gt` requires the timestamp field value to be greater than the specified
  4610. // value (exclusive). If the value of `gt` is larger than a specified `lt`
  4611. // or `lte`, the range is reversed, and the field value must be outside the
  4612. // specified range. If the field value doesn't meet the required conditions,
  4613. // an error message is generated.
  4614. //
  4615. // ```proto
  4616. // message MyTimestamp {
  4617. // // timestamp must be greater than '2023-01-01T00:00:00Z' [timestamp.gt]
  4618. // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.gt = { seconds: 1672444800 }];
  4619. //
  4620. // // timestamp must be greater than '2023-01-01T00:00:00Z' and less than '2023-01-02T00:00:00Z' [timestamp.gt_lt]
  4621. // google.protobuf.Timestamp another_value = 2 [(buf.validate.field).timestamp = { gt: { seconds: 1672444800 }, lt: { seconds: 1672531200 } }];
  4622. //
  4623. // // timestamp must be greater than '2023-01-02T00:00:00Z' or less than '2023-01-01T00:00:00Z' [timestamp.gt_lt_exclusive]
  4624. // google.protobuf.Timestamp other_value = 3 [(buf.validate.field).timestamp = { gt: { seconds: 1672531200 }, lt: { seconds: 1672444800 } }];
  4625. // }
  4626. // ```
  4627. google.protobuf.Timestamp gt = 5 [
  4628. (predefined).cel = {
  4629. id: "timestamp.gt"
  4630. expression:
  4631. "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
  4632. "? 'must be greater than %s'.format([rules.gt]) : ''"
  4633. },
  4634. (predefined).cel = {
  4635. id: "timestamp.gt_lt"
  4636. expression:
  4637. "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
  4638. "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
  4639. },
  4640. (predefined).cel = {
  4641. id: "timestamp.gt_lt_exclusive"
  4642. expression:
  4643. "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
  4644. "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
  4645. },
  4646. (predefined).cel = {
  4647. id: "timestamp.gt_lte"
  4648. expression:
  4649. "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
  4650. "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  4651. },
  4652. (predefined).cel = {
  4653. id: "timestamp.gt_lte_exclusive"
  4654. expression:
  4655. "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
  4656. "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  4657. }
  4658. ];
  4659. // `gte` requires the timestamp field value to be greater than or equal to the
  4660. // specified value (exclusive). If the value of `gte` is larger than a
  4661. // specified `lt` or `lte`, the range is reversed, and the field value
  4662. // must be outside the specified range. If the field value doesn't meet
  4663. // the required conditions, an error message is generated.
  4664. //
  4665. // ```proto
  4666. // message MyTimestamp {
  4667. // // timestamp must be greater than or equal to '2023-01-01T00:00:00Z' [timestamp.gte]
  4668. // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.gte = { seconds: 1672444800 }];
  4669. //
  4670. // // timestamp must be greater than or equal to '2023-01-01T00:00:00Z' and less than '2023-01-02T00:00:00Z' [timestamp.gte_lt]
  4671. // google.protobuf.Timestamp another_value = 2 [(buf.validate.field).timestamp = { gte: { seconds: 1672444800 }, lt: { seconds: 1672531200 } }];
  4672. //
  4673. // // timestamp must be greater than or equal to '2023-01-02T00:00:00Z' or less than '2023-01-01T00:00:00Z' [timestamp.gte_lt_exclusive]
  4674. // google.protobuf.Timestamp other_value = 3 [(buf.validate.field).timestamp = { gte: { seconds: 1672531200 }, lt: { seconds: 1672444800 } }];
  4675. // }
  4676. // ```
  4677. google.protobuf.Timestamp gte = 6 [
  4678. (predefined).cel = {
  4679. id: "timestamp.gte"
  4680. expression:
  4681. "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
  4682. "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
  4683. },
  4684. (predefined).cel = {
  4685. id: "timestamp.gte_lt"
  4686. expression:
  4687. "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
  4688. "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
  4689. },
  4690. (predefined).cel = {
  4691. id: "timestamp.gte_lt_exclusive"
  4692. expression:
  4693. "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
  4694. "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
  4695. },
  4696. (predefined).cel = {
  4697. id: "timestamp.gte_lte"
  4698. expression:
  4699. "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
  4700. "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  4701. },
  4702. (predefined).cel = {
  4703. id: "timestamp.gte_lte_exclusive"
  4704. expression:
  4705. "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
  4706. "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  4707. }
  4708. ];
  4709. // `gt_now` specifies that this field, of the `google.protobuf.Timestamp` type, must be greater than the current time. `gt_now` can only be used with the `within` rule.
  4710. //
  4711. // ```proto
  4712. // message MyTimestamp {
  4713. // // must be greater than now
  4714. // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.gt_now = true];
  4715. // }
  4716. // ```
  4717. bool gt_now = 8 [(predefined).cel = {
  4718. id: "timestamp.gt_now"
  4719. expression: "(rules.gt_now && this < now) ? 'must be greater than now' : ''"
  4720. }];
  4721. }
  4722. // `within` specifies that this field, of the `google.protobuf.Timestamp` type, must be within the specified duration of the current time. If the field value isn't within the duration, an error message is generated.
  4723. //
  4724. // ```proto
  4725. // message MyTimestamp {
  4726. // // must be within 1 hour of now
  4727. // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.within = {seconds: 3600}];
  4728. // }
  4729. // ```
  4730. optional google.protobuf.Duration within = 9 [(predefined).cel = {
  4731. id: "timestamp.within"
  4732. expression: "this < now-rules.within || this > now+rules.within ? 'must be within %s of now'.format([rules.within]) : ''"
  4733. }];
  4734. // `example` specifies values that the field may have. These values SHOULD
  4735. // conform to other rules. `example` values will not impact validation
  4736. // but may be used as helpful guidance on how to populate the given field.
  4737. //
  4738. // ```proto
  4739. // message MyTimestamp {
  4740. // google.protobuf.Timestamp value = 1 [
  4741. // (buf.validate.field).timestamp.example = { seconds: 1672444800 },
  4742. // (buf.validate.field).timestamp.example = { seconds: 1672531200 }
  4743. // ];
  4744. // }
  4745. // ```
  4746. repeated google.protobuf.Timestamp example = 10 [(predefined).cel = {
  4747. id: "timestamp.example"
  4748. expression: "true"
  4749. }];
  4750. // Extension fields that have the (buf.validate.predefined) option set
  4751. // will be treated as predefined field rules.
  4752. // See https://protovalidate.com/schemas/predefined-rules/
  4753. extensions 1000 to max;
  4754. }
  4755. // `Violations` is a collection of `Violation` messages. This message type is returned by
  4756. // Protovalidate when a proto message fails to meet the requirements set by the `Rule` validation rules.
  4757. // Each individual violation is represented by a `Violation` message.
  4758. message Violations {
  4759. // `violations` is a repeated field that contains all the `Violation` messages corresponding to the violations detected.
  4760. repeated Violation violations = 1;
  4761. }
  4762. // `Violation` represents a single instance where a validation rule, expressed
  4763. // as a `Rule`, was not met. It provides information about the field that
  4764. // caused the violation, the specific rule that wasn't fulfilled, and a
  4765. // human-readable error message.
  4766. //
  4767. // For example, consider the following message:
  4768. //
  4769. // ```proto
  4770. // message User {
  4771. // int32 age = 1 [(buf.validate.field).cel = {
  4772. // id: "user.age",
  4773. // expression: "this < 18 ? 'User must be at least 18 years old' : ''",
  4774. // }];
  4775. // }
  4776. // ```
  4777. //
  4778. // It could produce the following violation:
  4779. //
  4780. // ```json
  4781. // {
  4782. // "ruleId": "user.age",
  4783. // "message": "User must be at least 18 years old",
  4784. // "field": {
  4785. // "elements": [
  4786. // {
  4787. // "fieldNumber": 1,
  4788. // "fieldName": "age",
  4789. // "fieldType": "TYPE_INT32"
  4790. // }
  4791. // ]
  4792. // },
  4793. // "rule": {
  4794. // "elements": [
  4795. // {
  4796. // "fieldNumber": 23,
  4797. // "fieldName": "cel",
  4798. // "fieldType": "TYPE_MESSAGE",
  4799. // "index": "0"
  4800. // }
  4801. // ]
  4802. // }
  4803. // }
  4804. // ```
  4805. message Violation {
  4806. // `field` is a machine-readable path to the field that failed validation.
  4807. // This could be a nested field, in which case the path will include all the parent fields leading to the actual field that caused the violation.
  4808. //
  4809. // For example, consider the following message:
  4810. //
  4811. // ```proto
  4812. // message Message {
  4813. // bool a = 1 [(buf.validate.field).required = true];
  4814. // }
  4815. // ```
  4816. //
  4817. // It could produce the following violation:
  4818. //
  4819. // ```textproto
  4820. // violation {
  4821. // field { element { field_number: 1, field_name: "a", field_type: 8 } }
  4822. // ...
  4823. // }
  4824. // ```
  4825. optional FieldPath field = 5;
  4826. // `rule` is a machine-readable path that points to the specific rule that failed validation.
  4827. // This will be a nested field starting from the FieldRules of the field that failed validation.
  4828. // For custom rules, this will provide the path of the rule, e.g. `cel[0]`.
  4829. //
  4830. // For example, consider the following message:
  4831. //
  4832. // ```proto
  4833. // message Message {
  4834. // bool a = 1 [(buf.validate.field).required = true];
  4835. // bool b = 2 [(buf.validate.field).cel = {
  4836. // id: "custom_rule",
  4837. // expression: "!this ? 'b must be true': ''"
  4838. // }];
  4839. // }
  4840. // ```
  4841. //
  4842. // It could produce the following violations:
  4843. //
  4844. // ```textproto
  4845. // violation {
  4846. // rule { element { field_number: 25, field_name: "required", field_type: 8 } }
  4847. // ...
  4848. // }
  4849. // violation {
  4850. // rule { element { field_number: 23, field_name: "cel", field_type: 11, index: 0 } }
  4851. // ...
  4852. // }
  4853. // ```
  4854. optional FieldPath rule = 6;
  4855. // `rule_id` is the unique identifier of the `Rule` that was not fulfilled.
  4856. // This is the same `id` that was specified in the `Rule` message, allowing easy tracing of which rule was violated.
  4857. optional string rule_id = 2;
  4858. // `message` is a human-readable error message that describes the nature of the violation.
  4859. // This can be the default error message from the violated `Rule`, or it can be a custom message that gives more context about the violation.
  4860. optional string message = 3;
  4861. // `for_key` indicates whether the violation was caused by a map key, rather than a value.
  4862. optional bool for_key = 4;
  4863. reserved 1;
  4864. reserved "field_path";
  4865. }
  4866. // `FieldPath` provides a path to a nested protobuf field.
  4867. //
  4868. // This message provides enough information to render a dotted field path even without protobuf descriptors.
  4869. // It also provides enough information to resolve a nested field through unknown wire data.
  4870. message FieldPath {
  4871. // `elements` contains each element of the path, starting from the root and recursing downward.
  4872. repeated FieldPathElement elements = 1;
  4873. }
  4874. // `FieldPathElement` provides enough information to nest through a single protobuf field.
  4875. //
  4876. // If the selected field is a map or repeated field, the `subscript` value selects a specific element from it.
  4877. // A path that refers to a value nested under a map key or repeated field index will have a `subscript` value.
  4878. // The `field_type` field allows unambiguous resolution of a field even if descriptors are not available.
  4879. message FieldPathElement {
  4880. // `field_number` is the field number this path element refers to.
  4881. optional int32 field_number = 1;
  4882. // `field_name` contains the field name this path element refers to.
  4883. // This can be used to display a human-readable path even if the field number is unknown.
  4884. optional string field_name = 2;
  4885. // `field_type` specifies the type of this field. When using reflection, this value is not needed.
  4886. //
  4887. // This value is provided to make it possible to traverse unknown fields through wire data.
  4888. // When traversing wire data, be mindful of both packed[1] and delimited[2] encoding schemes.
  4889. //
  4890. // [1]: https://protobuf.dev/programming-guides/encoding/#packed
  4891. // [2]: https://protobuf.dev/programming-guides/encoding/#groups
  4892. //
  4893. // N.B.: Although groups are deprecated, the corresponding delimited encoding scheme is not, and
  4894. // can be explicitly used in Protocol Buffers 2023 Edition.
  4895. optional google.protobuf.FieldDescriptorProto.Type field_type = 3;
  4896. // `key_type` specifies the map key type of this field. This value is useful when traversing
  4897. // unknown fields through wire data: specifically, it allows handling the differences between
  4898. // different integer encodings.
  4899. optional google.protobuf.FieldDescriptorProto.Type key_type = 4;
  4900. // `value_type` specifies map value type of this field. This is useful if you want to display a
  4901. // value inside unknown fields through wire data.
  4902. optional google.protobuf.FieldDescriptorProto.Type value_type = 5;
  4903. // `subscript` contains a repeated index or map key, if this path element nests into a repeated or map field.
  4904. oneof subscript {
  4905. // `index` specifies a 0-based index into a repeated field.
  4906. uint64 index = 6;
  4907. // `bool_key` specifies a map key of type bool.
  4908. bool bool_key = 7;
  4909. // `int_key` specifies a map key of type int32, int64, sint32, sint64, sfixed32 or sfixed64.
  4910. int64 int_key = 8;
  4911. // `uint_key` specifies a map key of type uint32, uint64, fixed32 or fixed64.
  4912. uint64 uint_key = 9;
  4913. // `string_key` specifies a map key of type string.
  4914. string string_key = 10;
  4915. }
  4916. }