Download app/Rules/DomainRule.php from pnacorp/magicai: direct link, hf CLI and curl.
- Browser
- Download file 623 Bytes
-
https://huggingface.co/pnacorp/magicai/resolve/main/app/Rules/DomainRule.php
- Command line
-
hf download hf://pnacorp/magicai/app/Rules/DomainRule.php
-
curl -L -o DomainRule.php https://huggingface.co/pnacorp/magicai/resolve/main/app/Rules/DomainRule.php
623 Bytes
| declare(strict_types=1); | |
| namespace App\Rules; | |
| use Closure; | |
| use Illuminate\Contracts\Validation\ValidationRule; | |
| class DomainRule implements ValidationRule | |
| { | |
| public function __construct(public bool $allowWildcard = false) {} | |
| public function validate(string $attribute, mixed $value, Closure $fail): void | |
| { | |
| if ($value === '*' && $this->allowWildcard) { | |
| return; | |
| } | |
| if (! (bool) preg_match('/^(?:[a-z0-9](?:[a-z0-9-æøå]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$/iu', $value)) { | |
| $fail('The :attribute is not a valid domain.'); | |
| } | |
| } | |
| } | |