-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Added documentation for dnsMessage option #5804
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ Validates that a value is a valid URL string. | |
| | - `protocols`_ | | ||
| | - `payload`_ | | ||
| | - `checkDNS`_ | | ||
| | - `dnsMessage`_ | ||
+----------------+---------------------------------------------------------------------+ | ||
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Url` | | ||
+----------------+---------------------------------------------------------------------+ | ||
|
@@ -299,5 +300,78 @@ option to ``true``: | |
} | ||
} | ||
|
||
dnsMessage | ||
~~~~~~~~~~ | ||
|
||
.. versionadded:: 2.7 | ||
The ``dnsMessage`` option was introduced in Symfony 2.7. | ||
|
||
**type**: ``string`` **default**: ``The host could not be resolved.`` | ||
|
||
This message is shown when the ``checkDNS`` option is set to ``true`` and the | ||
DNS check failed. | ||
|
||
.. configuration-block:: | ||
|
||
.. code-block:: php-annotations | ||
|
||
// src/AppBundle/Entity/Author.php | ||
namespace AppBundle\Entity; | ||
|
||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
class Author | ||
{ | ||
/** | ||
* @Assert\Url( | ||
* dnsMessage = "The host '{{ value }}' could not be resolved" | ||
* ) | ||
*/ | ||
protected $bioUrl; | ||
} | ||
|
||
.. code-block:: yaml | ||
|
||
# src/AppBundle/Resources/config/validation.yml | ||
AppBundle\Entity\Author: | ||
properties: | ||
bioUrl: | ||
- Url: { dnsMessage: The host "{{ value }}" could not be resolved } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have to enclose the message in single quotes to have valid YAML here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, and what do you think to end the message with a period (in all examples) to have a complete sentence? |
||
|
||
.. code-block:: xml | ||
|
||
<!-- src/AppBundle/Resources/config/validation.xml --> | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> | ||
|
||
<class name="AppBundle\Entity\Author"> | ||
<property name="bioUrl"> | ||
<constraint name="Url"> | ||
<option name="dnsMessage">The host "{{ value }}" could not be resolved</option> | ||
</constraint> | ||
</property> | ||
</class> | ||
</constraint-mapping> | ||
|
||
.. code-block:: php | ||
|
||
// src/AppBundle/Entity/Author.php | ||
namespace AppBundle\Entity; | ||
|
||
use Symfony\Component\Validator\Mapping\ClassMetadata; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
class Author | ||
{ | ||
public static function loadValidatorMetadata(ClassMetadata $metadata) | ||
{ | ||
$metadata->addPropertyConstraint('bioUrl', new Assert\Url(array( | ||
'dnsMessage' => 'The host "{{ value }}" could not be resolved' | ||
))); | ||
} | ||
} | ||
|
||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This paragraph belongs to the previously described |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a
|
character in this line to end the cell (at the same position as on the other lines).