本文整理汇总了Java中org.apache.commons.validator.EmailValidator.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java EmailValidator.getInstance方法的具体用法?Java EmailValidator.getInstance怎么用?Java EmailValidator.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.validator.EmailValidator
的用法示例。
在下文中一共展示了EmailValidator.getInstance方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateEmailApache
import org.apache.commons.validator.EmailValidator; //导入方法依赖的package包/类
public static String validateEmailApache(String email){
email = email.trim();
EmailValidator eValidator = EmailValidator.getInstance();
if(eValidator.isValid(email)){
return email + " is a valid email address.";
}else{
return email + " is not a valid email address.";
}
}
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:10,代码来源:App.java
示例2: validatePreferenceValues
import org.apache.commons.validator.EmailValidator; //导入方法依赖的package包/类
/**
* @see org.kuali.rice.kcb.deliverer.MessageDeliverer#validatePreferenceValues(java.util.HashMap)
*/
public void validatePreferenceValues(HashMap<String, String> prefs) throws ErrorList {
boolean error = false;
ErrorList errorList = new ErrorList();
String[] validformats = {"text","html"};
if (!prefs.containsKey(getName()+"."+EMAIL_ADDR_PREF_KEY)) {
errorList.addError("Email Address is a required field.");
error = true;
} else {
String addressValue = (String) prefs.get(getName()+"."+EMAIL_ADDR_PREF_KEY);
EmailValidator validator = EmailValidator.getInstance();
if (!validator.isValid(addressValue)) {
errorList.addError("Email Address is required and must be properly formatted - \"[email protected]\".");
error = true;
}
}
// validate format
if (!prefs.containsKey(getName()+"."+EMAIL_DELIV_FRMT_PREF_KEY)) {
errorList.addError("Email Delivery Format is required.");
error = true;
} else {
String formatValue = (String) prefs.get(getName()+"."+EMAIL_DELIV_FRMT_PREF_KEY);
Set<String> formats = new HashSet<String>();
for (int i=0; i < validformats.length ; i++) {
formats.add(validformats[i]);
}
if (!formats.contains(formatValue)) {
errorList.addError("Email Delivery Format is required and must be entered as \"text\" or \"html\".");
error = true;
}
}
if (error) throw errorList;
}
示例3: isValidEmail
import org.apache.commons.validator.EmailValidator; //导入方法依赖的package包/类
/**
* Is this a valid email the service will recognize
* @param email
* @return
*/
private boolean isValidEmail(String email) {
// TODO: Use a generic Sakai utility class (when a suitable one exists)
if (email == null || email.equals(""))
{
return false;
}
email = email.trim();
//must contain @
if (!email.contains( "@" ))
{
return false;
}
//an email can't contain spaces
if (email.indexOf(" ") > 0)
{
return false;
}
//use commons-validator
EmailValidator validator = EmailValidator.getInstance();
return validator.isValid(email);
}
示例4: validateEmail
import org.apache.commons.validator.EmailValidator; //导入方法依赖的package包/类
/**
* Validate Email field data is acceptable
*
* @param context FacesContext
* @param component UIComponent
* @param value Object
* @throws ValidatorException
*/
public void validateEmail(FacesContext context, UIComponent component, Object value) throws ValidatorException
{
EmailValidator emailValidator = EmailValidator.getInstance();
if (!emailValidator.isValid((String) value))
{
String err =Application.getMessage(context, MSG_ERROR_MAIL_NOT_VALID);
throw new ValidatorException(new FacesMessage(err));
}
}
示例5: validate
import org.apache.commons.validator.EmailValidator; //导入方法依赖的package包/类
@Override
public Violation<T> validate(T o, String propertyName) {
EmailValidator v = EmailValidator.getInstance();
String emailAddress = getProperty(o, propertyName);
if(!v.isValid(emailAddress)){
return new ConstraintViolation<T>(o, propertyName, ConstraintViolationType.NON_VALID_EMAIL_ADDRESS);
}
return null;
}
示例6: isValidEmailAddress
import org.apache.commons.validator.EmailValidator; //导入方法依赖的package包/类
public static boolean isValidEmailAddress(String emailAddr){
EmailValidator eValidator = EmailValidator.getInstance();
return eValidator.isValid(emailAddr);
}
示例7: ValidateUser
import org.apache.commons.validator.EmailValidator; //导入方法依赖的package包/类
private String ValidateUser(User user){
ResourceBundleMessageSource r=new ResourceBundleMessageSource();
r.setBasename("messages_en");
user.setDob(new Date(user.getYear() - 1900, user.getMonth() - 1, user.getDay()));
if(user.getNick().length()==0)
return r.getMessage("judge.register.error.nick",null, new Locale("en"));
if ((user.getNick().length()) > 15)
return r.getMessage("judge.register.error.long25charact",null, new Locale("en"));
if (user.getNick().length() < 3)
return r.getMessage("judge.register.error.less3charact",null, new Locale("en"));
if (user.getName().length() < 1)
return r.getMessage("errormsg.7",null, new Locale("en"));
if (user.getName().length() > 30)
return r.getMessage("errormsg.6",null, new Locale("en"));
if (!user.getName().matches("[a-zA-Z\\.\\-\\'\\s]+"))
return r.getMessage("errormsg.8",null, new Locale("en"));
if (user.getLastname().length() < 1)
return r.getMessage("errormsg.10",null, new Locale("en"));
if (user.getLastname().length() > 50)
return r.getMessage("errormsg.9",null, new Locale("en"));
if (!user.getLastname().matches("[a-zA-Z\\.\\-\\'\\s]+"))
return r.getMessage("errormsg.11",null, new Locale("en"));
// si el correo ha sido cambiado y esta en uso por otra persona en el
// COJ
if(user.getEmail().length() == 0)
return r.getMessage("errormsg.51",null, new Locale("en"));
if (!StringUtils.isEmpty(user.getEmail()) && userDAO.bool("email.changed", user.getEmail(), user.getUid()) && userDAO.emailExistUpdate(user.getEmail().trim(), user.getUsername()))
return r.getMessage("judge.register.error.emailexist",null, new Locale("en"));
EmailValidator emailValidator = EmailValidator.getInstance(); //ver como inyectar este objeto
if (!emailValidator.isValid(user.getEmail()))
return r.getMessage("judge.register.error.bademail",null, new Locale("en"));
if (user.getCountry_id() == 0)
return r.getMessage("judge.register.error.country",null, new Locale("en"));
if (user.getInstitution_id() == 0)
return r.getMessage("judge.register.error.institution",null, new Locale("en"));
if (user.getLid() == 0)
return r.getMessage("judge.register.error.planguage",null, new Locale("en"));
if (user.getLocale() == 0)
return r.getMessage("judge.register.error.locale",null, new Locale("en"));
if(user.getName().length() == 0)
return r.getMessage("judge.register.error.name",null, new Locale("en"));
if (user.getGender() == 0)
return r.getMessage("judge.register.error.gender",null, new Locale("en"));
return "0";
}
示例8: validatePointOfContactInput
import org.apache.commons.validator.EmailValidator; //导入方法依赖的package包/类
protected List<String> validatePointOfContactInput(SimplePointOfContactBean simplePOC)
{
List<String> errors = new ArrayList<String>();
if (simplePOC == null) {
errors.add("Input point of contact object invalid"); //shouldn't happen
return errors;
}
SimpleOrganizationBean simpleOrg = simplePOC.getOrganization();
if (simpleOrg != null) {
String orgName = simpleOrg.getName();
if (orgName == null || !InputValidationUtil.isTextFieldWhiteList(orgName))
errors.add(PropertyUtil.getProperty("sample", "organization.name.invalid"));
} else
errors.add("Organization Name is a required field");
SimpleAddressBean addrBean = simplePOC.getAddress();
if (addrBean != null) {
String val = addrBean.getLine1();
if (val != null && val.length() > 0 && !InputValidationUtil.isTextFieldWhiteList(val))
errors.add(PropertyUtil.getProperty("sample", "organization.address1.invalid"));
val = addrBean.getLine2();
if (val != null && val.length() > 0 && !InputValidationUtil.isTextFieldWhiteList(val))
errors.add(PropertyUtil.getProperty("sample", "organization.address2.invalid"));
val = addrBean.getCity();
if (val != null && val.length() > 0 && !InputValidationUtil.isRelaxedAlphabetic(val))
errors.add(PropertyUtil.getProperty("sample", "organization.city.invalid"));
val = addrBean.getStateProvince();
if (val != null && val.length() > 0 && !InputValidationUtil.isRelaxedAlphabetic(val))
errors.add(PropertyUtil.getProperty("sample", "organization.state.invalid"));
val = addrBean.getCountry();
if (val != null && val.length() > 0 && !InputValidationUtil.isRelaxedAlphabetic(val))
errors.add(PropertyUtil.getProperty("sample", "organization.country.invalid"));
val = addrBean.getZip();
if (val != null && val.length() > 0 && !InputValidationUtil.isZipValid(addrBean.getZip()))
errors.add(PropertyUtil.getProperty("sample", "postalCode.invalid"));
}
String name = simplePOC.getFirstName();
if (name != null && name.length() > 0 && !InputValidationUtil.isRelaxedAlphabetic(name))
errors.add(PropertyUtil.getProperty("sample", "firstName.invalid"));
name = simplePOC.getLastName();
if (name != null && name.length() > 0 && !InputValidationUtil.isRelaxedAlphabetic(name))
errors.add(PropertyUtil.getProperty("sample", "lastName.invalid"));
name = simplePOC.getMiddleInitial();
if (name != null && name.length() > 0 && !InputValidationUtil.isRelaxedAlphabetic(name))
errors.add(PropertyUtil.getProperty("sample", "middleInitial.invalid"));
String phone = simplePOC.getPhoneNumber();
if ( phone.length() > 0 && !InputValidationUtil.isPhoneValid(phone))
errors.add(PropertyUtil.getProperty("sample", "phone.invalid"));
//
String email = simplePOC.getEmail();
EmailValidator emailValidator = EmailValidator.getInstance();
if (email != null && email.length() > 0 && !emailValidator.isValid(email))
errors.add("Email is invalid");
return errors;
}
示例9: isEmailValid
import org.apache.commons.validator.EmailValidator; //导入方法依赖的package包/类
public static boolean isEmailValid(String email) {
EmailValidator emailValidator = EmailValidator.getInstance();
return (email == null || email.length() == 0) ? true : emailValidator.isValid(email);
}
示例10: isValidMail
import org.apache.commons.validator.EmailValidator; //导入方法依赖的package包/类
private boolean isValidMail(String email) {
if (email == null || "".equals(email))
return false;
email = email.trim();
EmailValidator ev = EmailValidator.getInstance();
return ev.isValid(email);
}