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

io.inisos.bank4j.validator.constraintvalidators.BICValidator Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
package io.inisos.bank4j.validator.constraintvalidators;

import io.inisos.bank4j.validator.constraints.BIC;
import org.iban4j.BicUtil;
import org.iban4j.Iban4jException;

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

public class BICValidator implements ConstraintValidator {

    @Override
    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
        if (value != null && value.length() != 0) {
            try {
                BicUtil.validate(value);
                return true;
            } catch (Iban4jException e) {
                return false;
            }
        } else {
            return true;
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy