Business Rule for decimal values

Highlighted
Five Stars

Business Rule for decimal values

Hello,

 

I'm trying to define a business rule to check if my input is a numeric value or not.

Here's my input:

2019-09-18 15_25_34-ENTREGUES.XLSX - Excel.png

I've applied the next rule in a tMap but unfortunetely it doesn't work (the output gives me zeros):

StringHandling.LEN(out5.Volumen_DM3) > 0 &&
out5.Volumen_DM3.matches("^[0-9]+$")? 1:0

 

In my tMap input this field is defined as a string and the output is an integer since I've established 1 for correct and 0 incorrect.

 

Could anyone help me with this rule?

 

Thank you!!

Marc


Accepted Solutions
Sixteen Stars TRF
Sixteen Stars

Re: Business Rule for decimal values

Try "^[0-9,\.]+$" or maybe "^[0-9,\\.]+$"

TRF

View solution in original post


All Replies
Sixteen Stars TRF
Sixteen Stars

Re: Business Rule for decimal values

This one works:

StringHandling.LEN(row1.volume) > 0 && row1.volume.matches("^[0-9,]+$") ? 1 : 0 

Just add a comma into the brackets.


TRF
Sixteen Stars TRF
Sixteen Stars

Re: Business Rule for decimal values

Does this help?
If so, thanks to mark your case as solved.

TRF
Five Stars

Re: Business Rule for decimal values

Hello,

 

It works but I have still problems when the input value has a ".", for example: 1.503,67

 

Do you know what I would have to add in order to solve the problem?

 

Thank you!!

Sixteen Stars TRF
Sixteen Stars

Re: Business Rule for decimal values

Try "^[0-9,\.]+$" or maybe "^[0-9,\\.]+$"

TRF

View solution in original post

Five Stars

Re: Business Rule for decimal values

It works! Thank you!!

Sixteen Stars TRF
Sixteen Stars

Re: Business Rule for decimal values

You're welcome

TRF

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 3

Read about some useful Context Variable ideas

Blog