String emailAddress = "example"; if (Validator.isEmailAddress(emailAddress)) { // valid email address } else { // invalid email address }
String url = "www.example.com"; if (Validator.isUrl(url)) { // valid URL } else { // invalid URL }
String number = "1234"; if (Validator.isNumber(number)) { // valid number } else { // invalid number }These examples demonstrate the use of Validator methods to validate different types of data. The package library for the com.liferay.portal.kernel.util Validator class is "com.liferay.portal.kernel.util".