Class BeanValidationEntityValidatorServiceImpl

java.lang.Object
org.broadleafcommerce.openadmin.server.service.persistence.validation.EntityValidatorServiceImpl
org.broadleafcommerce.openadmin.server.service.persistence.validation.BeanValidationEntityValidatorServiceImpl
All Implemented Interfaces:
EntityValidatorService

public class BeanValidationEntityValidatorServiceImpl extends EntityValidatorServiceImpl

Implementation of the EntityValidatorService that runs entities through JSR-303 validations. The default behavior of this implementation is to use the out-of-the-box Broadleaf validations (through ValidationConfiguration in addition to any JSR-303 annotations that you have configured on your entity.

In order to use this validator rather than the default, you will need to include an implementation of Validator in your Spring root application context (not the servlet). For example, you would modify your applicationContext-admin.xml to inject Spring's default implementation of Validator (the one used by Spring MVC):

 <bean class=&quotorg.springframework.validation.beanvalidation.LocalValidatorFactoryBean&quot/>
 
Then override the the blEntityValidatorService bean to use this class instead:
 <bean id=&quotblEntityValidatorService&quot
        class=&quotorg.broadleafcommerce.openadmin.server.service.persistence.validation.BeanValidationEntityValidatorServiceImpl&quot/>
 

For more information on the default Spring JSR-303 validator, check out the docs at

Author:
Phillip Verheyden
See Also:
  • Field Details

    • validator

      @Autowired protected jakarta.validation.Validator validator
    • useDefaultEntityValidations

      protected boolean useDefaultEntityValidations
      If true (default behavior) this will invoke the default implementation to perform validations hooked up via ValidationConfiguration from AdminPresentation.
  • Constructor Details

    • BeanValidationEntityValidatorServiceImpl

      public BeanValidationEntityValidatorServiceImpl()
  • Method Details

    • validate

      public void validate(Entity entity, Serializable instance, Map<String,FieldMetadata> mergedProperties, RecordHelper recordHelper, boolean validateUnsubmittedProperties)
      Description copied from interface: EntityValidatorService
      Validate the given entity. Implementers should set Entity.setValidationFailure(boolean) appropriately. Validation is invoked after the entire instance has been populated according to BasicPersistenceModule.createPopulatedInstance(Serializable, Entity, Map, Boolean).
      Specified by:
      validate in interface EntityValidatorService
      Overrides:
      validate in class EntityValidatorServiceImpl
      Parameters:
      entity - DTO representation of instance
      instance - actual domain representation of submittedEntity. If this is null, all PropertyValidators will be skipped, as this instance type is consulted to match whether or not the properties from propertiesMetadata are applicable and should be validated
      mergedProperties - all of the merged properties metadata for the given Entity
      validateUnsubmittedProperties - if set to true, will ignore validation for properties that weren't submitted along with the entity
    • getValidator

      public jakarta.validation.Validator getValidator()
    • setValidator

      public void setValidator(jakarta.validation.Validator validator)
    • isUseDefaultEntityValidations

      public boolean isUseDefaultEntityValidations()
    • setUseDefaultEntityValidations

      public void setUseDefaultEntityValidations(boolean useDefaultEntityValidations)