Files
KanbanGit/app/Http/Requests/UpdateProjectNotificationActionRequest.php
T
Twyco 22caed4fa1
linter / quality (pull_request) Successful in 1m17s
tests / ci (8.4) (pull_request) Successful in 1m33s
request fix
2026-04-25 20:28:00 +02:00

46 lines
1.6 KiB
PHP

<?php
namespace App\Http\Requests;
use App\Enums\DiscordAllowedMentionType;
use App\Enums\NotificationChannel;
use App\Enums\NotificationEventType;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UpdateProjectNotificationActionRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return $this->user() !== null;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
$messageTemplateRules = $this->input('channel') === NotificationChannel::Discord->value
? ['required', 'string', 'max:2000']
: ['nullable', 'string', 'max:2000'];
return [
'name' => ['required', 'string', 'max:255'],
'event_type' => ['required', 'string', Rule::in(NotificationEventType::values())],
'channel' => ['required', 'string', Rule::in(NotificationChannel::values())],
'channel_configuration' => ['nullable', 'array'],
'channel_configuration.allowed_mentions' => ['nullable', 'array'],
'channel_configuration.allowed_mentions.*' => ['nullable', 'string', Rule::in(DiscordAllowedMentionType::values())],
'enabled' => ['required', 'boolean'],
'delivery_url' => ['nullable', 'string', 'max:2048', 'url'],
'message_template' => $messageTemplateRules,
];
}
}