List of usage examples for org.springframework.validation ValidationUtils rejectIfEmptyOrWhitespace
public static void rejectIfEmptyOrWhitespace(Errors errors, String field, String errorCode)
From source file:org.tsm.concharto.web.login.LoginFormValidator.java
public void validate(Object target, Errors errors) { ((SignupForm) target).setFromController(SignupForm.FORM_LOGIN); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "empty.authForm.password"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "empty.authForm.username"); }
From source file:csns.web.validator.AnnouncementValidator.java
@Override public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "content", "error.field.required"); }
From source file:org.jasig.portlet.ClassifiedsPortlet.domain.SubmitHeadingFormValidator.java
public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "headingname", "required.headingname"); Heading form = (Heading) target;//from w w w . j a v a 2 s .c om if (form.getHeadingname().length() > 36) { errors.rejectValue("headingname", "tolong.heading"); } ; }
From source file:org.openmrs.module.patientflags.web.validators.FlagValidator.java
public void validate(Object target, Errors errors) { Flag flagToValidate = (Flag) target; // name cannot be empty ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "patientflags.errors.noName"); // criteria is no longer required, because of custom cases //ValidationUtils.rejectIfEmptyOrWhitespace(errors, "criteria", "patientflags.errors.noCriteria"); // make sure that the string fields aren't too large if (flagToValidate.getName().length() > 255) errors.rejectValue("name", "patientflags.errors.nameTooLong"); if (flagToValidate.getCriteria().length() > 5000) errors.rejectValue("criteria", "patientflags.errors.criteriaTooLong"); if (flagToValidate.getMessage().length() > 255) errors.rejectValue("message", "patientflags.errors.messageTooLong"); if (flagToValidate.getEvaluator() == null) { errors.rejectValue("evaluator", "patientflags.errors.noEvaluator"); } else {// w w w .j ava 2 s. c om // run the target Flag's validate method to see if the criteria is well-formed FlagValidationResult result = flagToValidate.validate(); if (!result.getResult()) { String message = result.getLocalizedMessage(); errors.reject(null, Context.getMessageSourceService().getMessage("patientflags.errors.invalidCriteria") + (message != null ? ": " + message : "")); } } }
From source file:org.openmrs.module.patientflags.web.validators.TagValidator.java
public void validate(Object target, Errors errors) { Tag targetTag = (Tag) target;// www. ja v a 2 s. c o m FlagService flagService = Context.getService(FlagService.class); // name and criteria cannot be empty ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "patientflags.errors.noTag"); // make sure that the tag field isn't too large if (targetTag.getName().length() > 255) errors.rejectValue("name", "patientflags.errors.tagTooLong"); // if this is a new tag, make sure that a tag with the same name doesn't already exist // TODO this doesn't stop you from changing the name of tag to the identical name of another tag if (targetTag.getId() == null) { List<Tag> tags = flagService.getAllTags(); if (tags != null) { for (Tag tag : tags) { if (tag.getName().equalsIgnoreCase(targetTag.getName())) { errors.rejectValue("tag", "patientflags.errors.tagNameExists"); break; } } } } }
From source file:csns.web.validator.MFTScoreImporterValidator.java
@Override public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "date", "error.field.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "text", "error.field.required"); }
From source file:it.f2informatica.core.validator.ConsultantEducationValidator.java
@Override public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "school", FIELD_MANDATORY); doFurtherValidations(target, errors); }
From source file:it.f2informatica.core.validator.RoleModelValidator.java
@Override public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "roleId", "err.required"); }
From source file:it.f2informatica.core.validator.ConsultantPersonalDetailsValidator.java
@Override public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "consultantNo", FIELD_MANDATORY); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "fiscalCode", FIELD_MANDATORY); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", FIELD_MANDATORY); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstName", FIELD_MANDATORY); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastName", FIELD_MANDATORY); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "gender", FIELD_MANDATORY); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "birthDate", FIELD_MANDATORY); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "birthCity", FIELD_MANDATORY); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "birthCountry", FIELD_MANDATORY); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "birthDate", FIELD_MANDATORY); }
From source file:org.openmrs.module.facilitydata.validator.BaseFacilityMetadataValidator.java
/** * @see Validator#validate(Object, Errors) *///from w w w .ja v a2s . co m public void validate(Object o, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.null"); }