protovalidate icon indicating copy to clipboard operation
protovalidate copied to clipboard

[Feature Request] String TimeZone validation

Open dropwhile opened this issue 1 year ago • 2 comments

Feature description: Since google.protobuf.TimeStamp is just seconds and nanos in UTC, a somewhat common solution to a lack of timezone information is to simply send a timezone along with it. Sending a numerical offset is sometimes fragile as offsets can change due to daylight savings or tz updates, so a tz string may be sent along with a timestamp instead.

It would be nice to have a means to validate that the timezone is valid, as per the cel timezone supported formats (eg. TimeZone = "UTC" | LongTZ , as I don't think FixedTZ makes as much sense in this context)

Problem it solves or use case: Consider the following proto:

syntax = "proto3";
package some.thing.v1;

import "buf/validate/validate.proto";
import "google/protobuf/timestamp.proto";

message TimestampTZ {
  google.protobuf.Timestamp ts = 1;
  string tz = 2;
}

It would be nice to have something like:

  string tz = 2 [(buf.validate.field).string.timezone = true];

dropwhile avatar Sep 04 '24 22:09 dropwhile

Even if timezone is validated by protovalidate, to utilize the value itself the callers will need to re-parse it.

srikrsna-buf avatar Jun 24 '25 19:06 srikrsna-buf

Of course, yes. The same could also be said of UUID validation (and other examples too).

dropwhile avatar Jul 06 '25 03:07 dropwhile