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 field and rule value to violations #64

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

jchadwick-buf
Copy link
Member

Adds the ability to access the captured rule and field value from a Violation.

C++ protobuf doesn't really have a native "value" representation unlike other languages, so I've created a sort-of stand-in. The ProtoField class acts as a reference to a field on a message, and provides an interface to get a singular value as a variant. This should be good enough for most users, but users can also grab the information needed and use protobuf reflection directly instead if they have more complicated needs.

This is a breaking change. The API changes in the following ways:

  • Validator::Validate() now returns the wrapper type ValidationResult instead of Violations. This can be converted into the protobuf Violations form using the proto() method.
  • ValidationResult.violations() returns a ConstraintViolation. The underlying Violation can be accessed using the proto() method.

@jchadwick-buf jchadwick-buf requested a review from Alfus December 11, 2024 18:30
@jchadwick-buf jchadwick-buf merged commit 15d5717 into main Dec 12, 2024
6 checks passed
@jchadwick-buf jchadwick-buf deleted the jchadwick/field-rule-value branch December 12, 2024 15:25
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.

2 participants