uk.gov.service.payments.commons.api.validation.AllowedStringsValidator Maven / Gradle / Ivy
package uk.gov.service.payments.commons.api.validation;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Set;
public class AllowedStringsValidator implements ConstraintValidator {
private Set allowedStrings;
@Override
public void initialize(AllowedStrings parameters) {
allowedStrings = Set.of(parameters.allowed());
}
@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
if (value == null) return false;
return allowedStrings.contains(value);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy