Saturday, 11 November 2017

Validator class

Validator class(com.liferay.portal.kernel.util.Validator) provides us some utility methods to validate data and to check format of data.

Most frequently methods are:

Validator.isNotNull(String s)
Validator.isNull(String s)

And Instead of String we can also use long value,object,array,etc..

Ex:
String countryName = "India";
if(Validator.isNotNull(countryName))
System.out.println("country name is ****"+countryName);

Validator.equals(char c1,char c2)

And Instead of char we can use double,boolean Values

Ex:
char c1 = 'a';
char c2 = 'a';
if(Validator.equals(c1,c2))
System.out.println("c1 and c2 are equal");

And also we have many important methods to validate url,uri,number,password,email address,phone numbers.
You can press ctrl+space after validator and you can check all available methods.

This Validation helps us more during server side validation.


Source:
https://docs.liferay.com/portal/6.2/javadocs/com/liferay/portal/kernel/util/Validator.html

TEST

I am Java Developer. I have 6 year Experiance in this field and like to post in blogging. So keep sharing and like my post

0 comments:

Post a Comment

 

Copyright @ 2017 Liferay Article.