github.com/yoogoc/kratos-scaffold@v0.0.0-20240402032722-a538b3c18955/project_generator/resources/validate.proto (about)

     1  syntax = "proto2";
     2  package validate;
     3  
     4  option go_package = "github.com/envoyproxy/protoc-gen-validate/validate";
     5  option java_package = "io.envoyproxy.pgv.validate";
     6  
     7  import "google/protobuf/descriptor.proto";
     8  import "google/protobuf/duration.proto";
     9  import "google/protobuf/timestamp.proto";
    10  
    11  // Validation rules applied at the message level
    12  extend google.protobuf.MessageOptions {
    13      // Disabled nullifies any validation rules for this message, including any
    14      // message fields associated with it that do support validation.
    15      optional bool disabled = 1071;
    16      // Ignore skips generation of validation methods for this message.
    17      optional bool ignored = 1072;
    18  }
    19  
    20  // Validation rules applied at the oneof level
    21  extend google.protobuf.OneofOptions {
    22      // Required ensures that exactly one the field options in a oneof is set;
    23      // validation fails if no fields in the oneof are set.
    24      optional bool required = 1071;
    25  }
    26  
    27  // Validation rules applied at the field level
    28  extend google.protobuf.FieldOptions {
    29      // Rules specify the validations to be performed on this field. By default,
    30      // no validation is performed against a field.
    31      optional FieldRules rules = 1071;
    32  }
    33  
    34  // FieldRules encapsulates the rules for each type of field. Depending on the
    35  // field, the correct set should be used to ensure proper validations.
    36  message FieldRules {
    37      optional MessageRules message = 17;
    38      oneof type {
    39          // Scalar Field Types
    40          FloatRules    float    = 1;
    41          DoubleRules   double   = 2;
    42          Int32Rules    int32    = 3;
    43          Int64Rules    int64    = 4;
    44          UInt32Rules   uint32   = 5;
    45          UInt64Rules   uint64   = 6;
    46          SInt32Rules   sint32   = 7;
    47          SInt64Rules   sint64   = 8;
    48          Fixed32Rules  fixed32  = 9;
    49          Fixed64Rules  fixed64  = 10;
    50          SFixed32Rules sfixed32 = 11;
    51          SFixed64Rules sfixed64 = 12;
    52          BoolRules     bool     = 13;
    53          StringRules   string   = 14;
    54          BytesRules    bytes    = 15;
    55  
    56          // Complex Field Types
    57          EnumRules     enum     = 16;
    58          RepeatedRules repeated = 18;
    59          MapRules      map      = 19;
    60  
    61          // Well-Known Field Types
    62          AnyRules       any       = 20;
    63          DurationRules  duration  = 21;
    64          TimestampRules timestamp = 22;
    65      }
    66  }
    67  
    68  // FloatRules describes the constraints applied to `float` values
    69  message FloatRules {
    70      // Const specifies that this field must be exactly the specified value
    71      optional float const = 1;
    72  
    73      // Lt specifies that this field must be less than the specified value,
    74      // exclusive
    75      optional float lt = 2;
    76  
    77      // Lte specifies that this field must be less than or equal to the
    78      // specified value, inclusive
    79      optional float lte = 3;
    80  
    81      // Gt specifies that this field must be greater than the specified value,
    82      // exclusive. If the value of Gt is larger than a specified Lt or Lte, the
    83      // range is reversed.
    84      optional float gt = 4;
    85  
    86      // Gte specifies that this field must be greater than or equal to the
    87      // specified value, inclusive. If the value of Gte is larger than a
    88      // specified Lt or Lte, the range is reversed.
    89      optional float gte = 5;
    90  
    91      // In specifies that this field must be equal to one of the specified
    92      // values
    93      repeated float in = 6;
    94  
    95      // NotIn specifies that this field cannot be equal to one of the specified
    96      // values
    97      repeated float not_in = 7;
    98  
    99      // IgnoreEmpty specifies that the validation rules of this field should be
   100      // evaluated only if the field is not empty
   101      optional bool ignore_empty = 8;
   102  }
   103  
   104  // DoubleRules describes the constraints applied to `double` values
   105  message DoubleRules {
   106      // Const specifies that this field must be exactly the specified value
   107      optional double const = 1;
   108  
   109      // Lt specifies that this field must be less than the specified value,
   110      // exclusive
   111      optional double lt = 2;
   112  
   113      // Lte specifies that this field must be less than or equal to the
   114      // specified value, inclusive
   115      optional double lte = 3;
   116  
   117      // Gt specifies that this field must be greater than the specified value,
   118      // exclusive. If the value of Gt is larger than a specified Lt or Lte, the
   119      // range is reversed.
   120      optional double gt = 4;
   121  
   122      // Gte specifies that this field must be greater than or equal to the
   123      // specified value, inclusive. If the value of Gte is larger than a
   124      // specified Lt or Lte, the range is reversed.
   125      optional double gte = 5;
   126  
   127      // In specifies that this field must be equal to one of the specified
   128      // values
   129      repeated double in = 6;
   130  
   131      // NotIn specifies that this field cannot be equal to one of the specified
   132      // values
   133      repeated double not_in = 7;
   134  
   135      // IgnoreEmpty specifies that the validation rules of this field should be
   136      // evaluated only if the field is not empty
   137      optional bool ignore_empty = 8;
   138  }
   139  
   140  // Int32Rules describes the constraints applied to `int32` values
   141  message Int32Rules {
   142      // Const specifies that this field must be exactly the specified value
   143      optional int32 const = 1;
   144  
   145      // Lt specifies that this field must be less than the specified value,
   146      // exclusive
   147      optional int32 lt = 2;
   148  
   149      // Lte specifies that this field must be less than or equal to the
   150      // specified value, inclusive
   151      optional int32 lte = 3;
   152  
   153      // Gt specifies that this field must be greater than the specified value,
   154      // exclusive. If the value of Gt is larger than a specified Lt or Lte, the
   155      // range is reversed.
   156      optional int32 gt = 4;
   157  
   158      // Gte specifies that this field must be greater than or equal to the
   159      // specified value, inclusive. If the value of Gte is larger than a
   160      // specified Lt or Lte, the range is reversed.
   161      optional int32 gte = 5;
   162  
   163      // In specifies that this field must be equal to one of the specified
   164      // values
   165      repeated int32 in = 6;
   166  
   167      // NotIn specifies that this field cannot be equal to one of the specified
   168      // values
   169      repeated int32 not_in = 7;
   170  
   171      // IgnoreEmpty specifies that the validation rules of this field should be
   172      // evaluated only if the field is not empty
   173      optional bool ignore_empty = 8;
   174  }
   175  
   176  // Int64Rules describes the constraints applied to `int64` values
   177  message Int64Rules {
   178      // Const specifies that this field must be exactly the specified value
   179      optional int64 const = 1;
   180  
   181      // Lt specifies that this field must be less than the specified value,
   182      // exclusive
   183      optional int64 lt = 2;
   184  
   185      // Lte specifies that this field must be less than or equal to the
   186      // specified value, inclusive
   187      optional int64 lte = 3;
   188  
   189      // Gt specifies that this field must be greater than the specified value,
   190      // exclusive. If the value of Gt is larger than a specified Lt or Lte, the
   191      // range is reversed.
   192      optional int64 gt = 4;
   193  
   194      // Gte specifies that this field must be greater than or equal to the
   195      // specified value, inclusive. If the value of Gte is larger than a
   196      // specified Lt or Lte, the range is reversed.
   197      optional int64 gte = 5;
   198  
   199      // In specifies that this field must be equal to one of the specified
   200      // values
   201      repeated int64 in = 6;
   202  
   203      // NotIn specifies that this field cannot be equal to one of the specified
   204      // values
   205      repeated int64 not_in = 7;
   206  
   207      // IgnoreEmpty specifies that the validation rules of this field should be
   208      // evaluated only if the field is not empty
   209      optional bool ignore_empty = 8;
   210  }
   211  
   212  // UInt32Rules describes the constraints applied to `uint32` values
   213  message UInt32Rules {
   214      // Const specifies that this field must be exactly the specified value
   215      optional uint32 const = 1;
   216  
   217      // Lt specifies that this field must be less than the specified value,
   218      // exclusive
   219      optional uint32 lt = 2;
   220  
   221      // Lte specifies that this field must be less than or equal to the
   222      // specified value, inclusive
   223      optional uint32 lte = 3;
   224  
   225      // Gt specifies that this field must be greater than the specified value,
   226      // exclusive. If the value of Gt is larger than a specified Lt or Lte, the
   227      // range is reversed.
   228      optional uint32 gt = 4;
   229  
   230      // Gte specifies that this field must be greater than or equal to the
   231      // specified value, inclusive. If the value of Gte is larger than a
   232      // specified Lt or Lte, the range is reversed.
   233      optional uint32 gte = 5;
   234  
   235      // In specifies that this field must be equal to one of the specified
   236      // values
   237      repeated uint32 in = 6;
   238  
   239      // NotIn specifies that this field cannot be equal to one of the specified
   240      // values
   241      repeated uint32 not_in = 7;
   242  
   243      // IgnoreEmpty specifies that the validation rules of this field should be
   244      // evaluated only if the field is not empty
   245      optional bool ignore_empty = 8;
   246  }
   247  
   248  // UInt64Rules describes the constraints applied to `uint64` values
   249  message UInt64Rules {
   250      // Const specifies that this field must be exactly the specified value
   251      optional uint64 const = 1;
   252  
   253      // Lt specifies that this field must be less than the specified value,
   254      // exclusive
   255      optional uint64 lt = 2;
   256  
   257      // Lte specifies that this field must be less than or equal to the
   258      // specified value, inclusive
   259      optional uint64 lte = 3;
   260  
   261      // Gt specifies that this field must be greater than the specified value,
   262      // exclusive. If the value of Gt is larger than a specified Lt or Lte, the
   263      // range is reversed.
   264      optional uint64 gt = 4;
   265  
   266      // Gte specifies that this field must be greater than or equal to the
   267      // specified value, inclusive. If the value of Gte is larger than a
   268      // specified Lt or Lte, the range is reversed.
   269      optional uint64 gte = 5;
   270  
   271      // In specifies that this field must be equal to one of the specified
   272      // values
   273      repeated uint64 in = 6;
   274  
   275      // NotIn specifies that this field cannot be equal to one of the specified
   276      // values
   277      repeated uint64 not_in = 7;
   278  
   279      // IgnoreEmpty specifies that the validation rules of this field should be
   280      // evaluated only if the field is not empty
   281      optional bool ignore_empty = 8;
   282  }
   283  
   284  // SInt32Rules describes the constraints applied to `sint32` values
   285  message SInt32Rules {
   286      // Const specifies that this field must be exactly the specified value
   287      optional sint32 const = 1;
   288  
   289      // Lt specifies that this field must be less than the specified value,
   290      // exclusive
   291      optional sint32 lt = 2;
   292  
   293      // Lte specifies that this field must be less than or equal to the
   294      // specified value, inclusive
   295      optional sint32 lte = 3;
   296  
   297      // Gt specifies that this field must be greater than the specified value,
   298      // exclusive. If the value of Gt is larger than a specified Lt or Lte, the
   299      // range is reversed.
   300      optional sint32 gt = 4;
   301  
   302      // Gte specifies that this field must be greater than or equal to the
   303      // specified value, inclusive. If the value of Gte is larger than a
   304      // specified Lt or Lte, the range is reversed.
   305      optional sint32 gte = 5;
   306  
   307      // In specifies that this field must be equal to one of the specified
   308      // values
   309      repeated sint32 in = 6;
   310  
   311      // NotIn specifies that this field cannot be equal to one of the specified
   312      // values
   313      repeated sint32 not_in = 7;
   314  
   315      // IgnoreEmpty specifies that the validation rules of this field should be
   316      // evaluated only if the field is not empty
   317      optional bool ignore_empty = 8;
   318  }
   319  
   320  // SInt64Rules describes the constraints applied to `sint64` values
   321  message SInt64Rules {
   322      // Const specifies that this field must be exactly the specified value
   323      optional sint64 const = 1;
   324  
   325      // Lt specifies that this field must be less than the specified value,
   326      // exclusive
   327      optional sint64 lt = 2;
   328  
   329      // Lte specifies that this field must be less than or equal to the
   330      // specified value, inclusive
   331      optional sint64 lte = 3;
   332  
   333      // Gt specifies that this field must be greater than the specified value,
   334      // exclusive. If the value of Gt is larger than a specified Lt or Lte, the
   335      // range is reversed.
   336      optional sint64 gt = 4;
   337  
   338      // Gte specifies that this field must be greater than or equal to the
   339      // specified value, inclusive. If the value of Gte is larger than a
   340      // specified Lt or Lte, the range is reversed.
   341      optional sint64 gte = 5;
   342  
   343      // In specifies that this field must be equal to one of the specified
   344      // values
   345      repeated sint64 in = 6;
   346  
   347      // NotIn specifies that this field cannot be equal to one of the specified
   348      // values
   349      repeated sint64 not_in = 7;
   350  
   351      // IgnoreEmpty specifies that the validation rules of this field should be
   352      // evaluated only if the field is not empty
   353      optional bool ignore_empty = 8;
   354  }
   355  
   356  // Fixed32Rules describes the constraints applied to `fixed32` values
   357  message Fixed32Rules {
   358      // Const specifies that this field must be exactly the specified value
   359      optional fixed32 const = 1;
   360  
   361      // Lt specifies that this field must be less than the specified value,
   362      // exclusive
   363      optional fixed32 lt = 2;
   364  
   365      // Lte specifies that this field must be less than or equal to the
   366      // specified value, inclusive
   367      optional fixed32 lte = 3;
   368  
   369      // Gt specifies that this field must be greater than the specified value,
   370      // exclusive. If the value of Gt is larger than a specified Lt or Lte, the
   371      // range is reversed.
   372      optional fixed32 gt = 4;
   373  
   374      // Gte specifies that this field must be greater than or equal to the
   375      // specified value, inclusive. If the value of Gte is larger than a
   376      // specified Lt or Lte, the range is reversed.
   377      optional fixed32 gte = 5;
   378  
   379      // In specifies that this field must be equal to one of the specified
   380      // values
   381      repeated fixed32 in = 6;
   382  
   383      // NotIn specifies that this field cannot be equal to one of the specified
   384      // values
   385      repeated fixed32 not_in = 7;
   386  
   387      // IgnoreEmpty specifies that the validation rules of this field should be
   388      // evaluated only if the field is not empty
   389      optional bool ignore_empty = 8;
   390  }
   391  
   392  // Fixed64Rules describes the constraints applied to `fixed64` values
   393  message Fixed64Rules {
   394      // Const specifies that this field must be exactly the specified value
   395      optional fixed64 const = 1;
   396  
   397      // Lt specifies that this field must be less than the specified value,
   398      // exclusive
   399      optional fixed64 lt = 2;
   400  
   401      // Lte specifies that this field must be less than or equal to the
   402      // specified value, inclusive
   403      optional fixed64 lte = 3;
   404  
   405      // Gt specifies that this field must be greater than the specified value,
   406      // exclusive. If the value of Gt is larger than a specified Lt or Lte, the
   407      // range is reversed.
   408      optional fixed64 gt = 4;
   409  
   410      // Gte specifies that this field must be greater than or equal to the
   411      // specified value, inclusive. If the value of Gte is larger than a
   412      // specified Lt or Lte, the range is reversed.
   413      optional fixed64 gte = 5;
   414  
   415      // In specifies that this field must be equal to one of the specified
   416      // values
   417      repeated fixed64 in = 6;
   418  
   419      // NotIn specifies that this field cannot be equal to one of the specified
   420      // values
   421      repeated fixed64 not_in = 7;
   422  
   423      // IgnoreEmpty specifies that the validation rules of this field should be
   424      // evaluated only if the field is not empty
   425      optional bool ignore_empty = 8;
   426  }
   427  
   428  // SFixed32Rules describes the constraints applied to `sfixed32` values
   429  message SFixed32Rules {
   430      // Const specifies that this field must be exactly the specified value
   431      optional sfixed32 const = 1;
   432  
   433      // Lt specifies that this field must be less than the specified value,
   434      // exclusive
   435      optional sfixed32 lt = 2;
   436  
   437      // Lte specifies that this field must be less than or equal to the
   438      // specified value, inclusive
   439      optional sfixed32 lte = 3;
   440  
   441      // Gt specifies that this field must be greater than the specified value,
   442      // exclusive. If the value of Gt is larger than a specified Lt or Lte, the
   443      // range is reversed.
   444      optional sfixed32 gt = 4;
   445  
   446      // Gte specifies that this field must be greater than or equal to the
   447      // specified value, inclusive. If the value of Gte is larger than a
   448      // specified Lt or Lte, the range is reversed.
   449      optional sfixed32 gte = 5;
   450  
   451      // In specifies that this field must be equal to one of the specified
   452      // values
   453      repeated sfixed32 in = 6;
   454  
   455      // NotIn specifies that this field cannot be equal to one of the specified
   456      // values
   457      repeated sfixed32 not_in = 7;
   458  
   459      // IgnoreEmpty specifies that the validation rules of this field should be
   460      // evaluated only if the field is not empty
   461      optional bool ignore_empty = 8;
   462  }
   463  
   464  // SFixed64Rules describes the constraints applied to `sfixed64` values
   465  message SFixed64Rules {
   466      // Const specifies that this field must be exactly the specified value
   467      optional sfixed64 const = 1;
   468  
   469      // Lt specifies that this field must be less than the specified value,
   470      // exclusive
   471      optional sfixed64 lt = 2;
   472  
   473      // Lte specifies that this field must be less than or equal to the
   474      // specified value, inclusive
   475      optional sfixed64 lte = 3;
   476  
   477      // Gt specifies that this field must be greater than the specified value,
   478      // exclusive. If the value of Gt is larger than a specified Lt or Lte, the
   479      // range is reversed.
   480      optional sfixed64 gt = 4;
   481  
   482      // Gte specifies that this field must be greater than or equal to the
   483      // specified value, inclusive. If the value of Gte is larger than a
   484      // specified Lt or Lte, the range is reversed.
   485      optional sfixed64 gte = 5;
   486  
   487      // In specifies that this field must be equal to one of the specified
   488      // values
   489      repeated sfixed64 in = 6;
   490  
   491      // NotIn specifies that this field cannot be equal to one of the specified
   492      // values
   493      repeated sfixed64 not_in = 7;
   494  
   495      // IgnoreEmpty specifies that the validation rules of this field should be
   496      // evaluated only if the field is not empty
   497      optional bool ignore_empty = 8;
   498  }
   499  
   500  // BoolRules describes the constraints applied to `bool` values
   501  message BoolRules {
   502      // Const specifies that this field must be exactly the specified value
   503      optional bool const = 1;
   504  }
   505  
   506  // StringRules describe the constraints applied to `string` values
   507  message StringRules {
   508      // Const specifies that this field must be exactly the specified value
   509      optional string const = 1;
   510  
   511      // Len specifies that this field must be the specified number of
   512      // characters (Unicode code points). Note that the number of
   513      // characters may differ from the number of bytes in the string.
   514      optional uint64 len = 19;
   515  
   516      // MinLen specifies that this field must be the specified number of
   517      // characters (Unicode code points) at a minimum. Note that the number of
   518      // characters may differ from the number of bytes in the string.
   519      optional uint64 min_len = 2;
   520  
   521      // MaxLen specifies that this field must be the specified number of
   522      // characters (Unicode code points) at a maximum. Note that the number of
   523      // characters may differ from the number of bytes in the string.
   524      optional uint64 max_len = 3;
   525  
   526      // LenBytes specifies that this field must be the specified number of bytes
   527      // at a minimum
   528      optional uint64 len_bytes = 20;
   529  
   530      // MinBytes specifies that this field must be the specified number of bytes
   531      // at a minimum
   532      optional uint64 min_bytes = 4;
   533  
   534      // MaxBytes specifies that this field must be the specified number of bytes
   535      // at a maximum
   536      optional uint64 max_bytes = 5;
   537  
   538      // Pattern specifes that this field must match against the specified
   539      // regular expression (RE2 syntax). The included expression should elide
   540      // any delimiters.
   541      optional string pattern  = 6;
   542  
   543      // Prefix specifies that this field must have the specified substring at
   544      // the beginning of the string.
   545      optional string prefix   = 7;
   546  
   547      // Suffix specifies that this field must have the specified substring at
   548      // the end of the string.
   549      optional string suffix   = 8;
   550  
   551      // Contains specifies that this field must have the specified substring
   552      // anywhere in the string.
   553      optional string contains = 9;
   554  
   555      // NotContains specifies that this field cannot have the specified substring
   556      // anywhere in the string.
   557      optional string not_contains = 23;
   558  
   559      // In specifies that this field must be equal to one of the specified
   560      // values
   561      repeated string in     = 10;
   562  
   563      // NotIn specifies that this field cannot be equal to one of the specified
   564      // values
   565      repeated string not_in = 11;
   566  
   567      // WellKnown rules provide advanced constraints against common string
   568      // patterns
   569      oneof well_known {
   570          // Email specifies that the field must be a valid email address as
   571          // defined by RFC 5322
   572          bool email    = 12;
   573  
   574          // Hostname specifies that the field must be a valid hostname as
   575          // defined by RFC 1034. This constraint does not support
   576          // internationalized domain names (IDNs).
   577          bool hostname = 13;
   578  
   579          // Ip specifies that the field must be a valid IP (v4 or v6) address.
   580          // Valid IPv6 addresses should not include surrounding square brackets.
   581          bool ip       = 14;
   582  
   583          // Ipv4 specifies that the field must be a valid IPv4 address.
   584          bool ipv4     = 15;
   585  
   586          // Ipv6 specifies that the field must be a valid IPv6 address. Valid
   587          // IPv6 addresses should not include surrounding square brackets.
   588          bool ipv6     = 16;
   589  
   590          // Uri specifies that the field must be a valid, absolute URI as defined
   591          // by RFC 3986
   592          bool uri      = 17;
   593  
   594          // UriRef specifies that the field must be a valid URI as defined by RFC
   595          // 3986 and may be relative or absolute.
   596          bool uri_ref  = 18;
   597  
   598          // Address specifies that the field must be either a valid hostname as
   599          // defined by RFC 1034 (which does not support internationalized domain
   600          // names or IDNs), or it can be a valid IP (v4 or v6).
   601          bool address  = 21;
   602  
   603          // Uuid specifies that the field must be a valid UUID as defined by
   604          // RFC 4122
   605          bool uuid     = 22;
   606  
   607          // WellKnownRegex specifies a common well known pattern defined as a regex.
   608          KnownRegex well_known_regex = 24;
   609      }
   610  
   611    // This applies to regexes HTTP_HEADER_NAME and HTTP_HEADER_VALUE to enable
   612    // strict header validation.
   613    // By default, this is true, and HTTP header validations are RFC-compliant.
   614    // Setting to false will enable a looser validations that only disallows
   615    // \r\n\0 characters, which can be used to bypass header matching rules.
   616    optional bool strict = 25 [default = true];
   617  
   618    // IgnoreEmpty specifies that the validation rules of this field should be
   619    // evaluated only if the field is not empty
   620    optional bool ignore_empty = 26;
   621  }
   622  
   623  // WellKnownRegex contain some well-known patterns.
   624  enum KnownRegex {
   625    UNKNOWN = 0;
   626  
   627    // HTTP header name as defined by RFC 7230.
   628    HTTP_HEADER_NAME = 1;
   629  
   630    // HTTP header value as defined by RFC 7230.
   631    HTTP_HEADER_VALUE = 2;
   632  }
   633  
   634  // BytesRules describe the constraints applied to `bytes` values
   635  message BytesRules {
   636      // Const specifies that this field must be exactly the specified value
   637      optional bytes const = 1;
   638  
   639      // Len specifies that this field must be the specified number of bytes
   640      optional uint64 len = 13;
   641  
   642      // MinLen specifies that this field must be the specified number of bytes
   643      // at a minimum
   644      optional uint64 min_len = 2;
   645  
   646      // MaxLen specifies that this field must be the specified number of bytes
   647      // at a maximum
   648      optional uint64 max_len = 3;
   649  
   650      // Pattern specifes that this field must match against the specified
   651      // regular expression (RE2 syntax). The included expression should elide
   652      // any delimiters.
   653      optional string pattern  = 4;
   654  
   655      // Prefix specifies that this field must have the specified bytes at the
   656      // beginning of the string.
   657      optional bytes  prefix   = 5;
   658  
   659      // Suffix specifies that this field must have the specified bytes at the
   660      // end of the string.
   661      optional bytes  suffix   = 6;
   662  
   663      // Contains specifies that this field must have the specified bytes
   664      // anywhere in the string.
   665      optional bytes  contains = 7;
   666  
   667      // In specifies that this field must be equal to one of the specified
   668      // values
   669      repeated bytes in     = 8;
   670  
   671      // NotIn specifies that this field cannot be equal to one of the specified
   672      // values
   673      repeated bytes not_in = 9;
   674  
   675      // WellKnown rules provide advanced constraints against common byte
   676      // patterns
   677      oneof well_known {
   678          // Ip specifies that the field must be a valid IP (v4 or v6) address in
   679          // byte format
   680          bool ip   = 10;
   681  
   682          // Ipv4 specifies that the field must be a valid IPv4 address in byte
   683          // format
   684          bool ipv4 = 11;
   685  
   686          // Ipv6 specifies that the field must be a valid IPv6 address in byte
   687          // format
   688          bool ipv6 = 12;
   689      }
   690  
   691      // IgnoreEmpty specifies that the validation rules of this field should be
   692      // evaluated only if the field is not empty
   693      optional bool ignore_empty = 14;
   694  }
   695  
   696  // EnumRules describe the constraints applied to enum values
   697  message EnumRules {
   698      // Const specifies that this field must be exactly the specified value
   699      optional int32 const        = 1;
   700  
   701      // DefinedOnly specifies that this field must be only one of the defined
   702      // values for this enum, failing on any undefined value.
   703      optional bool  defined_only = 2;
   704  
   705      // In specifies that this field must be equal to one of the specified
   706      // values
   707      repeated int32 in           = 3;
   708  
   709      // NotIn specifies that this field cannot be equal to one of the specified
   710      // values
   711      repeated int32 not_in       = 4;
   712  }
   713  
   714  // MessageRules describe the constraints applied to embedded message values.
   715  // For message-type fields, validation is performed recursively.
   716  message MessageRules {
   717      // Skip specifies that the validation rules of this field should not be
   718      // evaluated
   719      optional bool skip     = 1;
   720  
   721      // Required specifies that this field must be set
   722      optional bool required = 2;
   723  }
   724  
   725  // RepeatedRules describe the constraints applied to `repeated` values
   726  message RepeatedRules {
   727      // MinItems specifies that this field must have the specified number of
   728      // items at a minimum
   729      optional uint64 min_items = 1;
   730  
   731      // MaxItems specifies that this field must have the specified number of
   732      // items at a maximum
   733      optional uint64 max_items = 2;
   734  
   735      // Unique specifies that all elements in this field must be unique. This
   736      // contraint is only applicable to scalar and enum types (messages are not
   737      // supported).
   738      optional bool   unique    = 3;
   739  
   740      // Items specifies the contraints to be applied to each item in the field.
   741      // Repeated message fields will still execute validation against each item
   742      // unless skip is specified here.
   743      optional FieldRules items = 4;
   744  
   745      // IgnoreEmpty specifies that the validation rules of this field should be
   746      // evaluated only if the field is not empty
   747      optional bool ignore_empty = 5;
   748  }
   749  
   750  // MapRules describe the constraints applied to `map` values
   751  message MapRules {
   752      // MinPairs specifies that this field must have the specified number of
   753      // KVs at a minimum
   754      optional uint64 min_pairs = 1;
   755  
   756      // MaxPairs specifies that this field must have the specified number of
   757      // KVs at a maximum
   758      optional uint64 max_pairs = 2;
   759  
   760      // NoSparse specifies values in this field cannot be unset. This only
   761      // applies to map's with message value types.
   762      optional bool no_sparse = 3;
   763  
   764      // Keys specifies the constraints to be applied to each key in the field.
   765      optional FieldRules keys   = 4;
   766  
   767      // Values specifies the constraints to be applied to the value of each key
   768      // in the field. Message values will still have their validations evaluated
   769      // unless skip is specified here.
   770      optional FieldRules values = 5;
   771  
   772      // IgnoreEmpty specifies that the validation rules of this field should be
   773      // evaluated only if the field is not empty
   774      optional bool ignore_empty = 6;
   775  }
   776  
   777  // AnyRules describe constraints applied exclusively to the
   778  // `google.protobuf.Any` well-known type
   779  message AnyRules {
   780      // Required specifies that this field must be set
   781      optional bool required = 1;
   782  
   783      // In specifies that this field's `type_url` must be equal to one of the
   784      // specified values.
   785      repeated string in     = 2;
   786  
   787      // NotIn specifies that this field's `type_url` must not be equal to any of
   788      // the specified values.
   789      repeated string not_in = 3;
   790  }
   791  
   792  // DurationRules describe the constraints applied exclusively to the
   793  // `google.protobuf.Duration` well-known type
   794  message DurationRules {
   795      // Required specifies that this field must be set
   796      optional bool required = 1;
   797  
   798      // Const specifies that this field must be exactly the specified value
   799      optional google.protobuf.Duration const = 2;
   800  
   801      // Lt specifies that this field must be less than the specified value,
   802      // exclusive
   803      optional google.protobuf.Duration lt = 3;
   804  
   805      // Lt specifies that this field must be less than the specified value,
   806      // inclusive
   807      optional google.protobuf.Duration lte = 4;
   808  
   809      // Gt specifies that this field must be greater than the specified value,
   810      // exclusive
   811      optional google.protobuf.Duration gt = 5;
   812  
   813      // Gte specifies that this field must be greater than the specified value,
   814      // inclusive
   815      optional google.protobuf.Duration gte = 6;
   816  
   817      // In specifies that this field must be equal to one of the specified
   818      // values
   819      repeated google.protobuf.Duration in = 7;
   820  
   821      // NotIn specifies that this field cannot be equal to one of the specified
   822      // values
   823      repeated google.protobuf.Duration not_in = 8;
   824  }
   825  
   826  // TimestampRules describe the constraints applied exclusively to the
   827  // `google.protobuf.Timestamp` well-known type
   828  message TimestampRules {
   829      // Required specifies that this field must be set
   830      optional bool required = 1;
   831  
   832      // Const specifies that this field must be exactly the specified value
   833      optional google.protobuf.Timestamp const = 2;
   834  
   835      // Lt specifies that this field must be less than the specified value,
   836      // exclusive
   837      optional google.protobuf.Timestamp lt = 3;
   838  
   839      // Lte specifies that this field must be less than the specified value,
   840      // inclusive
   841      optional google.protobuf.Timestamp lte = 4;
   842  
   843      // Gt specifies that this field must be greater than the specified value,
   844      // exclusive
   845      optional google.protobuf.Timestamp gt = 5;
   846  
   847      // Gte specifies that this field must be greater than the specified value,
   848      // inclusive
   849      optional google.protobuf.Timestamp gte = 6;
   850  
   851      // LtNow specifies that this must be less than the current time. LtNow
   852      // can only be used with the Within rule.
   853      optional bool lt_now  = 7;
   854  
   855      // GtNow specifies that this must be greater than the current time. GtNow
   856      // can only be used with the Within rule.
   857      optional bool gt_now  = 8;
   858  
   859      // Within specifies that this field must be within this duration of the
   860      // current time. This constraint can be used alone or with the LtNow and
   861      // GtNow rules.
   862      optional google.protobuf.Duration within = 9;
   863  }