github.com/googleapis/api-linter@v1.65.2/docs/rules/0143/standardized-codes.md (about) 1 --- 2 rule: 3 aip: 143 4 name: [core, '0143', standard-codes] 5 summary: Fields representing concepts with standardized codes must use them. 6 permalink: /143/standardized-codes 7 redirect_from: 8 - /0143/standardized-codes 9 --- 10 11 # Standardized codes 12 13 This rule attempts to enforce that standard codes for concepts like language, 14 currency, etc. are consistently used rather than any alternatives, as mandated 15 in [AIP-143][]. 16 17 ## Details 18 19 This rule looks at any field with a name that looks close to a field with a 20 common standardized code, but that is not exactly that. It complains if it 21 finds one and suggests the correct field name. 22 23 It currently spots the following common substitutes: 24 25 - `content_type` 26 - `country` 27 - `currency` 28 - `lang` 29 - `language` 30 - `mime` 31 - `mimetype` 32 - `tz` 33 - `timezone` 34 35 ## Examples 36 37 **Incorrect** code for this rule: 38 39 ```proto 40 // Incorrect. 41 message Book { 42 string name = 1; 43 string lang = 2; // Should be `language_code`. 44 } 45 ``` 46 47 **Correct** code for this rule: 48 49 ```proto 50 // Correct. 51 message Book { 52 string name = 1; 53 string language_code = 2; 54 } 55 ``` 56 57 ## Disabling 58 59 If you need to violate this rule, use a leading comment above the method. 60 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 61 62 ```proto 63 // (-- api-linter: core::0143::standardized-codes=disabled 64 // aip.dev/not-precedent: We need to do this because reasons. --) 65 message Book { 66 string name = 1; 67 string lang = 2; 68 } 69 ``` 70 71 If you need to violate this rule for an entire file, place the comment at the 72 top of the file. 73 74 [aip-143]: https://aip.dev/143 75 [aip.dev/not-precedent]: https://aip.dev/not-precedent