Interface IDatabaseLengthValidationConfiguration

All Known Implementing Classes:
DefaultDatabaseLengthValidationConfiguration

public interface IDatabaseLengthValidationConfiguration
Configuration for the DatabaseLengthValidation.
  • Method Details

    • getLocale

      Locale getLocale()
      Returns the locale to be used for validation messages.
      Returns:
      the locale to be used for validation messages
    • getTechnicalConstraintViolationMarker

      @CheckForNull IMarker getTechnicalConstraintViolationMarker()
      Returns the marker to be used for validation messages.
      Returns:
      the marker to be used for validation messages
    • getStringLengthConstraint

      @CheckForNull StringLengthConstraint getStringLengthConstraint()
      Returns the constraint to be used to validate String attributes.
      Returns:
      the constraint to be used to validate String attributes
    • getNumericConstraint

      @CheckForNull NumericConstraint getNumericConstraint(Class<? extends Number> numericDatatype)
      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

      default boolean shouldValidate(PolicyAttribute policyAttribute, IModelObject modelObject)
      Decides whether the given PolicyAttribute should be validated for the given IModelObject.
      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 attribute
      modelObject - the model object instance on which the attribute may be validated
      Returns:
      whether validation for the given combination of PolicyAttribute and IModelObject should 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 configured StringLengthConstraint.
      Parameters:
      attribute - the model type reference for the validated attribute
      modelObject - the model object instance on which the attribute was validated
      actualLength - the actual value's length in bytes according to the Charset used in the constraint
      lengthLimit - 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 configured NumericConstraint`s precision.
      Parameters:
      attribute - the model type reference for the validated attribute
      modelObject - the model object instance on which the attribute was validated
      actualPrecision - the actual value's length in digits
      precisionLimit - 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 configured NumericConstraint`s scale.
      Parameters:
      attribute - the model type reference for the validated attribute
      modelObject - the model object instance on which the attribute was validated
      actualScale - the actual value's amount of decimal places
      scaleLimit - the exceeded limit, set in the constraint