Class SimpleCharacteristicValueValidator
java.lang.Object
com.broadleafcommerce.catalog.service.validation.characteristic.SimpleCharacteristicValueValidator
- All Implemented Interfaces:
CharacteristicValueValidator
public class SimpleCharacteristicValueValidator
extends Object
implements CharacteristicValueValidator
An implementation of
CharacteristicValueValidator that handles validation for simple
CharacteristicValue.valueTypes, such as
BOOLEAN or
STRING.
Simple CharacteristicValue.valueTypes are identified as
"simple" because they are expected to be one-to-one matches to their parent
Characteristic.valueType.
- Since:
- Catalog Service 2.2.0, Release Train 2.2.0
- Author:
- Julia Lopez-Pozas (jlopezpozas)
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleCharacteristicValueValidator(List<String> nonSimpleCharacteristicValueTypes, List<String> simpleCharacteristicValueValueTypes) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddInvalidCVValueForCVValueTypeError(org.springframework.validation.Errors errors, String charValueValue, String charValueValueType) Method to add a validation error when the characteristic value's value does not match its value type.booleancanHandle(@NonNull CharacteristicValue characteristicValue, Characteristic characteristic) Checks if this Validator can handle validation for the givenCharacteristicValue.valueType.The list ofCharacteristic.valueTypesthis Validator does not handle.List of simpleCharacteristicValue.valueTypesthat match theCharacteristic.valueTypesthis validator handles.voidvalidate(@NonNull CharacteristicValue characteristicValue, @NonNull org.springframework.validation.Errors errors, Characteristic characteristic) Validates that eachCharacteristicValue.valuematches itsCharacteristicValue.valueType, along with someDefaultCharacteristicValueValueTypespecific validation forCharacteristicValues.
-
Constructor Details
-
SimpleCharacteristicValueValidator
-
-
Method Details
-
canHandle
public boolean canHandle(@NonNull @NonNull CharacteristicValue characteristicValue, @Nullable Characteristic characteristic) Description copied from interface:CharacteristicValueValidatorChecks if this Validator can handle validation for the givenCharacteristicValue.valueType.- Specified by:
canHandlein interfaceCharacteristicValueValidator- Parameters:
characteristicValue- theCharacteristicValueobject to check against this Validator's expectedCharacteristic.valueTypes.characteristic- theCharacteristicobject to check against this Validator's expectedCharacteristic.valueType. Can be null if the Validator has no need for theCharacteristic, likeSimpleCharacteristicValueValidator- Returns:
- true if this Validator handles validation for the
Characteristic.valueof thisCharacteristic.valueType, false if not
-
validate
public void validate(@NonNull @NonNull CharacteristicValue characteristicValue, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable Characteristic characteristic) Description copied from interface:CharacteristicValueValidatorValidates that eachCharacteristicValue.valuematches itsCharacteristicValue.valueType, along with someDefaultCharacteristicValueValueTypespecific validation forCharacteristicValues.- Specified by:
validatein interfaceCharacteristicValueValidator- Parameters:
characteristicValue- The product characteristic value to validateerrors- Holder for validation context informationcharacteristic- The product characteristic that can be used for validation, if necessary
-
addInvalidCVValueForCVValueTypeError
protected void addInvalidCVValueForCVValueTypeError(org.springframework.validation.Errors errors, String charValueValue, String charValueValueType) Method to add a validation error when the characteristic value's value does not match its value type.- Parameters:
errors- Holder for validation context informationcharValueValue- The characteristic value's valuecharValueValueType- The characteristic value's value type
-
getSimpleCharacteristicValueValueTypes
List of simpleCharacteristicValue.valueTypesthat match theCharacteristic.valueTypesthis validator handles. -
getNonSimpleCharacteristicValueTypes
The list ofCharacteristic.valueTypesthis Validator does not handle.
-