48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Modules\Client\app\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class CreateClientRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'name' => 'required|string|max:255|regex:/^(?![ .]+$)(?!\.)(?!.*[. ])[a-zA-Z. ]+$/',
|
|
'status' => 'required|in:active,inactive',
|
|
'link' => 'sometimes|nullable|string|max:10000',
|
|
'image' => 'sometimes|nullable|mimes:png,jpg,jpeg',
|
|
];
|
|
}
|
|
|
|
public function messages()
|
|
{
|
|
return [
|
|
'name.required' => 'The name field is required.',
|
|
'name.string' => 'The name field must be a string.',
|
|
'name.max' => 'The name may not be greater than 255 characters.',
|
|
'name.regex' => 'The name field only accepts letters, spaces, and dots, and must not start with a dot or contain both spaces and dots only.',
|
|
|
|
'status.required' => 'The status field is required.',
|
|
'status.in' => 'The status field must be either "active" or "inactive".',
|
|
|
|
'link.string' => 'The link field must be a string.',
|
|
'link.max' => 'The link may not be greater than 10000 characters.',
|
|
|
|
'image.mimes' => 'The image must be a file of type: png, jpg, jpeg.',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
}
|