@@ -25,7 +25,9 @@ Basic Usage
25
25
Acme\BlogBundle\Entity\Author :
26
26
properties :
27
27
bioUrl :
28
- - Url : ~
28
+ - Url :
29
+ message : The url "{{ value }}" is not a valid url.
30
+ protocols : [http, https]
29
31
30
32
.. code-block :: php-annotations
31
33
@@ -37,7 +39,10 @@ Basic Usage
37
39
class Author
38
40
{
39
41
/**
40
- * @Assert\Url()
42
+ * @Assert\Url(
43
+ * message = "The url '{{ value }}' is not a valid url",
44
+ * protocols = {"http", "https"}
45
+ * )
41
46
*/
42
47
protected $bioUrl;
43
48
}
@@ -52,7 +57,13 @@ Basic Usage
52
57
53
58
<class name =" Acme\BlogBundle\Entity\Author" >
54
59
<property name =" bioUrl" >
55
- <constraint name =" Url" />
60
+ <constraint name =" Url" >
61
+ <option name =" message" >The url "{{ value }}" is not a valid url.</option >
62
+ <option name =" protocols" >
63
+ <value >http</value >
64
+ <value >https</value >
65
+ </option >
66
+ </constraint >
56
67
</property >
57
68
</class >
58
69
</constraint-mapping >
@@ -69,7 +80,10 @@ Basic Usage
69
80
{
70
81
public static function loadValidatorMetadata(ClassMetadata $metadata)
71
82
{
72
- $metadata->addPropertyConstraint('bioUrl', new Assert\Url());
83
+ $metadata->addPropertyConstraint('bioUrl', new Assert\Url(array(
84
+ 'message' => 'The url "{{ value }}" is not a valid url.',
85
+ 'protocols' => array('http', 'https'),
86
+ )));
73
87
}
74
88
}
75
89
0 commit comments