validate.proto 199 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130
  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-python),
  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 [(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://buf.build/docs/protovalidate/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://buf.build/docs/protovalidate/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://buf.build/docs/protovalidate/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://buf.build/docs/protovalidate/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://buf.build/docs/protovalidate/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://buf.build/docs/protovalidate/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 = 1,
  2917. // (buf.validate.field).bool.example = 2
  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", (buf.validate.field).string.in = "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", (buf.validate.field).string.not_in = "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 be a valid UUID as defined by
  3341. // [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2). If the
  3342. // field value isn't a valid UUID, an error message will be generated.
  3343. //
  3344. // ```proto
  3345. // message MyString {
  3346. // // must be a valid UUID
  3347. // string value = 1 [(buf.validate.field).string.uuid = true];
  3348. // }
  3349. // ```
  3350. bool uuid = 22 [
  3351. (predefined).cel = {
  3352. id: "string.uuid"
  3353. message: "must be a valid UUID"
  3354. 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}$')"
  3355. },
  3356. (predefined).cel = {
  3357. id: "string.uuid_empty"
  3358. message: "value is empty, which is not a valid UUID"
  3359. expression: "!rules.uuid || this != ''"
  3360. }
  3361. ];
  3362. // `tuuid` (trimmed UUID) specifies that the field value must be a valid UUID as
  3363. // defined by [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2) with all dashes
  3364. // omitted. If the field value isn't a valid UUID without dashes, an error message
  3365. // will be generated.
  3366. //
  3367. // ```proto
  3368. // message MyString {
  3369. // // must be a valid trimmed UUID
  3370. // string value = 1 [(buf.validate.field).string.tuuid = true];
  3371. // }
  3372. // ```
  3373. bool tuuid = 33 [
  3374. (predefined).cel = {
  3375. id: "string.tuuid"
  3376. message: "must be a valid trimmed UUID"
  3377. expression: "!rules.tuuid || this == '' || this.matches('^[0-9a-fA-F]{32}$')"
  3378. },
  3379. (predefined).cel = {
  3380. id: "string.tuuid_empty"
  3381. message: "value is empty, which is not a valid trimmed UUID"
  3382. expression: "!rules.tuuid || this != ''"
  3383. }
  3384. ];
  3385. // `ip_with_prefixlen` specifies that the field value must be a valid IP
  3386. // (v4 or v6) address with prefix length—for example, "192.168.5.21/16" or
  3387. // "2001:0DB8:ABCD:0012::F1/64". If the field value isn't a valid IP with
  3388. // prefix length, an error message will be generated.
  3389. //
  3390. // ```proto
  3391. // message MyString {
  3392. // // must be a valid IP with prefix length
  3393. // string value = 1 [(buf.validate.field).string.ip_with_prefixlen = true];
  3394. // }
  3395. // ```
  3396. bool ip_with_prefixlen = 26 [
  3397. (predefined).cel = {
  3398. id: "string.ip_with_prefixlen"
  3399. message: "must be a valid IP prefix"
  3400. expression: "!rules.ip_with_prefixlen || this == '' || this.isIpPrefix()"
  3401. },
  3402. (predefined).cel = {
  3403. id: "string.ip_with_prefixlen_empty"
  3404. message: "value is empty, which is not a valid IP prefix"
  3405. expression: "!rules.ip_with_prefixlen || this != ''"
  3406. }
  3407. ];
  3408. // `ipv4_with_prefixlen` specifies that the field value must be a valid
  3409. // IPv4 address with prefix length—for example, "192.168.5.21/16". If the
  3410. // field value isn't a valid IPv4 address with prefix length, an error
  3411. // message will be generated.
  3412. //
  3413. // ```proto
  3414. // message MyString {
  3415. // // must be a valid IPv4 address with prefix length
  3416. // string value = 1 [(buf.validate.field).string.ipv4_with_prefixlen = true];
  3417. // }
  3418. // ```
  3419. bool ipv4_with_prefixlen = 27 [
  3420. (predefined).cel = {
  3421. id: "string.ipv4_with_prefixlen"
  3422. message: "must be a valid IPv4 address with prefix length"
  3423. expression: "!rules.ipv4_with_prefixlen || this == '' || this.isIpPrefix(4)"
  3424. },
  3425. (predefined).cel = {
  3426. id: "string.ipv4_with_prefixlen_empty"
  3427. message: "value is empty, which is not a valid IPv4 address with prefix length"
  3428. expression: "!rules.ipv4_with_prefixlen || this != ''"
  3429. }
  3430. ];
  3431. // `ipv6_with_prefixlen` specifies that the field value must be a valid
  3432. // IPv6 address with prefix length—for example, "2001:0DB8:ABCD:0012::F1/64".
  3433. // If the field value is not a valid IPv6 address with prefix length,
  3434. // an error message will be generated.
  3435. //
  3436. // ```proto
  3437. // message MyString {
  3438. // // must be a valid IPv6 address prefix length
  3439. // string value = 1 [(buf.validate.field).string.ipv6_with_prefixlen = true];
  3440. // }
  3441. // ```
  3442. bool ipv6_with_prefixlen = 28 [
  3443. (predefined).cel = {
  3444. id: "string.ipv6_with_prefixlen"
  3445. message: "must be a valid IPv6 address with prefix length"
  3446. expression: "!rules.ipv6_with_prefixlen || this == '' || this.isIpPrefix(6)"
  3447. },
  3448. (predefined).cel = {
  3449. id: "string.ipv6_with_prefixlen_empty"
  3450. message: "value is empty, which is not a valid IPv6 address with prefix length"
  3451. expression: "!rules.ipv6_with_prefixlen || this != ''"
  3452. }
  3453. ];
  3454. // `ip_prefix` specifies that the field value must be a valid IP (v4 or v6)
  3455. // prefix—for example, "192.168.0.0/16" or "2001:0DB8:ABCD:0012::0/64".
  3456. //
  3457. // The prefix must have all zeros for the unmasked bits. For example,
  3458. // "2001:0DB8:ABCD:0012::0/64" designates the left-most 64 bits for the
  3459. // prefix, and the remaining 64 bits must be zero.
  3460. //
  3461. // If the field value isn't a valid IP prefix, an error message will be
  3462. // generated.
  3463. //
  3464. // ```proto
  3465. // message MyString {
  3466. // // must be a valid IP prefix
  3467. // string value = 1 [(buf.validate.field).string.ip_prefix = true];
  3468. // }
  3469. // ```
  3470. bool ip_prefix = 29 [
  3471. (predefined).cel = {
  3472. id: "string.ip_prefix"
  3473. message: "must be a valid IP prefix"
  3474. expression: "!rules.ip_prefix || this == '' || this.isIpPrefix(true)"
  3475. },
  3476. (predefined).cel = {
  3477. id: "string.ip_prefix_empty"
  3478. message: "value is empty, which is not a valid IP prefix"
  3479. expression: "!rules.ip_prefix || this != ''"
  3480. }
  3481. ];
  3482. // `ipv4_prefix` specifies that the field value must be a valid IPv4
  3483. // prefix, for example "192.168.0.0/16".
  3484. //
  3485. // The prefix must have all zeros for the unmasked bits. For example,
  3486. // "192.168.0.0/16" designates the left-most 16 bits for the prefix,
  3487. // and the remaining 16 bits must be zero.
  3488. //
  3489. // If the field value isn't a valid IPv4 prefix, an error message
  3490. // will be generated.
  3491. //
  3492. // ```proto
  3493. // message MyString {
  3494. // // must be a valid IPv4 prefix
  3495. // string value = 1 [(buf.validate.field).string.ipv4_prefix = true];
  3496. // }
  3497. // ```
  3498. bool ipv4_prefix = 30 [
  3499. (predefined).cel = {
  3500. id: "string.ipv4_prefix"
  3501. message: "must be a valid IPv4 prefix"
  3502. expression: "!rules.ipv4_prefix || this == '' || this.isIpPrefix(4, true)"
  3503. },
  3504. (predefined).cel = {
  3505. id: "string.ipv4_prefix_empty"
  3506. message: "value is empty, which is not a valid IPv4 prefix"
  3507. expression: "!rules.ipv4_prefix || this != ''"
  3508. }
  3509. ];
  3510. // `ipv6_prefix` specifies that the field value must be a valid IPv6 prefix—for
  3511. // example, "2001:0DB8:ABCD:0012::0/64".
  3512. //
  3513. // The prefix must have all zeros for the unmasked bits. For example,
  3514. // "2001:0DB8:ABCD:0012::0/64" designates the left-most 64 bits for the
  3515. // prefix, and the remaining 64 bits must be zero.
  3516. //
  3517. // If the field value is not a valid IPv6 prefix, an error message will be
  3518. // generated.
  3519. //
  3520. // ```proto
  3521. // message MyString {
  3522. // // must be a valid IPv6 prefix
  3523. // string value = 1 [(buf.validate.field).string.ipv6_prefix = true];
  3524. // }
  3525. // ```
  3526. bool ipv6_prefix = 31 [
  3527. (predefined).cel = {
  3528. id: "string.ipv6_prefix"
  3529. message: "must be a valid IPv6 prefix"
  3530. expression: "!rules.ipv6_prefix || this == '' || this.isIpPrefix(6, true)"
  3531. },
  3532. (predefined).cel = {
  3533. id: "string.ipv6_prefix_empty"
  3534. message: "value is empty, which is not a valid IPv6 prefix"
  3535. expression: "!rules.ipv6_prefix || this != ''"
  3536. }
  3537. ];
  3538. // `host_and_port` specifies that the field value must be a valid host/port
  3539. // pair—for example, "example.com:8080".
  3540. //
  3541. // The host can be one of:
  3542. // - An IPv4 address in dotted decimal format—for example, "192.168.5.21".
  3543. // - An IPv6 address enclosed in square brackets—for example, "[2001:0DB8:ABCD:0012::F1]".
  3544. // - A hostname—for example, "example.com".
  3545. //
  3546. // The port is separated by a colon. It must be non-empty, with a decimal number
  3547. // in the range of 0-65535, inclusive.
  3548. bool host_and_port = 32 [
  3549. (predefined).cel = {
  3550. id: "string.host_and_port"
  3551. message: "must be a valid host (hostname or IP address) and port pair"
  3552. expression: "!rules.host_and_port || this == '' || this.isHostAndPort(true)"
  3553. },
  3554. (predefined).cel = {
  3555. id: "string.host_and_port_empty"
  3556. message: "value is empty, which is not a valid host and port pair"
  3557. expression: "!rules.host_and_port || this != ''"
  3558. }
  3559. ];
  3560. // `ulid` specifies that the field value must be a valid ULID (Universally Unique
  3561. // Lexicographically Sortable Identifier) as defined by the [ULID specification](https://github.com/ulid/spec).
  3562. // If the field value isn't a valid ULID, an error message will be generated.
  3563. //
  3564. // ```proto
  3565. // message MyString {
  3566. // // must be a valid ULID
  3567. // string value = 1 [(buf.validate.field).string.ulid = true];
  3568. // }
  3569. // ```
  3570. bool ulid = 35 [
  3571. (predefined).cel = {
  3572. id: "string.ulid"
  3573. message: "must be a valid ULID"
  3574. expression: "!rules.ulid || this == '' || this.matches('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$')"
  3575. },
  3576. (predefined).cel = {
  3577. id: "string.ulid_empty"
  3578. message: "value is empty, which is not a valid ULID"
  3579. expression: "!rules.ulid || this != ''"
  3580. }
  3581. ];
  3582. // `protobuf_fqn` specifies that the field value must be a valid fully-qualified
  3583. // Protobuf name as defined by the [Protobuf Language Specification](https://protobuf.com/docs/language-spec).
  3584. //
  3585. // A fully-qualified Protobuf name is a dot-separated list of Protobuf identifiers,
  3586. // where each identifier starts with a letter or underscore and is followed by zero or
  3587. // more letters, underscores, or digits.
  3588. //
  3589. // Examples: "buf.validate", "google.protobuf.Timestamp", "my_package.MyMessage".
  3590. //
  3591. // Note: historically, fully-qualified Protobuf names were represented with a leading
  3592. // dot (for example, ".buf.validate.StringRules"). Modern Protobuf does not use the
  3593. // leading dot, and most fully-qualified names are represented without it. Use
  3594. // `protobuf_dot_fqn` if a leading dot is required.
  3595. //
  3596. // If the field value isn't a valid fully-qualified Protobuf name, an error message
  3597. // will be generated.
  3598. //
  3599. // ```proto
  3600. // message MyString {
  3601. // // value must be a valid fully-qualified Protobuf name
  3602. // string value = 1 [(buf.validate.field).string.protobuf_fqn = true];
  3603. // }
  3604. // ```
  3605. bool protobuf_fqn = 37 [
  3606. (predefined).cel = {
  3607. id: "string.protobuf_fqn"
  3608. message: "must be a valid fully-qualified Protobuf name"
  3609. expression: "!rules.protobuf_fqn || this == '' || this.matches('^[A-Za-z_][A-Za-z_0-9]*(\\\\.[A-Za-z_][A-Za-z_0-9]*)*$')"
  3610. },
  3611. (predefined).cel = {
  3612. id: "string.protobuf_fqn_empty"
  3613. message: "value is empty, which is not a valid fully-qualified Protobuf name"
  3614. expression: "!rules.protobuf_fqn || this != ''"
  3615. }
  3616. ];
  3617. // `protobuf_dot_fqn` specifies that the field value must be a valid fully-qualified
  3618. // Protobuf name with a leading dot, as defined by the
  3619. // [Protobuf Language Specification](https://protobuf.com/docs/language-spec).
  3620. //
  3621. // A fully-qualified Protobuf name with a leading dot is a dot followed by a
  3622. // dot-separated list of Protobuf identifiers, where each identifier starts with a
  3623. // letter or underscore and is followed by zero or more letters, underscores, or
  3624. // digits.
  3625. //
  3626. // Examples: ".buf.validate", ".google.protobuf.Timestamp", ".my_package.MyMessage".
  3627. //
  3628. // Note: this is the historical representation of fully-qualified Protobuf names,
  3629. // where a leading dot denotes an absolute reference. Modern Protobuf does not use
  3630. // the leading dot, and most fully-qualified names are represented without it. Most
  3631. // users will want to use `protobuf_fqn` instead.
  3632. //
  3633. // If the field value isn't a valid fully-qualified Protobuf name with a leading dot,
  3634. // an error message will be generated.
  3635. //
  3636. // ```proto
  3637. // message MyString {
  3638. // // value must be a valid fully-qualified Protobuf name with a leading dot
  3639. // string value = 1 [(buf.validate.field).string.protobuf_dot_fqn = true];
  3640. // }
  3641. // ```
  3642. bool protobuf_dot_fqn = 38 [
  3643. (predefined).cel = {
  3644. id: "string.protobuf_dot_fqn"
  3645. message: "must be a valid fully-qualified Protobuf name with a leading dot"
  3646. expression: "!rules.protobuf_dot_fqn || this == '' || this.matches('^\\\\.[A-Za-z_][A-Za-z_0-9]*(\\\\.[A-Za-z_][A-Za-z_0-9]*)*$')"
  3647. },
  3648. (predefined).cel = {
  3649. id: "string.protobuf_dot_fqn_empty"
  3650. message: "value is empty, which is not a valid fully-qualified Protobuf name with a leading dot"
  3651. expression: "!rules.protobuf_dot_fqn || this != ''"
  3652. }
  3653. ];
  3654. // `well_known_regex` specifies a common well-known pattern
  3655. // defined as a regex. If the field value doesn't match the well-known
  3656. // regex, an error message will be generated.
  3657. //
  3658. // ```proto
  3659. // message MyString {
  3660. // // must be a valid HTTP header value
  3661. // string value = 1 [(buf.validate.field).string.well_known_regex = KNOWN_REGEX_HTTP_HEADER_VALUE];
  3662. // }
  3663. // ```
  3664. //
  3665. // #### KnownRegex
  3666. //
  3667. // `well_known_regex` contains some well-known patterns.
  3668. //
  3669. // | Name | Number | Description |
  3670. // |-------------------------------|--------|-------------------------------------------|
  3671. // | KNOWN_REGEX_UNSPECIFIED | 0 | |
  3672. // | KNOWN_REGEX_HTTP_HEADER_NAME | 1 | HTTP header name as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2) |
  3673. // | 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) |
  3674. KnownRegex well_known_regex = 24 [
  3675. (predefined).cel = {
  3676. id: "string.well_known_regex.header_name"
  3677. message: "must be a valid HTTP header name"
  3678. expression:
  3679. "rules.well_known_regex != 1 || this == '' || this.matches(!has(rules.strict) || rules.strict ?"
  3680. "'^:?[0-9a-zA-Z!#$%&\\'*+-.^_|~\\x60]+$' :"
  3681. "'^[^\\u0000\\u000A\\u000D]+$')"
  3682. },
  3683. (predefined).cel = {
  3684. id: "string.well_known_regex.header_name_empty"
  3685. message: "value is empty, which is not a valid HTTP header name"
  3686. expression: "rules.well_known_regex != 1 || this != ''"
  3687. },
  3688. (predefined).cel = {
  3689. id: "string.well_known_regex.header_value"
  3690. message: "must be a valid HTTP header value"
  3691. expression:
  3692. "rules.well_known_regex != 2 || this.matches(!has(rules.strict) || rules.strict ?"
  3693. "'^[^\\u0000-\\u0008\\u000A-\\u001F\\u007F]*$' :"
  3694. "'^[^\\u0000\\u000A\\u000D]*$')"
  3695. }
  3696. ];
  3697. }
  3698. // This applies to regexes `HTTP_HEADER_NAME` and `HTTP_HEADER_VALUE` to
  3699. // enable strict header validation. By default, this is true, and HTTP header
  3700. // validations are [RFC-compliant](https://datatracker.ietf.org/doc/html/rfc7230#section-3). Setting to false will enable looser
  3701. // validations that only disallow `\r\n\0` characters, which can be used to
  3702. // bypass header matching rules.
  3703. //
  3704. // ```proto
  3705. // message MyString {
  3706. // // The field `value` must have be a valid HTTP headers, but not enforced with strict rules.
  3707. // string value = 1 [(buf.validate.field).string.strict = false];
  3708. // }
  3709. // ```
  3710. optional bool strict = 25;
  3711. // `example` specifies values that the field may have. These values SHOULD
  3712. // conform to other rules. `example` values will not impact validation
  3713. // but may be used as helpful guidance on how to populate the given field.
  3714. //
  3715. // ```proto
  3716. // message MyString {
  3717. // string value = 1 [
  3718. // (buf.validate.field).string.example = "hello",
  3719. // (buf.validate.field).string.example = "world"
  3720. // ];
  3721. // }
  3722. // ```
  3723. repeated string example = 34 [(predefined).cel = {
  3724. id: "string.example"
  3725. expression: "true"
  3726. }];
  3727. // Extension fields that have the (buf.validate.predefined) option set
  3728. // will be treated as predefined field rules.
  3729. // See https://protovalidate.com/schemas/predefined-rules/
  3730. extensions 1000 to max;
  3731. }
  3732. // KnownRegex contains some well-known patterns.
  3733. enum KnownRegex {
  3734. KNOWN_REGEX_UNSPECIFIED = 0;
  3735. // HTTP header name as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2).
  3736. KNOWN_REGEX_HTTP_HEADER_NAME = 1;
  3737. // HTTP header value as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4).
  3738. KNOWN_REGEX_HTTP_HEADER_VALUE = 2;
  3739. }
  3740. // BytesRules describe the rules applied to `bytes` values. These rules
  3741. // may also be applied to the `google.protobuf.BytesValue` Well-Known-Type.
  3742. message BytesRules {
  3743. // `const` requires the field value to exactly match the specified bytes
  3744. // value. If the field value doesn't match, an error message is generated.
  3745. //
  3746. // ```proto
  3747. // message MyBytes {
  3748. // // must be "\x01\x02\x03\x04"
  3749. // bytes value = 1 [(buf.validate.field).bytes.const = "\x01\x02\x03\x04"];
  3750. // }
  3751. // ```
  3752. optional bytes const = 1 [(predefined).cel = {
  3753. id: "bytes.const"
  3754. expression: "this != getField(rules, 'const') ? 'must be %x'.format([getField(rules, 'const')]) : ''"
  3755. }];
  3756. // `len` requires the field value to have the specified length in bytes.
  3757. // If the field value doesn't match, an error message is generated.
  3758. //
  3759. // ```proto
  3760. // message MyBytes {
  3761. // // value length must be 4 bytes.
  3762. // optional bytes value = 1 [(buf.validate.field).bytes.len = 4];
  3763. // }
  3764. // ```
  3765. optional uint64 len = 13 [(predefined).cel = {
  3766. id: "bytes.len"
  3767. expression: "uint(this.size()) != rules.len ? 'must be %s bytes'.format([rules.len]) : ''"
  3768. }];
  3769. // `min_len` requires the field value to have at least the specified minimum
  3770. // length in bytes.
  3771. // If the field value doesn't meet the requirement, an error message is generated.
  3772. //
  3773. // ```proto
  3774. // message MyBytes {
  3775. // // value length must be at least 2 bytes.
  3776. // optional bytes value = 1 [(buf.validate.field).bytes.min_len = 2];
  3777. // }
  3778. // ```
  3779. optional uint64 min_len = 2 [(predefined).cel = {
  3780. id: "bytes.min_len"
  3781. expression: "uint(this.size()) < rules.min_len ? 'must be at least %s bytes'.format([rules.min_len]) : ''"
  3782. }];
  3783. // `max_len` requires the field value to have at most the specified maximum
  3784. // length in bytes.
  3785. // If the field value exceeds the requirement, an error message is generated.
  3786. //
  3787. // ```proto
  3788. // message MyBytes {
  3789. // // must be at most 6 bytes.
  3790. // optional bytes value = 1 [(buf.validate.field).bytes.max_len = 6];
  3791. // }
  3792. // ```
  3793. optional uint64 max_len = 3 [(predefined).cel = {
  3794. id: "bytes.max_len"
  3795. expression: "uint(this.size()) > rules.max_len ? 'must be at most %s bytes'.format([rules.max_len]) : ''"
  3796. }];
  3797. // `pattern` requires the field value to match the specified regular
  3798. // expression ([RE2 syntax](https://github.com/google/re2/wiki/Syntax)).
  3799. // The value of the field must be valid UTF-8 or validation will fail with a
  3800. // runtime error.
  3801. // If the field value doesn't match the pattern, an error message is generated.
  3802. //
  3803. // ```proto
  3804. // message MyBytes {
  3805. // // value must match regex pattern "^[a-zA-Z0-9]+$".
  3806. // optional bytes value = 1 [(buf.validate.field).bytes.pattern = "^[a-zA-Z0-9]+$"];
  3807. // }
  3808. // ```
  3809. optional string pattern = 4 [(predefined).cel = {
  3810. id: "bytes.pattern"
  3811. expression: "!string(this).matches(rules.pattern) ? 'must match regex pattern `%s`'.format([rules.pattern]) : ''"
  3812. }];
  3813. // `prefix` requires the field value to have the specified bytes at the
  3814. // beginning of the string.
  3815. // If the field value doesn't meet the requirement, an error message is generated.
  3816. //
  3817. // ```proto
  3818. // message MyBytes {
  3819. // // value does not have prefix \x01\x02
  3820. // optional bytes value = 1 [(buf.validate.field).bytes.prefix = "\x01\x02"];
  3821. // }
  3822. // ```
  3823. optional bytes prefix = 5 [(predefined).cel = {
  3824. id: "bytes.prefix"
  3825. expression: "!this.startsWith(rules.prefix) ? 'does not have prefix %x'.format([rules.prefix]) : ''"
  3826. }];
  3827. // `suffix` requires the field value to have the specified bytes at the end
  3828. // of the string.
  3829. // If the field value doesn't meet the requirement, an error message is generated.
  3830. //
  3831. // ```proto
  3832. // message MyBytes {
  3833. // // value does not have suffix \x03\x04
  3834. // optional bytes value = 1 [(buf.validate.field).bytes.suffix = "\x03\x04"];
  3835. // }
  3836. // ```
  3837. optional bytes suffix = 6 [(predefined).cel = {
  3838. id: "bytes.suffix"
  3839. expression: "!this.endsWith(rules.suffix) ? 'does not have suffix %x'.format([rules.suffix]) : ''"
  3840. }];
  3841. // `contains` requires the field value to have the specified bytes anywhere in
  3842. // the string.
  3843. // If the field value doesn't meet the requirement, an error message is generated.
  3844. //
  3845. // ```proto
  3846. // message MyBytes {
  3847. // // value does not contain \x02\x03
  3848. // optional bytes value = 1 [(buf.validate.field).bytes.contains = "\x02\x03"];
  3849. // }
  3850. // ```
  3851. optional bytes contains = 7 [(predefined).cel = {
  3852. id: "bytes.contains"
  3853. expression: "!this.contains(rules.contains) ? 'does not contain %x'.format([rules.contains]) : ''"
  3854. }];
  3855. // `in` requires the field value to be equal to one of the specified
  3856. // values. If the field value doesn't match any of the specified values, an
  3857. // error message is generated.
  3858. //
  3859. // ```proto
  3860. // message MyBytes {
  3861. // // value must in ["\x01\x02", "\x02\x03", "\x03\x04"]
  3862. // optional bytes value = 1 [(buf.validate.field).bytes.in = {"\x01\x02", "\x02\x03", "\x03\x04"}];
  3863. // }
  3864. // ```
  3865. repeated bytes in = 8 [(predefined).cel = {
  3866. id: "bytes.in"
  3867. expression: "getField(rules, 'in').size() > 0 && !(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  3868. }];
  3869. // `not_in` requires the field value to be not equal to any of the specified
  3870. // values.
  3871. // If the field value matches any of the specified values, an error message is
  3872. // generated.
  3873. //
  3874. // ```proto
  3875. // message MyBytes {
  3876. // // value must not in ["\x01\x02", "\x02\x03", "\x03\x04"]
  3877. // optional bytes value = 1 [(buf.validate.field).bytes.not_in = {"\x01\x02", "\x02\x03", "\x03\x04"}];
  3878. // }
  3879. // ```
  3880. repeated bytes not_in = 9 [(predefined).cel = {
  3881. id: "bytes.not_in"
  3882. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  3883. }];
  3884. // WellKnown rules provide advanced rules against common byte
  3885. // patterns
  3886. oneof well_known {
  3887. // `ip` ensures that the field `value` is a valid IP address (v4 or v6) in byte format.
  3888. // If the field value doesn't meet this rule, an error message is generated.
  3889. //
  3890. // ```proto
  3891. // message MyBytes {
  3892. // // must be a valid IP address
  3893. // optional bytes value = 1 [(buf.validate.field).bytes.ip = true];
  3894. // }
  3895. // ```
  3896. bool ip = 10 [
  3897. (predefined).cel = {
  3898. id: "bytes.ip"
  3899. message: "must be a valid IP address"
  3900. expression: "!rules.ip || this.size() == 0 || this.size() == 4 || this.size() == 16"
  3901. },
  3902. (predefined).cel = {
  3903. id: "bytes.ip_empty"
  3904. message: "value is empty, which is not a valid IP address"
  3905. expression: "!rules.ip || this.size() != 0"
  3906. }
  3907. ];
  3908. // `ipv4` ensures that the field `value` is a valid IPv4 address in byte format.
  3909. // If the field value doesn't meet this rule, an error message is generated.
  3910. //
  3911. // ```proto
  3912. // message MyBytes {
  3913. // // must be a valid IPv4 address
  3914. // optional bytes value = 1 [(buf.validate.field).bytes.ipv4 = true];
  3915. // }
  3916. // ```
  3917. bool ipv4 = 11 [
  3918. (predefined).cel = {
  3919. id: "bytes.ipv4"
  3920. message: "must be a valid IPv4 address"
  3921. expression: "!rules.ipv4 || this.size() == 0 || this.size() == 4"
  3922. },
  3923. (predefined).cel = {
  3924. id: "bytes.ipv4_empty"
  3925. message: "value is empty, which is not a valid IPv4 address"
  3926. expression: "!rules.ipv4 || this.size() != 0"
  3927. }
  3928. ];
  3929. // `ipv6` ensures that the field `value` is a valid IPv6 address in byte format.
  3930. // If the field value doesn't meet this rule, an error message is generated.
  3931. // ```proto
  3932. // message MyBytes {
  3933. // // must be a valid IPv6 address
  3934. // optional bytes value = 1 [(buf.validate.field).bytes.ipv6 = true];
  3935. // }
  3936. // ```
  3937. bool ipv6 = 12 [
  3938. (predefined).cel = {
  3939. id: "bytes.ipv6"
  3940. message: "must be a valid IPv6 address"
  3941. expression: "!rules.ipv6 || this.size() == 0 || this.size() == 16"
  3942. },
  3943. (predefined).cel = {
  3944. id: "bytes.ipv6_empty"
  3945. message: "value is empty, which is not a valid IPv6 address"
  3946. expression: "!rules.ipv6 || this.size() != 0"
  3947. }
  3948. ];
  3949. // `uuid` ensures that the field value encodes 128-bit UUID data as defined
  3950. // by [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2).
  3951. // The field must contain exactly 16 bytes representing the UUID. If the
  3952. // field value isn't a valid UUID, an error message will be generated.
  3953. //
  3954. // ```proto
  3955. // message MyBytes {
  3956. // // must be a valid UUID
  3957. // optional bytes value = 1 [(buf.validate.field).bytes.uuid = true];
  3958. // }
  3959. // ```
  3960. bool uuid = 15 [
  3961. (predefined).cel = {
  3962. id: "bytes.uuid"
  3963. message: "must be a valid UUID"
  3964. expression: "!rules.uuid || this.size() == 0 || this.size() == 16"
  3965. },
  3966. (predefined).cel = {
  3967. id: "bytes.uuid_empty"
  3968. message: "value is empty, which is not a valid UUID"
  3969. expression: "!rules.uuid || this.size() != 0"
  3970. }
  3971. ];
  3972. }
  3973. // `example` specifies values that the field may have. These values SHOULD
  3974. // conform to other rules. `example` values will not impact validation
  3975. // but may be used as helpful guidance on how to populate the given field.
  3976. //
  3977. // ```proto
  3978. // message MyBytes {
  3979. // bytes value = 1 [
  3980. // (buf.validate.field).bytes.example = "\x01\x02",
  3981. // (buf.validate.field).bytes.example = "\x02\x03"
  3982. // ];
  3983. // }
  3984. // ```
  3985. repeated bytes example = 14 [(predefined).cel = {
  3986. id: "bytes.example"
  3987. expression: "true"
  3988. }];
  3989. // Extension fields that have the (buf.validate.predefined) option set
  3990. // will be treated as predefined field rules.
  3991. // See https://protovalidate.com/schemas/predefined-rules/
  3992. extensions 1000 to max;
  3993. }
  3994. // EnumRules describe the rules applied to `enum` values.
  3995. message EnumRules {
  3996. // `const` requires the field value to exactly match the specified enum value.
  3997. // If the field value doesn't match, an error message is generated.
  3998. //
  3999. // ```proto
  4000. // enum MyEnum {
  4001. // MY_ENUM_UNSPECIFIED = 0;
  4002. // MY_ENUM_VALUE1 = 1;
  4003. // MY_ENUM_VALUE2 = 2;
  4004. // }
  4005. //
  4006. // message MyMessage {
  4007. // // The field `value` must be exactly MY_ENUM_VALUE1.
  4008. // MyEnum value = 1 [(buf.validate.field).enum.const = 1];
  4009. // }
  4010. // ```
  4011. optional int32 const = 1 [(predefined).cel = {
  4012. id: "enum.const"
  4013. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  4014. }];
  4015. // `defined_only` requires the field value to be one of the defined values for
  4016. // this enum, failing on any undefined value.
  4017. //
  4018. // ```proto
  4019. // enum MyEnum {
  4020. // MY_ENUM_UNSPECIFIED = 0;
  4021. // MY_ENUM_VALUE1 = 1;
  4022. // MY_ENUM_VALUE2 = 2;
  4023. // }
  4024. //
  4025. // message MyMessage {
  4026. // // The field `value` must be a defined value of MyEnum.
  4027. // MyEnum value = 1 [(buf.validate.field).enum.defined_only = true];
  4028. // }
  4029. // ```
  4030. optional bool defined_only = 2;
  4031. // `in` requires the field value to be equal to one of the
  4032. // specified enum values. If the field value doesn't match any of the
  4033. // specified values, an error message is generated.
  4034. //
  4035. // ```proto
  4036. // enum MyEnum {
  4037. // MY_ENUM_UNSPECIFIED = 0;
  4038. // MY_ENUM_VALUE1 = 1;
  4039. // MY_ENUM_VALUE2 = 2;
  4040. // }
  4041. //
  4042. // message MyMessage {
  4043. // // The field `value` must be equal to one of the specified values.
  4044. // MyEnum value = 1 [(buf.validate.field).enum = { in: [1, 2]}];
  4045. // }
  4046. // ```
  4047. repeated int32 in = 3 [(predefined).cel = {
  4048. id: "enum.in"
  4049. expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  4050. }];
  4051. // `not_in` requires the field value to be not equal to any of the
  4052. // specified enum values. If the field value matches one of the specified
  4053. // values, an error message is generated.
  4054. //
  4055. // ```proto
  4056. // enum MyEnum {
  4057. // MY_ENUM_UNSPECIFIED = 0;
  4058. // MY_ENUM_VALUE1 = 1;
  4059. // MY_ENUM_VALUE2 = 2;
  4060. // }
  4061. //
  4062. // message MyMessage {
  4063. // // The field `value` must not be equal to any of the specified values.
  4064. // MyEnum value = 1 [(buf.validate.field).enum = { not_in: [1, 2]}];
  4065. // }
  4066. // ```
  4067. repeated int32 not_in = 4 [(predefined).cel = {
  4068. id: "enum.not_in"
  4069. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  4070. }];
  4071. // `example` specifies values that the field may have. These values SHOULD
  4072. // conform to other rules. `example` values will not impact validation
  4073. // but may be used as helpful guidance on how to populate the given field.
  4074. //
  4075. // ```proto
  4076. // enum MyEnum {
  4077. // MY_ENUM_UNSPECIFIED = 0;
  4078. // MY_ENUM_VALUE1 = 1;
  4079. // MY_ENUM_VALUE2 = 2;
  4080. // }
  4081. //
  4082. // message MyMessage {
  4083. // (buf.validate.field).enum.example = 1,
  4084. // (buf.validate.field).enum.example = 2
  4085. // }
  4086. // ```
  4087. repeated int32 example = 5 [(predefined).cel = {
  4088. id: "enum.example"
  4089. expression: "true"
  4090. }];
  4091. // Extension fields that have the (buf.validate.predefined) option set
  4092. // will be treated as predefined field rules.
  4093. // See https://protovalidate.com/schemas/predefined-rules/
  4094. extensions 1000 to max;
  4095. }
  4096. // RepeatedRules describe the rules applied to `repeated` values.
  4097. message RepeatedRules {
  4098. // `min_items` requires that this field must contain at least the specified
  4099. // minimum number of items.
  4100. //
  4101. // Note that `min_items = 1` is equivalent to setting a field as `required`.
  4102. //
  4103. // ```proto
  4104. // message MyRepeated {
  4105. // // value must contain at least 2 items
  4106. // repeated string value = 1 [(buf.validate.field).repeated.min_items = 2];
  4107. // }
  4108. // ```
  4109. optional uint64 min_items = 1 [(predefined).cel = {
  4110. id: "repeated.min_items"
  4111. expression: "uint(this.size()) < rules.min_items ? 'must contain at least %d item(s)'.format([rules.min_items]) : ''"
  4112. }];
  4113. // `max_items` denotes that this field must not exceed a
  4114. // certain number of items as the upper limit. If the field contains more
  4115. // items than specified, an error message will be generated, requiring the
  4116. // field to maintain no more than the specified number of items.
  4117. //
  4118. // ```proto
  4119. // message MyRepeated {
  4120. // // value must contain no more than 3 item(s)
  4121. // repeated string value = 1 [(buf.validate.field).repeated.max_items = 3];
  4122. // }
  4123. // ```
  4124. optional uint64 max_items = 2 [(predefined).cel = {
  4125. id: "repeated.max_items"
  4126. expression: "uint(this.size()) > rules.max_items ? 'must contain no more than %s item(s)'.format([rules.max_items]) : ''"
  4127. }];
  4128. // `unique` indicates that all elements in this field must
  4129. // be unique. This rule is strictly applicable to scalar and enum
  4130. // types, with message types not being supported.
  4131. //
  4132. // ```proto
  4133. // message MyRepeated {
  4134. // // repeated value must contain unique items
  4135. // repeated string value = 1 [(buf.validate.field).repeated.unique = true];
  4136. // }
  4137. // ```
  4138. optional bool unique = 3 [(predefined).cel = {
  4139. id: "repeated.unique"
  4140. message: "repeated value must contain unique items"
  4141. expression: "!rules.unique || this.unique()"
  4142. }];
  4143. // `items` details the rules to be applied to each item
  4144. // in the field. Even for repeated message fields, validation is executed
  4145. // against each item unless `ignore` is specified.
  4146. //
  4147. // ```proto
  4148. // message MyRepeated {
  4149. // // The items in the field `value` must follow the specified rules.
  4150. // repeated string value = 1 [(buf.validate.field).repeated.items = {
  4151. // string: {
  4152. // min_len: 3
  4153. // max_len: 10
  4154. // }
  4155. // }];
  4156. // }
  4157. // ```
  4158. //
  4159. // Note that the `required` rule does not apply. Repeated items
  4160. // cannot be unset.
  4161. optional FieldRules items = 4;
  4162. // Extension fields that have the (buf.validate.predefined) option set
  4163. // will be treated as predefined field rules.
  4164. // See https://protovalidate.com/schemas/predefined-rules/
  4165. extensions 1000 to max;
  4166. }
  4167. // MapRules describe the rules applied to `map` values.
  4168. message MapRules {
  4169. // Specifies the minimum number of key-value pairs allowed. If the field has
  4170. // fewer key-value pairs than specified, an error message is generated.
  4171. //
  4172. // ```proto
  4173. // message MyMap {
  4174. // // The field `value` must have at least 2 key-value pairs.
  4175. // map<string, string> value = 1 [(buf.validate.field).map.min_pairs = 2];
  4176. // }
  4177. // ```
  4178. optional uint64 min_pairs = 1 [(predefined).cel = {
  4179. id: "map.min_pairs"
  4180. expression: "uint(this.size()) < rules.min_pairs ? 'map must be at least %d entries'.format([rules.min_pairs]) : ''"
  4181. }];
  4182. // Specifies the maximum number of key-value pairs allowed. If the field has
  4183. // more key-value pairs than specified, an error message is generated.
  4184. //
  4185. // ```proto
  4186. // message MyMap {
  4187. // // The field `value` must have at most 3 key-value pairs.
  4188. // map<string, string> value = 1 [(buf.validate.field).map.max_pairs = 3];
  4189. // }
  4190. // ```
  4191. optional uint64 max_pairs = 2 [(predefined).cel = {
  4192. id: "map.max_pairs"
  4193. expression: "uint(this.size()) > rules.max_pairs ? 'map must be at most %d entries'.format([rules.max_pairs]) : ''"
  4194. }];
  4195. // Specifies the rules to be applied to each key in the field.
  4196. //
  4197. // ```proto
  4198. // message MyMap {
  4199. // // The keys in the field `value` must follow the specified rules.
  4200. // map<string, string> value = 1 [(buf.validate.field).map.keys = {
  4201. // string: {
  4202. // min_len: 3
  4203. // max_len: 10
  4204. // }
  4205. // }];
  4206. // }
  4207. // ```
  4208. //
  4209. // Note that the `required` rule does not apply. Map keys cannot be unset.
  4210. optional FieldRules keys = 4;
  4211. // Specifies the rules to be applied to the value of each key in the
  4212. // field. Message values will still have their validations evaluated unless
  4213. // `ignore` is specified.
  4214. //
  4215. // ```proto
  4216. // message MyMap {
  4217. // // The values in the field `value` must follow the specified rules.
  4218. // map<string, string> value = 1 [(buf.validate.field).map.values = {
  4219. // string: {
  4220. // min_len: 5
  4221. // max_len: 20
  4222. // }
  4223. // }];
  4224. // }
  4225. // ```
  4226. // Note that the `required` rule does not apply. Map values cannot be unset.
  4227. optional FieldRules values = 5;
  4228. // Extension fields that have the (buf.validate.predefined) option set
  4229. // will be treated as predefined field rules.
  4230. // See https://protovalidate.com/schemas/predefined-rules/
  4231. extensions 1000 to max;
  4232. }
  4233. // AnyRules describe rules applied exclusively to the `google.protobuf.Any` well-known type.
  4234. message AnyRules {
  4235. // `in` requires the field's `type_url` to be equal to one of the
  4236. // specified values. If it doesn't match any of the specified values, an error
  4237. // message is generated.
  4238. //
  4239. // ```proto
  4240. // message MyAny {
  4241. // // The `value` field must have a `type_url` equal to one of the specified values.
  4242. // google.protobuf.Any value = 1 [(buf.validate.field).any = {
  4243. // in: ["type.googleapis.com/MyType1", "type.googleapis.com/MyType2"]
  4244. // }];
  4245. // }
  4246. // ```
  4247. repeated string in = 2;
  4248. // `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.
  4249. //
  4250. // ```proto
  4251. // message MyAny {
  4252. // // The `value` field must not have a `type_url` equal to any of the specified values.
  4253. // google.protobuf.Any value = 1 [(buf.validate.field).any = {
  4254. // not_in: ["type.googleapis.com/ForbiddenType1", "type.googleapis.com/ForbiddenType2"]
  4255. // }];
  4256. // }
  4257. // ```
  4258. repeated string not_in = 3;
  4259. }
  4260. // DurationRules describe the rules applied exclusively to the `google.protobuf.Duration` well-known type.
  4261. message DurationRules {
  4262. // `const` dictates that the field must match the specified value of the `google.protobuf.Duration` type exactly.
  4263. // If the field's value deviates from the specified value, an error message
  4264. // will be generated.
  4265. //
  4266. // ```proto
  4267. // message MyDuration {
  4268. // // value must equal 5s
  4269. // google.protobuf.Duration value = 1 [(buf.validate.field).duration.const = "5s"];
  4270. // }
  4271. // ```
  4272. optional google.protobuf.Duration const = 2 [(predefined).cel = {
  4273. id: "duration.const"
  4274. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  4275. }];
  4276. oneof less_than {
  4277. // `lt` stipulates that the field must be less than the specified value of the `google.protobuf.Duration` type,
  4278. // exclusive. If the field's value is greater than or equal to the specified
  4279. // value, an error message will be generated.
  4280. //
  4281. // ```proto
  4282. // message MyDuration {
  4283. // // must be less than 5s
  4284. // google.protobuf.Duration value = 1 [(buf.validate.field).duration.lt = "5s"];
  4285. // }
  4286. // ```
  4287. google.protobuf.Duration lt = 3 [(predefined).cel = {
  4288. id: "duration.lt"
  4289. expression:
  4290. "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
  4291. "? 'must be less than %s'.format([rules.lt]) : ''"
  4292. }];
  4293. // `lte` indicates that the field must be less than or equal to the specified
  4294. // value of the `google.protobuf.Duration` type, inclusive. If the field's value is greater than the specified value,
  4295. // an error message will be generated.
  4296. //
  4297. // ```proto
  4298. // message MyDuration {
  4299. // // must be less than or equal to 10s
  4300. // google.protobuf.Duration value = 1 [(buf.validate.field).duration.lte = "10s"];
  4301. // }
  4302. // ```
  4303. google.protobuf.Duration lte = 4 [(predefined).cel = {
  4304. id: "duration.lte"
  4305. expression:
  4306. "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
  4307. "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
  4308. }];
  4309. }
  4310. oneof greater_than {
  4311. // `gt` requires the duration field value to be greater than the specified
  4312. // value (exclusive). If the value of `gt` is larger than a specified `lt`
  4313. // or `lte`, the range is reversed, and the field value must be outside the
  4314. // specified range. If the field value doesn't meet the required conditions,
  4315. // an error message is generated.
  4316. //
  4317. // ```proto
  4318. // message MyDuration {
  4319. // // duration must be greater than 5s [duration.gt]
  4320. // google.protobuf.Duration value = 1 [(buf.validate.field).duration.gt = { seconds: 5 }];
  4321. //
  4322. // // duration must be greater than 5s and less than 10s [duration.gt_lt]
  4323. // google.protobuf.Duration another_value = 2 [(buf.validate.field).duration = { gt: { seconds: 5 }, lt: { seconds: 10 } }];
  4324. //
  4325. // // duration must be greater than 10s or less than 5s [duration.gt_lt_exclusive]
  4326. // google.protobuf.Duration other_value = 3 [(buf.validate.field).duration = { gt: { seconds: 10 }, lt: { seconds: 5 } }];
  4327. // }
  4328. // ```
  4329. google.protobuf.Duration gt = 5 [
  4330. (predefined).cel = {
  4331. id: "duration.gt"
  4332. expression:
  4333. "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
  4334. "? 'must be greater than %s'.format([rules.gt]) : ''"
  4335. },
  4336. (predefined).cel = {
  4337. id: "duration.gt_lt"
  4338. expression:
  4339. "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
  4340. "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
  4341. },
  4342. (predefined).cel = {
  4343. id: "duration.gt_lt_exclusive"
  4344. expression:
  4345. "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
  4346. "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
  4347. },
  4348. (predefined).cel = {
  4349. id: "duration.gt_lte"
  4350. expression:
  4351. "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
  4352. "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  4353. },
  4354. (predefined).cel = {
  4355. id: "duration.gt_lte_exclusive"
  4356. expression:
  4357. "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
  4358. "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  4359. }
  4360. ];
  4361. // `gte` requires the duration field value to be greater than or equal to the
  4362. // specified value (exclusive). If the value of `gte` is larger than a
  4363. // specified `lt` or `lte`, the range is reversed, and the field value must
  4364. // be outside the specified range. If the field value doesn't meet the
  4365. // required conditions, an error message is generated.
  4366. //
  4367. // ```proto
  4368. // message MyDuration {
  4369. // // duration must be greater than or equal to 5s [duration.gte]
  4370. // google.protobuf.Duration value = 1 [(buf.validate.field).duration.gte = { seconds: 5 }];
  4371. //
  4372. // // duration must be greater than or equal to 5s and less than 10s [duration.gte_lt]
  4373. // google.protobuf.Duration another_value = 2 [(buf.validate.field).duration = { gte: { seconds: 5 }, lt: { seconds: 10 } }];
  4374. //
  4375. // // duration must be greater than or equal to 10s or less than 5s [duration.gte_lt_exclusive]
  4376. // google.protobuf.Duration other_value = 3 [(buf.validate.field).duration = { gte: { seconds: 10 }, lt: { seconds: 5 } }];
  4377. // }
  4378. // ```
  4379. google.protobuf.Duration gte = 6 [
  4380. (predefined).cel = {
  4381. id: "duration.gte"
  4382. expression:
  4383. "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
  4384. "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
  4385. },
  4386. (predefined).cel = {
  4387. id: "duration.gte_lt"
  4388. expression:
  4389. "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
  4390. "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
  4391. },
  4392. (predefined).cel = {
  4393. id: "duration.gte_lt_exclusive"
  4394. expression:
  4395. "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
  4396. "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
  4397. },
  4398. (predefined).cel = {
  4399. id: "duration.gte_lte"
  4400. expression:
  4401. "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
  4402. "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  4403. },
  4404. (predefined).cel = {
  4405. id: "duration.gte_lte_exclusive"
  4406. expression:
  4407. "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
  4408. "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  4409. }
  4410. ];
  4411. }
  4412. // `in` asserts that the field must be equal to one of the specified values of the `google.protobuf.Duration` type.
  4413. // If the field's value doesn't correspond to any of the specified values,
  4414. // an error message will be generated.
  4415. //
  4416. // ```proto
  4417. // message MyDuration {
  4418. // // must be in list [1s, 2s, 3s]
  4419. // google.protobuf.Duration value = 1 [(buf.validate.field).duration.in = ["1s", "2s", "3s"]];
  4420. // }
  4421. // ```
  4422. repeated google.protobuf.Duration in = 7 [(predefined).cel = {
  4423. id: "duration.in"
  4424. expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  4425. }];
  4426. // `not_in` denotes that the field must not be equal to
  4427. // any of the specified values of the `google.protobuf.Duration` type.
  4428. // If the field's value matches any of these values, an error message will be
  4429. // generated.
  4430. //
  4431. // ```proto
  4432. // message MyDuration {
  4433. // // value must not be in list [1s, 2s, 3s]
  4434. // google.protobuf.Duration value = 1 [(buf.validate.field).duration.not_in = ["1s", "2s", "3s"]];
  4435. // }
  4436. // ```
  4437. repeated google.protobuf.Duration not_in = 8 [(predefined).cel = {
  4438. id: "duration.not_in"
  4439. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  4440. }];
  4441. // `example` specifies values that the field may have. These values SHOULD
  4442. // conform to other rules. `example` values will not impact validation
  4443. // but may be used as helpful guidance on how to populate the given field.
  4444. //
  4445. // ```proto
  4446. // message MyDuration {
  4447. // google.protobuf.Duration value = 1 [
  4448. // (buf.validate.field).duration.example = { seconds: 1 },
  4449. // (buf.validate.field).duration.example = { seconds: 2 },
  4450. // ];
  4451. // }
  4452. // ```
  4453. repeated google.protobuf.Duration example = 9 [(predefined).cel = {
  4454. id: "duration.example"
  4455. expression: "true"
  4456. }];
  4457. // Extension fields that have the (buf.validate.predefined) option set
  4458. // will be treated as predefined field rules.
  4459. // See https://protovalidate.com/schemas/predefined-rules/
  4460. extensions 1000 to max;
  4461. }
  4462. // FieldMaskRules describe rules applied exclusively to the `google.protobuf.FieldMask` well-known type.
  4463. message FieldMaskRules {
  4464. // `const` dictates that the field must match the specified value of the `google.protobuf.FieldMask` type exactly.
  4465. // If the field's value deviates from the specified value, an error message
  4466. // will be generated.
  4467. //
  4468. // ```proto
  4469. // message MyFieldMask {
  4470. // // value must equal ["a"]
  4471. // google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask.const = {
  4472. // paths: ["a"]
  4473. // }];
  4474. // }
  4475. // ```
  4476. optional google.protobuf.FieldMask const = 1 [(predefined).cel = {
  4477. id: "field_mask.const"
  4478. expression: "this.paths != getField(rules, 'const').paths ? 'must equal paths %s'.format([getField(rules, 'const').paths]) : ''"
  4479. }];
  4480. // `in` requires the field value to only contain paths matching specified
  4481. // values or their subpaths.
  4482. // If any of the field value's paths doesn't match the rule,
  4483. // an error message is generated.
  4484. // See: https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask
  4485. //
  4486. // ```proto
  4487. // message MyFieldMask {
  4488. // // The `value` FieldMask must only contain paths listed in `in`.
  4489. // google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask = {
  4490. // in: ["a", "b", "c.a"]
  4491. // }];
  4492. // }
  4493. // ```
  4494. repeated string in = 2 [(predefined).cel = {
  4495. id: "field_mask.in"
  4496. 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')]) : ''"
  4497. }];
  4498. // `not_in` requires the field value to not contain paths matching specified
  4499. // values or their subpaths.
  4500. // If any of the field value's paths matches the rule,
  4501. // an error message is generated.
  4502. // See: https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask
  4503. //
  4504. // ```proto
  4505. // message MyFieldMask {
  4506. // // The `value` FieldMask shall not contain paths listed in `not_in`.
  4507. // google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask = {
  4508. // not_in: ["forbidden", "immutable", "c.a"]
  4509. // }];
  4510. // }
  4511. // ```
  4512. repeated string not_in = 3 [(predefined).cel = {
  4513. id: "field_mask.not_in"
  4514. 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')]) : ''"
  4515. }];
  4516. // `example` specifies values that the field may have. These values SHOULD
  4517. // conform to other rules. `example` values will not impact validation
  4518. // but may be used as helpful guidance on how to populate the given field.
  4519. //
  4520. // ```proto
  4521. // message MyFieldMask {
  4522. // google.protobuf.FieldMask value = 1 [
  4523. // (buf.validate.field).field_mask.example = { paths: ["a", "b"] },
  4524. // (buf.validate.field).field_mask.example = { paths: ["c.a", "d"] },
  4525. // ];
  4526. // }
  4527. // ```
  4528. repeated google.protobuf.FieldMask example = 4 [(predefined).cel = {
  4529. id: "field_mask.example"
  4530. expression: "true"
  4531. }];
  4532. // Extension fields that have the (buf.validate.predefined) option set
  4533. // will be treated as predefined field rules.
  4534. // See https://protovalidate.com/schemas/predefined-rules/
  4535. extensions 1000 to max;
  4536. }
  4537. // TimestampRules describe the rules applied exclusively to the `google.protobuf.Timestamp` well-known type.
  4538. message TimestampRules {
  4539. // `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.
  4540. //
  4541. // ```proto
  4542. // message MyTimestamp {
  4543. // // value must equal 2023-05-03T10:00:00Z
  4544. // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.const = {seconds: 1727998800}];
  4545. // }
  4546. // ```
  4547. optional google.protobuf.Timestamp const = 2 [(predefined).cel = {
  4548. id: "timestamp.const"
  4549. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  4550. }];
  4551. oneof less_than {
  4552. // `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.
  4553. //
  4554. // ```proto
  4555. // message MyTimestamp {
  4556. // // timestamp must be less than '2023-01-01T00:00:00Z' [timestamp.lt]
  4557. // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.lt = { seconds: 1672444800 }];
  4558. // }
  4559. // ```
  4560. google.protobuf.Timestamp lt = 3 [(predefined).cel = {
  4561. id: "timestamp.lt"
  4562. expression:
  4563. "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
  4564. "? 'must be less than %s'.format([rules.lt]) : ''"
  4565. }];
  4566. // `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.
  4567. //
  4568. // ```proto
  4569. // message MyTimestamp {
  4570. // // timestamp must be less than or equal to '2023-05-14T00:00:00Z' [timestamp.lte]
  4571. // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.lte = { seconds: 1678867200 }];
  4572. // }
  4573. // ```
  4574. google.protobuf.Timestamp lte = 4 [(predefined).cel = {
  4575. id: "timestamp.lte"
  4576. expression:
  4577. "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
  4578. "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
  4579. }];
  4580. // `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.
  4581. //
  4582. // ```proto
  4583. // message MyTimestamp {
  4584. // // must be less than now
  4585. // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.lt_now = true];
  4586. // }
  4587. // ```
  4588. bool lt_now = 7 [(predefined).cel = {
  4589. id: "timestamp.lt_now"
  4590. expression: "(rules.lt_now && this > now) ? 'must be less than now' : ''"
  4591. }];
  4592. }
  4593. oneof greater_than {
  4594. // `gt` requires the timestamp field value to be greater than the specified
  4595. // value (exclusive). If the value of `gt` is larger than a specified `lt`
  4596. // or `lte`, the range is reversed, and the field value must be outside the
  4597. // specified range. If the field value doesn't meet the required conditions,
  4598. // an error message is generated.
  4599. //
  4600. // ```proto
  4601. // message MyTimestamp {
  4602. // // timestamp must be greater than '2023-01-01T00:00:00Z' [timestamp.gt]
  4603. // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.gt = { seconds: 1672444800 }];
  4604. //
  4605. // // timestamp must be greater than '2023-01-01T00:00:00Z' and less than '2023-01-02T00:00:00Z' [timestamp.gt_lt]
  4606. // google.protobuf.Timestamp another_value = 2 [(buf.validate.field).timestamp = { gt: { seconds: 1672444800 }, lt: { seconds: 1672531200 } }];
  4607. //
  4608. // // timestamp must be greater than '2023-01-02T00:00:00Z' or less than '2023-01-01T00:00:00Z' [timestamp.gt_lt_exclusive]
  4609. // google.protobuf.Timestamp other_value = 3 [(buf.validate.field).timestamp = { gt: { seconds: 1672531200 }, lt: { seconds: 1672444800 } }];
  4610. // }
  4611. // ```
  4612. google.protobuf.Timestamp gt = 5 [
  4613. (predefined).cel = {
  4614. id: "timestamp.gt"
  4615. expression:
  4616. "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
  4617. "? 'must be greater than %s'.format([rules.gt]) : ''"
  4618. },
  4619. (predefined).cel = {
  4620. id: "timestamp.gt_lt"
  4621. expression:
  4622. "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
  4623. "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
  4624. },
  4625. (predefined).cel = {
  4626. id: "timestamp.gt_lt_exclusive"
  4627. expression:
  4628. "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
  4629. "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
  4630. },
  4631. (predefined).cel = {
  4632. id: "timestamp.gt_lte"
  4633. expression:
  4634. "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
  4635. "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  4636. },
  4637. (predefined).cel = {
  4638. id: "timestamp.gt_lte_exclusive"
  4639. expression:
  4640. "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
  4641. "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  4642. }
  4643. ];
  4644. // `gte` requires the timestamp field value to be greater than or equal to the
  4645. // specified value (exclusive). If the value of `gte` is larger than a
  4646. // specified `lt` or `lte`, the range is reversed, and the field value
  4647. // must be outside the specified range. If the field value doesn't meet
  4648. // the required conditions, an error message is generated.
  4649. //
  4650. // ```proto
  4651. // message MyTimestamp {
  4652. // // timestamp must be greater than or equal to '2023-01-01T00:00:00Z' [timestamp.gte]
  4653. // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.gte = { seconds: 1672444800 }];
  4654. //
  4655. // // timestamp must be greater than or equal to '2023-01-01T00:00:00Z' and less than '2023-01-02T00:00:00Z' [timestamp.gte_lt]
  4656. // google.protobuf.Timestamp another_value = 2 [(buf.validate.field).timestamp = { gte: { seconds: 1672444800 }, lt: { seconds: 1672531200 } }];
  4657. //
  4658. // // 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]
  4659. // google.protobuf.Timestamp other_value = 3 [(buf.validate.field).timestamp = { gte: { seconds: 1672531200 }, lt: { seconds: 1672444800 } }];
  4660. // }
  4661. // ```
  4662. google.protobuf.Timestamp gte = 6 [
  4663. (predefined).cel = {
  4664. id: "timestamp.gte"
  4665. expression:
  4666. "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
  4667. "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
  4668. },
  4669. (predefined).cel = {
  4670. id: "timestamp.gte_lt"
  4671. expression:
  4672. "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
  4673. "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
  4674. },
  4675. (predefined).cel = {
  4676. id: "timestamp.gte_lt_exclusive"
  4677. expression:
  4678. "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
  4679. "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
  4680. },
  4681. (predefined).cel = {
  4682. id: "timestamp.gte_lte"
  4683. expression:
  4684. "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
  4685. "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  4686. },
  4687. (predefined).cel = {
  4688. id: "timestamp.gte_lte_exclusive"
  4689. expression:
  4690. "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
  4691. "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  4692. }
  4693. ];
  4694. // `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.
  4695. //
  4696. // ```proto
  4697. // message MyTimestamp {
  4698. // // must be greater than now
  4699. // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.gt_now = true];
  4700. // }
  4701. // ```
  4702. bool gt_now = 8 [(predefined).cel = {
  4703. id: "timestamp.gt_now"
  4704. expression: "(rules.gt_now && this < now) ? 'must be greater than now' : ''"
  4705. }];
  4706. }
  4707. // `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.
  4708. //
  4709. // ```proto
  4710. // message MyTimestamp {
  4711. // // must be within 1 hour of now
  4712. // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.within = {seconds: 3600}];
  4713. // }
  4714. // ```
  4715. optional google.protobuf.Duration within = 9 [(predefined).cel = {
  4716. id: "timestamp.within"
  4717. expression: "this < now-rules.within || this > now+rules.within ? 'must be within %s of now'.format([rules.within]) : ''"
  4718. }];
  4719. // `example` specifies values that the field may have. These values SHOULD
  4720. // conform to other rules. `example` values will not impact validation
  4721. // but may be used as helpful guidance on how to populate the given field.
  4722. //
  4723. // ```proto
  4724. // message MyTimestamp {
  4725. // google.protobuf.Timestamp value = 1 [
  4726. // (buf.validate.field).timestamp.example = { seconds: 1672444800 },
  4727. // (buf.validate.field).timestamp.example = { seconds: 1672531200 },
  4728. // ];
  4729. // }
  4730. // ```
  4731. repeated google.protobuf.Timestamp example = 10 [(predefined).cel = {
  4732. id: "timestamp.example"
  4733. expression: "true"
  4734. }];
  4735. // Extension fields that have the (buf.validate.predefined) option set
  4736. // will be treated as predefined field rules.
  4737. // See https://protovalidate.com/schemas/predefined-rules/
  4738. extensions 1000 to max;
  4739. }
  4740. // `Violations` is a collection of `Violation` messages. This message type is returned by
  4741. // Protovalidate when a proto message fails to meet the requirements set by the `Rule` validation rules.
  4742. // Each individual violation is represented by a `Violation` message.
  4743. message Violations {
  4744. // `violations` is a repeated field that contains all the `Violation` messages corresponding to the violations detected.
  4745. repeated Violation violations = 1;
  4746. }
  4747. // `Violation` represents a single instance where a validation rule, expressed
  4748. // as a `Rule`, was not met. It provides information about the field that
  4749. // caused the violation, the specific rule that wasn't fulfilled, and a
  4750. // human-readable error message.
  4751. //
  4752. // For example, consider the following message:
  4753. //
  4754. // ```proto
  4755. // message User {
  4756. // int32 age = 1 [(buf.validate.field).cel = {
  4757. // id: "user.age",
  4758. // expression: "this < 18 ? 'User must be at least 18 years old' : ''",
  4759. // }];
  4760. // }
  4761. // ```
  4762. //
  4763. // It could produce the following violation:
  4764. //
  4765. // ```json
  4766. // {
  4767. // "ruleId": "user.age",
  4768. // "message": "User must be at least 18 years old",
  4769. // "field": {
  4770. // "elements": [
  4771. // {
  4772. // "fieldNumber": 1,
  4773. // "fieldName": "age",
  4774. // "fieldType": "TYPE_INT32"
  4775. // }
  4776. // ]
  4777. // },
  4778. // "rule": {
  4779. // "elements": [
  4780. // {
  4781. // "fieldNumber": 23,
  4782. // "fieldName": "cel",
  4783. // "fieldType": "TYPE_MESSAGE",
  4784. // "index": "0"
  4785. // }
  4786. // ]
  4787. // }
  4788. // }
  4789. // ```
  4790. message Violation {
  4791. // `field` is a machine-readable path to the field that failed validation.
  4792. // 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.
  4793. //
  4794. // For example, consider the following message:
  4795. //
  4796. // ```proto
  4797. // message Message {
  4798. // bool a = 1 [(buf.validate.field).required = true];
  4799. // }
  4800. // ```
  4801. //
  4802. // It could produce the following violation:
  4803. //
  4804. // ```textproto
  4805. // violation {
  4806. // field { element { field_number: 1, field_name: "a", field_type: 8 } }
  4807. // ...
  4808. // }
  4809. // ```
  4810. optional FieldPath field = 5;
  4811. // `rule` is a machine-readable path that points to the specific rule that failed validation.
  4812. // This will be a nested field starting from the FieldRules of the field that failed validation.
  4813. // For custom rules, this will provide the path of the rule, e.g. `cel[0]`.
  4814. //
  4815. // For example, consider the following message:
  4816. //
  4817. // ```proto
  4818. // message Message {
  4819. // bool a = 1 [(buf.validate.field).required = true];
  4820. // bool b = 2 [(buf.validate.field).cel = {
  4821. // id: "custom_rule",
  4822. // expression: "!this ? 'b must be true': ''"
  4823. // }]
  4824. // }
  4825. // ```
  4826. //
  4827. // It could produce the following violations:
  4828. //
  4829. // ```textproto
  4830. // violation {
  4831. // rule { element { field_number: 25, field_name: "required", field_type: 8 } }
  4832. // ...
  4833. // }
  4834. // violation {
  4835. // rule { element { field_number: 23, field_name: "cel", field_type: 11, index: 0 } }
  4836. // ...
  4837. // }
  4838. // ```
  4839. optional FieldPath rule = 6;
  4840. // `rule_id` is the unique identifier of the `Rule` that was not fulfilled.
  4841. // This is the same `id` that was specified in the `Rule` message, allowing easy tracing of which rule was violated.
  4842. optional string rule_id = 2;
  4843. // `message` is a human-readable error message that describes the nature of the violation.
  4844. // 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.
  4845. optional string message = 3;
  4846. // `for_key` indicates whether the violation was caused by a map key, rather than a value.
  4847. optional bool for_key = 4;
  4848. reserved 1;
  4849. reserved "field_path";
  4850. }
  4851. // `FieldPath` provides a path to a nested protobuf field.
  4852. //
  4853. // This message provides enough information to render a dotted field path even without protobuf descriptors.
  4854. // It also provides enough information to resolve a nested field through unknown wire data.
  4855. message FieldPath {
  4856. // `elements` contains each element of the path, starting from the root and recursing downward.
  4857. repeated FieldPathElement elements = 1;
  4858. }
  4859. // `FieldPathElement` provides enough information to nest through a single protobuf field.
  4860. //
  4861. // If the selected field is a map or repeated field, the `subscript` value selects a specific element from it.
  4862. // A path that refers to a value nested under a map key or repeated field index will have a `subscript` value.
  4863. // The `field_type` field allows unambiguous resolution of a field even if descriptors are not available.
  4864. message FieldPathElement {
  4865. // `field_number` is the field number this path element refers to.
  4866. optional int32 field_number = 1;
  4867. // `field_name` contains the field name this path element refers to.
  4868. // This can be used to display a human-readable path even if the field number is unknown.
  4869. optional string field_name = 2;
  4870. // `field_type` specifies the type of this field. When using reflection, this value is not needed.
  4871. //
  4872. // This value is provided to make it possible to traverse unknown fields through wire data.
  4873. // When traversing wire data, be mindful of both packed[1] and delimited[2] encoding schemes.
  4874. //
  4875. // [1]: https://protobuf.dev/programming-guides/encoding/#packed
  4876. // [2]: https://protobuf.dev/programming-guides/encoding/#groups
  4877. //
  4878. // N.B.: Although groups are deprecated, the corresponding delimited encoding scheme is not, and
  4879. // can be explicitly used in Protocol Buffers 2023 Edition.
  4880. optional google.protobuf.FieldDescriptorProto.Type field_type = 3;
  4881. // `key_type` specifies the map key type of this field. This value is useful when traversing
  4882. // unknown fields through wire data: specifically, it allows handling the differences between
  4883. // different integer encodings.
  4884. optional google.protobuf.FieldDescriptorProto.Type key_type = 4;
  4885. // `value_type` specifies map value type of this field. This is useful if you want to display a
  4886. // value inside unknown fields through wire data.
  4887. optional google.protobuf.FieldDescriptorProto.Type value_type = 5;
  4888. // `subscript` contains a repeated index or map key, if this path element nests into a repeated or map field.
  4889. oneof subscript {
  4890. // `index` specifies a 0-based index into a repeated field.
  4891. uint64 index = 6;
  4892. // `bool_key` specifies a map key of type bool.
  4893. bool bool_key = 7;
  4894. // `int_key` specifies a map key of type int32, int64, sint32, sint64, sfixed32 or sfixed64.
  4895. int64 int_key = 8;
  4896. // `uint_key` specifies a map key of type uint32, uint64, fixed32 or fixed64.
  4897. uint64 uint_key = 9;
  4898. // `string_key` specifies a map key of type string.
  4899. string string_key = 10;
  4900. }
  4901. }