IsEmailAddressFunction implements DDMExpressionFunction.Function1<String, Boolean> { @Override public Boolean apply(String parameter) { return Stream.of( StringUtil.split(parameter, CharPool.COMMA) ).map( String::trim ).allMatch( Validator::isEmailAddress ); }  @Override Boolean apply(String parameter); @Override String getName(); static final String NAME; }
@Test public void testEmailList() { IsEmailAddressFunction isEmailAddressFunction = new IsEmailAddressFunction(); Boolean result = isEmailAddressFunction.apply( "test1@liferay.com, test2@liferay.com"); Assert.assertTrue(result); }
@Test public void testInvalidEmail() { IsEmailAddressFunction isEmailAddressFunction = new IsEmailAddressFunction(); Boolean result = isEmailAddressFunction.apply( "test1@liferay.com, invalid email"); Assert.assertFalse(result); }
@Test public void testSingleEmail() { IsEmailAddressFunction isEmailAddressFunction = new IsEmailAddressFunction(); Boolean result = isEmailAddressFunction.apply("test@liferay.com"); Assert.assertTrue(result); }