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

Remove nested violations #180

Merged
merged 22 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9a12cd8
Don't use nested violations
yevhenii-nadtochii Jan 7, 2025
3e478fe
Deprecate field with nested violations
yevhenii-nadtochii Jan 7, 2025
8427747
Take the latest `base`
yevhenii-nadtochii Jan 8, 2025
8a983fd
Remove usages of `if_invalid`
yevhenii-nadtochii Jan 8, 2025
8da107f
Bump the version -> `2.0.0-SNAPSHOT.186`
yevhenii-nadtochii Jan 8, 2025
b557134
Merge branch 'master' into remove-nested-violations
yevhenii-nadtochii Jan 8, 2025
58e99b1
Introduce constants
yevhenii-nadtochii Jan 9, 2025
d558857
Remove no longer valid test case
yevhenii-nadtochii Jan 9, 2025
4b2b6fa
Fix a comment
yevhenii-nadtochii Jan 9, 2025
5c092b9
Use Kotlin API
yevhenii-nadtochii Jan 9, 2025
7c68a28
Update docs
yevhenii-nadtochii Jan 9, 2025
86a399f
Fix code block generation
yevhenii-nadtochii Jan 9, 2025
740a276
Remove no longer used subscriber
yevhenii-nadtochii Jan 9, 2025
8f9ebf7
Remove unused property from the projection state
yevhenii-nadtochii Jan 9, 2025
d9f2a7e
Merge branch 'refs/heads/master' into remove-nested-violations
yevhenii-nadtochii Jan 9, 2025
e7b583d
Bump the version -> `2.0.0-SNAPSHOT.187`
yevhenii-nadtochii Jan 9, 2025
1b87d09
Proofread the error message
yevhenii-nadtochii Jan 9, 2025
8a93809
Proofread docs
yevhenii-nadtochii Jan 9, 2025
6b54db8
Document deprecations
yevhenii-nadtochii Jan 9, 2025
5196807
Move the constant to a companion object
yevhenii-nadtochii Jan 9, 2025
d205ea9
Document an optional `errorMessage`
yevhenii-nadtochii Jan 9, 2025
ab9112a
Remove the default value for `SimpleRule()` pseudo-constructor
yevhenii-nadtochii Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/io/spine/dependency/local/Base.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ package io.spine.dependency.local
@Suppress("ConstPropertyName")
object Base {
const val version = "2.0.0-SNAPSHOT.236"
const val versionForBuildScript = "2.0.0-SNAPSHOT.232"
const val versionForBuildScript = "2.0.0-SNAPSHOT.236"
const val group = Spine.group
const val artifact = "spine-base"
const val lib = "$group:$artifact:$version"
Expand Down
56 changes: 28 additions & 28 deletions dependencies.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


# Dependencies of `io.spine.validation:spine-validation-java:2.0.0-SNAPSHOT.186`
# Dependencies of `io.spine.validation:spine-validation-java:2.0.0-SNAPSHOT.187`

## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3.
Expand Down Expand Up @@ -848,12 +848,12 @@

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Jan 08 17:59:43 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Jan 09 10:27:12 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.validation:spine-validation-java-bundle:2.0.0-SNAPSHOT.186`
# Dependencies of `io.spine.validation:spine-validation-java-bundle:2.0.0-SNAPSHOT.187`

## Runtime
1. **Group** : org.jetbrains. **Name** : annotations. **Version** : 24.0.1.
Expand Down Expand Up @@ -1448,12 +1448,12 @@ This report was generated on **Wed Jan 08 17:59:43 WET 2025** using [Gradle-Lice

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Jan 08 17:59:43 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Jan 09 10:27:13 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.validation:spine-validation-java-runtime:2.0.0-SNAPSHOT.186`
# Dependencies of `io.spine.validation:spine-validation-java-runtime:2.0.0-SNAPSHOT.187`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -2110,12 +2110,12 @@ This report was generated on **Wed Jan 08 17:59:43 WET 2025** using [Gradle-Lice

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Jan 08 17:59:43 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Jan 09 10:27:13 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.validation:spine-validation-java-tests:2.0.0-SNAPSHOT.186`
# Dependencies of `io.spine.validation:spine-validation-java-tests:2.0.0-SNAPSHOT.187`

## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3.
Expand Down Expand Up @@ -3031,12 +3031,12 @@ This report was generated on **Wed Jan 08 17:59:43 WET 2025** using [Gradle-Lice

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Jan 08 17:59:44 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Jan 09 10:27:13 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.validation:spine-validation-model:2.0.0-SNAPSHOT.186`
# Dependencies of `io.spine.validation:spine-validation-model:2.0.0-SNAPSHOT.187`

## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3.
Expand Down Expand Up @@ -3895,12 +3895,12 @@ This report was generated on **Wed Jan 08 17:59:44 WET 2025** using [Gradle-Lice

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Jan 08 17:59:44 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Jan 09 10:27:13 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.validation:spine-validation-proto:2.0.0-SNAPSHOT.186`
# Dependencies of `io.spine.validation:spine-validation-proto:2.0.0-SNAPSHOT.187`

## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3.
Expand Down Expand Up @@ -4785,12 +4785,12 @@ This report was generated on **Wed Jan 08 17:59:44 WET 2025** using [Gradle-Lice

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Jan 08 17:59:44 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Jan 09 10:27:14 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.validation:spine-validation-consumer:2.0.0-SNAPSHOT.186`
# Dependencies of `io.spine.validation:spine-validation-consumer:2.0.0-SNAPSHOT.187`

## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3.
Expand Down Expand Up @@ -5657,12 +5657,12 @@ This report was generated on **Wed Jan 08 17:59:44 WET 2025** using [Gradle-Lice

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Jan 08 17:59:44 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Jan 09 10:27:14 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.validation:spine-validation-consumer-dependency:2.0.0-SNAPSHOT.186`
# Dependencies of `io.spine.validation:spine-validation-consumer-dependency:2.0.0-SNAPSHOT.187`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -6410,12 +6410,12 @@ This report was generated on **Wed Jan 08 17:59:44 WET 2025** using [Gradle-Lice

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Jan 08 17:59:45 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Jan 09 10:27:14 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.validation:spine-validation-extensions:2.0.0-SNAPSHOT.186`
# Dependencies of `io.spine.validation:spine-validation-extensions:2.0.0-SNAPSHOT.187`

## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3.
Expand Down Expand Up @@ -7308,12 +7308,12 @@ This report was generated on **Wed Jan 08 17:59:45 WET 2025** using [Gradle-Lice

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Jan 08 17:59:45 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Jan 09 10:27:14 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.validation:spine-validation-runtime:2.0.0-SNAPSHOT.186`
# Dependencies of `io.spine.validation:spine-validation-runtime:2.0.0-SNAPSHOT.187`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -8064,12 +8064,12 @@ This report was generated on **Wed Jan 08 17:59:45 WET 2025** using [Gradle-Lice

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Jan 08 17:59:45 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Jan 09 10:27:14 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.validation:spine-validation-validating:2.0.0-SNAPSHOT.186`
# Dependencies of `io.spine.validation:spine-validation-validating:2.0.0-SNAPSHOT.187`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -8824,12 +8824,12 @@ This report was generated on **Wed Jan 08 17:59:45 WET 2025** using [Gradle-Lice

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Jan 08 17:59:45 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Jan 09 10:27:14 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.validation:spine-validation-vanilla:2.0.0-SNAPSHOT.186`
# Dependencies of `io.spine.validation:spine-validation-vanilla:2.0.0-SNAPSHOT.187`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -9575,12 +9575,12 @@ This report was generated on **Wed Jan 08 17:59:45 WET 2025** using [Gradle-Lice

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Jan 08 17:59:46 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Jan 09 10:27:15 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.validation:spine-validation-configuration:2.0.0-SNAPSHOT.186`
# Dependencies of `io.spine.validation:spine-validation-configuration:2.0.0-SNAPSHOT.187`

## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3.
Expand Down Expand Up @@ -10449,12 +10449,12 @@ This report was generated on **Wed Jan 08 17:59:46 WET 2025** using [Gradle-Lice

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Jan 08 17:59:46 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Jan 09 10:27:15 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.validation:spine-validation-context:2.0.0-SNAPSHOT.186`
# Dependencies of `io.spine.validation:spine-validation-context:2.0.0-SNAPSHOT.187`

## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3.
Expand Down Expand Up @@ -11323,4 +11323,4 @@ This report was generated on **Wed Jan 08 17:59:46 WET 2025** using [Gradle-Lice

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Jan 08 17:59:46 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Jan 09 10:27:15 CET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,17 @@ public static String ofAll(Collection<ConstraintViolation> violations) {

@Override
public String toString() {
var builder = buildMessage();
for (var violation : this.violation.getViolationList()) {
builder.append(lineSeparator());
var nested = of(violation);
builder.append(nested);
}
return builder.toString();
}

private StringBuilder buildMessage() {
var typeName = violation.getTypeName();
var path = violation.getFieldPath();
var fieldPath = path.getFieldNameCount() == 0
? ""
: Field.withPath(path).toString();
? ""
: Field.withPath(path).toString();
var formattedMessage = format(violation.getMessage());
var result = new StringBuilder();
appendPrefix(result, typeName);
appendPrefix(result, fieldPath);
result.append(formattedMessage);
return result;
return result.toString();
}

private static void appendPrefix(StringBuilder target, String prefix) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,7 @@ internal class MessageValidator private constructor(private val validatedMessage
.map { msg -> childViolations(fieldValue.context(), msg) }
.flatMap { violations -> violations.stream() }
.collect(toList())
if (childViolations.isNotEmpty()) {
val parentViolation = violation(constraint, fieldValue).copy {
violation += childViolations
}
violations.add(parentViolation)
}
violations.addAll(childViolations)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@ message ConstraintViolation {
//
google.protobuf.Any field_value = 4;

// If the field type is message (not scalar type or enum), its fields may violate
// one or more validation constraints.
//
// This field is not populated, if fields of the corresponding message type do not have
// validation constraints, and simply non-default value was required in the parent message.
//
repeated ConstraintViolation violation = 5;
// Deprecated: all violations are top-level now. Their nesting is reflected in the value
// of `field_path` field.
repeated ConstraintViolation violation = 5 [deprecated = true];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please document the deprecation.

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ option java_multiple_files = true;

message Cloud {

int32 cubic_meters = 1 [(min).value = "1", (min).exclusive = true];
int32 cubic_meters = 1 [(min) = { value: "1", exclusive: true, error_msg: "Bad cloud!" }];
}
12 changes: 4 additions & 8 deletions java-tests/consumer/src/main/proto/test/blizzard.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import "google/protobuf/any.proto";
import "spine/validation/test/weather.proto";

message Snowflake {
int32 edges = 1 [(min).value = "3"];
int32 vertices = 2 [(min).value = "3"];
int32 edges = 1 [(min) = { value: "3", error_msg: "Bad snow flake!" }];
int32 vertices = 2 [(min) = { value: "3", error_msg: "Bad snow flake!" }];
}

message Blizzard {
Expand All @@ -24,16 +24,12 @@ message Blizzard {

message RainDrop {

int32 mass_in_grams = 1 [(min) = { value: "1", exclusive: false}];
int32 mass_in_grams = 1 [(min) = { value: "1" error_msg: "Bad rain drop!" }];
}

message Rain {

repeated RainDrop rain_drop = 1 [
(required) = true,
(validate) = true,
(if_invalid).error_msg = "Bad rain drop!"
];
repeated RainDrop rain_drop = 1 [(required) = true, (validate) = true];
}

message Region {
Expand Down
Loading
Loading