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

uk.gov.service.payments.commons.api.validation.AllowedStringsValidator Maven / Gradle / Ivy

There is a newer version: 1.0.20241216100655
Show newest version
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