Class EntityValidatorManager
- java.lang.Object
-
- com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidatorManager
-
- All Implemented Interfaces:
EntityValidator
public class EntityValidatorManager extends Object implements EntityValidator
Given multipleEntityValidator
, runs through validations of each of them. This is the main avenue by which validation happens in theCrudEntityHelper
.- Author:
- Phillip Verheyden (phillipuniverse)
-
-
Constructor Summary
Constructors Constructor Description EntityValidatorManager(List<EntityValidator> validators)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
supports(Class<?> clazz, ContextInfo context)
Whether or not this validator supports validating the given service classvoid
validate(Object businessInstance, org.springframework.validation.Errors errors, ContextInfo context)
Default validation that handles create, replace and update.void
validateForCreate(Object businessInstance, org.springframework.validation.Errors errors, ContextInfo context)
Validate a new repositoryInstance being added based on its businessInstance representationvoid
validateForReplace(Object businessInstance, org.springframework.validation.Errors errors, ContextInfo context)
Validate a replacement for the repositoryInstance.void
validateForUpdate(Object updatedBusinessInstance, org.springframework.validation.Errors errors, ContextInfo context)
Validate an update to a repositoryInstance based upon the business representation of the result of applying the update.
-
-
-
Constructor Detail
-
EntityValidatorManager
public EntityValidatorManager(List<EntityValidator> validators)
-
-
Method Detail
-
supports
public boolean supports(Class<?> clazz, ContextInfo context)
Description copied from interface:EntityValidator
Whether or not this validator supports validating the given service class- Specified by:
supports
in interfaceEntityValidator
- Parameters:
clazz
- thecontext
- what context this validator is running in- Returns:
- whether or not this validator should be executed
-
validate
public void validate(@NonNull Object businessInstance, @NonNull org.springframework.validation.Errors errors, ContextInfo context)
Description copied from interface:EntityValidator
Default validation that handles create, replace and update. This is invoked by default by each individual lifecycle method and is available as a simple override point for global validation that should apply to all contexts.
- Specified by:
validate
in interfaceEntityValidator
- Parameters:
businessInstance
- representation of the repositoryInstanceerrors
- holder for validation context information. When adding field validation errors, the field names should be in the context of the businessInstancecontext
- current context this validation is running in
-
validateForCreate
public void validateForCreate(@NonNull Object businessInstance, @NonNull org.springframework.validation.Errors errors, ContextInfo context)
Description copied from interface:EntityValidator
Validate a new repositoryInstance being added based on its businessInstance representation- Specified by:
validateForCreate
in interfaceEntityValidator
- Parameters:
businessInstance
- representation of the repositoryInstance being used to createerrors
- holder for validation context information. When adding field validation errors, the field names should be in the context of the businessInstancecontext
- current context this validation is running in
-
validateForUpdate
public void validateForUpdate(@NonNull Object updatedBusinessInstance, @NonNull org.springframework.validation.Errors errors, ContextInfo context)
Description copied from interface:EntityValidator
Validate an update to a repositoryInstance based upon the business representation of the result of applying the update.Note that this method validates
updatedBusinessInstance
, which is the businessInstance representation of the repositoryInstance after applying the requested changes (but before persisting them).updatedBusinessInstance
is not an object that just contains the requested changes.- Specified by:
validateForUpdate
in interfaceEntityValidator
- Parameters:
updatedBusinessInstance
- the business representation of the result of applying some updates to an existing repositoryInstanceerrors
- holder for validation context information. When adding field validation errors, the field names should be in the context of the updatedBusinessInstancecontext
- current context this validation is running in
-
validateForReplace
public void validateForReplace(@NonNull Object businessInstance, @NonNull org.springframework.validation.Errors errors, ContextInfo context)
Description copied from interface:EntityValidator
Validate a replacement for the repositoryInstance. All fields in businessInstance are direct replacements for those in repositoryInstance- Specified by:
validateForReplace
in interfaceEntityValidator
- Parameters:
businessInstance
- representation of the repositoryInstance being used as a replacementerrors
- holder for validation context information. When adding field validation errors, the field names should be in the context of the businessInstancecontext
- current context this validation is running in
-
-