List of usage examples for org.springframework.validation ValidationUtils rejectIfEmptyOrWhitespace
public static void rejectIfEmptyOrWhitespace(Errors errors, String field, String errorCode)
From source file:org.openmrs.module.dataimporttool.resources.DataImportToolValidator.java
public void validate(Object obj, Errors e) { ValidationUtils.rejectIfEmptyOrWhitespace(e, "matchFile", "matchFile.empty"); ValidationUtils.rejectIfEmpty(e, "leftDbDriver", "leftDbDriver.empty"); ValidationUtils.rejectIfEmpty(e, "rightDbDriver", "rightDbDriver.empty"); ValidationUtils.rejectIfEmpty(e, "MatchLocation", "MatchLocation.empty"); ValidationUtils.rejectIfEmpty(e, "rightDbLocation", "rightDbLocation.empty"); ValidationUtils.rejectIfEmpty(e, "leftDbLocation", "leftDbLocation.empty"); ValidationUtils.rejectIfEmpty(e, "leftDbName", "leftDbName.empty"); ValidationUtils.rejectIfEmpty(e, "rightDbName", "rightDbName.empty"); DataImportTool dit = (DataImportTool) obj; if (dit.getMatchFormat().compareToIgnoreCase("xls") != 0) e.rejectValue("matchFormat", "Match format must be xls"); }
From source file:csns.web.validator.RegistrationValidator.java
@Override public void validate(Object target, Errors errors) { super.validate(target, errors); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password1", "error.field.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password2", "error.field.required"); }
From source file:nl.conspect.legacy.domain.UserValidator.java
public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "displayName", "required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "emailAddress", "required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "emailValidation", "required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "passwordValidation", "required"); NewUserRegistrationForm registration = (NewUserRegistrationForm) target; if (registration.getEmailAddress() != null && registration.getEmailValidation() != null) { if (!registration.getEmailAddress().equals(registration.getEmailValidation())) { errors.reject("email.validation.failed", "Email and Email Validation aren't equal."); }/* w ww. j a va2 s . com*/ } if (registration.getPassword() != null && registration.getPasswordValidation() != null) { if (!registration.getPassword().equals(registration.getPasswordValidation())) { errors.reject("password.validation.failed", "Password and Password Validation aren't equal."); } } }
From source file:fi.koku.kks.model.Creation.java
@Override public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "NotEmpty.creation.name"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "field", "NotEmpty.creation.field"); }
From source file:org.tsm.concharto.web.spotlight.SpotlightValidator.java
public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "link", "empty.spotlight.link"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "label", "empty.spotlight.label"); }
From source file:fm.last.citrine.web.TaskDTOValidator.java
@Override public void validate(Object object, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "task.groupName", "group.empty"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "task.name", "name.empty"); Task task = ((TaskDTO) object).getTask(); if (!StringUtils.isEmpty(task.getTimerSchedule())) { // if there is a timer schedule, check it is valid for quartz cron trigger try {/*from w w w . jav a 2 s . c om*/ new CronExpression(task.getTimerSchedule()); } catch (ParseException e) { errors.rejectValue("task.timerSchedule", "timer.schedule.invalid", e.getMessage()); } } if (task.getGroupName() != null && Constants.GROUP_NAME_ALL.equals(task.getGroupName().trim())) { errors.rejectValue("task.groupName", "group.illegal", Constants.GROUP_NAME_ALL + " not allowed as group name"); } }
From source file:de.berlios.jhelpdesk.web.tools.AnnouncementValidator.java
public void validate(Object announcement, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "title", "errors.announcement.title"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lead", "errors.announcement.lead"); }
From source file:de.berlios.jhelpdesk.web.tools.UserValidator.java
public void validate(Object user, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstName", "errors.hduser.firstName"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastName", "errors.hduser.lastName"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "login", "errors.hduser.login"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "errors.hduser.password"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "errors.hduser.email"); User u = (User) user;//from w w w.jav a 2 s . com String expression = "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$"; CharSequence inputStr = u.getEmail(); Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(inputStr); if (!matcher.matches()) { errors.rejectValue("email", "errors.hduser.email.invalid"); } if (u.getUserRole() == null) { errors.rejectValue("userRole", "errors.hduser.userRole.notset"); } }
From source file:org.tsm.concharto.web.edit.EventFormValidator.java
public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "summary", "empty.event.summary"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "when", "empty.event.when"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "geometry", "empty.event.geometry"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "source", "empty.event.source"); ValidationHelper.rejectIfTooLong(errors, "description", EventForm.SZ_DESCRIPTION, "tooLong"); //These should never trigger if the HTML is coded correctly ValidationHelper.rejectIfTooLong(errors, "summary", EventForm.SZ_SUMMARY, "tooLong"); ValidationHelper.rejectIfTooLong(errors, "tags", EventForm.SZ_TAGS, "tooLong"); ValidationHelper.rejectIfTooLong(errors, "where", EventForm.SZ_WHERE, "tooLong"); ValidationHelper.rejectIfTooLong(errors, "source", EventForm.SZ_SOURCE, "tooLong"); EventForm eventForm = (EventForm) target; if ((null != eventForm.getGeometry()) && (0 == eventForm.getGeometry().getNumPoints())) { errors.rejectValue("geometry", "empty.event.geometry"); }// ww w . j ava 2 s.com }
From source file:org.jasig.portlet.ClassifiedsPortlet.domain.SubmitCategoryFormValidator.java
public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "required.category"); Category form = (Category) target;/*from ww w. j a v a 2s. c o m*/ if (form.getName().length() > 36) { errors.rejectValue("name", "tolong.category"); } ; }