camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brad Johnson <brad.john...@mediadriver.com>
Subject Re: How to validate Body Content in Map Object
Date Wed, 16 Mar 2016 15:42:55 GMT
Michelle,

You are using a custom CSV reader it would appear rather than one of the
off the shelf readers like beanio or bindy or xxx that come with Camel.
Obviously you've left that a very black box so I don't really know what you
are doing it in but if that is truly custom you may want to validate the
CSV contents as you read it in.

What sort of validation are you trying to do.  If you could be a bit more
specific about it that would help suggest some possible solutions.  Claus
shows the XML version of some validation using the simple language and
that's probably what you'll have to go with if you want such flexibility.
Simple also works in the Java DSL if that's your preference.

How many different record types are you dealing with?

If you create custom validators that doesn't mean you are writing a POJO
per map.  For example, if my validator class is:

public class MyValidator {

     public Boolean validateAllNotNull(Map map)
{
     //iterate through the entry set and verify that there aren't any null
entities in the values.
}

}

...that could be reused anywhere you want to verify that things were
unmarshaled correctly.

More importantly, how are you going to determine which validator mechanisms
to call after you unmarshal your CSVs into maps.  If you say there are too
many to create POJOs for, which may well be true, you'd still have to
create many different routes to send the maps to the right set of
validators.

So if you can give us a more concrete example of what you're trying to do
we can probably help with some suggestions.  Definitely give this a look
again too:

http://camel.apache.org/validate.html

On Wed, Mar 16, 2016 at 3:23 AM, Claus Ibsen <claus.ibsen@gmail.com> wrote:

> Ah quick thought could be to add a component that validates using a
> Camel language, and uses simple by default, then you can do
>
> body[foo] == 'Hello'
> body[bar] > 100
>
> eg in a plain text file where each line is a predicate.
>
> <to uri="camel-validator:myFile.txt/">
>
> It could also be some kind of xml file where you can setup multiple
> groups in the same file, and then refer to which one
>
> <to uri="camel-validator:myFile.xml?rule=foo"/>
>
> <validate-rules>
> <validate id="foo">
>   <simple>body[foo] == 'Hello'</simple>
>   <simple>body[bar] &gt; 100</simple>
> </validate>
> <validate id="dude">
>   <simple>body[yay] == 'Hello'</simple>
>   <simple>body[something] in ['a', 'b']</simple>
> </validate>
> </validate-rules>
>
>
>
> On Wed, Mar 16, 2016 at 9:19 AM, Claus Ibsen <claus.ibsen@gmail.com>
> wrote:
> > No there is no such component.
> >
> > Creating a pojo vs a xml both requires work. The former is just java,
> > the latter introduces a new limited language.
> >
> > How much validation do you need, eg what are your criteria's?
> >
> > On Wed, Mar 16, 2016 at 9:08 AM, Michele
> > <michele.mazzilli@finconsgroup.com> wrote:
> >> Hi Ranx,
> >>
> >> thanks so much.
> >>
> >> Exactly, key/values validation... I have different file with different
> >> criterions of validations and to create different Pojo is much
> expensive.
> >>
> >> Is there a compenent in camel with xml configuration to validate a Map
> >> Object?
> >>
> >> Thaks in advance
> >>
> >> Best Regards
> >>
> >> Michele
> >>
> >>
> >>
> >> --
> >> View this message in context:
> http://camel.465427.n5.nabble.com/How-to-validate-Body-Content-in-Map-Object-tp5779118p5779142.html
> >> Sent from the Camel - Users mailing list archive at Nabble.com.
> >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > http://davsclaus.com @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message