Class Validator
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.spi.Validator
- All Implemented Interfaces:
AutoCloseable, CamelContextAware, Service, ShutdownableService, HasCamelContext, StatefulService, SuspendableService
Validates message content against a declared
invokes the registered
during route
startup.
DataType, as described in the
Transformer and Validator documentation.
When a route declares an inputType or outputType with validate = true,
invalid reference
org.apache.camel.processor.ContractAdvice
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 ValidationException to signal the failure.
Validators are registered in the ValidatorRegistry keyed by their target DataType. Custom validators
extend this abstract class and are registered via the DSL (e.g., inputType / outputType with
validate = true), which wires them through
invalid reference
org.apache.camel.model.ValidatorDefinition
- See Also:
-
Field Summary
Fields inherited from class BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@Nullable CamelContextReturns the camel context.@Nullable DataTypegetType()Get 'from' data type.voidsetCamelContext(CamelContext context) Injects theCamelContextSet data type.toString()abstract voidPerform data validation with specified type.Methods inherited from class BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doStart, doStop, doSuspend, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ShutdownableService
shutdownMethods inherited from interface StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
Validator
public Validator()
-
-
Method Details
-
validate
Perform data validation with specified type.- Parameters:
message- message to apply validationtype- the data type- Throws:
ValidationException- thrown if any validation error is detected
-
getType
Get 'from' data type. -
setType
-
getCamelContext
Description copied from interface:HasCamelContextReturns the camel context.- Specified by:
getCamelContextin interfaceHasCamelContext- Returns:
- the camel context.
-
setCamelContext
Description copied from interface:CamelContextAwareInjects theCamelContext- Specified by:
setCamelContextin interfaceCamelContextAware- Parameters:
context- the Camel context
-
toString
-