Переглянути джерело

[Validator] changed the convention for placeholders in messages to be compatible with Twig (from %limit% to {{ limit }})

Fabien Potencier 14 роки тому
батько
коміт
9580c74f0b

+ 1 - 1
src/Symfony/Component/Validator/ConstraintViolation.php

@@ -34,7 +34,7 @@ class ConstraintViolation
         $sources = array();
         $targets = array();
         foreach ($this->messageParameters as $key => $value) {
-            $sources[] = '%'.$key.'%';
+            $sources[] = '{{ '.$key.' }}';
             $targets[] = (string) $value;
         }
 

+ 1 - 1
src/Symfony/Component/Validator/Constraints/AssertType.php

@@ -4,7 +4,7 @@ namespace Symfony\Component\Validator\Constraints;
 
 class AssertType extends \Symfony\Component\Validator\Constraint
 {
-    public $message = 'This value should be of type %type%';
+    public $message = 'This value should be of type {{ type }}';
     public $type;
 
     /**

+ 2 - 2
src/Symfony/Component/Validator/Constraints/Choice.php

@@ -18,8 +18,8 @@ class Choice extends \Symfony\Component\Validator\Constraint
     public $min = null;
     public $max = null;
     public $message = 'This value should be one of the given choices';
-    public $minMessage = 'You should select at least %limit% choices';
-    public $maxMessage = 'You should select at most %limit% choices';
+    public $minMessage = 'You should select at least {{ limit }} choices';
+    public $maxMessage = 'You should select at most {{ limit }} choices';
 
     /**
      * {@inheritDoc}

+ 2 - 2
src/Symfony/Component/Validator/Constraints/Collection.php

@@ -7,8 +7,8 @@ class Collection extends \Symfony\Component\Validator\Constraint
     public $fields;
     public $allowExtraFields = false;
     public $allowMissingFields = false;
-    public $extraFieldsMessage = 'The fields %fields% were not expected';
-    public $missingFieldsMessage = 'The fields %fields% are missing';
+    public $extraFieldsMessage = 'The fields {{ fields }} were not expected';
+    public $missingFieldsMessage = 'The fields {{ fields }} are missing';
 
     public function requiredOptions()
     {

+ 2 - 2
src/Symfony/Component/Validator/Constraints/File.php

@@ -8,6 +8,6 @@ class File extends \Symfony\Component\Validator\Constraint
     public $mimeTypes = array();
     public $notFoundMessage = 'The file could not be found';
     public $notReadableMessage = 'The file is not readable';
-    public $maxSizeMessage = 'The file is too large (%size%). Allowed maximum size is %limit%';
-    public $mimeTypesMessage = 'The mime type of the file is invalid (%type%). Allowed mime types are %types%';
+    public $maxSizeMessage = 'The file is too large ({{ size }}). Allowed maximum size is {{ limit }}';
+    public $mimeTypesMessage = 'The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}';
 }

+ 1 - 1
src/Symfony/Component/Validator/Constraints/Max.php

@@ -4,7 +4,7 @@ namespace Symfony\Component\Validator\Constraints;
 
 class Max extends \Symfony\Component\Validator\Constraint
 {
-    public $message = 'This value should be %limit% or less';
+    public $message = 'This value should be {{ limit }} or less';
     public $limit;
 
     /**

+ 1 - 1
src/Symfony/Component/Validator/Constraints/MaxLength.php

@@ -4,7 +4,7 @@ namespace Symfony\Component\Validator\Constraints;
 
 class MaxLength extends \Symfony\Component\Validator\Constraint
 {
-    public $message = 'This value is too long. It should have %limit% characters or less';
+    public $message = 'This value is too long. It should have {{ limit }} characters or less';
     public $limit;
     public $charset = 'UTF-8';
 

+ 1 - 1
src/Symfony/Component/Validator/Constraints/Min.php

@@ -4,7 +4,7 @@ namespace Symfony\Component\Validator\Constraints;
 
 class Min extends \Symfony\Component\Validator\Constraint
 {
-    public $message = 'This value should be %limit% or more';
+    public $message = 'This value should be {{ limit }} or more';
     public $limit;
 
     /**

+ 1 - 1
src/Symfony/Component/Validator/Constraints/MinLength.php

@@ -4,7 +4,7 @@ namespace Symfony\Component\Validator\Constraints;
 
 class MinLength extends \Symfony\Component\Validator\Constraint
 {
-    public $message = 'This value is too short. It should have %limit% characters or more';
+    public $message = 'This value is too short. It should have {{ limit }} characters or more';
     public $limit;
     public $charset = 'UTF-8';
 

+ 1 - 1
src/Symfony/Component/Validator/Constraints/Valid.php

@@ -4,6 +4,6 @@ namespace Symfony\Component\Validator\Constraints;
 
 class Valid extends \Symfony\Component\Validator\Constraint
 {
-    public $message = 'This value should be instance of class %class%';
+    public $message = 'This value should be instance of class {{ class }}';
     public $class;
 }