BenSampo / laravel-embed

Effortless responsive embeds for videos, slideshows and more.
MIT License
135 stars 19 forks source link

Validation Rule try/catch mismatch causes passed exception #22

Open thumbtech opened 8 months ago

thumbtech commented 8 months ago

In ValueObjects/Url.php __construct you are throwing InvalidArgumentException but your try new Url($value) in Rules/EmbeddableUrl.php is catching ServiceNotFoundException so the exception is thrown.

thumbtech commented 8 months ago

Also FWIW Illuminate\Contracts\Validation\Rule is being deprecated in favor of Illuminate\Contracts\Validation\ValidationRule

thumbtech commented 8 months ago

If you update test_it_fails_for_an_invalid_url in EmbeddableUrlTest.php like so, your test will fail

    public function test_it_fails_for_an_invalid_url()
    {
        $this->assertFalse(
            (new EmbeddableUrl)
                ->passes('', '[xyz]')
        );
    }