Skip to content

Commit

Permalink
Add timestamp.valid
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Bos committed Oct 20, 2023
1 parent 8fa0222 commit 1d006a5
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,6 @@ message TimestampGTNowWithin {
within: {seconds: 3600}
}];
}
message TimestampValid {
google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp.valid = true];
}
5 changes: 5 additions & 0 deletions proto/protovalidate/buf/validate/validate.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3697,4 +3697,9 @@ message TimestampRules {
id: "timestamp.within",
expression: "this < now-rules.within || this > now+rules.within ? 'value must be within %s of now'.format([rules.within]) : ''"
}];

// `valid` specifies that this field, of the `google.protobuf.Timestamp` type, must adhere to the documented specification:
// * the `seconds` field must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.
// * the `nanos` field must be from 0 to 999,999,999 inclusive.
bool valid = 10;
}
154 changes: 110 additions & 44 deletions tools/internal/gen/buf/validate/conformance/cases/wkt_timestamp.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1d006a5

Please sign in to comment.