List of usage examples for org.springframework.validation ValidationUtils rejectIfEmptyOrWhitespace
public static void rejectIfEmptyOrWhitespace(Errors errors, String field, String errorCode)
From source file:com.springmvc.videoteca.spring.validator.ClienteFormValidator.java
@Override public void validate(Object o, Errors errors) { Cliente target;/*from w ww . j a v a 2 s . c o m*/ target = (Cliente) o; ValidationUtils.rejectIfEmptyOrWhitespace(errors, "nombre", "NotEmpty.clienteForm.nombre"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dni", "NotEmpty.clienteForm.dni"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "nick", "NotEmpty.clienteForm.userName"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "NotEmpty.clienteForm.email"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "NotEmpty.clienteForm.password"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "confirmPassword", "NotEmpty.clienteForm.confirmPassword"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "celular", "NotEmpty.clienteForm.celular"); if (!emailValidator.valid(target.getEmail())) { errors.rejectValue("email", "Pattern.clienteForm.email"); } if (!dniValidator.valid(target.getDni())) { errors.rejectValue("dni", "Pattern.clienteForm.dni"); } if (!telefonoValidator.valid(target.getCelular())) { errors.rejectValue("celular", "Pattern.clienteForm.celular"); } if (!target.getPassword().equals(target.getConfirmPassword())) { errors.rejectValue("confirmPassword", "Diff.clienteform.confirmPassword"); } }
From source file:org.guanxi.sp.engine.form.RegisterIdPFormValidator.java
public void validate(Object obj, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "filename", "error.field.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "entityID", "error.field.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "aa", "error.field.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "x509", "error.field.required"); }
From source file:org.oncoblocks.centromere.core.test.EntrezGeneValidator.java
@Override public void validate(Object o, Errors errors) { EntrezGene gene = (EntrezGene) o;/*from w ww .j a v a 2s . c om*/ ValidationUtils.rejectIfEmptyOrWhitespace(errors, "primaryGeneSymbol", "symbol.empty"); }
From source file:com.chevres.rss.restapi.controller.validators.UserUpdateValidator.java
@Override public void validate(Object o, Errors errors) { User user = (User) o;//from w ww . j a v a 2 s.c o m if (user.getType() != null && (!user.getType().equals(User.ADMIN_TYPE_LABEL) && !user.getType().equals(User.USER_TYPE_LABEL))) { errors.rejectValue("type", "error.type"); } if (user.getUsername() != null) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "error.username"); } if (user.getPassword() != null) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "error.password"); } }
From source file:org.openmrs.module.patientflags.web.validators.PriorityValidator.java
public void validate(Object target, Errors errors) { Priority priorityToValidate = (Priority) target; // name and rank cannot be empty ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "patientflags.errors.noPriorityName"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rank", "patientflags.errors.noRank"); // make sure that the name field isn't too large if (priorityToValidate.getName().length() > 255) errors.rejectValue("name", "patientflags.errors.priorityNameTooLong"); // make sure that the style field isn't too large if (priorityToValidate.getStyle().length() > 255) errors.rejectValue("style", "patientflags.errors.styleTooLong"); }
From source file:com.apress.progwt.server.web.domain.validation.MailingListCommandValidator.java
/** * lookup messages from resource bundle/*from ww w . jav a2 s .c o m*/ */ public void validate(Object command, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "required"); }
From source file:com.vmg.validator.LoginValidator.java
public void validate(Object target, Errors errors) { RegisterBean regBean = (RegisterBean) target; if (!regBean.getPassword().equals(regBean.getConfirmPassword())) { errors.rejectValue("confirmPassword", "notmatch.password"); }//from w ww. j ava 2s . c o m if (regBean.getRegisterId() <= 0) { errors.rejectValue("registerId", "negativeValue", new Object[] { "'registerId'" }, "Register Id can't be negative"); } // ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstName", "firstName.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastName", "lastName.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userName", "userName.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "password.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "confirmPassword", "confirmPassword.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "Email"); }
From source file:com.apress.progwt.server.web.domain.validation.PasswordChangeCommandValidator.java
/** * lookup messages from resource bundle// w ww . jav a2 s. c o m */ public void validate(Object command, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "oldPassword", "required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "newPassword", "required"); PasswordChangeCommand comm = (PasswordChangeCommand) command; if (comm.getNewPassword().equals(comm.getOldPassword())) { errors.rejectValue("newPassword", "invalid"); } }
From source file:org.tsm.concharto.web.forgot.ForgotValidator.java
public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "empty.authForm.username"); }
From source file:org.tsm.concharto.web.feedback.FeedbackValidator.java
public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "empty.feedback.name"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "empty.feedback.email"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "subject", "empty.feedback.subject"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "body", "empty.feedback.body"); }