Skip to content

Updated the behavior of the checkDNS option #9131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions reference/constraints/Url.rst
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ checkDNS

By default, this constraint just validates the syntax of the given URL. If you
also need to check whether the associated host exists, set the ``checkDNS``
option to ``true``:
option to the value of any of the ``CHECK_DNS_TYPE_*`` constants in the
:class:`Symfony\\Component\\Validator\\Constraints\\Url` class:

.. configuration-block::

Expand All @@ -248,7 +249,7 @@ option to ``true``:
{
/**
* @Assert\Url(
* checkDNS = true
* checkDNS = "ANY"
* )
*/
protected $bioUrl;
Expand All @@ -260,7 +261,7 @@ option to ``true``:
AppBundle\Entity\Author:
properties:
bioUrl:
- Url: { checkDNS: true }
- Url: { checkDNS: 'ANY' }

.. code-block:: xml

Expand All @@ -273,7 +274,7 @@ option to ``true``:
<class name="AppBundle\Entity\Author">
<property name="bioUrl">
<constraint name="Url">
<option name="checkDNS">true</option>
<option name="checkDNS">ANY</option>
</constraint>
</property>
</class>
Expand All @@ -292,13 +293,13 @@ option to ``true``:
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('bioUrl', new Assert\Url(array(
'checkDNS' => true,
'checkDNS' => Assert\Url::CHECK_DNS_TYPE_ANY,
)));
}
}

This option uses the :phpfunction:`checkdnsrr` PHP function to check the validity
of the ``ANY`` DNS record corresponding to the host associated with the given URL.
of the DNS record corresponding to the host associated with the given URL.

dnsMessage
~~~~~~~~~~
Expand Down