
net.ulrice.databinding.validation.impl.IntegerLengthValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ulrice-databinding Show documentation
Show all versions of ulrice-databinding Show documentation
Ulrice-Databinding is a databinding-extension for Ulrice
The newest version!
package net.ulrice.databinding.validation.impl;
/**
* Integer validator checking the minimum and maximum value of an Integer.
*
* @author - [email protected]
*/
import net.ulrice.databinding.IFBinding;
import net.ulrice.databinding.validation.AbstractValidator;
import net.ulrice.databinding.validation.ValidationError;
import net.ulrice.databinding.validation.ValidationResult;
public class IntegerLengthValidator extends AbstractValidator {
private final Integer minValue;
private final Integer maxValue;
public IntegerLengthValidator (Integer minValue, Integer maxValue) {
this.minValue = minValue;
this.maxValue = maxValue;
}
@Override
protected ValidationResult validate(IFBinding bindingId, Integer attribute, Object rawAttribute) {
ValidationResult result = new ValidationResult();
if (attribute == null) {
return result;
}
if (minValue != null && attribute < minValue) {
// TODO Christof Internationalize
result.addValidationError(new ValidationError(bindingId, "min. Wert: " + minValue, null));
}
if (maxValue != null && attribute > maxValue) {
// TODO Christof Internationalize
result.addValidationError(new ValidationError(bindingId, "max. Wert: " + maxValue, null));
}
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy