-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStoreWorkspaceChatRequest.php
More file actions
49 lines (43 loc) · 1.55 KB
/
StoreWorkspaceChatRequest.php
File metadata and controls
49 lines (43 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class StoreWorkspaceChatRequest extends FormRequest
{
public function authorize(): bool
{
return $this->user() !== null;
}
protected function prepareForValidation(): void
{
$this->merge([
'chat_name' => is_string($this->chat_name) ? trim($this->chat_name) : $this->chat_name,
]);
}
/**
* @return array<string, ValidationRule|array<int, ValidationRule|string>|string>
*/
public function rules(): array
{
return [
'chat_name' => ['required', 'string', 'max:255', 'regex:/\\S/'],
'chat_kind' => ['required', 'string', 'in:direct,group'],
'chat_submission_token' => ['required', 'string'],
'workspace_agent_id' => ['nullable', 'integer', 'exists:workspace_agents,id'],
];
}
/**
* @return array<string, string>
*/
public function messages(): array
{
return [
'chat_name.required' => 'Enter a chat name to create it in this workspace.',
'chat_name.regex' => 'Chat names cannot be blank.',
'chat_kind.required' => 'Choose whether this chat is direct or group.',
'chat_kind.in' => 'Chats must be direct or group conversations.',
'chat_submission_token.required' => 'Refresh the workspace before creating a chat.',
'workspace_agent_id.exists' => 'Choose a valid agent for this workspace.',
];
}
}