validate.proto 199 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134
  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 = { seconds: 5 }];
  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 = { seconds: 5 }];
  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 = { seconds: 10 }];
  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 = {
  4420. // in: [{ seconds: 1 }, { seconds: 2 }, { seconds: 3 }]
  4421. // }];
  4422. // }
  4423. // ```
  4424. repeated google.protobuf.Duration in = 7 [(predefined).cel = {
  4425. id: "duration.in"
  4426. expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
  4427. }];
  4428. // `not_in` denotes that the field must not be equal to
  4429. // any of the specified values of the `google.protobuf.Duration` type.
  4430. // If the field's value matches any of these values, an error message will be
  4431. // generated.
  4432. //
  4433. // ```proto
  4434. // message MyDuration {
  4435. // // value must not be in list [1s, 2s, 3s]
  4436. // google.protobuf.Duration value = 1 [(buf.validate.field).duration = {
  4437. // not_in: [{ seconds: 1 }, { seconds: 2 }, { seconds: 3 }]
  4438. // }];
  4439. // }
  4440. // ```
  4441. repeated google.protobuf.Duration not_in = 8 [(predefined).cel = {
  4442. id: "duration.not_in"
  4443. expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
  4444. }];
  4445. // `example` specifies values that the field may have. These values SHOULD
  4446. // conform to other rules. `example` values will not impact validation
  4447. // but may be used as helpful guidance on how to populate the given field.
  4448. //
  4449. // ```proto
  4450. // message MyDuration {
  4451. // google.protobuf.Duration value = 1 [
  4452. // (buf.validate.field).duration.example = { seconds: 1 },
  4453. // (buf.validate.field).duration.example = { seconds: 2 },
  4454. // ];
  4455. // }
  4456. // ```
  4457. repeated google.protobuf.Duration example = 9 [(predefined).cel = {
  4458. id: "duration.example"
  4459. expression: "true"
  4460. }];
  4461. // Extension fields that have the (buf.validate.predefined) option set
  4462. // will be treated as predefined field rules.
  4463. // See https://protovalidate.com/schemas/predefined-rules/
  4464. extensions 1000 to max;
  4465. }
  4466. // FieldMaskRules describe rules applied exclusively to the `google.protobuf.FieldMask` well-known type.
  4467. message FieldMaskRules {
  4468. // `const` dictates that the field must match the specified value of the `google.protobuf.FieldMask` type exactly.
  4469. // If the field's value deviates from the specified value, an error message
  4470. // will be generated.
  4471. //
  4472. // ```proto
  4473. // message MyFieldMask {
  4474. // // value must equal ["a"]
  4475. // google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask.const = {
  4476. // paths: ["a"]
  4477. // }];
  4478. // }
  4479. // ```
  4480. optional google.protobuf.FieldMask const = 1 [(predefined).cel = {
  4481. id: "field_mask.const"
  4482. expression: "this.paths != getField(rules, 'const').paths ? 'must equal paths %s'.format([getField(rules, 'const').paths]) : ''"
  4483. }];
  4484. // `in` requires the field value to only contain paths matching specified
  4485. // values or their subpaths.
  4486. // If any of the field value's paths doesn't match the rule,
  4487. // an error message is generated.
  4488. // See: https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask
  4489. //
  4490. // ```proto
  4491. // message MyFieldMask {
  4492. // // The `value` FieldMask must only contain paths listed in `in`.
  4493. // google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask = {
  4494. // in: ["a", "b", "c.a"]
  4495. // }];
  4496. // }
  4497. // ```
  4498. repeated string in = 2 [(predefined).cel = {
  4499. id: "field_mask.in"
  4500. 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')]) : ''"
  4501. }];
  4502. // `not_in` requires the field value to not contain paths matching specified
  4503. // values or their subpaths.
  4504. // If any of the field value's paths matches the rule,
  4505. // an error message is generated.
  4506. // See: https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask
  4507. //
  4508. // ```proto
  4509. // message MyFieldMask {
  4510. // // The `value` FieldMask shall not contain paths listed in `not_in`.
  4511. // google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask = {
  4512. // not_in: ["forbidden", "immutable", "c.a"]
  4513. // }];
  4514. // }
  4515. // ```
  4516. repeated string not_in = 3 [(predefined).cel = {
  4517. id: "field_mask.not_in"
  4518. 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')]) : ''"
  4519. }];
  4520. // `example` specifies values that the field may have. These values SHOULD
  4521. // conform to other rules. `example` values will not impact validation
  4522. // but may be used as helpful guidance on how to populate the given field.
  4523. //
  4524. // ```proto
  4525. // message MyFieldMask {
  4526. // google.protobuf.FieldMask value = 1 [
  4527. // (buf.validate.field).field_mask.example = { paths: ["a", "b"] },
  4528. // (buf.validate.field).field_mask.example = { paths: ["c.a", "d"] },
  4529. // ];
  4530. // }
  4531. // ```
  4532. repeated google.protobuf.FieldMask example = 4 [(predefined).cel = {
  4533. id: "field_mask.example"
  4534. expression: "true"
  4535. }];
  4536. // Extension fields that have the (buf.validate.predefined) option set
  4537. // will be treated as predefined field rules.
  4538. // See https://protovalidate.com/schemas/predefined-rules/
  4539. extensions 1000 to max;
  4540. }
  4541. // TimestampRules describe the rules applied exclusively to the `google.protobuf.Timestamp` well-known type.
  4542. message TimestampRules {
  4543. // `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.
  4544. //
  4545. // ```proto
  4546. // message MyTimestamp {
  4547. // // value must equal 2023-05-03T10:00:00Z
  4548. // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.const = {seconds: 1727998800}];
  4549. // }
  4550. // ```
  4551. optional google.protobuf.Timestamp const = 2 [(predefined).cel = {
  4552. id: "timestamp.const"
  4553. expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
  4554. }];
  4555. oneof less_than {
  4556. // `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.
  4557. //
  4558. // ```proto
  4559. // message MyTimestamp {
  4560. // // timestamp must be less than '2023-01-01T00:00:00Z' [timestamp.lt]
  4561. // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.lt = { seconds: 1672444800 }];
  4562. // }
  4563. // ```
  4564. google.protobuf.Timestamp lt = 3 [(predefined).cel = {
  4565. id: "timestamp.lt"
  4566. expression:
  4567. "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
  4568. "? 'must be less than %s'.format([rules.lt]) : ''"
  4569. }];
  4570. // `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.
  4571. //
  4572. // ```proto
  4573. // message MyTimestamp {
  4574. // // timestamp must be less than or equal to '2023-05-14T00:00:00Z' [timestamp.lte]
  4575. // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.lte = { seconds: 1678867200 }];
  4576. // }
  4577. // ```
  4578. google.protobuf.Timestamp lte = 4 [(predefined).cel = {
  4579. id: "timestamp.lte"
  4580. expression:
  4581. "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
  4582. "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
  4583. }];
  4584. // `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.
  4585. //
  4586. // ```proto
  4587. // message MyTimestamp {
  4588. // // must be less than now
  4589. // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.lt_now = true];
  4590. // }
  4591. // ```
  4592. bool lt_now = 7 [(predefined).cel = {
  4593. id: "timestamp.lt_now"
  4594. expression: "(rules.lt_now && this > now) ? 'must be less than now' : ''"
  4595. }];
  4596. }
  4597. oneof greater_than {
  4598. // `gt` requires the timestamp field value to be greater than the specified
  4599. // value (exclusive). If the value of `gt` is larger than a specified `lt`
  4600. // or `lte`, the range is reversed, and the field value must be outside the
  4601. // specified range. If the field value doesn't meet the required conditions,
  4602. // an error message is generated.
  4603. //
  4604. // ```proto
  4605. // message MyTimestamp {
  4606. // // timestamp must be greater than '2023-01-01T00:00:00Z' [timestamp.gt]
  4607. // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.gt = { seconds: 1672444800 }];
  4608. //
  4609. // // timestamp must be greater than '2023-01-01T00:00:00Z' and less than '2023-01-02T00:00:00Z' [timestamp.gt_lt]
  4610. // google.protobuf.Timestamp another_value = 2 [(buf.validate.field).timestamp = { gt: { seconds: 1672444800 }, lt: { seconds: 1672531200 } }];
  4611. //
  4612. // // timestamp must be greater than '2023-01-02T00:00:00Z' or less than '2023-01-01T00:00:00Z' [timestamp.gt_lt_exclusive]
  4613. // google.protobuf.Timestamp other_value = 3 [(buf.validate.field).timestamp = { gt: { seconds: 1672531200 }, lt: { seconds: 1672444800 } }];
  4614. // }
  4615. // ```
  4616. google.protobuf.Timestamp gt = 5 [
  4617. (predefined).cel = {
  4618. id: "timestamp.gt"
  4619. expression:
  4620. "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
  4621. "? 'must be greater than %s'.format([rules.gt]) : ''"
  4622. },
  4623. (predefined).cel = {
  4624. id: "timestamp.gt_lt"
  4625. expression:
  4626. "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
  4627. "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
  4628. },
  4629. (predefined).cel = {
  4630. id: "timestamp.gt_lt_exclusive"
  4631. expression:
  4632. "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
  4633. "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
  4634. },
  4635. (predefined).cel = {
  4636. id: "timestamp.gt_lte"
  4637. expression:
  4638. "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
  4639. "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  4640. },
  4641. (predefined).cel = {
  4642. id: "timestamp.gt_lte_exclusive"
  4643. expression:
  4644. "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
  4645. "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
  4646. }
  4647. ];
  4648. // `gte` requires the timestamp field value to be greater than or equal to the
  4649. // specified value (exclusive). If the value of `gte` is larger than a
  4650. // specified `lt` or `lte`, the range is reversed, and the field value
  4651. // must be outside the specified range. If the field value doesn't meet
  4652. // the required conditions, an error message is generated.
  4653. //
  4654. // ```proto
  4655. // message MyTimestamp {
  4656. // // timestamp must be greater than or equal to '2023-01-01T00:00:00Z' [timestamp.gte]
  4657. // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.gte = { seconds: 1672444800 }];
  4658. //
  4659. // // timestamp must be greater than or equal to '2023-01-01T00:00:00Z' and less than '2023-01-02T00:00:00Z' [timestamp.gte_lt]
  4660. // google.protobuf.Timestamp another_value = 2 [(buf.validate.field).timestamp = { gte: { seconds: 1672444800 }, lt: { seconds: 1672531200 } }];
  4661. //
  4662. // // 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]
  4663. // google.protobuf.Timestamp other_value = 3 [(buf.validate.field).timestamp = { gte: { seconds: 1672531200 }, lt: { seconds: 1672444800 } }];
  4664. // }
  4665. // ```
  4666. google.protobuf.Timestamp gte = 6 [
  4667. (predefined).cel = {
  4668. id: "timestamp.gte"
  4669. expression:
  4670. "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
  4671. "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
  4672. },
  4673. (predefined).cel = {
  4674. id: "timestamp.gte_lt"
  4675. expression:
  4676. "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
  4677. "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
  4678. },
  4679. (predefined).cel = {
  4680. id: "timestamp.gte_lt_exclusive"
  4681. expression:
  4682. "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
  4683. "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
  4684. },
  4685. (predefined).cel = {
  4686. id: "timestamp.gte_lte"
  4687. expression:
  4688. "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
  4689. "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  4690. },
  4691. (predefined).cel = {
  4692. id: "timestamp.gte_lte_exclusive"
  4693. expression:
  4694. "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
  4695. "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
  4696. }
  4697. ];
  4698. // `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.
  4699. //
  4700. // ```proto
  4701. // message MyTimestamp {
  4702. // // must be greater than now
  4703. // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.gt_now = true];
  4704. // }
  4705. // ```
  4706. bool gt_now = 8 [(predefined).cel = {
  4707. id: "timestamp.gt_now"
  4708. expression: "(rules.gt_now && this < now) ? 'must be greater than now' : ''"
  4709. }];
  4710. }
  4711. // `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.
  4712. //
  4713. // ```proto
  4714. // message MyTimestamp {
  4715. // // must be within 1 hour of now
  4716. // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.within = {seconds: 3600}];
  4717. // }
  4718. // ```
  4719. optional google.protobuf.Duration within = 9 [(predefined).cel = {
  4720. id: "timestamp.within"
  4721. expression: "this < now-rules.within || this > now+rules.within ? 'must be within %s of now'.format([rules.within]) : ''"
  4722. }];
  4723. // `example` specifies values that the field may have. These values SHOULD
  4724. // conform to other rules. `example` values will not impact validation
  4725. // but may be used as helpful guidance on how to populate the given field.
  4726. //
  4727. // ```proto
  4728. // message MyTimestamp {
  4729. // google.protobuf.Timestamp value = 1 [
  4730. // (buf.validate.field).timestamp.example = { seconds: 1672444800 },
  4731. // (buf.validate.field).timestamp.example = { seconds: 1672531200 },
  4732. // ];
  4733. // }
  4734. // ```
  4735. repeated google.protobuf.Timestamp example = 10 [(predefined).cel = {
  4736. id: "timestamp.example"
  4737. expression: "true"
  4738. }];
  4739. // Extension fields that have the (buf.validate.predefined) option set
  4740. // will be treated as predefined field rules.
  4741. // See https://protovalidate.com/schemas/predefined-rules/
  4742. extensions 1000 to max;
  4743. }
  4744. // `Violations` is a collection of `Violation` messages. This message type is returned by
  4745. // Protovalidate when a proto message fails to meet the requirements set by the `Rule` validation rules.
  4746. // Each individual violation is represented by a `Violation` message.
  4747. message Violations {
  4748. // `violations` is a repeated field that contains all the `Violation` messages corresponding to the violations detected.
  4749. repeated Violation violations = 1;
  4750. }
  4751. // `Violation` represents a single instance where a validation rule, expressed
  4752. // as a `Rule`, was not met. It provides information about the field that
  4753. // caused the violation, the specific rule that wasn't fulfilled, and a
  4754. // human-readable error message.
  4755. //
  4756. // For example, consider the following message:
  4757. //
  4758. // ```proto
  4759. // message User {
  4760. // int32 age = 1 [(buf.validate.field).cel = {
  4761. // id: "user.age",
  4762. // expression: "this < 18 ? 'User must be at least 18 years old' : ''",
  4763. // }];
  4764. // }
  4765. // ```
  4766. //
  4767. // It could produce the following violation:
  4768. //
  4769. // ```json
  4770. // {
  4771. // "ruleId": "user.age",
  4772. // "message": "User must be at least 18 years old",
  4773. // "field": {
  4774. // "elements": [
  4775. // {
  4776. // "fieldNumber": 1,
  4777. // "fieldName": "age",
  4778. // "fieldType": "TYPE_INT32"
  4779. // }
  4780. // ]
  4781. // },
  4782. // "rule": {
  4783. // "elements": [
  4784. // {
  4785. // "fieldNumber": 23,
  4786. // "fieldName": "cel",
  4787. // "fieldType": "TYPE_MESSAGE",
  4788. // "index": "0"
  4789. // }
  4790. // ]
  4791. // }
  4792. // }
  4793. // ```
  4794. message Violation {
  4795. // `field` is a machine-readable path to the field that failed validation.
  4796. // 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.
  4797. //
  4798. // For example, consider the following message:
  4799. //
  4800. // ```proto
  4801. // message Message {
  4802. // bool a = 1 [(buf.validate.field).required = true];
  4803. // }
  4804. // ```
  4805. //
  4806. // It could produce the following violation:
  4807. //
  4808. // ```textproto
  4809. // violation {
  4810. // field { element { field_number: 1, field_name: "a", field_type: 8 } }
  4811. // ...
  4812. // }
  4813. // ```
  4814. optional FieldPath field = 5;
  4815. // `rule` is a machine-readable path that points to the specific rule that failed validation.
  4816. // This will be a nested field starting from the FieldRules of the field that failed validation.
  4817. // For custom rules, this will provide the path of the rule, e.g. `cel[0]`.
  4818. //
  4819. // For example, consider the following message:
  4820. //
  4821. // ```proto
  4822. // message Message {
  4823. // bool a = 1 [(buf.validate.field).required = true];
  4824. // bool b = 2 [(buf.validate.field).cel = {
  4825. // id: "custom_rule",
  4826. // expression: "!this ? 'b must be true': ''"
  4827. // }]
  4828. // }
  4829. // ```
  4830. //
  4831. // It could produce the following violations:
  4832. //
  4833. // ```textproto
  4834. // violation {
  4835. // rule { element { field_number: 25, field_name: "required", field_type: 8 } }
  4836. // ...
  4837. // }
  4838. // violation {
  4839. // rule { element { field_number: 23, field_name: "cel", field_type: 11, index: 0 } }
  4840. // ...
  4841. // }
  4842. // ```
  4843. optional FieldPath rule = 6;
  4844. // `rule_id` is the unique identifier of the `Rule` that was not fulfilled.
  4845. // This is the same `id` that was specified in the `Rule` message, allowing easy tracing of which rule was violated.
  4846. optional string rule_id = 2;
  4847. // `message` is a human-readable error message that describes the nature of the violation.
  4848. // 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.
  4849. optional string message = 3;
  4850. // `for_key` indicates whether the violation was caused by a map key, rather than a value.
  4851. optional bool for_key = 4;
  4852. reserved 1;
  4853. reserved "field_path";
  4854. }
  4855. // `FieldPath` provides a path to a nested protobuf field.
  4856. //
  4857. // This message provides enough information to render a dotted field path even without protobuf descriptors.
  4858. // It also provides enough information to resolve a nested field through unknown wire data.
  4859. message FieldPath {
  4860. // `elements` contains each element of the path, starting from the root and recursing downward.
  4861. repeated FieldPathElement elements = 1;
  4862. }
  4863. // `FieldPathElement` provides enough information to nest through a single protobuf field.
  4864. //
  4865. // If the selected field is a map or repeated field, the `subscript` value selects a specific element from it.
  4866. // A path that refers to a value nested under a map key or repeated field index will have a `subscript` value.
  4867. // The `field_type` field allows unambiguous resolution of a field even if descriptors are not available.
  4868. message FieldPathElement {
  4869. // `field_number` is the field number this path element refers to.
  4870. optional int32 field_number = 1;
  4871. // `field_name` contains the field name this path element refers to.
  4872. // This can be used to display a human-readable path even if the field number is unknown.
  4873. optional string field_name = 2;
  4874. // `field_type` specifies the type of this field. When using reflection, this value is not needed.
  4875. //
  4876. // This value is provided to make it possible to traverse unknown fields through wire data.
  4877. // When traversing wire data, be mindful of both packed[1] and delimited[2] encoding schemes.
  4878. //
  4879. // [1]: https://protobuf.dev/programming-guides/encoding/#packed
  4880. // [2]: https://protobuf.dev/programming-guides/encoding/#groups
  4881. //
  4882. // N.B.: Although groups are deprecated, the corresponding delimited encoding scheme is not, and
  4883. // can be explicitly used in Protocol Buffers 2023 Edition.
  4884. optional google.protobuf.FieldDescriptorProto.Type field_type = 3;
  4885. // `key_type` specifies the map key type of this field. This value is useful when traversing
  4886. // unknown fields through wire data: specifically, it allows handling the differences between
  4887. // different integer encodings.
  4888. optional google.protobuf.FieldDescriptorProto.Type key_type = 4;
  4889. // `value_type` specifies map value type of this field. This is useful if you want to display a
  4890. // value inside unknown fields through wire data.
  4891. optional google.protobuf.FieldDescriptorProto.Type value_type = 5;
  4892. // `subscript` contains a repeated index or map key, if this path element nests into a repeated or map field.
  4893. oneof subscript {
  4894. // `index` specifies a 0-based index into a repeated field.
  4895. uint64 index = 6;
  4896. // `bool_key` specifies a map key of type bool.
  4897. bool bool_key = 7;
  4898. // `int_key` specifies a map key of type int32, int64, sint32, sint64, sfixed32 or sfixed64.
  4899. int64 int_key = 8;
  4900. // `uint_key` specifies a map key of type uint32, uint64, fixed32 or fixed64.
  4901. uint64 uint_key = 9;
  4902. // `string_key` specifies a map key of type string.
  4903. string string_key = 10;
  4904. }
  4905. }