From ed5767225950df765dc7c62b8106dcf0763e8390 Mon Sep 17 00:00:00 2001 From: Asis Pattisahusiwa <79239132+asispts@users.noreply.github.com> Date: Thu, 18 Apr 2024 21:42:00 +0700 Subject: [PATCH 01/13] Review translation --- Resources/translations/validators.id.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/translations/validators.id.xlf b/Resources/translations/validators.id.xlf index 980b1a67..b894c69d 100644 --- a/Resources/translations/validators.id.xlf +++ b/Resources/translations/validators.id.xlf @@ -192,7 +192,7 @@ No temporary folder was configured in php.ini, or the configured folder does not exist. - Tidak ada folder sementara yang dikonfigurasi di php.ini, atau folder yang dikonfigurasi tidak ada. + Tidak ada folder sementara yang dikonfigurasi di php.ini, atau folder yang dikonfigurasi tidak ada. Cannot write temporary file to disk. From 2d3ea9d973f1001a5ff2a5e62a9ab3c973692367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C4=81vis=20Z=C4=81l=C4=ABtis?= Date: Fri, 19 Apr 2024 00:42:17 +0300 Subject: [PATCH 02/13] [Validator] review validators.lv.xlf --- Resources/translations/validators.lv.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/translations/validators.lv.xlf b/Resources/translations/validators.lv.xlf index 9bbaafd0..66e370fe 100644 --- a/Resources/translations/validators.lv.xlf +++ b/Resources/translations/validators.lv.xlf @@ -440,7 +440,7 @@ This URL is missing a top-level domain. - Šim URL trūkst augšējā līmeņa domēna. + Šim URL trūkst augšējā līmeņa domēna. From f4532b0970fe0d2840dcc8abbb1058c0bfe1bb02 Mon Sep 17 00:00:00 2001 From: Ivan Mezinov Date: Sat, 20 Apr 2024 19:09:02 +0300 Subject: [PATCH 03/13] review: translation RU --- Resources/translations/validators.ru.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/translations/validators.ru.xlf b/Resources/translations/validators.ru.xlf index 241cba52..dbee06a9 100644 --- a/Resources/translations/validators.ru.xlf +++ b/Resources/translations/validators.ru.xlf @@ -440,7 +440,7 @@ This URL is missing a top-level domain. - Этому URL не хватает домена верхнего уровня. + В этом URL отсутствует домен верхнего уровня. From 4fd83b897474393a6483dde2bdfd189a05530256 Mon Sep 17 00:00:00 2001 From: Linas Ramanauskas Date: Sat, 20 Apr 2024 21:12:13 +0300 Subject: [PATCH 04/13] #53771 Updated validator Lithuanian translations --- Resources/translations/validators.lt.xlf | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Resources/translations/validators.lt.xlf b/Resources/translations/validators.lt.xlf index 26b3a4e7..e16daea9 100644 --- a/Resources/translations/validators.lt.xlf +++ b/Resources/translations/validators.lt.xlf @@ -136,7 +136,7 @@ This value is not a valid IP address. - Ši vertė nėra galiojantis IP adresas. + Ši reikšmė nėra tinkamas IP adresas. This value is not a valid language. @@ -192,7 +192,7 @@ No temporary folder was configured in php.ini, or the configured folder does not exist. - php.ini nesukonfigūruotas laikinas aplankas, arba sukonfigūruotas aplankas neegzistuoja. + php.ini nesukonfigūruotas laikinas aplankas arba sukonfigūruotas aplankas neegzistuoja. Cannot write temporary file to disk. @@ -224,7 +224,7 @@ This value is not a valid International Bank Account Number (IBAN). - Ši vertė nėra galiojantis Tarptautinis Banko Sąskaitos Numeris (IBAN). + Ši reikšmė nėra tinkamas Tarptautinis Banko Sąskaitos Numeris (IBAN). This value is not a valid ISBN-10. @@ -312,7 +312,7 @@ This value is not a valid Business Identifier Code (BIC). - Ši vertė nėra galiojantis Verslo Identifikavimo Kodas (BIC). + Ši reikšmė nėra tinkamas Verslo Identifikavimo Kodas (BIC). Error @@ -320,7 +320,7 @@ This value is not a valid UUID. - Ši vertė nėra galiojantis UUID. + Ši reikšmė nėra tinkamas UUID. This value should be a multiple of {{ compared_value }}. @@ -432,15 +432,15 @@ The detected character encoding is invalid ({{ detected }}). Allowed encodings are {{ encodings }}. - Nustatyta simbolių koduotė yra netinkama ({{ detected }}). Leidžiamos koduotės yra {{ encodings }}. + Aptikta simbolių koduotė yra netinkama ({{ detected }}). Leidžiamos koduotės yra {{ encodings }}. This value is not a valid MAC address. - Ši vertė nėra galiojantis MAC adresas. + Ši reikšmė nėra tinkamas MAC adresas. This URL is missing a top-level domain. - Šiam URL trūksta aukščiausio lygio domeno. + Šiam URL trūksta aukščiausio lygio domeno. From ac354f49eae83ff8bcdab29c0768e3905a8c8076 Mon Sep 17 00:00:00 2001 From: AbdelatifAitBara Date: Sat, 20 Apr 2024 21:26:36 +0200 Subject: [PATCH 05/13] Updated id=113 Arabic translation. --- Resources/translations/validators.ar.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/translations/validators.ar.xlf b/Resources/translations/validators.ar.xlf index a96cce98..08012ac2 100644 --- a/Resources/translations/validators.ar.xlf +++ b/Resources/translations/validators.ar.xlf @@ -440,7 +440,7 @@ This URL is missing a top-level domain. - هذا الرابط يفتقر إلى نطاق أعلى مستوى. + هذا الرابط يفتقر إلى نطاق المستوى الأعلى. From 1b5d9cda453c21f5fec36c3f4c5832b51cca77e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oriol=20Vi=C3=B1als?= Date: Mon, 22 Apr 2024 15:31:01 +0200 Subject: [PATCH 06/13] Update spanish and catalan translations --- Resources/translations/validators.ca.xlf | 46 ++++++++++++------------ Resources/translations/validators.es.xlf | 4 +-- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Resources/translations/validators.ca.xlf b/Resources/translations/validators.ca.xlf index c9da5988..652c0a48 100644 --- a/Resources/translations/validators.ca.xlf +++ b/Resources/translations/validators.ca.xlf @@ -108,7 +108,7 @@ This value is not a valid URL. - Aquest valor no és una URL vàlida. + Aquest valor no és un URL vàlid. The two values should be equal. @@ -116,7 +116,7 @@ The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}. - L'arxiu és massa gran. El tamany màxim permés és {{ limit }} {{ suffix }}. + L'arxiu és massa gran. La mida màxima permesa és {{ limit }} {{ suffix }}. The file is too large. @@ -136,7 +136,7 @@ This value is not a valid IP address. - Aquest valor no és una adreça IP vàlida. + Aquest valor no és una adreça IP vàlida. This value is not a valid language. @@ -160,19 +160,19 @@ The image width is too big ({{ width }}px). Allowed maximum width is {{ max_width }}px. - L'amplària de la imatge és massa gran ({{ width }}px). L'amplària màxima permesa són {{ max_width }}px. + L'amplària de la imatge és massa gran ({{ width }}px). L'amplària màxima permesa és {{ max_width }}px. The image width is too small ({{ width }}px). Minimum width expected is {{ min_width }}px. - L'amplària de la imatge és massa petita ({{ width }}px). L'amplària mínima requerida són {{ min_width }}px. + L'amplària de la imatge és massa petita ({{ width }}px). L'amplària mínima requerida és {{ min_width }}px. The image height is too big ({{ height }}px). Allowed maximum height is {{ max_height }}px. - L'altura de la imatge és massa gran ({{ height }}px). L'altura màxima permesa són {{ max_height }}px. + L'altura de la imatge és massa gran ({{ height }}px). L'altura màxima permesa és {{ max_height }}px. The image height is too small ({{ height }}px). Minimum height expected is {{ min_height }}px. - L'altura de la imatge és massa petita ({{ height }}px). L'altura mínima requerida són {{ min_height }}px. + L'altura de la imatge és massa petita ({{ height }}px). L'altura mínima requerida és {{ min_height }}px. This value should be the user's current password. @@ -192,7 +192,7 @@ No temporary folder was configured in php.ini, or the configured folder does not exist. - No s'ha configurat cap carpeta temporal en php.ini, o la carpeta configurada no existeix. + No s'ha configurat cap carpeta temporal en php.ini, o la carpeta configurada no existeix. Cannot write temporary file to disk. @@ -200,7 +200,7 @@ A PHP extension caused the upload to fail. - Una extensió de PHP va fer que la pujada fallara. + Una extensió de PHP va fer que la pujada fallarà. This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more. @@ -224,7 +224,7 @@ This value is not a valid International Bank Account Number (IBAN). - Aquest valor no és un Número de Compte Bancari Internacional (IBAN) vàlid. + Aquest valor no és un Número de Compte Bancari Internacional (IBAN) vàlid. This value is not a valid ISBN-10. @@ -276,31 +276,31 @@ This value should not be identical to {{ compared_value_type }} {{ compared_value }}. - Aquest valor no hauria de idèntic a {{ compared_value_type }} {{ compared_value }}. + Aquest valor no hauria de ser idèntic a {{ compared_value_type }} {{ compared_value }}. The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}. - La proporció de l'imatge és massa gran ({{ ratio }}). La màxima proporció permesa és {{ max_ratio }}. + La proporció de la imatge és massa gran ({{ ratio }}). La màxima proporció permesa és {{ max_ratio }}. The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}. - La proporció de l'imatge és massa petita ({{ ratio }}). La mínima proporció permesa és {{ max_ratio }}. + La proporció de la imatge és massa petita ({{ ratio }}). La mínima proporció permesa és {{ min_ratio }}. The image is square ({{ width }}x{{ height }}px). Square images are not allowed. - L'imatge és quadrada({{ width }}x{{ height }}px). Les imatges quadrades no estan permeses. + La imatge és quadrada({{ width }}x{{ height }}px). Les imatges quadrades no estan permeses. The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed. - L'imatge està orientada horitzontalment ({{ width }}x{{ height }}px). Les imatges orientades horitzontalment no estan permeses. + La imatge està orientada horitzontalment ({{ width }}x{{ height }}px). Les imatges orientades horitzontalment no estan permeses. The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed. - L'imatge està orientada verticalment ({{ width }}x{{ height }}px). Les imatges orientades verticalment no estan permeses. + La imatge està orientada verticalment ({{ width }}x{{ height }}px). Les imatges orientades verticalment no estan permeses. An empty file is not allowed. - No està permès un fixter buit. + No està permès un fitxer buit. The host could not be resolved. @@ -312,7 +312,7 @@ This value is not a valid Business Identifier Code (BIC). - Aquest valor no és un Codi d'Identificador de Negocis (BIC) vàlid. + Aquest valor no és un Codi d'identificació bancari (BIC) vàlid. Error @@ -320,7 +320,7 @@ This value is not a valid UUID. - Aquest valor no és un UUID vàlid. + Aquest valor no és un UUID vàlid. This value should be a multiple of {{ compared_value }}. @@ -428,19 +428,19 @@ The extension of the file is invalid ({{ extension }}). Allowed extensions are {{ extensions }}. - L'extensió del fitxer no és vàlida ({{ extension }}). Les extensions permeses són {{ extensions }}. + L'extensió del fitxer no és vàlida ({{ extension }}). Les extensions permeses són {{ extensions }}. The detected character encoding is invalid ({{ detected }}). Allowed encodings are {{ encodings }}. - S'ha detectat que la codificació de caràcters no és vàlida ({{ detected }}). Les codificacions permeses són {{ encodings }}. + S'ha detectat que la codificació de caràcters no és vàlida ({{ detected }}). Les codificacions permeses són {{ encodings }}. This value is not a valid MAC address. - Aquest valor no és una adreça MAC vàlida. + Aquest valor no és una adreça MAC vàlida. This URL is missing a top-level domain. - Aquesta URL no conté un domini de nivell superior. + Aquesta URL no conté un domini de primer nivell. diff --git a/Resources/translations/validators.es.xlf b/Resources/translations/validators.es.xlf index 141ec515..d5804547 100644 --- a/Resources/translations/validators.es.xlf +++ b/Resources/translations/validators.es.xlf @@ -404,7 +404,7 @@ The filename is too long. It should have {{ filename_max_length }} character or less.|The filename is too long. It should have {{ filename_max_length }} characters or less. - El nombre del archivo es demasido largo. Debe tener {{ filename_max_length }} carácter o menos.|El nombre del archivo es demasido largo. Debe tener {{ filename_max_length }} caracteres o menos. + El nombre del archivo es demasiado largo. Debe tener {{ filename_max_length }} carácter o menos.|El nombre del archivo es demasiado largo. Debe tener {{ filename_max_length }} caracteres o menos. The password strength is too low. Please use a stronger password. @@ -440,7 +440,7 @@ This URL is missing a top-level domain. - Esta URL no contiene una extensión de dominio (TLD). + Esta URL no contiene una extensión de dominio (TLD). From 6dfedb289103e3778457cd07a4b0718cddff81ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Verlhac?= Date: Sat, 20 Apr 2024 13:06:54 +0200 Subject: [PATCH 07/13] review: FR translation Fix #54649 --- Resources/translations/validators.fr.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/translations/validators.fr.xlf b/Resources/translations/validators.fr.xlf index 27a57d03..a60384c5 100644 --- a/Resources/translations/validators.fr.xlf +++ b/Resources/translations/validators.fr.xlf @@ -440,7 +440,7 @@ This URL is missing a top-level domain. - Cette URL est dépourvue de domaine de premier niveau. + Cette URL doit contenir un de domaine de premier niveau. From 229cb30cdb81b27a2a8beac5d63ab8c84724429f Mon Sep 17 00:00:00 2001 From: Antoine Lamirault Date: Tue, 23 Apr 2024 21:37:17 +0200 Subject: [PATCH 08/13] Fix french translation --- Resources/translations/validators.fr.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/translations/validators.fr.xlf b/Resources/translations/validators.fr.xlf index a60384c5..4e949d83 100644 --- a/Resources/translations/validators.fr.xlf +++ b/Resources/translations/validators.fr.xlf @@ -440,7 +440,7 @@ This URL is missing a top-level domain. - Cette URL doit contenir un de domaine de premier niveau. + Cette URL doit contenir un domaine de premier niveau. From e5a2362393f961f1c2528505cf9db55a3573e980 Mon Sep 17 00:00:00 2001 From: Simone Ruggieri <36771527+Simopich@users.noreply.github.com> Date: Wed, 24 Apr 2024 17:08:17 +0200 Subject: [PATCH 09/13] Reviewed italian translation --- Resources/translations/validators.it.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/translations/validators.it.xlf b/Resources/translations/validators.it.xlf index df67a2c0..74f3a75b 100644 --- a/Resources/translations/validators.it.xlf +++ b/Resources/translations/validators.it.xlf @@ -440,7 +440,7 @@ This URL is missing a top-level domain. - Questo URL è privo di un dominio di primo livello. + Questo URL è privo di un dominio di primo livello. From 0fefb7f0fc1323edc4827a724ef3c05f22a4751e Mon Sep 17 00:00:00 2001 From: ffd000 <66318502+ffd000@users.noreply.github.com> Date: Wed, 24 Apr 2024 12:08:44 +0300 Subject: [PATCH 10/13] [Validator] Review Bulgarian (bg) translation --- Resources/translations/validators.bg.xlf | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Resources/translations/validators.bg.xlf b/Resources/translations/validators.bg.xlf index de24ec5e..d2405339 100644 --- a/Resources/translations/validators.bg.xlf +++ b/Resources/translations/validators.bg.xlf @@ -68,7 +68,7 @@ The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}. - Mime типа на файла е невалиден ({{ type }}). Разрешени mime типове са {{ types }}. + Mime типът на файла е невалиден ({{ type }}). Разрешени mime типове са {{ types }}. This value should be {{ limit }} or less. @@ -136,7 +136,7 @@ This value is not a valid IP address. - Тази стойност не е валиден IP адрес. + Стойността не е валиден IP адрес. This value is not a valid language. @@ -156,7 +156,7 @@ The size of the image could not be detected. - Размера на изображението не може да бъде определен. + Размерът на изображението не може да бъде определен. The image width is too big ({{ width }}px). Allowed maximum width is {{ max_width }}px. @@ -192,7 +192,7 @@ No temporary folder was configured in php.ini, or the configured folder does not exist. - В php.ini не е конфигурирана временна директория, или конфигурираната директория не съществува. + В php.ini не е конфигурирана временна директория или конфигурираната директория не съществува. Cannot write temporary file to disk. @@ -224,7 +224,7 @@ This value is not a valid International Bank Account Number (IBAN). - Тази стойност не е валиден международен банков сметка номер (IBAN). + Стойността не е валиден Международен номер на банкова сметка (IBAN). This value is not a valid ISBN-10. @@ -312,7 +312,7 @@ This value is not a valid Business Identifier Code (BIC). - Тази стойност не е валиден код за идентификация на бизнеса (BIC). + Стойността не е валиден Бизнес идентификационен код (BIC). Error @@ -320,7 +320,7 @@ This value is not a valid UUID. - Тази стойност не е валиден UUID. + Стойността не е валиден UUID. This value should be a multiple of {{ compared_value }}. @@ -328,7 +328,7 @@ This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}. - Бизнес идентификационния код (BIC) не е свързан с IBAN {{ iban }}. + Бизнес идентификационният код (BIC) не е свързан с IBAN {{ iban }}. This value should be valid JSON. @@ -360,7 +360,7 @@ This password has been leaked in a data breach, it must not be used. Please use another password. - Тази парола е компрометирана, не трябва да бъде използвана. Моля използвайте друга парола. + Тази парола е компрометирана, не може да бъде използвана. Моля използвайте друга парола. This value should be between {{ min }} and {{ max }}. @@ -436,11 +436,11 @@ This value is not a valid MAC address. - Тази стойност не е валиден MAC адрес. + Стойността не е валиден MAC адрес. This URL is missing a top-level domain. - На този URL липсва домейн от най-високо ниво. + На този URL липсва домейн от най-високо ниво. From a349814e40e8496bdefb7ba1fbe1f112d7bfb0e1 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 27 Apr 2024 10:58:07 +0200 Subject: [PATCH 11/13] detect wrong usages of minMessage/maxMessage in options --- Constraints/Range.php | 2 +- Tests/Constraints/RangeTest.php | 56 ++++++++++++++++++++++-- Tests/Constraints/RangeValidatorTest.php | 24 ---------- 3 files changed, 53 insertions(+), 29 deletions(-) diff --git a/Constraints/Range.php b/Constraints/Range.php index 6a4cd900..32c62104 100644 --- a/Constraints/Range.php +++ b/Constraints/Range.php @@ -95,7 +95,7 @@ public function __construct( throw new LogicException(sprintf('The "%s" constraint requires the Symfony PropertyAccess component to use the "minPropertyPath" or "maxPropertyPath" option. Try running "composer require symfony/property-access".', static::class)); } - if (null !== $this->min && null !== $this->max && ($minMessage || $maxMessage)) { + if (null !== $this->min && null !== $this->max && ($minMessage || $maxMessage || isset($options['minMessage']) || isset($options['maxMessage']))) { throw new ConstraintDefinitionException(sprintf('The "%s" constraint can not use "minMessage" and "maxMessage" when the "min" and "max" options are both set. Use "notInRangeMessage" instead.', static::class)); } } diff --git a/Tests/Constraints/RangeTest.php b/Tests/Constraints/RangeTest.php index 132be131..a306b104 100644 --- a/Tests/Constraints/RangeTest.php +++ b/Tests/Constraints/RangeTest.php @@ -30,7 +30,7 @@ public function testThrowsConstraintExceptionIfBothMinLimitAndPropertyPath() public function testThrowsConstraintExceptionIfBothMinLimitAndPropertyPathNamed() { - $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); + $this->expectException(ConstraintDefinitionException::class); $this->expectExceptionMessage('requires only one of the "min" or "minPropertyPath" options to be set, not both.'); new Range(min: 'min', minPropertyPath: 'minPropertyPath'); } @@ -47,7 +47,7 @@ public function testThrowsConstraintExceptionIfBothMaxLimitAndPropertyPath() public function testThrowsConstraintExceptionIfBothMaxLimitAndPropertyPathNamed() { - $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); + $this->expectException(ConstraintDefinitionException::class); $this->expectExceptionMessage('requires only one of the "max" or "maxPropertyPath" options to be set, not both.'); new Range(max: 'max', maxPropertyPath: 'maxPropertyPath'); } @@ -65,10 +65,58 @@ public function testThrowsNoDefaultOptionConfiguredException() new Range('value'); } - public function testThrowsConstraintDefinitionExceptionIfBothMinAndMaxAndMinMessageOrMaxMessage() + public function testThrowsConstraintDefinitionExceptionIfBothMinAndMaxAndMinMessageAndMaxMessage() { - $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); + $this->expectException(ConstraintDefinitionException::class); $this->expectExceptionMessage('can not use "minMessage" and "maxMessage" when the "min" and "max" options are both set. Use "notInRangeMessage" instead.'); new Range(min: 'min', max: 'max', minMessage: 'minMessage', maxMessage: 'maxMessage'); } + + public function testThrowsConstraintDefinitionExceptionIfBothMinAndMaxAndMinMessage() + { + $this->expectException(ConstraintDefinitionException::class); + $this->expectExceptionMessage('can not use "minMessage" and "maxMessage" when the "min" and "max" options are both set. Use "notInRangeMessage" instead.'); + new Range(min: 'min', max: 'max', minMessage: 'minMessage'); + } + + public function testThrowsConstraintDefinitionExceptionIfBothMinAndMaxAndMaxMessage() + { + $this->expectException(ConstraintDefinitionException::class); + $this->expectExceptionMessage('can not use "minMessage" and "maxMessage" when the "min" and "max" options are both set. Use "notInRangeMessage" instead.'); + new Range(min: 'min', max: 'max', maxMessage: 'maxMessage'); + } + + public function testThrowsConstraintDefinitionExceptionIfBothMinAndMaxAndMinMessageAndMaxMessageOptions() + { + $this->expectException(ConstraintDefinitionException::class); + $this->expectExceptionMessage('can not use "minMessage" and "maxMessage" when the "min" and "max" options are both set. Use "notInRangeMessage" instead.'); + new Range([ + 'min' => 'min', + 'minMessage' => 'minMessage', + 'max' => 'max', + 'maxMessage' => 'maxMessage', + ]); + } + + public function testThrowsConstraintDefinitionExceptionIfBothMinAndMaxAndMinMessageOptions() + { + $this->expectException(ConstraintDefinitionException::class); + $this->expectExceptionMessage('can not use "minMessage" and "maxMessage" when the "min" and "max" options are both set. Use "notInRangeMessage" instead.'); + new Range([ + 'min' => 'min', + 'minMessage' => 'minMessage', + 'max' => 'max', + ]); + } + + public function testThrowsConstraintDefinitionExceptionIfBothMinAndMaxAndMaxMessageOptions() + { + $this->expectException(ConstraintDefinitionException::class); + $this->expectExceptionMessage('can not use "minMessage" and "maxMessage" when the "min" and "max" options are both set. Use "notInRangeMessage" instead.'); + new Range([ + 'min' => 'min', + 'max' => 'max', + 'maxMessage' => 'maxMessage', + ]); + } } diff --git a/Tests/Constraints/RangeValidatorTest.php b/Tests/Constraints/RangeValidatorTest.php index 876595c3..c0eb5e61 100644 --- a/Tests/Constraints/RangeValidatorTest.php +++ b/Tests/Constraints/RangeValidatorTest.php @@ -1037,30 +1037,6 @@ public static function provideMessageIfMinAndMaxSet(): array 'not_in_range_message', Range::NOT_IN_RANGE_ERROR, ], - [ - ['minMessage' => 'min_message'], - 0, - $notInRangeMessage, - Range::NOT_IN_RANGE_ERROR, - ], - [ - ['maxMessage' => 'max_message'], - 0, - $notInRangeMessage, - Range::NOT_IN_RANGE_ERROR, - ], - [ - ['minMessage' => 'min_message'], - 15, - $notInRangeMessage, - Range::NOT_IN_RANGE_ERROR, - ], - [ - ['maxMessage' => 'max_message'], - 15, - $notInRangeMessage, - Range::NOT_IN_RANGE_ERROR, - ], ]; } From 8a2f9f786ae44dd22dd1bbc624767c4e9118e1fc Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 27 Apr 2024 11:31:10 +0200 Subject: [PATCH 12/13] detect wrong e-mail validation modes --- Constraints/Email.php | 4 ++++ Tests/Constraints/EmailTest.php | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/Constraints/Email.php b/Constraints/Email.php index 912878de..e9e0e06d 100644 --- a/Constraints/Email.php +++ b/Constraints/Email.php @@ -62,6 +62,10 @@ public function __construct( throw new InvalidArgumentException('The "mode" parameter value is not valid.'); } + if (null !== $mode && !\in_array($mode, self::$validationModes, true)) { + throw new InvalidArgumentException('The "mode" parameter value is not valid.'); + } + parent::__construct($options, $groups, $payload); $this->message = $message ?? $this->message; diff --git a/Tests/Constraints/EmailTest.php b/Tests/Constraints/EmailTest.php index bf719b6f..3451fdfb 100644 --- a/Tests/Constraints/EmailTest.php +++ b/Tests/Constraints/EmailTest.php @@ -33,6 +33,13 @@ public function testUnknownModesTriggerException() new Email(['mode' => 'Unknown Mode']); } + public function testUnknownModeArgumentsTriggerException() + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('The "mode" parameter value is not valid.'); + new Email(null, null, 'Unknown Mode'); + } + public function testNormalizerCanBeSet() { $email = new Email(['normalizer' => 'trim']); From 4761a08d161d823ec281151ade0905547e0502a7 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 28 Apr 2024 12:38:38 +0200 Subject: [PATCH 13/13] fix merge --- Constraints/Email.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Constraints/Email.php b/Constraints/Email.php index 9f4e3778..ddc740ab 100644 --- a/Constraints/Email.php +++ b/Constraints/Email.php @@ -68,7 +68,7 @@ public function __construct( throw new InvalidArgumentException('The "mode" parameter value is not valid.'); } - if (null !== $mode && !\in_array($mode, self::$validationModes, true)) { + if (null !== $mode && !\in_array($mode, self::VALIDATION_MODES, true)) { throw new InvalidArgumentException('The "mode" parameter value is not valid.'); }