Decimal Attributes

Attribute type idType specific restriction parameters
decimalminValue: Minimum decimal value (inclusive)
maxValue: Maximum decimal value (inclusive)
minDecimal: The minimum length (inclusive) of integer part (digits left of decimal point)
maxDecimal: The maximum length (inclusive) of integer part (digits left of decimal point)
minFraction: The minimum length (inclusive) of fractional part (digit right of decimal point)
maxFraction: The maximum length (inclusive) of fractional part (digit right of decimal point)
maxDigits: Maximum length of decimal and fraction part (without “.” - inclusive)
patterns: List of patters that the value must match (Java Pattern). Values has to match all the patters. Pattern is only matched against the attribute value - without unit.
units: List of possible units to use (units have to be defined in unitsOfMeasure section of datastandard)

📘

All restrictions are validated in provided order.

Attribute validation will fail on the first unfulfilled restriction.

Code Examples:

{
  "id" : "WRENCH_HEAD_SIZE_MM",
  "name" : "Wrench Head Size (mm)",
  "type" : {
    "id" : "decimal",
    "restriction" : {
      "parameters" : {
        "minValue" : "0.5",
        "minDecimal" : "0",
        "maxValue" : "99",
        "maxFraction" : "1",
        "maxDecimal" : "2",
        "maxDigits" : "3",
        "minFraction" : "0"
      }
    }
  }
}
Attribute decimalAttribute = AttributeBuilder
        .decimalAttribute("WRENCH_HEAD_SIZE_MM", "Wrench Head Size (mm)")
        .withMinValue(new BigDecimal("0.5"))
        .withMaxValue(new BigDecimal(99))
        .withMinFraction(0)
        .withMaxFraction(1)
        .withMinDecimal(0)
        .withMaxDecimal(2)
        .withMaxDigits(3)
        .build();