All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.srplib.validation.PositiveNumberValidator Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
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."));
        }

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy