[resolved] Need help with data validation logic

Nine Stars

[resolved] Need help with data validation logic

I am trying to validate the Latitude data.
How can I check if the cleaned latitude value is not alpha and within the desired latitude range?
My tmap logic so far:
( row1.LAT ==null
|| row1.LAT ==""
|| row1.LAT.length() <4
)? "":
( StringHandling.IS_ALPHA( row1.LAT.replaceAll("","").trim()
)==false
&& Integer.parseInt(row1.LAT.replaceAll("","").trim()) > 19.718234
&& Integer.parseInt(row1.LAT.replaceAll("","").trim()) < 70.306897835
)? (row1.LAT.replaceAll("","").trim()) : ""
ERROR MESSAGE
Exception in component tMap_1
java.lang.NumberFormatException: For input string: "51.1635"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at ...

Accepted Solutions
Community Manager

Re: [resolved] Need help with data validation logic

Hi
The input parameter "51.1635" can't be parsed to a int with method Integer.parseInt(), the characters in the input string must all be decimal digits, except that the first character may be an ASCII minus sign "-". Try to use method Double.parseDouble(),
Double.parseDouble(row1.LAT.replaceAll("","").trim()) > 19.718234
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

All Replies
Community Manager

Re: [resolved] Need help with data validation logic

Hi
The input parameter "51.1635" can't be parsed to a int with method Integer.parseInt(), the characters in the input string must all be decimal digits, except that the first character may be an ASCII minus sign "-". Try to use method Double.parseDouble(),
Double.parseDouble(row1.LAT.replaceAll("","").trim()) > 19.718234
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Nine Stars

Re: [resolved] Need help with data validation logic

That worked thanks.
Community Manager

Re: [resolved] Need help with data validation logic

Hi
Thanks for your feedback! Smiley Wink
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business