Skip to content

Commit

Permalink
fix(core): change property options to values for multiselect, depreca…
Browse files Browse the repository at this point in the history
…ted the older and will be removed in 0.20
  • Loading branch information
Skraye committed Aug 14, 2024
1 parent f0c0f93 commit b103faf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
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;
Expand All @@ -19,11 +18,19 @@
@NoArgsConstructor
public class MultiselectInput extends Input<List<String>> implements ItemTypeInterface {
@Schema(
title = "List of values available."
title = "Deprecated, please use `values` instead."
)
@NotNull
// @NotNull
@Deprecated
List<@Regex String> options;

@Schema(
title = "List of values available."
)
// FIXME: REMOVE `options` in 0.20 and bring back the NotNull
// @NotNull
List<@Regex String> values;

@Schema(
title = "Type of the different values available.",
description = "Cannot be of type `ARRAY` nor 'MULTISELECT'."
Expand All @@ -33,10 +40,21 @@ public class MultiselectInput extends Input<List<String>> implements ItemTypeInt

@Override
public void validate(List<String> inputs) throws ConstraintViolationException {
if (values != null && options != null) {
throw ManualConstraintViolation.toConstraintViolationException(
"you can't define both `values` and `options`",
this,
MultiselectInput.class,
getId(),
""
);
}

for(String input : inputs){
if (!options.contains(input)) {
List<@Regex String> finalValues = this.values != null ? this.values : this.options;
if (!finalValues.contains(input)) {
throw ManualConstraintViolation.toConstraintViolationException(
"it must match the values `" + options + "`",
"it must match the values `" + finalValues + "`",
this,
MultiselectInput.class,
getId(),
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/inputs/InputsForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
multiple
>
<el-option
v-for="item in input.options"
v-for="item in (input.values ?? input.options)"
:key="item"
:label="item"
:value="item"
Expand Down

0 comments on commit b103faf

Please sign in to comment.