public Optional<Violation> validate(IndexSetConfig newConfig) {

        // Don't validate prefix conflicts in case of an update
        if (Strings.isNullOrEmpty(newConfig.id())) {
            final Violation prefixViolation = validatePrefix(newConfig);
            if (prefixViolation != null) {
                return Optional.of(prefixViolation);
            }
        }

        final Violation fieldMappingViolation = validateMappingChangesAreLegal(newConfig);
        if (fieldMappingViolation != null) {
            return Optional.of(fieldMappingViolation);
        }

        Violation refreshIntervalViolation = validateSimpleIndexSetConfig(newConfig);
        if (refreshIntervalViolation != null){
            return Optional.of(refreshIntervalViolation);
        }
        return Optional.empty();
    }
@Test
    public void testValidationOfProfilesInIndexSetConfig() {
        final IndexSet indexSet = mock(IndexSet.class);
        when(indexSetRegistry.iterator()).thenReturn(Collections.singleton(indexSet).iterator());
        when(indexSet.getIndexPrefix()).thenReturn("foo");

        this.validator = new IndexSetValidator(indexSetRegistry, elasticsearchConfiguration, dataTieringOrchestrator, dataTieringChecker);
        IndexSetConfig config = testIndexSetConfig().toBuilder().indexTemplateType(EVENT_TEMPLATE_TYPE).fieldTypeProfile("smth").build();
        assertThat(validator.validate(config)).hasValueSatisfying(v ->
                assertThat(v.message()).contains("Profiles cannot be set for events and failures index sets"));

        config = testIndexSetConfig().toBuilder().indexTemplateType("failures").fieldTypeProfile("smth").build();
        assertThat(validator.validate(config)).hasValueSatisfying(v ->
                assertThat(v.message()).contains("Profiles cannot be set for events and failures index sets"));

        config = testIndexSetConfig().toBuilder().indexTemplateType(EVENT_TEMPLATE_TYPE).fieldTypeProfile("").build();
        assertThat(validator.validate(config)).isEmpty();
        config = testIndexSetConfig().toBuilder().indexTemplateType(EVENT_TEMPLATE_TYPE).fieldTypeProfile(null).build();
        assertThat(validator.validate(config)).isEmpty();
        config = testIndexSetConfig().toBuilder().indexTemplateType("failures").fieldTypeProfile("").build();
        assertThat(validator.validate(config)).isEmpty();
        config = testIndexSetConfig().toBuilder().indexTemplateType("failures").fieldTypeProfile(null).build();
        assertThat(validator.validate(config)).isEmpty();

        config = testIndexSetConfig().toBuilder().indexTemplateType(DEFAULT_INDEX_TEMPLATE_TYPE).fieldTypeProfile("smth").build();
        assertThat(validator.validate(config)).isEmpty();
    }