Question

UTF characters problem over a validation rule

Hi guys!

I'm having a little bit problem. I'm making a Validation Rule to test an email address (because the PEGA validation only see if you've an "@", so it's not a valid one) using the "ñ" character (an special character from Spain. UTF-8) over the regular expresion. Nothings matter and the email is not validate it.

Ok... so I decided to replace all the "ñ" characters over the string (theValue) and then validate it without these characters... again, nothing matters.

Could you help me to improve something to do this? I'm over Pega 8.2.1 Cloud and i suppose that my cloud machine don't have the UTF8 encoding....

A testing email address (property value - text):
jaimeñherraiz@mail.test

The java code:

  1. if (theValue== null || theValue.trim().equals("")) return false;
  2. String mail = theValue.toString();
  3.  
  4. if (mail.indexOf("ñ") >0 ) { //"escaping" "ñ" character...
  5. mail = mail.replace("ñ", "n");
  6. }
  7.  
  8. //first pattern. Working fine over other plattform, don't at PEGA
  9. //"^([a-z0-9ñ])+([a-z0-9._ñ-])*(@){1}([a-z0-9ñ]){1}(([a-z0-9_ñ-])((\\.){1}([a-z0-9_ñ-]))*)+((\\.){1}([a-z]){2,4})+$";
  10.  
  11. //second pattern
  12. String regex = "^(?!\\.)(([^\\r\\\\]|\\\\[\\r\\\\])*|([-a-z0-9!#$%&'*+/=?^_`\\{|\\}~]|(?<!\\.)\\.)*)(?<!\\.)@[a-z0-9][\\w\\.-]*[a-z0-9]\\.[a-z][a-z\\.]*[a-z]$";
  13. if (mail.matches(regex) ){
  14. return true;
  15.  
  16. }else{
  17. return false;
  18. }

Thanks in advance!

***Edited by Moderator: Lochan to update platform capability tags***

Correct Answer
October 31, 2019 - 2:51am

To resolved this issue finnaly we moved the edit validation rule from the Property to the Post-Action of the flow. It seens that the validate rules works different on client side from the server (pega) side.

So, exactly the same java code and valid rule work fine, but only if we use the Post-Action and not the validation over the property. (We didn't used the Pega SR)

Cheers
Jaime

Comments

Keep up to date on this post and subscribe to comments

October 10, 2019 - 1:02am

Hi @JaimeH04,

You can resolve the issue either one of the below one.

1. The default encoding is based on the JVM settings, not anything in Pega.  UTF-8 is a common default, but not guaranteed since your JVM might set another encoding.The easiest way to do this is to set the JVM level encoding using this Java option. This makes Pega encode everything in UTF-8 and will be the most consistent overall

-Dfile.encoding=UTF-8 . 

2. In Dev Studio, open the Dynamic System Settings.

  1. In the navigation panel, click Records.
  2. Click SysAdmin > Dynamic System Settings.
  3. Click Pega-RulesEngine RuleManagement/EnableUnicodeRuleNames.
  4. On the Settings tab, in the Value field, enter true, and then click Save.

 

October 17, 2019 - 2:25am
Response to Thangasuresh-pega

Hi Thangasuresh-pega!

The first one doesn't works. It's fine in order to name rules with the utf-8 characters, but not for use these over java code

So, I'm gonna make a Service Request for this issue because my sense it0s that we don't have the unicode code active over the java virtual machine at cloud

Thank you!

October 17, 2019 - 3:56am
Response to JaimeH04

Hi @JaimeH04,

Did you try the second option? 

October 17, 2019 - 4:04am
Response to Thangasuresh-pega

hehehe... ok, I mean that the second option doesn't works XD. I's only to accept the unicode characters in the rule names.

So indeed, the next phase it's change the JVM (java virtual machine) to accept the unicode characters. I don't know how to do this because our company has PEGA on cloud, so i undestand that i need to put the SR because we cannot do that... or it's possible to do this by our side?

October 17, 2019 - 4:26am
Response to JaimeH04

Hi @JaimeH04,

Its good to create a SR to get support/update from pega team, Thanks.

October 31, 2019 - 2:51am

To resolved this issue finnaly we moved the edit validation rule from the Property to the Post-Action of the flow. It seens that the validate rules works different on client side from the server (pega) side.

So, exactly the same java code and valid rule work fine, but only if we use the Post-Action and not the validation over the property. (We didn't used the Pega SR)

Cheers
Jaime