Issues (73)

src/Rules/ValidUrl.php (1 issue)

1
<?php
2
3
namespace Milwad\LaravelValidate\Rules;
4
5
use Illuminate\Contracts\Validation\Rule;
6
7
class ValidUrl implements Rule
8
{
9
    /**
10
     * Check url is valid.
11
     */
12
    public function passes($attribute, $value): bool
13
    {
14
        return preg_match('/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/', $value);
0 ignored issues
show
Bug Best Practice introduced by
The expression return preg_match('/http...~#?&\/\/=]*)/', $value) returns the type integer which is incompatible with the type-hinted return boolean.
Loading history...
15
    }
16
17
    /**
18
     * Get the validation error message.
19
     */
20
    public function message(): string
21
    {
22
        return __('validate.url');
23
    }
24
}
25