public interface EntityValidatorService
BasicPersistenceModule#createPopulatedInstance(Serializable, Entity, Map, Boolean)}
|Modifier and Type||Method and Description|
Set the global validators that will be run on every entity that is attempted to be saved in the admin.
Validate the given entity.
void validate(Entity submittedEntity, @Nonnull Serializable instance, Map<String,FieldMetadata> propertiesMetadata, RecordHelper recordHelper, boolean validateUnsubmittedProperties)
Entity.setValidationFailure(boolean)appropriately. Validation is invoked after the entire instance has been populated according to
BasicPersistenceModule.createPopulatedInstance(Serializable, Entity, Map, Boolean).
entity- DTO representation of instance
instance- actual domain representation of submittedEntity. If this is null, all
PropertyValidators will be skipped, as this instance type is consulted to match whether or not the properties from propertiesMetadata are applicable and should be validated
propertiesMetadata- all of the merged properties metadata for the given
validateUnsubmittedProperties- if set to true, will ignore validation for properties that weren't submitted along with the entity
void setGlobalEntityValidators(List<GlobalPropertyValidator> globalEntityValidators)
Set the global validators that will be run on every entity that is attempted to be saved in the admin. Global
validators are useful to operate on things like field types and other scenarios that could occur with a number of
entities. Rather than being required to define a
ValidationConfiguration on all of those properties, this
can more conveniently validate that set of properties.
An example of a global validator in Broadleaf is the
RequiredPropertyValidator which will ensure that every
property that is marked as required will fail validation if a value is unset.
globalEntityValidators- the globalEntityValidators to set
Copyright © 2019. All rights reserved.