Class RequiredIfPropertyValidator
java.lang.Object
org.broadleafcommerce.openadmin.server.service.persistence.validation.ValidationConfigurationBasedPropertyValidator
org.broadleafcommerce.openadmin.server.service.persistence.validation.RequiredIfPropertyValidator
- All Implemented Interfaces:
PropertyValidator
@Component("blRequiredIfPropertyValidator")
public class RequiredIfPropertyValidator
extends ValidationConfigurationBasedPropertyValidator
Makes a field required if the value of another field matches another value.
Designed for use where selecting a radio makes another field required.
This validator supports two approaches. For both approaches, use compareField to indicate the property name you want to compare ...
To compare against a specific value, also provide a "compareFieldValue" attribute.
To compare against a specific fieldName, also provide a "compareFieldName" attribute
- Author:
- Brian Polster
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringlookupCompareFieldName(String currentFieldName, Map<String, String> validationConfiguration) validate(Entity entity, Serializable instance, Map<String, FieldMetadata> entityFieldMetadata, Map<String, String> validationConfiguration, BasicFieldMetadata propertyMetadata, String propertyName, String value) Validates a property for an entityMethods inherited from class org.broadleafcommerce.openadmin.server.service.persistence.validation.ValidationConfigurationBasedPropertyValidator
validateInternal
-
Field Details
-
LOG
protected static final org.apache.commons.logging.Log LOG
-
-
Constructor Details
-
RequiredIfPropertyValidator
public RequiredIfPropertyValidator()
-
-
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:PropertyValidatorValidates a property for an entity- Specified by:
validatein interfacePropertyValidator- Overrides:
validatein classValidationConfigurationBasedPropertyValidator- Parameters:
entity- Entity DTO of the entity attempting to saveinstance- actual object representation of entity. This can be cast to entity interfaces (like Sku or Product)entityFieldMetadata- complete field metadata for all properties in entityvalidationConfiguration- the map represented by the set ofConfigurationItemfor aValidationConfigurationon a property. This map could be null if thisPropertyValidatoris being invoked outside of the context of a particular property (like a global validator)propertyMetadata-BasicFieldMetadatacorresponding to the property that is being validpropertyName- 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.
-
lookupCompareFieldName
-