Skip to content

Commit

Permalink
bug symfony#57894 [Validator] Add tldMessage parameter to Url con…
Browse files Browse the repository at this point in the history
…straint constructor (syjust)

This PR was submitted for the 7.2 branch but it was merged into the 7.1 branch instead.

Discussion
----------

[Validator] Add `tldMessage` parameter to `Url` constraint constructor

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        |
| License       | MIT

according to the following documentation
https://symfony.com/doc/current/reference/constraints/Url.html#tldmessage

The Url Constraint does not allow to set tldMessage as the [following documentation](https://symfony.com/doc/current/reference/constraints/Url.html#tldmessage) explains. This is due to a missing Constructor Argument. This PR will fix that issue and let the Url Constraint works as described in the documentation.

Commits
-------

8db4a92 [Validator] add tldMessage in URL constructor
  • Loading branch information
fabpot committed Aug 3, 2024
2 parents 1a09bff + 8db4a92 commit 0c91466
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Symfony/Component/Validator/Constraints/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function __construct(
?array $groups = null,
mixed $payload = null,
?bool $requireTld = null,
?string $tldMessage = null,
) {
parent::__construct($options, $groups, $payload);

Expand All @@ -66,6 +67,7 @@ public function __construct(
$this->relativeProtocol = $relativeProtocol ?? $this->relativeProtocol;
$this->normalizer = $normalizer ?? $this->normalizer;
$this->requireTld = $requireTld ?? $this->requireTld;
$this->tldMessage = $tldMessage ?? $this->tldMessage;

if (null !== $this->normalizer && !\is_callable($this->normalizer)) {
throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', get_debug_type($this->normalizer)));
Expand Down

0 comments on commit 0c91466

Please sign in to comment.