Package org.faktorips.runtime.validation
Interface IDatabaseLengthValidationConfiguration
- All Known Implementing Classes:
DefaultDatabaseLengthValidationConfiguration
public interface IDatabaseLengthValidationConfiguration
Configuration for the
DatabaseLengthValidation.-
Method Summary
Modifier and TypeMethodDescriptioncreateMessageForPrecisionViolation(PolicyAttribute attribute, IModelObject modelObject, Class<? extends Number> numericDatatype, int actualPrecision, int precisionLimit) Creates a message to indicate that the given attribute's value on the given model object exceeds the configuredNumericConstraint`sprecision.createMessageForScaleViolation(PolicyAttribute attribute, IModelObject modelObject, Class<? extends Number> numericDatatype, int actualScale, int scaleLimit) Creates a message to indicate that the given attribute's value on the given model object exceeds the configuredNumericConstraint`sscale.createMessageForStringLengthViolation(PolicyAttribute attribute, IModelObject modelObject, int actualLength, int lengthLimit) Creates a message to indicate that the given attribute's value on the given model object exceeds the configuredStringLengthConstraint.Returns the locale to be used for validation messages.getNumericConstraint(Class<? extends Number> numericDatatype) Returns the constraint to be used to validate numeric attributes of the given type.Returns the constraint to be used to validate String attributes.Returns the marker to be used for validation messages.default booleanshouldValidate(PolicyAttribute policyAttribute, IModelObject modelObject) Decides whether the givenPolicyAttributeshould be validated for the givenIModelObject.
-
Method Details
-
getLocale
Locale getLocale()Returns the locale to be used for validation messages.- Returns:
- the locale to be used for validation messages
-
getTechnicalConstraintViolationMarker
Returns the marker to be used for validation messages.- Returns:
- the marker to be used for validation messages
-
getStringLengthConstraint
Returns the constraint to be used to validate String attributes.- Returns:
- the constraint to be used to validate String attributes
-
getNumericConstraint
Returns the constraint to be used to validate numeric attributes of the given type.- Parameters:
numericDatatype- a (wrapper) class used for numeric values - primitive types should not be used and are validated with the same settings as their wrapper types.- Returns:
- the constraint to be used to validate numeric attributes of the given type
-
shouldValidate
Decides whether the givenPolicyAttributeshould be validated for the givenIModelObject.- Implementation Requirements:
- Implementers should use this to prevent validation of fields that allow values exceeding the configured limits, for example because they are only transitive and not persisted.
- Parameters:
policyAttribute- the model type reference for the validated attributemodelObject- the model object instance on which the attribute may be validated- Returns:
- whether validation for the given combination of
PolicyAttributeandIModelObjectshould run
-
createMessageForStringLengthViolation
Message createMessageForStringLengthViolation(PolicyAttribute attribute, IModelObject modelObject, int actualLength, int lengthLimit) Creates a message to indicate that the given attribute's value on the given model object exceeds the configuredStringLengthConstraint.- Parameters:
attribute- the model type reference for the validated attributemodelObject- the model object instance on which the attribute was validatedactualLength- the actual value's length in bytes according to theCharsetused in the constraintlengthLimit- the exceeded limit, set in the constraint
-
createMessageForPrecisionViolation
Message createMessageForPrecisionViolation(PolicyAttribute attribute, IModelObject modelObject, Class<? extends Number> numericDatatype, int actualPrecision, int precisionLimit) Creates a message to indicate that the given attribute's value on the given model object exceeds the configuredNumericConstraint`sprecision.- Parameters:
attribute- the model type reference for the validated attributemodelObject- the model object instance on which the attribute was validatedactualPrecision- the actual value's length in digitsprecisionLimit- the exceeded limit, set in the constraint
-
createMessageForScaleViolation
Message createMessageForScaleViolation(PolicyAttribute attribute, IModelObject modelObject, Class<? extends Number> numericDatatype, int actualScale, int scaleLimit) Creates a message to indicate that the given attribute's value on the given model object exceeds the configuredNumericConstraint`sscale.- Parameters:
attribute- the model type reference for the validated attributemodelObject- the model object instance on which the attribute was validatedactualScale- the actual value's amount of decimal placesscaleLimit- the exceeded limit, set in the constraint
-