Package org.faktorips.runtime.validation
Class GenericRelevanceValidation
java.lang.Object
org.faktorips.runtime.validation.GenericRelevanceValidation
Class for validating the attribute relevance and value range.
- Since:
- 21.6
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionGenericRelevanceValidation
(IModelObject modelObject, Class<? extends IModelObject> definingModelObjectClass, PolicyAttribute policyAttribute, IGenericAttributeValidationConfiguration config) -
Method Summary
Modifier and TypeMethodDescriptionstatic MessageList
of
(IModelObject modelObject, Class<? extends IModelObject> definingModelObjectClass, String propertyName, IValidationContext validationContext) Creates aGenericRelevanceValidation
for the given model object's attribute using the validation context toget
theIGenericAttributeValidationConfiguration
andvalidates
the attribute.validate()
Checks the attribute for the following violations: Mandatory violation: The attribute is aRelevance.MANDATORY
field and the value is missing.
-
Constructor Details
-
GenericRelevanceValidation
public GenericRelevanceValidation(IModelObject modelObject, Class<? extends IModelObject> definingModelObjectClass, PolicyAttribute policyAttribute, IGenericAttributeValidationConfiguration config)
-
-
Method Details
-
of
public static MessageList of(IModelObject modelObject, Class<? extends IModelObject> definingModelObjectClass, String propertyName, IValidationContext validationContext) Creates aGenericRelevanceValidation
for the given model object's attribute using the validation context toget
theIGenericAttributeValidationConfiguration
andvalidates
the attribute.- Parameters:
modelObject
- the model object to validatepropertyName
- the name of aPolicyAttribute
of the model objectvalidationContext
- the context containing information on what to validate and how to create error messages- Returns:
- the messages resulting from the validation, if any, or an empty message list if
validation was successful (or not performed because of
IGenericAttributeValidationConfiguration.shouldValidate(PolicyAttribute, IModelObject)
returningfalse
-
validate
Checks the attribute for the following violations:- Mandatory violation: The attribute is a
Relevance.MANDATORY
field and the value is missing. - Irrelevant violation: The value set is empty(
Relevance.IRRELEVANT
), so the attribute cannot have a value. - Value set violation: The attribute contains a value that is not part of the value set.
- Returns:
- A MessageList with the validation results
- Mandatory violation: The attribute is a
-