You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Christian Mueller (JIRA)" <ji...@apache.org> on 2010/04/21 23:35:20 UTC

[jira] Commented: (CAMEL-1537) Predicate for validation

    [ https://issues.apache.org/activemq/browse/CAMEL-1537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=59013#action_59013 ] 

Christian Mueller commented on CAMEL-1537:
------------------------------------------

Currently I'm studying the Predicates, ProcessorDefinition, ...

In my opinion, we could provide the validation functionality for:
- xml validation
- bean validation (JSR 303)
- regExp validation for csv, fixed length, ...

I start with the regExp validation, because it's similar to the filter and choice predicate and it's a good starting point for me to discover this part of Camel... :-)

Currently, I can write a route like this to validate against a regular expression:

{code}
from("direct:start")
  .validate(body(String.class).regex("^\\d{2}\\.\\d{2}\\.\\d{4}$"))
.to("mock:result");
{code}

To validate with the bean validation feature (JSR 303), I could imagine a route definition like this:

{code}
from("direct:start")
  .validate(body())
.to("mock:result");
{code}

or

{code}
from("direct:start")
  .validate(body()).group(Default.class)
.to("mock:result");
{code}

if you want to define the constraint group, which should be evaluated.

For the validation against an XML schema, I could imagine the following route definition:

{code}
from("direct:start")
  .validate(body()).resource(schema.xsd)
.to("mock:result");
{code}

What do you think?

> Predicate for validation 
> -------------------------
>
>                 Key: CAMEL-1537
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1537
>             Project: Apache Camel
>          Issue Type: New Feature
>    Affects Versions: 2.0-M1
>            Reporter: Claus Ibsen
>            Assignee: Christian Mueller
>            Priority: Minor
>             Fix For: Future
>
>
> The current validator is a component and its a bit clumsy as it throws an exception if validation error.
> So if we have a nice Predicate for it, it can be like a xpath predicate or the likes.
> [17:58]  <jstrachan> http://camel.apache.org/validation.html
> [17:58]  <ulhasb> jstrachan: thanks for the quick responses
> [17:59]  <cibsen> jstrachan we should maybe have a predicate for schema validation
> [17:59]  <cibsen> then you can route it a bit more nice without try .. catch
> [18:00]  * fbolton has quit ("Leaving.")
> [18:03]  * gertv has quit (Client closed connection)
> [18:05]  <jstrachan> cibsen: yeah
> [18:05]  <jstrachan> cibsen: maybe a kinda predicate language using the other validators? filter().validate(theValidationEndpointUri).to("blah")

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.