Download app/Concerns/ProfileValidationRules.php from lifedebugger/CAPS04-FE-REFACTOR-2: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/spaces/lifedebugger/CAPS04-FE-REFACTOR-2/resolve/main/app/Concerns/ProfileValidationRules.php
- Command line
-
hf download hf://spaces/lifedebugger/CAPS04-FE-REFACTOR-2/app/Concerns/ProfileValidationRules.php
-
curl -L -o ProfileValidationRules.php https://huggingface.co/spaces/lifedebugger/CAPS04-FE-REFACTOR-2/resolve/main/app/Concerns/ProfileValidationRules.php
1.26 kB
| namespace App\Concerns; | |
| use App\Models\User; | |
| use Illuminate\Contracts\Validation\ValidationRule; | |
| use Illuminate\Validation\Rule; | |
| trait ProfileValidationRules | |
| { | |
| /** | |
| * Get the validation rules used to validate user profiles. | |
| * | |
| * @return array<string, array<int, ValidationRule|array<mixed>|string>> | |
| */ | |
| protected function profileRules(?int $userId = null): array | |
| { | |
| return [ | |
| 'name' => $this->nameRules(), | |
| 'email' => $this->emailRules($userId), | |
| ]; | |
| } | |
| /** | |
| * Get the validation rules used to validate user names. | |
| * | |
| * @return array<int, ValidationRule|array<mixed>|string> | |
| */ | |
| protected function nameRules(): array | |
| { | |
| return ['required', 'string', 'max:255']; | |
| } | |
| /** | |
| * Get the validation rules used to validate user emails. | |
| * | |
| * @return array<int, ValidationRule|array<mixed>|string> | |
| */ | |
| protected function emailRules(?int $userId = null): array | |
| { | |
| return [ | |
| 'required', | |
| 'string', | |
| 'email', | |
| 'max:255', | |
| $userId === null | |
| ? Rule::unique(User::class) | |
| : Rule::unique(User::class)->ignore($userId), | |
| ]; | |
| } | |
| } | |