// Do not edit directly!
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
[id="extensions-bean-validator"]
= Bean Validator
:page-aliases: extensions/bean-validator.adoc
:linkattrs:
:cq-artifact-id: camel-quarkus-bean-validator
:cq-native-supported: true
:cq-status: Stable
:cq-status-deprecation: Stable
:cq-description: Validate the message body using the Java Bean Validation API.
:cq-deprecated: false
:cq-jvm-since: 1.0.0
:cq-native-since: 1.0.0

ifeval::[{doc-show-badges} == true]
[.badges]
[.badge-key]##JVM since##[.badge-supported]##1.0.0## [.badge-key]##Native since##[.badge-supported]##1.0.0##
endif::[]

Validate the message body using the Java Bean Validation API.

[id="extensions-bean-validator-whats-inside"]
== What's inside

* xref:{cq-camel-components}::bean-validator-component.adoc[Bean Validator component], URI syntax: `bean-validator:label`

Please refer to the above link for usage and configuration details.

[id="extensions-bean-validator-maven-coordinates"]
== Maven coordinates

https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-bean-validator[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"]

Or add the coordinates to your existing project:

[source,xml]
----
<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-bean-validator</artifactId>
</dependency>
----
ifeval::[{doc-show-user-guide-link} == true]
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
endif::[]

[id="extensions-bean-validator-usage"]
== Usage
[id="extensions-bean-validator-usage-configuring-the-validatorfactory"]
=== Configuring the ValidatorFactory

Implementation of this extension leverages the https://quarkus.io/guides/validation[Quarkus Hibernate Validator extension].

Therefore it is not possible to configure the `ValidatorFactory` by Camel's properties (`constraintValidatorFactory`, `messageInterpolator`, `traversableResolver`, `validationProviderResolver` and `validatorFactory`).

You can configure the `ValidatorFactory` by the creation of beans which will be injected into the default `ValidatorFactory` (created by Quarkus).
See the https://quarkus.io/guides/validation#hibernate-validator-extension-and-cdi[Quarkus CDI documentation] for more information.

[id="extensions-bean-validator-usage-custom-validation-groups-in-native-mode"]
=== Custom validation groups in native mode

When using custom validation groups in native mode, all the interfaces need to be registered for reflection (see the https://quarkus.io/guides/writing-native-applications-tips#register-reflection[documentation]).

Example:
[source,java]
----
@RegisterForReflection
public interface OptionalChecks {
}
----


[id="extensions-bean-validator-camel-quarkus-limitations"]
== Camel Quarkus limitations

It is not possible to describe your constraints as XML (by providing the file META-INF/validation.xml), only Java annotations are supported.
This is caused by the limitation of the Quarkus Hibernate Validator extension (see the https://github.com/quarkusio/quarkus/issues/24027[issue]).

