diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionValidatorImpl.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionValidatorImpl.java index c95e12dc5e..f3748e07d5 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionValidatorImpl.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionValidatorImpl.java @@ -108,8 +108,18 @@ public final class ConfigDescriptionValidatorImpl implements ConfigDescriptionVa if (configDescriptionParameter != null) { // If the parameter supports multiple selection, then it may be provided as an array if (configDescriptionParameter.isMultiple() && configurationParameters.get(key) instanceof List) { + List values = (List) configurationParameters.get(key); + // check if multipleLimit is obeyed + Integer multipleLimit = configDescriptionParameter.getMultipleLimit(); + if (multipleLimit != null && values.size() > multipleLimit) { + MessageKey messageKey = MessageKey.MULTIPLE_LIMIT_VIOLATED; + ConfigValidationMessage message = new ConfigValidationMessage( + configDescriptionParameter.getName(), messageKey.defaultMessage, messageKey.key, + multipleLimit, values.size()); + configDescriptionValidationMessages.add(message); + } // Perform validation on each value in the list separately - for (Object value : (List) configurationParameters.get(key)) { + for (Object value : values) { ConfigValidationMessage message = validateParameter(configDescriptionParameter, value); if (message != null) { configDescriptionValidationMessages.add(message); diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/MessageKey.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/MessageKey.java index ddf0218819..e2c4484f92 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/MessageKey.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/MessageKey.java @@ -29,19 +29,17 @@ final class MessageKey { "The value must not consist of more than {0} characters."); static final MessageKey MAX_VALUE_NUMERIC_VIOLATED = new MessageKey("max_value_numeric_violated", "The value must not be greater than {0}."); - static final MessageKey MAX_VALUE_OPTIONS_VIOLATED = new MessageKey("max_value_options_violated", - "There are not more than {0} options allowed."); static final MessageKey MIN_VALUE_TXT_VIOLATED = new MessageKey("min_value_txt_violated", "The value must not consist of less than {0} characters."); static final MessageKey MIN_VALUE_NUMERIC_VIOLATED = new MessageKey("min_value_numeric_violated", "The value must not be less than {0}."); - static final MessageKey MIN_VALUE_OPTIONS_VIOLATED = new MessageKey("min_value_options_violated", - "There are at least {0} options required."); static final MessageKey PATTERN_VIOLATED = new MessageKey("pattern_violated", "The value {0} does not match the pattern {1}."); + static final MessageKey MULTIPLE_LIMIT_VIOLATED = new MessageKey("multiple_limit_violated", + "Only {0} elements are allowed but {1} are provided."); /** The key to be used for internationalization. */ final String key; diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation.properties index d079098fcb..baa0ec3275 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation.properties @@ -4,10 +4,9 @@ data_type_violated=The data type of the value ({0}) does not match with the type max_value_txt_violated=The value must not consist of more than {0} characters. max_value_numeric_violated=The value must not be greater than {0}. -max_value_options_violated=There are not more than {0} options allowed. min_value_txt_violated=The value must not consist of less than {0} characters. min_value_numeric_violated=The value must not be less than {0}. -min_value_options_violated=There are at least {0} options required. pattern_violated=The value {0} does not match the pattern {1}. +multiple_limit_violated=Only {0} elements are allowed but {1} are provided. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_ar.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_ar.properties index 6c9f9762ec..34286941ad 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_ar.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_ar.properties @@ -4,10 +4,8 @@ data_type_violated=نوع القيمة لا تتوافق مع النوع الم max_value_txt_violated=يجب ألا تتكون القيمة أكثر من {0} حرف. max_value_numeric_violated=يجب ألا تكون القيمة أكبر من {0}. -max_value_options_violated=لا يوجد أكثر من {0} من الخيارات المسموح بها. min_value_txt_violated=يجب ألا تتكون القيمة أقل من {0} حرف. min_value_numeric_violated=يجب ألا تكون القيمة أقل من {0}. -min_value_options_violated=هناك على الأقل {0} خيارات مطلوبة. pattern_violated=القيمة {0} لا تتطابق مع النمط {1}. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_bg.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_bg.properties index 4ba1b36674..eb8f74a506 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_bg.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_bg.properties @@ -4,10 +4,8 @@ data_type_violated=Типа на информацията на стойност max_value_txt_violated=Стойността не трябва да съдържа повече от {0} знака. max_value_numeric_violated=Стойността не трябва да е по голяма от {0}. -max_value_options_violated=Няма повече от {0} позволени опции. min_value_txt_violated=Стойността не трябва да съдържа по малко от {0} знака. min_value_numeric_violated=Стойността не трябва да е по-малка от {0}. -min_value_options_violated=Изискват се поне {0} опции. pattern_violated=Стойността {0} не съвпада с модела {1}. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_cs.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_cs.properties index b8d7b305a2..eb7bf7978f 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_cs.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_cs.properties @@ -4,10 +4,8 @@ data_type_violated=Datový typ hodnoty se neshoduje s deklarací typu ({0}) v po max_value_txt_violated=Hodnota nesmí obsahovat více než {0} znaků. max_value_numeric_violated=Hodnota nesmí být větší než {0}. -max_value_options_violated=Není povoleno více než {0} možností. min_value_txt_violated=Hodnota nesmí obsahovat méně než {0} znaků. min_value_numeric_violated=Hodnota nesmí být menší než {0}. -min_value_options_violated=Je vyžadováno alespoň {0} možností. pattern_violated=Hodnota {0} neodpovídá vzoru {1}. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_de.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_de.properties index c2ffd275db..05e1e715d0 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_de.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_de.properties @@ -4,10 +4,8 @@ data_type_violated=Der Datentyp des Wertes ({0}) stimmt nicht mit der Typen-Dekl max_value_txt_violated=Der Wert darf maximal {0} Zeichen enthalten. max_value_numeric_violated=Der Wert darf nicht größer als {0} sein. -max_value_options_violated=Es sind maximal {0} Optionen erlaubt. min_value_txt_violated=Der Wert muss mindestens {0} Zeichen enthalten. min_value_numeric_violated=Der Wert muss mindestens {0} sein. -min_value_options_violated=Es werden mindestens {0} Optionen erwartet. pattern_violated=Der Wert {0} entspricht nicht dem Muster {1}. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_el.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_el.properties index cb4f1f882f..b716807416 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_el.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_el.properties @@ -4,10 +4,8 @@ data_type_violated=Ο τύπος δεδομένων της τιμής δεν τ max_value_txt_violated=Η τιμή δεν πρέπει να αποτελείται από περισσότερους από {0} χαρακτήρες. max_value_numeric_violated=Η τιμή δεν πρέπει να είναι μεγαλύτερη από {0}. -max_value_options_violated=Δεν επιτρέπονται περισσότερες από {0} επιλογές. min_value_txt_violated=Η τιμή δεν πρέπει να αποτελείται από λιγότερους από {0} χαρακτήρες. min_value_numeric_violated=Η τιμή δεν πρέπει να είναι μικρότερη από {0}. -min_value_options_violated=Απαιτούνται τουλάχιστον {0} επιλογές. pattern_violated=Η τιμή {0} δεν ταιριάζει με το μοτίβο {1}. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_es.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_es.properties index ebb623f3c7..91732ec8e5 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_es.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_es.properties @@ -4,10 +4,8 @@ data_type_violated=El tipo de datos del valor no coincide con la declaración de max_value_txt_violated=El valor no puede tener más de {0} caracteres. max_value_numeric_violated=El valor no puede ser mayor que {0}. -max_value_options_violated=No hay más de {0} opciones permitidas. min_value_txt_violated=El valor no puede tener menos de {0} caracteres. min_value_numeric_violated=El valor no puede ser menor que {0}. -min_value_options_violated=Hay al menos {0} opciones necesarias. pattern_violated=El valor {0} no coincide con el patrón {1}. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_fi.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_fi.properties index da559bb35e..ebb9fce824 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_fi.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_fi.properties @@ -4,10 +4,8 @@ data_type_violated=Arvon datatyyppi ({0}) ei vastaa konfiguraation määritelmä max_value_txt_violated=Arvo ei saa sisältää enemmän kuin {0} merkkiä. max_value_numeric_violated=Arvo ei saa olla suurempi kuin {0}. -max_value_options_violated=Enemmän kuin {0} vaihtoehtoa ei ole sallittu. min_value_txt_violated=Arvo ei saa sisältää vähemmän kuin {0} merkkiä. min_value_numeric_violated=Arvo ei saa olla pienempi kuin {0}. -min_value_options_violated=Vaaditaan vähintään {0} vaihtoehtoa. pattern_violated=Arvo {0} ei vastaa malli-lauseketta {1}. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_fr.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_fr.properties index d54f3e0096..9f860c8ab0 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_fr.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_fr.properties @@ -4,10 +4,8 @@ data_type_violated=Le type de données de la valeur ne correspond pas à la déc max_value_txt_violated=La valeur ne doit pas contenir plus de {0} caractères. max_value_numeric_violated=La valeur ne doit pas être supérieure à {0}. -max_value_options_violated=Il n''y a pas plus de {0} options autorisées. min_value_txt_violated=La valeur ne doit pas contenir moins de {0} caractères. min_value_numeric_violated=La valeur ne doit pas être inférieure à {0}. -min_value_options_violated=Il y a au moins {0} options nécessaires. pattern_violated=La valeur {0} ne correspond pas au modèle {1}. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_he.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_he.properties index fadb12e981..58edd6c20b 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_he.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_he.properties @@ -4,10 +4,8 @@ data_type_violated=סוג הנתונים של הערך ({0}) אינו תואם max_value_txt_violated=הערך אינו יכול לכלול יותר מ- {0} תווים. max_value_numeric_violated=הערך אינו יכול להיות גדול מ-{0}. -max_value_options_violated=אין יותר מ- {0} אפשרויות מותרות. min_value_txt_violated=הערך איננו יכול לכלול פחות מ- {0} תווים. min_value_numeric_violated=הערך איננו יכול להיות קטן מ- {0}. -min_value_options_violated=נדרשת הגדרה של לפחות {0} אפשרויות. pattern_violated=הערך {0} לא מתאים לתבנית {1}. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_hu.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_hu.properties index 1200a3b367..7399bd2fbe 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_hu.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_hu.properties @@ -4,10 +4,8 @@ data_type_violated=A konfigurációs beállításokban szereplő típus megadás max_value_txt_violated=Az érték {0} karakternél rövidebb kell legyen. max_value_numeric_violated=Az érték nem lehet nagyobb, mint {0}. -max_value_options_violated=Maximum {0} lehetőség megengedett. min_value_txt_violated=Az érték {0} karakternél hosszabb kell legyen. min_value_numeric_violated=Az érték nem lehet kisebb, mint {0}. -min_value_options_violated=Legalább {0} lehetőség szükséges. pattern_violated=Az {0} érték nem felel meg a(z) {1} mintának. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_it.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_it.properties index 2fe9a3cf12..ae45c16fa5 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_it.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_it.properties @@ -4,10 +4,8 @@ data_type_violated=Il tipo di dati del valore ({0}) non corrisponde alla dichiar max_value_txt_violated=Il valore non deve contenere più di {0} caratteri. max_value_numeric_violated=Il valore non deve essere maggiore di {0}. -max_value_options_violated=Non ci sono più di {0} opzioni permesse. min_value_txt_violated=Il valore non deve consistere di meno di {0} caratteri. min_value_numeric_violated=Il valore non deve essere inferiore a {0}. -min_value_options_violated=Ci sono almeno {0} opzioni richieste. pattern_violated=Il valore {0} non corrisponde al modello {1}. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_ja.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_ja.properties index 8b0b4fcdaf..392bac6727 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_ja.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_ja.properties @@ -4,10 +4,8 @@ data_type_violated=値のデータ型が、設定説明の型宣言 ({0}) と一 max_value_txt_violated=値は {0} 文字以上で構成することはできません。 max_value_numeric_violated=値は{0} を超えてはいけません。 -max_value_options_violated=許可されるオプションは{0} 個までです。 min_value_txt_violated=値は{0} 文字未満であってはなりません。 min_value_numeric_violated=値は{0} 以上である必要があります。 -min_value_options_violated=少なくとも{0} 個のオプションが必要です。 pattern_violated=値{0} がパターン{1} と一致しません。 diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_lb.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_lb.properties index 6acf69d7d2..4b68dc6b18 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_lb.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_lb.properties @@ -4,10 +4,8 @@ data_type_violated=Den Datentyp vum Wäert ({0}) stëmmt net mat der Typendeklar max_value_txt_violated=Dëse Wäert däerf net méi wéi {0} Zeechen hunn. max_value_numeric_violated=Dëse Wäert muss méi grouss wéi {0} sinn. -max_value_options_violated=Et sinn net méi wéi {0} Optiounen erlaabt. min_value_txt_violated=Dëse Wäert muss mindestens {0} Zeechen hunn. min_value_numeric_violated=Dëse Wäert muss mindestens {0} sinn. -min_value_options_violated=Et ginn op mannst {0} Optiounen erwaart. pattern_violated=De Wäert {0} passt net mam Muster {1} iwwerteneen. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_nl.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_nl.properties index b5d03a2a27..39e11f0ec0 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_nl.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_nl.properties @@ -4,10 +4,8 @@ data_type_violated=Het gegevenstype van de waarde komt niet overeen met de type max_value_txt_violated=De waarde mag niet meer dan {0} tekens bevatten. max_value_numeric_violated=De waarde mag niet groter zijn dan {0}. -max_value_options_violated=Er zijn niet meer dan {0} opties toegestaan. min_value_txt_violated=De waarde mag niet minder dan {0} tekens bevatten. min_value_numeric_violated=De waarde mag niet kleiner zijn dan {0}. -min_value_options_violated=Er zijn ten minste {0} opties vereist. pattern_violated=De waarde {0} komt niet overeen met het patroon {1}. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_no.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_no.properties index e0692c7a90..c5d47671c1 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_no.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_no.properties @@ -4,10 +4,8 @@ data_type_violated=Datatypen til verdien samsvarer ikke med typedeklarasjonen ({ max_value_txt_violated=Verdien må ikke bestå av mer enn {0} tegn. max_value_numeric_violated=Verdien kan ikke være større enn {0}. -max_value_options_violated=Det er ikke mer enn {0} alternativer tillatt. min_value_txt_violated=Verdien må ikke bestå av mindre enn {0} tegn. -min_value_numeric_violated=Verdien må ikke være mindre enn {0}. -min_value_options_violated=Det er nødvendig med minst {0} valg. +min_value_numeric_violated=Verdien må ikke være mindre enn {0}.\ pattern_violated=Verdien {0} samsvarer ikke med mønsteret {1}. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_pl.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_pl.properties index 15019f379f..af54ae23c9 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_pl.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_pl.properties @@ -4,10 +4,8 @@ data_type_violated=Typ danych wartości nie pasuje do deklaracji typu ({0}) w op max_value_txt_violated=Wartość nie może składać się z więcej niż {0} znaków. max_value_numeric_violated=Wartość musi być większa niż {0}. -max_value_options_violated=Nie ma więcej niż {0} opcji dozwolonych. min_value_txt_violated=Wartość nie może składać się z mniej niż {0} znaków. min_value_numeric_violated=Wartość nie może być mniejsza niż {0}. -min_value_options_violated=Wymagana liczba opcji\: {0}. pattern_violated=Wartość {0} nie pasuje do wzoru {1}. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_pt.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_pt.properties index 48f59fa531..6b0af9327f 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_pt.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_pt.properties @@ -4,10 +4,8 @@ data_type_violated=O tipo de dados do valor não coincide com a declaração de max_value_txt_violated=O valor não pode conter mais de {0} caracteres. max_value_numeric_violated=O valor não deve ser maior que {0}. -max_value_options_violated=Não há mais do que {0} opções permitidas. min_value_txt_violated=O valor não pode conter menos de {0} caracteres. min_value_numeric_violated=O valor não deve ser menor que {0}. -min_value_options_violated=Existem pelo menos {0} opções obrigatórias. pattern_violated=O valor {0} não corresponde ao padrão {1}. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_ro.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_ro.properties index 0ec085f61e..f2d1bee6fd 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_ro.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_ro.properties @@ -4,10 +4,8 @@ data_type_violated=Tipul de date al valorii nu se potrivește cu declarația de max_value_txt_violated=Valoarea nu trebuie să conțină mai mult de {0} caractere. max_value_numeric_violated=Valoarea nu trebuie să fie mai mare de {0}. -max_value_options_violated=Nu există mai mult de {0} opțiuni permise. min_value_txt_violated=Valoarea nu trebuie să fie mai mică de {0} caractere. min_value_numeric_violated=Valoarea nu trebuie să fie mai mică de {0}. -min_value_options_violated=Există cel puțin {0} opțiuni necesare. pattern_violated=Valoarea {0} nu se potrivește cu modelul {1}. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_ru.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_ru.properties index d8fcbbaaab..ba9bbbe2e5 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_ru.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_ru.properties @@ -4,10 +4,8 @@ data_type_violated=Тип данных значения не соответст max_value_txt_violated=Значение не должно содержать больше, чем {0} символов. max_value_numeric_violated=Значение должно быть меньше, чем {0}. -max_value_options_violated=Доступно не более {0} вариантов. min_value_txt_violated=Значение должно содержать более {0} символов. min_value_numeric_violated=Значение должно быть больше, чем {0}. -min_value_options_violated=Требуется как минимум {0} вариантов. pattern_violated=Значение {0} не соответствует шаблону {1}. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_sv.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_sv.properties index 8fb8f71800..4f44bf79e9 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_sv.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_sv.properties @@ -4,10 +4,8 @@ data_type_violated=Datatypen för värdet stämmer inte överens med typ-deklara max_value_txt_violated=Värdet får inte bestå av mer än {0} tecken. max_value_numeric_violated=Värdet får inte vara större än {0}. -max_value_options_violated=Det finns inte mer än {0} tillåtna alternativ. min_value_txt_violated=Värdet får inte bestå av mindre än {0} tecken. min_value_numeric_violated=Värdet får inte vara mindre än {0}. -min_value_options_violated=Det krävs minst {0} alternativ. pattern_violated=Värdet {0} uppfyller inte mönstret {1}. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_tr.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_tr.properties index 5f14a48500..684664285e 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_tr.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_tr.properties @@ -4,10 +4,8 @@ data_type_violated=Değerin veri tipi ({0})''nin yapılandırma açıklamasında max_value_txt_violated=Değer {0}''dan fazla karakter içeremez. max_value_numeric_violated=Değer {0}''dan büyük olamaz. -max_value_options_violated={0}''dan fazla seçeneğe izin verilmemektedir. min_value_txt_violated=Değer {0}''dan daha az karakter içeremez. min_value_numeric_violated=Değer {0}''dan az olamaz. -min_value_options_violated=En az {0} adet seçenek gereklidir. pattern_violated={0} değeri, {1} ablonu ile uyumsuz. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_uk.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_uk.properties index b2468cc6f9..f7f0d36bdd 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_uk.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_uk.properties @@ -4,10 +4,8 @@ data_type_violated=Тип даних значення не відповідає max_value_txt_violated=Значення не може складатися з більш ніж {0} символів. max_value_numeric_violated=Значення не має бути більшим за {0}. -max_value_options_violated=Дозволено не більше ніж {0} варіантів. min_value_txt_violated=Значення не може складатися з менш ніж {0} символів. min_value_numeric_violated=Значення не має бути меншим за {0}. -min_value_options_violated=Необхідні принаймні {0} опції. pattern_violated=Значення {0} не відповідає шаблону{1}. diff --git a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_zh.properties b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_zh.properties index f37d1d57af..b25f8c5396 100644 --- a/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_zh.properties +++ b/bundles/org.openhab.core.config.core/src/main/resources/OH-INF/i18n/validation_zh.properties @@ -4,10 +4,8 @@ data_type_violated=该值的数据类型与配置描述中的类型声明({0}) max_value_txt_violated=该值不能超过{0} 字符。 max_value_numeric_violated=该值必须大于 {0}。 -max_value_options_violated=允许的选项不超过 {0} 个。 min_value_txt_violated=该值不能小于 {0} 个字符。 min_value_numeric_violated=该值不能小于 {0}。 -min_value_options_violated=至少需要 {0} 个选项。 pattern_violated=该值 {0} 与模式 {1} 不匹配。 diff --git a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionValidatorTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionValidatorTest.java index 7118fe82c6..ff2fcfcb9e 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionValidatorTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionValidatorTest.java @@ -31,7 +31,6 @@ import java.util.stream.Stream; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.openhab.core.config.core.ConfigDescription; import org.openhab.core.config.core.ConfigDescriptionBuilder; @@ -83,6 +82,7 @@ public class ConfigDescriptionValidatorTest { private static final String TXT_MAX_PARAM_NAME = "txt-max-name"; private static final String TXT_PATTERN_PARAM_NAME = "txt-pattern-name"; private static final String TXT_MAX_PATTERN_PARAM_NAME = "txt-max-pattern-name"; + private static final String TXT_MULTIPLE_LIMIT_PARAM_NAME = "txt-multiple-limit-name"; private static final String INT_PARAM_NAME = "int-param"; private static final String INT_REQUIRED_PARAM_NAME = "int-required-param"; @@ -112,6 +112,8 @@ public class ConfigDescriptionValidatorTest { private static final ConfigDescriptionParameter TXT_MAX_PATTERN_PARAM = ConfigDescriptionParameterBuilder .create(TXT_MAX_PATTERN_PARAM_NAME, ConfigDescriptionParameter.Type.TEXT).withMaximum(MAX) .withPattern(PATTERN).build(); + private static final ConfigDescriptionParameter TXT_MULTIPLE_LIMIT_PARAM = ConfigDescriptionParameterBuilder + .create(TXT_MULTIPLE_LIMIT_PARAM_NAME, Type.TEXT).withMultiple(true).withMultipleLimit(2).build(); private static final ConfigDescriptionParameter INT_PARAM = ConfigDescriptionParameterBuilder .create(INT_PARAM_NAME, ConfigDescriptionParameter.Type.INTEGER).build(); @@ -142,11 +144,10 @@ public class ConfigDescriptionValidatorTest { } private static final ConfigDescription CONFIG_DESCRIPTION = ConfigDescriptionBuilder.create(CONFIG_DESCRIPTION_URI) - .withParameters(Stream - .of(BOOL_PARAM, BOOL_REQUIRED_PARAM, TXT_PARAM, TXT_REQUIRED_PARAM, TXT_MIN_PARAM, TXT_MAX_PARAM, - TXT_PATTERN_PARAM, TXT_MAX_PATTERN_PARAM, INT_PARAM, INT_REQUIRED_PARAM, INT_MIN_PARAM, - INT_MAX_PARAM, DECIMAL_PARAM, DECIMAL_REQUIRED_PARAM, DECIMAL_MIN_PARAM, DECIMAL_MAX_PARAM) - .collect(toList())) + .withParameters(Stream.of(BOOL_PARAM, BOOL_REQUIRED_PARAM, TXT_PARAM, TXT_REQUIRED_PARAM, TXT_MIN_PARAM, + TXT_MAX_PARAM, TXT_PATTERN_PARAM, TXT_MAX_PATTERN_PARAM, TXT_MULTIPLE_LIMIT_PARAM, INT_PARAM, + INT_REQUIRED_PARAM, INT_MIN_PARAM, INT_MAX_PARAM, DECIMAL_PARAM, DECIMAL_REQUIRED_PARAM, + DECIMAL_MIN_PARAM, DECIMAL_MAX_PARAM).collect(toList())) .build(); private Map params; @@ -155,13 +156,11 @@ public class ConfigDescriptionValidatorTest { @BeforeEach public void setUp() { ConfigDescriptionRegistry configDescriptionRegistry = mock(ConfigDescriptionRegistry.class); - when(configDescriptionRegistry.getConfigDescription(any())).thenAnswer(new Answer() { - @Override - public ConfigDescription answer(InvocationOnMock invocation) throws Throwable { - URI uri = (URI) invocation.getArgument(0); - return !CONFIG_DESCRIPTION_URI.equals(uri) ? null : CONFIG_DESCRIPTION; - } - }); + when(configDescriptionRegistry.getConfigDescription(any())) + .thenAnswer((Answer) invocation -> { + URI uri = invocation.getArgument(0); + return !CONFIG_DESCRIPTION_URI.equals(uri) ? null : CONFIG_DESCRIPTION; + }); BundleContext bundleContext = mock(BundleContext.class); when(bundleContext.getBundle()).thenReturn(mock(Bundle.class)); @@ -179,6 +178,7 @@ public class ConfigDescriptionValidatorTest { params.put(TXT_MAX_PARAM_NAME, String.valueOf(MIN_VIOLATED)); params.put(TXT_PATTERN_PARAM_NAME, "abbbc"); params.put(TXT_MAX_PATTERN_PARAM_NAME, "abc"); + params.put(TXT_MULTIPLE_LIMIT_PARAM_NAME, List.of("1", "2")); params.put(INT_PARAM_NAME, null); params.put(INT_REQUIRED_PARAM_NAME, 0); params.put(INT_MIN_PARAM_NAME, MIN); @@ -422,6 +422,16 @@ public class ConfigDescriptionValidatorTest { // MISC VALIDATIONS // =========================================================================== + @Test + public void assertValidationThrowsExceptionForMultipleLimitViolated() { + List expected = List.of(new ConfigValidationMessage(TXT_MULTIPLE_LIMIT_PARAM_NAME, + MessageKey.MULTIPLE_LIMIT_VIOLATED.defaultMessage, MessageKey.MULTIPLE_LIMIT_VIOLATED.key, 2, 3)); + params.put(TXT_MULTIPLE_LIMIT_PARAM_NAME, List.of("1", "2", "3")); + ConfigValidationException exception = Assertions.assertThrows(ConfigValidationException.class, + () -> configDescriptionValidator.validate(params, CONFIG_DESCRIPTION_URI)); + assertThat(getConfigValidationMessages(exception), is(expected)); + } + @Test public void assertValidationThrowsExceptionContainingMultipleVariousViolations() { List expected = Stream.of(