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 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.boolean
canHandle
(@NonNull CharacteristicValue characteristicValue, Characteristic characteristic) Checks if this Validator can handle validation for the givenCharacteristicValue.valueType
.The list ofCharacteristic.valueTypes
this Validator does not handle.List of simpleCharacteristicValue.valueTypes
that match theCharacteristic.valueTypes
this validator handles.void
validate
(@NonNull CharacteristicValue characteristicValue, @NonNull org.springframework.validation.Errors errors, Characteristic characteristic) Validates that eachCharacteristicValue.value
matches itsCharacteristicValue.valueType
, along with someDefaultCharacteristicValueValueType
specific validation forCharacteristicValues
.
-
Constructor Details
-
SimpleCharacteristicValueValidator
-
-
Method Details
-
canHandle
public boolean canHandle(@NonNull @NonNull CharacteristicValue characteristicValue, @Nullable Characteristic characteristic) Description copied from interface:CharacteristicValueValidator
Checks if this Validator can handle validation for the givenCharacteristicValue.valueType
.- Specified by:
canHandle
in interfaceCharacteristicValueValidator
- Parameters:
characteristicValue
- theCharacteristicValue
object to check against this Validator's expectedCharacteristic.valueTypes
.characteristic
- theCharacteristic
object 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.value
of 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:CharacteristicValueValidator
Validates that eachCharacteristicValue.value
matches itsCharacteristicValue.valueType
, along with someDefaultCharacteristicValueValueType
specific validation forCharacteristicValues
.- Specified by:
validate
in 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.valueTypes
that match theCharacteristic.valueTypes
this validator handles. -
getNonSimpleCharacteristicValueTypes
The list ofCharacteristic.valueTypes
this Validator does not handle.
-