-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(): multiselect input string * feat(): multiple type for multiselect
- Loading branch information
Showing
9 changed files
with
119 additions
and
13 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
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
7 changes: 7 additions & 0 deletions
7
core/src/main/java/io/kestra/core/models/flows/input/ItemTypeInterface.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.kestra.core.models.flows.input; | ||
|
||
import io.kestra.core.models.flows.Type; | ||
|
||
public interface ItemTypeInterface { | ||
Type getItemType(); | ||
} |
48 changes: 48 additions & 0 deletions
48
core/src/main/java/io/kestra/core/models/flows/input/MultiselectInput.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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package io.kestra.core.models.flows.input; | ||
|
||
import io.kestra.core.models.flows.Input; | ||
import io.kestra.core.models.flows.Type; | ||
import io.kestra.core.models.validations.ManualConstraintViolation; | ||
import io.kestra.core.validations.Regex; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.ConstraintViolationException; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
import java.util.List; | ||
|
||
@SuperBuilder | ||
@Getter | ||
@NoArgsConstructor | ||
public class MultiselectInput extends Input<List<String>> implements ItemTypeInterface { | ||
@Schema( | ||
title = "List of values available." | ||
) | ||
@NotNull | ||
List<@Regex String> options; | ||
|
||
@Schema( | ||
title = "Type of the different values available.", | ||
description = "Cannot be of type `ARRAY` nor 'MULTISELECT'." | ||
) | ||
@Builder.Default | ||
private Type itemType = Type.STRING; | ||
|
||
@Override | ||
public void validate(List<String> inputs) throws ConstraintViolationException { | ||
for(String input : inputs){ | ||
if (!options.contains(input)) { | ||
throw ManualConstraintViolation.toConstraintViolationException( | ||
"it must match the values `" + options + "`", | ||
this, | ||
MultiselectInput.class, | ||
getId(), | ||
input | ||
); | ||
} | ||
} | ||
} | ||
} |
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
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