Class ValidationConfigurationBasedPropertyValidator

java.lang.Object
org.broadleafcommerce.openadmin.server.service.persistence.validation.ValidationConfigurationBasedPropertyValidator
All Implemented Interfaces:
PropertyValidator
Direct Known Subclasses:
AdminRegexValidator, AfterStartDateValidator, CronExpressionValidator, GreaterThanMinValueValidator, MatchesFieldValidator, MaxGreaterThanMinValidator, RegexPropertyValidator, RequiredIfPropertyValidator, SandBoxNameValidator, SkuNamePropertyValidator, UriPropertyValidator

public abstract class ValidationConfigurationBasedPropertyValidator extends Object implements PropertyValidator
Provides a default validate method that uses the validation configuration map to pull out the error key and pre-populate the PropertyValidationResult based on ConfigurationItem.ERROR_MESSAGE.

This class should be used as your base if you are writing a validator based on a ValidationConfiguration

Author:
Phillip Verheyden (phillipuniverse)
  • Constructor Details

    • ValidationConfigurationBasedPropertyValidator

      public ValidationConfigurationBasedPropertyValidator()
  • Method Details

    • validate

      public PropertyValidationResult validate(Entity entity, Serializable instance, Map<String,FieldMetadata> entityFieldMetadata, Map<String,String> validationConfiguration, BasicFieldMetadata propertyMetadata, String propertyName, String value)
      Description copied from interface: PropertyValidator
      Validates a property for an entity
      Specified by:
      validate in interface PropertyValidator
      Parameters:
      entity - Entity DTO of the entity attempting to save
      instance - actual object representation of entity. This can be cast to entity interfaces (like Sku or Product)
      entityFieldMetadata - complete field metadata for all properties in entity
      validationConfiguration - the map represented by the set of ConfigurationItem for a ValidationConfiguration on a property. This map could be null if this PropertyValidator is being invoked outside of the context of a particular property (like a global validator)
      propertyMetadata - BasicFieldMetadata corresponding to the property that is being valid
      propertyName - the property name of the value attempting to be saved (could be a sub-entity obtained via dot notation like 'defaultSku.name')
      value - the value attempted to be saved
      Returns:
      true if this passes validation, false otherwise.
    • validateInternal

      public boolean validateInternal(Entity entity, Serializable instance, Map<String,FieldMetadata> entityFieldMetadata, Map<String,String> validationConfiguration, BasicFieldMetadata propertyMetadata, String propertyName, String value)
      Delegate method for ValidationConfiguration-based processors that don't need to return an error message