Posts about Quarkus

Custom Hibernate constraint in Kotlin

February 17th 2023 Kotlin Quarkus

Quarkus uses Hibernate Validator for validation. This means that the correct way to do custom field validation is to create a custom constraint. The steps to do this are well documented. However, since I am still learning Kotlin, it was not trivial for me to convert the sample code to Kotlin, especially the annotation part.

Programmatic validation constraints in Quarkus

February 10th 2023 Quarkus

Validation in Quarkus is based on the Hibernate Validator. Annotations are the preferred way for adding constraints. Unfortunately, this approach cannot be used if you generate your model classes from an OpenAPI specification.

Custom validation response in Quarkus

February 3rd 2023 Quarkus

Quarkus has extensive built-in support for validation with Hibernate Validator. You just need to add some annotations to your models and your endpoint for Quarkus to return a 400 response listing the detected constraint violations. But what if you want to modify or even localize this response?

Localized REST responses in Quarkus

January 20th 2023 Quarkus

It is not too uncommon that REST responses have to be localized because they are displayed directly in the user interface. However, I could not find an example of this in the Quarkus documentation. Localization is only mentioned in the context of data validation and the approach used there isn't applicable to other use cases.

Using MDC in Quarkus

January 6th 2023 Quarkus

Mapped Diagnostic Context (MDC) can be very useful to enrich log messages with correlation information. Unfortunately, the Quarkus logging documentation does not say much about it. I could only find it mentioned among the logging format patterns. Still, it seems to be well supported according to a GitHub issue I found.