Skip to content

Commit

Permalink
Remove Violations message
Browse files Browse the repository at this point in the history
**This is a breaking change.**

Closes #96.
  • Loading branch information
jchadwick-buf committed Oct 14, 2024
1 parent 3f80b76 commit 169285e
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 249 deletions.
2 changes: 1 addition & 1 deletion docs/custom-constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The `Constraint` message is used to define validation rules for messages or
fields in a message. The constraints are then evaluated using
the `protovalidate` tool to ensure that the data conforms to the specified
rules. If any violations occur during validation, they are reported using
the `Violations` message. The `Violation` message provides detailed information
the `Violation` message. The `Violation` message provides detailed information
about the violated constraint, including the field path, the constraint ID, and
the error message.

Expand Down
14 changes: 6 additions & 8 deletions docs/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ three fields:
- `constraint_id`: the id of the constraint that failed validation.
- `message`: a human-readable error message for this violation.

### Violations
### Violation

The `Violations` message is used to collect all violations that occur during
constraint validation. It has one field:
The `Violation` message is used to collect all violations that occur during
constraint validation. One or more `Violation` messages are returned by
`protovalidate` when a message fails to fulfill the requirements of the
constraint validation.

- `violations`: a repeated field of `Violation` messages. `Violations` are
returned by `protovalidate` when a message fails to fulfill the requirements
of the constraint validation.

In summary, the `Constraints` and `Violations` messages provide a way to define
In summary, the `Constraints` and `Violation` messages provide a way to define
and enforce validation constraints using the Common Expression Language (CEL)
syntax. Standard constraints are defined using the `Constraints` message and
provide a set of predefined validation rules that can be applied to various.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,19 @@ message TestConformanceResponse {
map<string, TestResult> results = 1;
}

// ValidationError is the result if the test failed due to validation errors.
message ValidationError {
// `violations` is a repeated field that contains all the `Violation` messages corresponding to the violations detected.
repeated Violation violations = 1;
}

// TestResult is the result of a single test. Only one of the fields will be set.
message TestResult {
oneof result {
// success is true if the test succeeded.
bool success = 1;
// validation_error is the error if the test failed due to validation errors.
Violations validation_error = 2;
ValidationError validation_error = 2;
// compilation_error is the error if the test failed due to compilation errors.
string compilation_error = 3;
// runtime_error is the error if the test failed due to runtime errors.
Expand Down
8 changes: 0 additions & 8 deletions proto/protovalidate/buf/validate/validate.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4749,14 +4749,6 @@ message TimestampRules {
extensions 1000 to max;
}

// `Violations` is a collection of `Violation` messages. This message type is returned by
// protovalidate when a proto message fails to meet the requirements set by the `Constraint` validation rules.
// Each individual violation is represented by a `Violation` message.
message Violations {
// `violations` is a repeated field that contains all the `Violation` messages corresponding to the violations detected.
repeated Violation violations = 1;
}

// `Violation` represents a single instance where a validation rule, expressed
// as a `Constraint`, was not met. It provides information about the field that
// caused the violation, the specific constraint that wasn't fulfilled, and a
Expand Down
Loading

0 comments on commit 169285e

Please sign in to comment.