org.srplib.validation.PositiveNumberValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of srp-validation-support Show documentation
Show all versions of srp-validation-support Show documentation
Single Responsibility Principle (SRP) libraries collection
package org.srplib.validation;
/**
* Validates if {@link Number} is positive.
*
* @author Anton Pechinsky
*/
public class PositiveNumberValidator implements Validator {
@Override
public void validate(Validatable validatable) {
Number value = validatable.getValue();
boolean valid = value.doubleValue() > 0.0d;
if (!valid) {
validatable.addError(Validators.newError("Value should be positive."));
}
}
}