Class EntityValidatorManager
java.lang.Object
com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidatorManager
- All Implemented Interfaces:
EntityValidator
Given multiple
EntityValidator
, runs through validations of each of them. This is the
main avenue by which validation happens in the CrudEntityHelper
.- Author:
- Phillip Verheyden (phillipuniverse)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
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 Details
-
EntityValidatorManager
-
-
Method Details
-
supports
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
-