List of usage examples for org.springframework.validation ValidationUtils rejectIfEmptyOrWhitespace
public static void rejectIfEmptyOrWhitespace(Errors errors, String field, String errorCode)
From source file:mylife.validator.userValidator.java
@Override public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "user.username.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "user.password.required"); }
From source file:com.springdemob.formvalidator.LoginFormValidator.java
@Override public void validate(Object o, Errors errors) { LoginForm loginForm = (LoginForm) o; ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "NotEmpty.loginForm.username"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "NotEmpty.loginForm.password"); }
From source file:CRM.Validation.UserValidation.java
@Override public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "Users.username.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "Users.password.required"); }
From source file:com.onclave.testbench.simpleForm.SimpleFormValidator.java
public void validate(Object object, Errors errors) { StudentPOJO student = (StudentPOJO) object; ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "simpleFormValidity.name"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "age", "simpleFormValidity.age"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "simpleFormValidity.email"); // if(!student.getEmail().matches(EMAIL_PATTERN)) { // System.out.println("===========================Email Pattern does not match==========================="); // errors.rejectValue("email", "simpleFormValidity.email"); // }//from www . ja va 2 s . c o m if (student.getAge() < 5 || student.getAge() > 200) { errors.rejectValue("age", "simpleFormValidity.age"); } }
From source file:org.dspace.app.webui.cris.validator.PJSearchValidator.java
public void validate(Object arg0, Errors arg1) { PJSearchDTO dto = (PJSearchDTO) arg0; if (dto.getSearchMode() != null) { if (dto.getAdvancedSyntax()) { ValidationUtils.rejectIfEmptyOrWhitespace(arg1, "queryString", "error.validation.hku.search.query.empty"); }//from w ww .j av a2 s. c o m } else if (dto.getCodeSearchMode() != null) { ValidationUtils.rejectIfEmptyOrWhitespace(arg1, "codeQuery", "error.validation.hku.search.query.empty"); } else { arg1.reject("error.validation.hku.search.unknow-mode"); } }
From source file:org.tsm.concharto.web.util.AuthFormValidatorHelper.java
public static void validatePasswordFields(AuthForm authForm, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "empty.authForm.password"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "passwordConfirm", "empty.authForm.passwordConfirm"); if (!StringUtils.isEmpty(authForm.getPassword()) && !StringUtils.isEmpty(authForm.getPasswordConfirm())) { if (!authForm.getPassword().equals(authForm.getPasswordConfirm())) { errors.rejectValue("password", "notSame.authForm.password"); }/*from ww w . j a v a 2 s . com*/ if (authForm.getPassword().length() < MIN_PASSWORD_SIZE) { errors.rejectValue("password", "tooSmall.authForm.password"); } ValidationHelper.rejectIfTooLong(errors, "password", User.SZ_PASSWORD, "tooLong.signupForm"); } }
From source file:validation.UsersValidator.java
@Override public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "users.username.required"); //ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "users.password.required"); Users users = (Users) target;/*from w w w . ja v a2s .c o m*/ if (users.getUsername().length() > 45) { errors.rejectValue("username", "users.username.length"); } if (!users.getUsername().matches("^[A-Za-z0-9]*$")) { errors.rejectValue("username", "users.username.pattern"); } // if (users.getPassword().length() <= 8 && users.getPassword().length() >= 12) { // errors.rejectValue("password", "users.password.length"); // } // if (!users.getPassword().matches("^[A-Za-z0-9]*$")) { // errors.rejectValue("password", "users.password.pattern"); // } }
From source file:org.jasig.cas.validation.UsernamePasswordCredentialsValidator.java
public void validate(final Object o, final Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "required.username"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "required.password"); }
From source file:validation.InteractionsValidator.java
@Override public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstname", "interaction.firstname.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastname", "interaction.lastnamame.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "typeofinteraction", "typeofinteraction.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "interactiontime", "interaction.interactiontime.required"); Interactions interactions = (Interactions) target; // if (!interactions.getFirstname().matches("^[a-zA-Z0-9-_. ]+$")) { // errors.rejectValue("firstname", "interactions.firstname.pattern", "default"); // }//from www . ja v a 2s .c om // // if (!interactions.getLastname().matches("^[a-zA-Z0-9-_. ]+$")) { // errors.rejectValue("lastname", "interactions.lastname.pattern", "default"); // } }
From source file:org.dspace.app.webui.cris.validator.RPSearchValidator.java
public void validate(Object arg0, Errors arg1) { RPSearchDTO dto = (RPSearchDTO) arg0; if (dto.getSearchMode() != null) { if (dto.getAdvancedSyntax()) { ValidationUtils.rejectIfEmptyOrWhitespace(arg1, "queryString", "error.validation.hku.search.query.empty"); }//from w ww .j a va2s . c o m } else if (dto.getStaffNoSearchMode() != null) { ValidationUtils.rejectIfEmptyOrWhitespace(arg1, "staffQuery", "error.validation.hku.search.query.empty"); } else if (dto.getRpSearchMode() != null) { String query = dto.getRpQuery(); ValidationUtils.rejectIfEmptyOrWhitespace(arg1, "rpQuery", "error.validation.hku.search.query.empty"); if (query != null) { if (!(((query.toLowerCase().startsWith("rp") && StringUtils.isNumeric(query.substring(2)) && query.length() > 2)) || StringUtils.isNumeric(query))) { arg1.reject("error.validation.hku.search.query.numberformatexception"); } } } else { arg1.reject("error.validation.hku.search.unknow-mode"); } }