Access validation methods

0 votes
Hi there,

I am currently implementing the GUI for user registration. Here, I'd like to display some custom messages to the user, if there is a validation problem. Unfortunately, I could not find any way t access the App42's validation methods. Also, the exceptions thrown at e.g. invalid e-mail address seem to not contain any error codes.

Is there a way to access those validation methods or what is common practice here?

 

Thanks in advance,

flogy
asked Oct 11, 2014 in App42 Cloud API-BaaS by flogy (16 points)

2 Answers

0 votes
 
Best answer

Hello, 

Please find a below code snippet and add this method in your app and call this method before making a call to App42 Server:

public boolean isValidEmail(String checkString) {

Pattern p = Pattern.compile("^[\\w\\]([\\.\\w])+[\\w]+@([\\w\\]+\\.)+[A-Z]{2,4}$", Pattern.CASE_INSENSITIVE);

Matcher m = p.matcher(checkString);

boolean b = m.matches();
if (b != true)

   return false;

 

return true;

}

 

Let us know if it helps.

Himanshu Sharma

 

answered Oct 14, 2014 by hs00105 (2,005 points)
selected Oct 14, 2014 by flogy
Hello,
thanks for your reply. I will go by calling the Util.throwExceptionIfEmailNotValid(...) method then (seems to be the code you have posted).

Thanks,
flogy
0 votes

These validations are checked at client side and does not have any error codes.  These validations include null, blank or invalid value of parameters. You can simply catch these App42Exception and can check for error message to handle it.

Let me know if it helps.

Thanks

AJay

answered Oct 11, 2014 by ajay123 (899 points)
Thanks for your quick answer. I see, but I'd like to avoid parsing the error messages to determine, what the problem might be... That's why I asked about the error codes.
Is there no public API to call those validation methods directly? Something like ValidationUtil.isUserNameValid(String userName)?
Thanks
Which SDK you are using? I will give you util method name for the same.
I'm using both, Java SDK and Android SDK. Thank you very much!
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...