/** * Validate current property value(s) and report any validation problems via the * {@link PropertyValidation} that is returned. * * @return {@link PropertyValidation} containing validation errors if found. */ public PropertyValidation validate() { PropertyValidation errors = PropertyValidation.createFor(this); validate(errors); return errors; }
/** * Check if the property would have validation errors if given value would be set. * * @param value * Value to check for. * @return {@link PropertyValidation} with errors if ones exist. */ protected PropertyValidation validateForValue(T value) { PropertyValidation propertyValidation = PropertyValidation.createFor(this); if (CollectionUtils.isNotEmpty(validators)) { for (ISinglePropertyValidator<? super T> validator : validators) { validator.validateForValue(this, propertyValidation, value); } } return propertyValidation; }
/** * Validates with the group validators this property, based on the changes of the single * properties reported by update list. * * @param propertyUpdates * Information about updates. * @throws PropertyValidationException * If validation fails. */ public void validateForPropertiesUpdate(Collection<IPropertyUpdate<?>> propertyUpdates) throws PropertyValidationException { PropertyValidation propertyValidation = PropertyValidation.createFor(this); for (IGroupedProperyValidator groupedProperyValidator : validators) { groupedProperyValidator.validateForPropertyUpdates(this, propertyUpdates, propertyValidation); } // if has errors raise exception, otherwise create property update if (propertyValidation.hasErrors()) { throw new PropertyValidationException(propertyValidation); } }