laravel-embed icon indicating copy to clipboard operation
laravel-embed copied to clipboard

Validation Rule try/catch mismatch causes passed exception

Open thumbtech opened this issue 2 years ago • 2 comments

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 avatar Feb 19 '24 21:02 thumbtech

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

thumbtech avatar Feb 19 '24 21:02 thumbtech

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]')
        );
    }

thumbtech avatar Feb 26 '24 20:02 thumbtech