I'm working on a route in Talend that should interogate an api and store the resulting data in a queue.
I have issues with the request to have 2 validations of data posted on api.
One of them is to have only digits and commas in string posted and the second is to have at most 200 numbers (ex: 123,34,35,780,01, ..... to have no more than 200 numbers between commas
A colleague suggest to use regular expresions and I found this expression ^[0-9]+(,[0-9]+)*$ for doing the first demand but I do not know how to use it in my route.
I use cREST and I do not know where to put this expression for doing the validation.
Can you help me?
Thanks,
Aurel
One possiblity is to put a cMessageRouter component after the cREST component. You can then pull a 'when trigger' and enter a predicate that will be evaluated to conditionally send the message to your queue. Assuming that your API returns a raw string (in which case you should make sure to set the Accept-Type of the cREST component to 'any') and using the Simple language, the
predicate could look like
"${body} regex '[your regex]'". If the predicate evaluates to false, you can pull an 'otherwise trigger' from the cMessageRouter to send the message to a dead-letter queue, as shown below.Note that you can have the cMessageRouter component evaluate multiple predicates and send the message to different destinations depending on the condition that is fulfilled.