Skip to content
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

Add example options for most types #239

Merged
merged 3 commits into from
Aug 21, 2024
Merged

Conversation

sudorandom
Copy link
Contributor

This PR adds an example field for many types. Examples are no-op constraints that allow you to declare what an example value for each field may look like. These values SHOULD match the other constraints. It's planned that a buf lint rule will check these values to see if they do, in fact, validate given the other constraints on the field. Here are the types that this was added to:

  • float
  • double
  • int32
  • int64
  • uint32
  • uint64
  • sint32
  • sint64
  • fixed32
  • fixed64
  • sfixed32
  • sfixed64
  • bool
  • string
  • bytes
  • enum
  • duration
  • timestamp

All fields are repeatable, to allow for multiple examples. I'm unsure if there is a better way to have a no-op constraint other than expression: "true", so please let me know if I can just exclude expression altogether or if there is another way to do that. This resolves #237.

@sudorandom sudorandom changed the title Add examples for most types Add example options for most types Aug 20, 2024
@rodaine
Copy link
Member

rodaine commented Aug 20, 2024

I'm unsure if there is a better way to have a no-op constraint other than expression: "true", so please let me know if I can just exclude expression altogether or if there is another way to do that.

The cleanest noop is not setting anything, but yeah a CEL expression of true is probably the easiest (though I know protovalidate-go will optimize it all away).

@sudorandom
Copy link
Contributor Author

@rodaine I noticed the CI is failing. I've also had issues with CI with a pull request against the buf repo. Is it because the PR is not from someone on the buf org or something?

Error: Resource not accessible by integration - https://docs.github.com/rest/issues/comments#create-an-issue-comment

@rodaine
Copy link
Member

rodaine commented Aug 20, 2024

Yeah I think so. Letting the team know about it. Might just be a configuration issue.

@rodaine
Copy link
Member

rodaine commented Aug 20, 2024

Fix in flight: bufbuild/buf-action#64

@sudorandom
Copy link
Contributor Author

@rodaine oh, right. It got to the next error. I was wondering if I should check in changes to MODULE.bazel.lock. I guess so?

@rodaine
Copy link
Member

rodaine commented Aug 20, 2024

Oh man it looks like you hit a bunch of landmines. One sec while I update golangci-lint.

Copy link
Member

@rodaine rodaine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @sudorandom!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Add "example" options
2 participants