Skip to content

Commit

Permalink
Bump build.buf:protovalidate from 0.4.2 to 0.5.0 (#329)
Browse files Browse the repository at this point in the history
* Bump build.buf:protovalidate from 0.4.2 to 0.5.0

Bumps [build.buf:protovalidate](https://github.com/bufbuild/protovalidate-java) from 0.4.2 to 0.5.0.
- [Release notes](https://github.com/bufbuild/protovalidate-java/releases)
- [Commits](bufbuild/protovalidate-java@v0.4.2...v0.5.0)

---
updated-dependencies:
- dependency-name: build.buf:protovalidate
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andrew Parmet <[email protected]>
  • Loading branch information
dependabot[bot] and andrewparmet authored Jan 21, 2025
1 parent f297fee commit 774f3c2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protobuf-java = "4.29.1"
protobuf-js = "7.4.0"
protobufGradlePlugin = "0.9.4"
protovalidate = "0.9.0"
protovalidateJava = "0.4.2"
protovalidateJava = "0.5.0"
slf4j = "2.0.16"

# build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,15 @@ class Validator @JvmOverloads constructor(
descriptor.nestedTypes.forEach(::doLoad)
}

fun validate(message: Message): ValidationResult =
evaluatorsByFullTypeName
fun validate(message: Message): ValidationResult {
val result = evaluatorsByFullTypeName
.getValue(message::class.findAnnotation<GeneratedMessage>()!!.fullTypeName)
.evaluate(MessageValue(message.toDynamicMessage(runtimeContext)), failFast)

return if (result.isEmpty()) {
ValidationResult.EMPTY
} else {
ValidationResult(result.map { it.build() })
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ object Main {
TestResult.newBuilder().setSuccess(true).build()
} else {
TestResult.newBuilder()
.setValidationError(Violations.newBuilder().addAllViolations(result.violations).build())
.setValidationError(
Violations.newBuilder()
.addAllViolations(result.toProto().violationsList)
.build()
)
.build()
}
} catch (e: ExecutionException) {
Expand Down

0 comments on commit 774f3c2

Please sign in to comment.