1 | <?php |
||
2 | |||
3 | namespace Milwad\LaravelValidate\Rules; |
||
4 | |||
5 | use Illuminate\Contracts\Validation\Rule; |
||
6 | |||
7 | class ValidPort implements Rule |
||
8 | { |
||
9 | /** |
||
10 | * Check port is valid. |
||
11 | */ |
||
12 | public function passes($attribute, $value): bool |
||
13 | { |
||
14 | return preg_match('/^((6553[0-5])|(655[0-2][0-9])|(65[0-4][0-9]{2})|(6[0-4][0-9]{3})|([1-5][0-9]{4})|([0-5]{0,5})|([0-9]{1,4}))$/', $value); |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
15 | } |
||
16 | |||
17 | /** |
||
18 | * Get the validation error message. |
||
19 | */ |
||
20 | public function message(): string |
||
21 | { |
||
22 | return __('validate.port'); |
||
23 | } |
||
24 | } |
||
25 |