-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Support specification validation for google.protobuf.Timestamp #101
Comments
Hey @simonbos! Thanks for the thorough report! I can definitely see this as a
I believe the duration WKT has similar limitations.
While I agree the constraints are documented by the type and meant to be intrinsic, technically a valid value of a timestamp message is what's valid for the contained int64 and int32; the type itself cannot encode those semantics. To be consistent (and to not potentially break consumers of protovalidate), we will still want to require opting-into semantic validation of the field. |
Hi @rodaine, thanks for the reply! I tried out the expressions using the following:
But I had some issues selecting the fields:
I believe this behavior is documented in the cel-spec. For the seconds restriction, we can also express it using
Indeed, duration.proto also documents some upper and lower bounds.
Agreed! |
Oh that's right, it's not treated as a proto message within CEL's type system. Looking at cel-go, google.protobuf.Timestamp values are converted to Go's |
Ok, that's clear, I'll have a look for implementing this (first in Go). |
Update protovalidate-go to work with the latest protovalidate proto rules, including the Ignore enum. Update to the latest golangci-lint and fix lint warnings. --------- Co-authored-by: Chris Roche <[email protected]>
Feature description:
The well-known
google.protobuf.Timestamp
specification imposes some constraints on the fields (see source):This feature request suggests to enhance protovalidate to support this validation out-of-the-box.
Problem it solves or use case:
With the current implementation, developers would have to program this validation outside of protovalidate (or maybe use some complicated CEL expression). In Go, the specification validation is typically done with CheckValid. However, this has some issues:
Proposed implementation or solution:
I propose to add an extra validation rule for timestamp. For the implementation I am not sure since I am not experienced with CEL. From what I can see, the general idea is either:
Contribution:
I would be willing to implement this feature; as long as there is consensus on how it should be implemented.
Examples or references:
Additional context:
The text was updated successfully, but these errors were encountered: