Skip to content

Commit

Permalink
fix(survey): include required into checkbox-list validation logic (V4…
Browse files Browse the repository at this point in the history
…-1200)
  • Loading branch information
lukashroch committed Jun 24, 2024
1 parent 9ac7116 commit b053119
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,14 @@ export default defineComponent({
const localeOptions = computed(
() => props.prompt.options[i18n.locale] ?? props.prompt.options.en,
);
const isExclusiveSelected = computed(() => !!localeOptions.value.find(option => option.exclusive && props.value.includes(option.value)));
const isMinSatisfied = computed(() => !props.prompt.validation.min || props.value.length >= props.prompt.validation.min);
const isMaxSatisfied = computed(() => !props.prompt.validation.max || props.value.length <= props.prompt.validation.max);
const isExclusiveSelected = computed(() => !!localeOptions.value.find(option => option.exclusive && props.value.includes(option.value)));
const isRequiredSatisfied = computed(() => !props.prompt.validation.required || !!props.value.length);
const isValid = computed(() => isRequiredSatisfied.value && (isExclusiveSelected.value || (isMinSatisfied.value && isMaxSatisfied.value)));
const disableOption = (value: string) => !props.value.includes(value)
&& (isExclusiveSelected.value || (!!props.prompt.validation.max && props.value.length === props.prompt.validation.max));
const isValid = computed(() => {
if (!props.prompt.validation.required)
return false;
return isExclusiveSelected.value || (isMinSatisfied.value && isMaxSatisfied.value);
});
const confirm = () => {
if (isValid.value)
Expand Down

0 comments on commit b053119

Please sign in to comment.