-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to validate for any of multiple templates in TemplateValid…
…ator
- Loading branch information
eschleb
committed
Jul 23, 2024
1 parent
7f1b1f5
commit 00038e5
Showing
5 changed files
with
38 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 16 additions & 8 deletions
24
...oss/magnolia/definition/custom/validator/template/TemplateValidatorDefinitionBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
package com.merkle.oss.magnolia.definition.custom.validator.template; | ||
|
||
import java.util.Arrays; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
import com.merkle.oss.magnolia.definition.builder.validator.AbstractConfiguredFieldValidatorDefinitionBuilder; | ||
|
||
public class TemplateValidatorDefinitionBuilder extends AbstractConfiguredFieldValidatorDefinitionBuilder<TemplateValidatorDefinition, TemplateValidatorDefinitionBuilder> { | ||
|
||
public TemplateValidatorDefinition build(final String templateId) { | ||
return build("templateValidator", templateId); | ||
} | ||
public TemplateValidatorDefinition build(final String name, final String templateId) { | ||
final TemplateValidatorDefinition definition = new TemplateValidatorDefinition(templateId); | ||
super.populate(definition, name); | ||
return definition; | ||
} | ||
public TemplateValidatorDefinition build(final String templateId, final String... additionalTemplateIds) { | ||
return build("templateValidator", templateId, additionalTemplateIds); | ||
} | ||
|
||
public TemplateValidatorDefinition build(final String name, final String templateId, final String... additionalTemplateIds) { | ||
final TemplateValidatorDefinition definition = new TemplateValidatorDefinition(Stream.concat( | ||
Stream.of(templateId), | ||
Arrays.stream(additionalTemplateIds) | ||
).collect(Collectors.toSet())); | ||
super.populate(definition, name); | ||
return definition; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters