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

com.godmonth.util.validations.DecimalScaleValidator Maven / Gradle / Ivy

package com.godmonth.util.validations;

import java.math.BigDecimal;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class DecimalScaleValidator implements
		ConstraintValidator {

	private DecimalScale constraintAnnotation;

	@Override
	public void initialize(DecimalScale constraintAnnotation) {
		this.constraintAnnotation = constraintAnnotation;
	}

	@Override
	public boolean isValid(BigDecimal value, ConstraintValidatorContext context) {
		if (value != null) {
			return value.scale() <= constraintAnnotation.scale();
		} else {
			return true;
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy