github.com/googleapis/api-linter@v1.65.2/docs/rules/0143/string-type.md (about)

     1  ---
     2  rule:
     3    aip: 143
     4    name: [core, '0143', string-type]
     5    summary: Fields representing standardized codes must be strings.
     6  permalink: /143/string-type
     7  redirect_from:
     8    - /0143/string-type
     9  ---
    10  
    11  # Standardized code strings
    12  
    13  This rule attempts to enforce that standard codes for concepts like language,
    14  currency, etc. are strings, as mandated in [AIP-143][].
    15  
    16  ## Details
    17  
    18  This rule looks at any field with a name matching a standardized code, and
    19  complains if it has a type other than `string`.
    20  
    21  It currently matches the following field names:
    22  
    23  - `currency_code`
    24  - `country_code`
    25  - `language_code`
    26  - `mime_type`
    27  - `time_zone`
    28  
    29  ## Examples
    30  
    31  **Incorrect** code for this rule:
    32  
    33  ```proto
    34  // Incorrect.
    35  // This enum should not exist.
    36  enum LanguageCode {
    37    LANGUAGE_CODE_UNSPECIFIED = 0;
    38    EN_US = 1;
    39    EN_GB = 2;
    40  }
    41  
    42  message Book {
    43    string name = 1;
    44    LanguageCode language_code = 2;  // Should be `string`.
    45  }
    46  ```
    47  
    48  **Correct** code for this rule:
    49  
    50  ```proto
    51  // Correct.
    52  message Book {
    53    string name = 1;
    54    string language_code = 2;
    55  }
    56  ```
    57  
    58  ## Disabling
    59  
    60  If you need to violate this rule, use a leading comment above the method.
    61  Remember to also include an [aip.dev/not-precedent][] comment explaining why.
    62  
    63  ```proto
    64  // (-- api-linter: core::0143::string-type=disabled
    65  //     aip.dev/not-precedent: We need to do this because reasons. --)
    66  enum LanguageCode {
    67    LANGUAGE_CODE_UNSPECIFIED = 0;
    68    EN_US = 1;
    69    EN_GB = 2;
    70  }
    71  
    72  message Book {
    73    string name = 1;
    74    LanguageCode language_code = 2;
    75  }
    76  ```
    77  
    78  If you need to violate this rule for an entire file, place the comment at the
    79  top of the file.
    80  
    81  [aip-143]: https://aip.dev/143
    82  [aip.dev/not-precedent]: https://aip.dev/not-precedent