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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleansupports(Class<?> clazz, ContextInfo context) Whether or not this validator supports validating the given service classvoidvalidate(Object businessInstance, org.springframework.validation.Errors errors, ContextInfo context) Default validation that handles create, replace and update.voidvalidateForCreate(Object businessInstance, org.springframework.validation.Errors errors, ContextInfo context) Validate a new repositoryInstance being added based on its businessInstance representationvoidvalidateForReplace(Object businessInstance, org.springframework.validation.Errors errors, ContextInfo context) Validate a replacement for the repositoryInstance.voidvalidateForUpdate(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:EntityValidatorWhether or not this validator supports validating the given service class- Specified by:
supportsin 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:EntityValidatorDefault 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:
validatein 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:EntityValidatorValidate a new repositoryInstance being added based on its businessInstance representation- Specified by:
validateForCreatein 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:EntityValidatorValidate 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).updatedBusinessInstanceis not an object that just contains the requested changes.- Specified by:
validateForUpdatein 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:EntityValidatorValidate a replacement for the repositoryInstance. All fields in businessInstance are direct replacements for those in repositoryInstance- Specified by:
validateForReplacein 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
-