github.com/googleapis/api-linter@v1.65.2/docs/rules/0142/time-field-names.md (about) 1 --- 2 rule: 3 aip: 142 4 name: [core, '0142', time-field-names] 5 summary: Timestamps should use `google.protobuf.Timestamp`. 6 permalink: /142/time-field-names 7 redirect_from: 8 - /0142/time-field-names 9 --- 10 11 # Timestamp field names 12 13 This rule enforces that timestamps are named using the imperative mood and with 14 a `_time` suffix, as mandated in [AIP-142][]. 15 16 ## Details 17 18 This rule looks at each `google.protobuf.Timestamp` field and ensures that it 19 has a `_time` suffix. If it is a repeated field, the `_times` suffix is also 20 allowed. 21 22 It also looks for common field names, regardless of type, and complains if they 23 are used. These are: 24 25 - created 26 - creation 27 - expired 28 - modified 29 - updated 30 - purged 31 32 ## Examples 33 34 **Incorrect** code for this rule: 35 36 ```proto 37 // Incorrect. 38 message Book { 39 string name = 1; 40 google.protobuf.Timestamp published = 2; // Should be `publish_time`. 41 repeated google.protobuf.Timestamp updated = 3; // Should be `update_time` or `update_times`. 42 } 43 ``` 44 45 **Correct** code for this rule: 46 47 ```proto 48 // Correct. 49 message Book { 50 string name = 1; 51 google.protobuf.Timestamp publish_time = 2; 52 repeated google.protobuf.Timestamp update_times = 3; 53 } 54 ``` 55 56 ## Disabling 57 58 If you need to violate this rule, use a leading comment above the method. 59 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 60 61 ```proto 62 // (-- api-linter: core::0142::time-field-names=disabled 63 // aip.dev/not-precedent: We need to do this because reasons. --) 64 message Book { 65 string name = 1; 66 google.protobuf.Timestamp published = 2; 67 } 68 ``` 69 70 If you need to violate this rule for an entire file, place the comment at the 71 top of the file. 72 73 [aip-142]: https://aip.dev/142 74 [aip.dev/not-precedent]: https://aip.dev/not-precedent