Creating validation rules for more complex requirements

Sometimes validation rules require multiple inputs to provide a pass/fail result, so it is often easier to build and understand the code if it is written using Java.

If you aren't familiar with code routines in Talend, it is recommended that you first complete the recipe Creating custom functions using code routines, Chapter 5 , Using Java in Talend that will take you through the setup of code routines.

Getting ready

Open the job jo_cook_ch03_0060_validationCodeRoutine.

How to do it…

  1. Create a new code routine called validation, and copy the following code into it:
     /** * validateCustomerAge: Check customer is 18 or over for UK, 21 or over for rest of world. * returns true if valid, false if invalid ...

Get Talend Open Studio Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.