-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): create SELECT input and deprecate ENUM
close #4063
- Loading branch information
Showing
6 changed files
with
44 additions
and
3 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
37 changes: 37 additions & 0 deletions
37
core/src/main/java/io/kestra/core/models/flows/input/SelectInput.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,37 @@ | ||
package io.kestra.core.models.flows.input; | ||
|
||
import io.kestra.core.models.flows.Input; | ||
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.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
import java.util.List; | ||
|
||
@SuperBuilder | ||
@Getter | ||
@NoArgsConstructor | ||
public class SelectInput extends Input<String> { | ||
@Schema( | ||
title = "List of values." | ||
) | ||
@NotNull | ||
List<@Regex String> values; | ||
|
||
@Override | ||
public void validate(String input) throws ConstraintViolationException { | ||
if (!values.contains(input) & this.getRequired()) { | ||
throw ManualConstraintViolation.toConstraintViolationException( | ||
"it must match the values `" + values + "`", | ||
this, | ||
SelectInput.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