use of org.grails.validation.MinSizeConstraint in project grails-core by grails.
the class ConstrainedProperty method setMinSize.
/**
* @param minSize The minLength to set.
*/
public void setMinSize(Integer minSize) {
Constraint c = appliedConstraints.get(MIN_SIZE_CONSTRAINT);
if (c == null) {
c = new MinSizeConstraint();
c.setOwningClass(owningClass);
c.setPropertyName(propertyName);
appliedConstraints.put(MIN_SIZE_CONSTRAINT, c);
}
c.setParameter(minSize);
}
use of org.grails.validation.MinSizeConstraint in project grails-core by grails.
the class ConstrainedProperty method getMinSize.
/**
* @return Returns the minSize.
*/
@Override
public Integer getMinSize() {
Integer minSize = null;
MinSizeConstraint minSizeConstraint = (MinSizeConstraint) appliedConstraints.get(MIN_SIZE_CONSTRAINT);
SizeConstraint sizeConstraint = (SizeConstraint) appliedConstraints.get(SIZE_CONSTRAINT);
if (minSizeConstraint != null || sizeConstraint != null) {
int minSizeConstraintValue = minSizeConstraint == null ? Integer.MIN_VALUE : minSizeConstraint.getMinSize();
int sizeConstraintLowValue = sizeConstraint == null ? Integer.MIN_VALUE : sizeConstraint.getRange().getFromInt();
minSize = Math.max(minSizeConstraintValue, sizeConstraintLowValue);
}
return minSize;
}
Aggregations