Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Url validator] Returns false for valid (and existing) url #32506

Closed
@kptLucek

Description

@kptLucek

Symfony version(s) affected: 4.3.2 (propably earlier versions too)

Description
Url validator returns false (invalid url) on valid, and existing url - pattern issue

How to reproduce
Simply get an validator instance, and validate string/model with Url validator.
Url must contain underscores _ (im amazed to see them in url tho)

$url        = 'http://www.cku_zsr_glubczyce.wodip.opole.pl';
$violations = $this->validator->validate(['url' => $url], [
    new Collection([
        'fields' => [
            'url' => [new Url()]
        ]
    ])
]);
if ($violations->count() > 0) {
/** @var ConstraintViolation $violation */
foreach ($violations as $violation) {
    echo $violation->getPropertyPath() . ' :: ' . $violation->getMessage() . "\n";
}

Possible Solution
Update pattern in validator :)

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions