Bean Validator
Validate the message body against its Jakarta Bean Validation constraints, failing with a BeanValidationException on a violation.
What’s inside
-
Bean Validator component, URI syntax:
bean-validator:label
Please refer to the above links for usage and configuration details.
Maven coordinates
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-bean-validator-starter</artifactId>
</dependency> Spring Boot Auto-Configuration
The starter supports 9 options, which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
camel.component.bean-validator.autowired-enabled | Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | Boolean |
camel.component.bean-validator.constraint-validator-factory | The ConstraintValidatorFactory that creates the ConstraintValidator instances of the constraints, for example to inject dependencies into custom validators. When not set, the one of META-INF/validation.xml or the default of Hibernate Validator is used, which calls the no-argument constructor. Not used when a validatorFactory is set. The option is a jakarta.validation.ConstraintValidatorFactory type. | ConstraintValidatorFactory | |
camel.component.bean-validator.enabled | Whether to enable auto configuration of the bean-validator component. This is enabled by default. | Boolean | |
camel.component.bean-validator.ignore-xml-configuration | Whether to ignore the META-INF/validation.xml file when the ValidatorFactory is built, so the provider, MessageInterpolator, TraversableResolver, ConstraintValidatorFactory, constraint mapping files and properties it configures are not used. Not used when a validatorFactory is set. | false | Boolean |
camel.component.bean-validator.lazy-start-producer | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | Boolean |
camel.component.bean-validator.message-interpolator | The MessageInterpolator that turns the message templates of the violated constraints, such as \{jakarta.validation.constraints.NotNull.message}, into the messages of the BeanValidationException. When not set, the one of META-INF/validation.xml or the ResourceBundleMessageInterpolator of Hibernate Validator is used. Not used when a validatorFactory is set. The option is a jakarta.validation.MessageInterpolator type. | MessageInterpolator | |
camel.component.bean-validator.traversable-resolver | The TraversableResolver that decides whether the validation may reach a property, and whether it may cascade into it. When not set, the one of META-INF/validation.xml or the default of Hibernate Validator is used: it reaches every property, but skips the properties that Jakarta Persistence has not loaded yet when Jakarta Persistence is on the classpath. Not used when a validatorFactory is set. The option is a jakarta.validation.TraversableResolver type. | TraversableResolver | |
camel.component.bean-validator.validation-provider-resolver | The ValidationProviderResolver that returns the Jakarta Bean Validation providers. The first provider (or the default-provider of META-INF/validation.xml) builds the ValidatorFactory. When not set, the single ValidationProviderResolverFactory in the registry creates it, if there is one; otherwise the default resolver finds the providers with the Java ServiceLoader. Not used when a validatorFactory is set. The option is a jakarta.validation.ValidationProviderResolver type. | ValidationProviderResolver | |
camel.component.bean-validator.validator-factory | The ValidatorFactory that gives the Validator of all endpoints; a single ValidatorFactory in the registry is used automatically. When set, the ignoreXmlConfiguration, validationProviderResolver, messageInterpolator, traversableResolver and constraintValidatorFactory options of the component and of its endpoints are not used. When not set, each endpoint builds its own ValidatorFactory from these options. The option is a jakarta.validation.ValidatorFactory type. | ValidatorFactory |