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

org.droitateddb.validation.MinValidator Maven / Gradle / Ivy

Go to download

droitatedDB is a lightweight framework, which frees you from the burden of dealing with Androids SQLite database directly if you don't want to and let's you access it directly if you have to.

There is a newer version: 0.1.10
Show newest version
package org.droitateddb.validation;

import java.math.BigDecimal;

/**
 * Implementation of the @Min validation annotation
 *
 * @author Falk Appel
 * @author Alexander Frank
 */
public class MinValidator implements CustomValidator {

    public static final int ERROR_CODE = 2;

    @Override
    public ValidationResult onValidate(Min annotation, Number toByValidated) {
        long min = annotation.value();

        if (toByValidated == null) {
            return ValidationResult.valid();
        }

        if (new BigDecimal(toByValidated.toString()).compareTo(new BigDecimal(min)) >= 0) {
            return ValidationResult.valid();
        }
        return ValidationResult.invalid(ERROR_CODE, "The field as to be greater or equal to " + min);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy