This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 24fedf300851a24afa9ca699d0e655582c995641 Author: Otavio Rodolfo Piske <angusyo...@gmail.com> AuthorDate: Fri Feb 16 13:25:25 2024 +0100 CAMEL-20410: documentation fixes for camel-bean-validator - Fixed samples - Converted to use tabs - Fixed grammar and typos - Fixed punctuation - Added and/or fixed links --- .../src/main/docs/bean-validator-component.adoc | 48 ++++++++++++++-------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/components/camel-bean-validator/src/main/docs/bean-validator-component.adoc b/components/camel-bean-validator/src/main/docs/bean-validator-component.adoc index d1f501598a6..5aec4d15d6c 100644 --- a/components/camel-bean-validator/src/main/docs/bean-validator-component.adoc +++ b/components/camel-bean-validator/src/main/docs/bean-validator-component.adoc @@ -40,9 +40,8 @@ for this component: bean-validator:label[?options] ------------------------------ -Where *label* is an arbitrary text value describing the endpoint. + - You can append query options to the URI in the following format, -?option=value&option=value&... +Where *label* is an arbitrary text value describing the endpoint. +You can append query options to the URI in the following format: `?option=value&option=value&...` // component-configure options: START @@ -68,17 +67,25 @@ To use Hibernate Validator in the OSGi environment use dedicated The snippet below demonstrates this approach. You can also use `HibernateValidationProviderResolver`. -*Using HibernateValidationProviderResolver* +=== Using HibernateValidationProviderResolver +[tabs] +==== +Java:: ++ [source,java] -------------------------------------------------------------------------------------------------------------------------------- from("direct:test"). to("bean-validator://ValidationProviderResolverTest?validationProviderResolver=#myValidationProviderResolver"); -------------------------------------------------------------------------------------------------------------------------------- + +XML:: ++ [source,xml] -------------------------------------------------------------------------------------------------------------------------------- <bean id="myValidationProviderResolver" class="org.apache.camel.component.bean.validator.HibernateValidationProviderResolver"/> -------------------------------------------------------------------------------------------------------------------------------- +==== If no custom `ValidationProviderResolver` is defined and the validator component has been deployed into the OSGi environment, @@ -116,7 +123,7 @@ public interface OptionalChecks { --------------------------------- with the following Camel route, only the *@NotNull* constraints on the -attributes manufacturer and licensePlate will be validated (Camel uses +attributes `manufacturer` and `licensePlate` will be validated (Camel uses the default group `jakarta.validation.groups.Default`). [source,java] @@ -137,7 +144,7 @@ from("direct:start") ---------------------------------------------- If you want to check the constraints from both groups, you have to -define a new interface first +define a new interface first: *AllChecks.java* @@ -148,7 +155,7 @@ public interface AllChecks { } ----------------------------------------------------- -and then your route definition should looks like this +And then your route definition should look like this: [source,java] ----------------------------------------- @@ -159,15 +166,20 @@ from("direct:start") And if you have to provide your own message interpolator, traversable resolver and constraint validator factory, you have to write a route -like this +like this: +[tabs] +==== +Java:: ++ [source,xml] ------------------------------------------------------------------------------------------------------ <bean id="myMessageInterpolator" class="my.ConstraintValidatorFactory" /> <bean id="myTraversableResolver" class="my.TraversableResolver" /> <bean id="myConstraintValidatorFactory" class="my.ConstraintValidatorFactory" /> ------------------------------------------------------------------------------------------------------ - +XML:: ++ [source,java] ------------------------------------------------------------------------------------------------------ from("direct:start") @@ -175,13 +187,16 @@ from("direct:start") &traversableResolver=#myTraversableResolver&constraintValidatorFactory=#myConstraintValidatorFactory") .to("mock:end") ------------------------------------------------------------------------------------------------------ +==== It's also possible to describe your constraints as XML and not as Java -annotations. In this case, you have to provide the file -`META-INF/validation.xml` which could looks like this - -*validation.xml* +annotations. +In this case, you have to provide the files `META-INF/validation.xml` and `constraints-car.xml` which could look like this: +[tabs] +==== +validation.xml:: ++ [source,xml] ------------------------------------------------------------------------------------------------------------------------------ <validation-config @@ -199,10 +214,8 @@ annotations. In this case, you have to provide the file </validation-config> ------------------------------------------------------------------------------------------------------------------------------ -and the `constraints-car.xml` file - -*constraints-car.xml* - +constraints-car.xml:: ++ [source,xml] ---------------------------------------------------------------------------------------------------- <constraint-mappings @@ -233,6 +246,7 @@ and the `constraints-car.xml` file </bean> </constraint-mappings> ---------------------------------------------------------------------------------------------------- +==== Here is the XML syntax for the example route definition where **OrderedChecks** can be https://github.com/apache/camel/blob/main/components/camel-bean-validator/src/test/java/org/apache/camel/component/bean/validator/OrderedChecks.java