Files
KanbanGit/app/Http/Requests/DeleteProjectRequest.php
T
Twyco 73cee8178f
linter / quality (pull_request) Successful in 2m28s
tests / ci (8.4) (pull_request) Successful in 1m22s
Enforce request validation style rules
2026-04-11 19:44:21 +02:00

44 lines
938 B
PHP

<?php
namespace App\Http\Requests;
use App\Models\Project;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class DeleteProjectRequest extends FormRequest
{
public function authorize(): bool
{
return $this->user() !== null;
}
/**
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
/** @var Project $project */
$project = $this->route('project');
return [
'confirmation_key' => [
'required',
'string',
Rule::in([$project->key]),
],
];
}
/**
* @return array<string, string>
*/
public function messages(): array
{
return [
'confirmation_key.in' => 'Enter the exact project key to confirm deletion.',
];
}
}