class ValidEnumValueOrProfileAttributeValidator implements
        ConstraintValidator<ValidEnumValueOrProfileAttribute, String>, ValidationErrorDescriptorBuilder {

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        final Pattern pattern = getProfileAttributeFunctionPattern();
        return value == null || enumNames.contains(value) || pattern == null || pattern.matcher(value).matches();
    }

}