davsclaus commented on code in PR #23968:
URL: https://github.com/apache/camel/pull/23968#discussion_r3400960090


##########
core/camel-api/src/main/java/org/apache/camel/spi/Validator.java:
##########
@@ -26,12 +26,21 @@
 import org.jspecify.annotations.Nullable;
 
 /**
- * <a href="https://camel.apache.org/validator.html";>Validator</a> performs 
message content validation according to the
- * declared data type. {@link org.apache.camel.processor.ContractAdvice} 
applies Validator if input/output type is
- * declared on a route with validation enabled.
+ * Validates message content against a declared {@link DataType}, as described 
in the
+ * <a href="https://camel.apache.org/manual/transformer.html";>Transformer and 
Validator</a> documentation.
+ * <p/>
+ * When a route declares an {@code inputType} or {@code outputType} with 
{@code validate = true},
+ * {@link org.apache.camel.processor.ContractAdvice} invokes the registered 
{@code Validator} for that type before (or
+ * after) the route's main processing logic. If the message content does not 
satisfy the validator's rules, the
+ * validator should throw a {@link org.apache.camel.ValidationException} to 
signal the failure.
+ * <p/>
+ * Validators are registered in the {@link ValidatorRegistry} keyed by their 
target {@link DataType}. Custom validators
+ * extend this abstract class and are typically annotated with {@link 
DataTypeTransformer} to be picked up automatically
+ * during route startup.

Review Comment:
   The `@DataTypeTransformer` annotation is transformer-specific — no validator 
in the codebase uses it. Validators are registered through DSL model 
definitions (`ValidatorDefinition` in `DefaultCamelContext`), not via 
annotation-driven classpath scanning.
   
   The `@see DataTypeTransformer` tag below is also misleading on a validator 
class. Consider replacing with something like `@see 
org.apache.camel.model.ValidatorDefinition`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to