Class DefaultBundleProductTypeValidator
java.lang.Object
com.broadleafcommerce.catalog.service.validation.product.type.DefaultBundleProductTypeValidator
- All Implemented Interfaces:
ProductTypeValidator
The default product type validator that is used to validate the bundle products.
This validator validates that:
- The default price is not null
- The option with the type
DefaultProductOptionType.VARIANT_DISTINGUISHING
can't be added to aDefaultProductType.BUNDLE
product - The option with the type
DefaultProductOptionType.ITEM_CHOICE
and target typeDefaultItemChoiceTargetType.SPECIFIC_VARIANTS
can't be added to aDefaultProductType.BUNDLE
product
- Author:
- Dima Myroniuk (dmyroniuk)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canValidateCreate
(Product product) Whether or not this validator supports validation to create this product.boolean
canValidateReplace
(Product product, Product existingProduct) Whether or not this validator supports validation to replace this product.boolean
canValidateUpdate
(Product product, Product existingProduct) Whether or not this validator supports validation to update this product.protected void
validateBundleProductOptions
(Product product, String productType, org.springframework.validation.Errors errors) TheDefaultProductType.BUNDLE
product can't have theDefaultProductOptionType.VARIANT_DISTINGUISHING
options.protected void
validateProductFields
(Product product, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) void
validateProductForCreate
(Product product, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Validate the product for create.void
validateProductForReplace
(Product product, org.springframework.validation.Errors errors, Product existingProduct, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Validate the product for replace.void
validateProductForUpdate
(Product product, org.springframework.validation.Errors errors, Product existingProduct, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Validate the product for update.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.catalog.service.validation.product.type.ProductTypeValidator
validateDefaultPrice
-
Constructor Details
-
DefaultBundleProductTypeValidator
public DefaultBundleProductTypeValidator()
-
-
Method Details
-
canValidateCreate
Description copied from interface:ProductTypeValidator
Whether or not this validator supports validation to create this product.- Specified by:
canValidateCreate
in interfaceProductTypeValidator
- Parameters:
product
- the product to validate- Returns:
- true if this validator can validate the product creation
-
canValidateUpdate
Description copied from interface:ProductTypeValidator
Whether or not this validator supports validation to update this product.- Specified by:
canValidateUpdate
in interfaceProductTypeValidator
- Parameters:
product
- the product to validate- Returns:
- true if this validator can validate the product update
-
canValidateReplace
Description copied from interface:ProductTypeValidator
Whether or not this validator supports validation to replace this product.- Specified by:
canValidateReplace
in interfaceProductTypeValidator
- Parameters:
product
- the product to validate- Returns:
- true if this validator can validate the product replace
-
validateProductForCreate
public void validateProductForCreate(@NonNull Product product, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:ProductTypeValidator
Validate the product for create.- Specified by:
validateProductForCreate
in interfaceProductTypeValidator
- Parameters:
product
- the product to validateerrors
- holder for validation context information. When adding field validation errors, the field names should be in the context of the productcontext
- current context this validation is running in
-
validateProductForUpdate
public void validateProductForUpdate(@NonNull Product product, @NonNull org.springframework.validation.Errors errors, Product existingProduct, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:ProductTypeValidator
Validate the product for update.- Specified by:
validateProductForUpdate
in interfaceProductTypeValidator
- Parameters:
product
- the product to validateerrors
- holder for validation context information. When adding field validation errors, the field names should be in the context of the productexistingProduct
- the current product in the databasecontext
- current context this validation is running in
-
validateProductForReplace
public void validateProductForReplace(@NonNull Product product, @NonNull org.springframework.validation.Errors errors, @NonNull Product existingProduct, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:ProductTypeValidator
Validate the product for replace.- Specified by:
validateProductForReplace
in interfaceProductTypeValidator
- Parameters:
product
- the product to validateerrors
- holder for validation context information. When adding field validation errors, the field names should be in the context of the productexistingProduct
- the current product in the databasecontext
- current context this validation is running in
-
validateProductFields
protected void validateProductFields(Product product, org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) -
validateBundleProductOptions
protected void validateBundleProductOptions(Product product, String productType, org.springframework.validation.Errors errors) TheDefaultProductType.BUNDLE
product can't have theDefaultProductOptionType.VARIANT_DISTINGUISHING
options. If the option hasDefaultProductOptionType.ITEM_CHOICE
type, it can't have the item with theDefaultItemChoiceTargetType.SPECIFIC_VARIANTS
type.- Parameters:
product
- the product to validateproductType
- the type of the producterrors
- holder for validation context information. When adding field validation errors, the field names should be in the context of the product
-