Interface EntityValidator
- All Known Implementing Classes:
EntityValidatorManager
,RuleValidatorManager
Validator used prior to mapping via the DomainMapperManager
. Modeled very similarly after
Spring's Validator
except with an additional ContextInfo
along with explicit
invocations for create/update/replace used in the CrudEntityHelper
.
To use EntityValidator
in contexts outside of the CrudEntityHelper
, consider
injecting the EntityValidatorManager
instead, which has a group of
EntityValidator
instances inside of it.
- Author:
- Phillip Verheyden (phillipuniverse)
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
supports
(Class<?> serviceClass, ContextInfo context) Whether or not this validator supports validating the given service classdefault void
validate
(Object businessInstance, org.springframework.validation.Errors errors, ContextInfo context) Default validation that handles create, replace and update.default void
validateForCreate
(Object businessInstance, org.springframework.validation.Errors errors, ContextInfo context) Validate a new repositoryInstance being added based on its businessInstance representationdefault void
validateForReplace
(Object businessInstance, org.springframework.validation.Errors errors, ContextInfo context) Validate a replacement for the repositoryInstance.default 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.
-
Method Details
-
supports
Whether or not this validator supports validating the given service class- Parameters:
serviceClass
- thecontext
- what context this validator is running in- Returns:
- whether or not this validator should be executed
-
validate
default void validate(@NonNull Object businessInstance, @NonNull org.springframework.validation.Errors errors, ContextInfo context) 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.
- 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
default void validateForCreate(@NonNull Object businessInstance, @NonNull org.springframework.validation.Errors errors, ContextInfo context) Validate a new repositoryInstance being added based on its businessInstance representation- 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
default void validateForUpdate(@NonNull Object updatedBusinessInstance, @NonNull 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.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.- 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
default void validateForReplace(@NonNull Object businessInstance, @NonNull org.springframework.validation.Errors errors, ContextInfo context) Validate a replacement for the repositoryInstance. All fields in businessInstance are direct replacements for those in repositoryInstance- 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
-