Skip to content

Commit

Permalink
Rename DomainBlacklist rule
Browse files Browse the repository at this point in the history
  • Loading branch information
realodix committed May 4, 2024
1 parent dd24163 commit bc5b248
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/Http/Requests/StoreUrlRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Http\Requests;

use App\Rules\AlphaNumHyphen;
use App\Rules\Url\DomainBlacklist;
use App\Rules\Url\NotBlacklistedDomain;
use Illuminate\Foundation\Http\FormRequest;

class StoreUrlRequest extends FormRequest
Expand All @@ -26,7 +26,7 @@ public function authorize()
public function rules()
{
return [
'long_url' => ['required', 'url', 'max:65535', new DomainBlacklist],
'long_url' => ['required', 'url', 'max:65535', new NotBlacklistedDomain],
'custom_key' => ['nullable', 'max:20', new AlphaNumHyphen, 'unique:urls,keyword'],
];
}
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Requests/UpdateUrlRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Http\Requests;

use App\Models\Url;
use App\Rules\Url\DomainBlacklist;
use App\Rules\Url\NotBlacklistedDomain;
use Illuminate\Foundation\Http\FormRequest;

class UpdateUrlRequest extends FormRequest
Expand All @@ -27,7 +27,7 @@ public function rules(): array

return [
'title' => ["max:{$titleLength}"],
'long_url' => ['required', 'url', 'max:65535', new DomainBlacklist],
'long_url' => ['required', 'url', 'max:65535', new NotBlacklistedDomain],
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use App\Helpers\Helper;
use Illuminate\Contracts\Validation\ValidationRule;

class DomainBlacklist implements ValidationRule
class NotBlacklistedDomain implements ValidationRule
{
/**
* Run the validation rule.
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Rule/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Tests\Unit\Rule;

use App\Rules\Url\DomainBlacklist;
use App\Rules\Url\KeywordBlacklist;
use App\Rules\Url\NotBlacklistedDomain;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Test;
Expand All @@ -27,7 +27,7 @@ protected function setUp(): void
#[DataProvider('domainBlacklistPassDataProvider')]
public function domainBlacklistPass($value): void
{
$val = Helper::validator(['foo' => $value], ['foo' => new DomainBlacklist]);
$val = Helper::validator(['foo' => $value], ['foo' => new NotBlacklistedDomain]);

$this->assertTrue($val->passes());
$this->assertSame([], $val->messages()->messages());
Expand All @@ -41,7 +41,7 @@ public function domainBlacklistPass($value): void
#[DataProvider('domainBlacklistFailDataProvider')]
public function domainBlacklistFail($value): void
{
$val = Helper::validator(['foo' => $value], ['foo' => new DomainBlacklist]);
$val = Helper::validator(['foo' => $value], ['foo' => new NotBlacklistedDomain]);

$this->assertTrue($val->fails());
$this->assertSame([
Expand Down

0 comments on commit bc5b248

Please sign in to comment.