Integer Attributes
Attribute type id | Type specific restriction parameters |
---|---|
integer | minValue: Minimum integer value (inclusive) |
maxValue: Maximum integer value (inclusive) | |
maxDigits: Maximum string length | |
patterns: List of patterns 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" : "WIDTH",
"name" : "Width",
"type" : {
"id" : "integer",
"restriction" : {
"parameters" : {
"minValue" : "0",
"maxValue" : "999999999",
"maxDigits" : "9"
},
"patterns" : [ {
"pattern" : "1\\d*",
"message" : "Value has to start with 1."
} ]
},
"units" : [ "CM", "INCH" ]
}
}
Attribute integerAttribute = AttributeBuilder
.integerAttribute("WIDTH", "Width")
.withMinValue(0)
.withMaxValue(999999999)
.withMaxDigits(9)
.withUnits(List.of(UnitOfMeasureBuilder.regularUnitOfMeasure("CM", "cm").build(),
UnitOfMeasureBuilder.regularUnitOfMeasure("INCH", "inch").build()))
.withPattern(Pattern.compile("1\\d*"), "Value has to start with 1.")
.build();
Updated over 1 year ago