diff --git a/src/components/FeatureType/FeatureTypeCustomForm.vue b/src/components/FeatureType/FeatureTypeCustomForm.vue index bdb0fc4fe41b733b395c8a2ef9f049624eff39e5..07873b80ca997f14fc5417bafa7a13fe2561f6f2 100644 --- a/src/components/FeatureType/FeatureTypeCustomForm.vue +++ b/src/components/FeatureType/FeatureTypeCustomForm.vue @@ -490,20 +490,23 @@ export default { return occurences.length === 1; }, - checkListOptions() { - if (!['list', 'pre_recorded_list'].includes(this.form.field_type.value)) return true; + checkOptions() { if (this.form.field_type.value === 'list') { - return this.form.options.value.length >= 2 && !this.form.options.value.includes(''); + return this.form.options.value.length >= 2 && !this.form.options.value.includes('') ? + '' : 'Veuillez renseigner au moins 2 options.'; } if (this.form.field_type.value === 'pre_recorded_list') { - return this.form.options.value.length === 1; + return this.form.options.value.length === 1 ? + '' : 'Veuillez renseigner une option.'; } + return ''; }, checkCustomForm() { this.form.label.errors = []; this.form.name.errors = []; this.form.options.errors = []; + const optionError = this.checkOptions(); let isValid = true; if (!this.form.label.value) { //* vérifier que le label est renseigné @@ -525,9 +528,9 @@ export default { 'Les champs personnalisés ne peuvent pas avoir des noms similaires.', ]; isValid = false; - } else if (!this.checkListOptions()) { + } else if (optionError) { //* s'il s'agit d'un type liste, vérifier que le champ option est bien renseigné - this.form.options.errors = ['Veuillez compléter ce champ.']; + this.form.options.errors = [optionError]; isValid = false; } else if (this.hasDuplicateOptions()) { //* pour le cas d'options dupliqués