-
Notifications
You must be signed in to change notification settings - Fork 5
Attribute maxLen and minLen definition
Min/max string length of a PmAttr may be defined as follows:
A definition @PmAttrCfg(minLen=2, maxLen=5)
defines fix string length limits for the attribute.
If the PmAttr is bound to a bean field, it may re-use the @Size restriction of the bound field. Precondition for that feature:
-
The class of the bean that contains the bound field must be known. That information is provided if
a) the PmAttr parent is a kind of PmBean or
b)@PmAttrCfg(beanInfoClass=MyBean.class)
is specified. -
The bound field name must be known.
This is automatically ensured if the field is bound to a PmAttr having the same name or via@PmAttrCfg(valuePath="pmBean.beanFieldName")
.
If the field value is defined via manually implemented get/setBackingValue() methods, the corresponding bean field to read the @Size (and @NotNull) information from may be specified via@PmAttrCfg(..., beanInfoField="beanFieldName")
.
If the min/max limits depend on some dynamic conditions, you may override getMinLen() and getMaxLen() to provide your calculated limits.
The default min length is zero. The default max length depends on the attribute type:
- PmAttrString: 255
- Subclasses of PmAttrNumBase: String length needed for decimal representation of getMaxValue().
PmAttrStringImpl uses the min/max information for its validation.
For all other attribute types PmAttr.getMinLen() and PmAttr.getMaxLen() may optionally used as a hint to restrict related widgets.