Class RegexPropertyValidator
java.lang.Object
org.broadleafcommerce.openadmin.server.service.persistence.validation.ValidationConfigurationBasedPropertyValidator
org.broadleafcommerce.openadmin.server.service.persistence.validation.RegexPropertyValidator
- All Implemented Interfaces:
PropertyValidator
@Component("blRegexPropertyValidator")
public class RegexPropertyValidator
extends ValidationConfigurationBasedPropertyValidator
Validates a field against a configured 'regularExpression' item
- Author:
- Phillip Verheyden
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ExploitProtectionServiceprotected static final org.apache.commons.logging.Logprotected booleanWhether or not this validator should succeed (and thus pass validation) even when the configured regular expression pattern is invalid.protected booleanDenotes what should occur when this validator encounters a null value to validate against. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ExploitProtectionServicebooleanbooleanvoidsetSucceedForInvalidRegex(boolean succeedForInvalidRegex) voidsetSucceedForNullValues(boolean succeedForNullValues) 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 -
succeedForNullValues
protected boolean succeedForNullValuesDenotes what should occur when this validator encounters a null value to validate against. Default behavior is to allow them, which means that this validator will always return true with null values -
succeedForInvalidRegex
protected boolean succeedForInvalidRegexWhether or not this validator should succeed (and thus pass validation) even when the configured regular expression pattern is invalid. While this value defaults to true, it might be beneficial to set this to false in a development environment to debug problems in regular expressions. In either case, this validator will log that there is an invalid regular expression -
exploitProtectionService
-
-
Constructor Details
-
RegexPropertyValidator
public RegexPropertyValidator()
-
-
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.
-
initExploitProtectionService
- Throws:
ServiceException
-
isSucceedForNullValues
public boolean isSucceedForNullValues() -
setSucceedForNullValues
public void setSucceedForNullValues(boolean succeedForNullValues) -
isSucceedForInvalidRegex
public boolean isSucceedForInvalidRegex() -
setSucceedForInvalidRegex
public void setSucceedForInvalidRegex(boolean succeedForInvalidRegex)
-