Skip to content

Commit a2b2fdf

Browse files
committed
Update Url.rst
1 parent fc3e50b commit a2b2fdf

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

reference/constraints/Url.rst

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ Basic Usage
2525
Acme\BlogBundle\Entity\Author:
2626
properties:
2727
bioUrl:
28-
- Url: ~
28+
- Url:
29+
message: The url "{{ value }}" is not a valid url.
30+
protocols: [http, https]
2931
3032
.. code-block:: php-annotations
3133
@@ -37,7 +39,10 @@ Basic Usage
3739
class Author
3840
{
3941
/**
40-
* @Assert\Url()
42+
* @Assert\Url(
43+
* message = "The url '{{ value }}' is not a valid url",
44+
* protocols = {"http", "https"}
45+
* )
4146
*/
4247
protected $bioUrl;
4348
}
@@ -52,7 +57,13 @@ Basic Usage
5257
5358
<class name="Acme\BlogBundle\Entity\Author">
5459
<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>
5667
</property>
5768
</class>
5869
</constraint-mapping>
@@ -69,7 +80,10 @@ Basic Usage
6980
{
7081
public static function loadValidatorMetadata(ClassMetadata $metadata)
7182
{
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+
)));
7387
}
7488
}
7589

0 commit comments

Comments
 (0)