51 lines
1.6 KiB
PHP
51 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Modules\Transformation\app\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class TransformationRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'before' => 'sometimes|nullable|image|mimes:jpeg,png,jpg,gif',
|
|
'after' => 'sometimes|nullable|image|mimes:jpeg,png,jpg,gif',
|
|
// 'name' => 'required|nullable|string|max:255|regex:/^(?![ .]+$)(?!\.)(?!.*[. ])[a-zA-Z. ]+$/',
|
|
'grade' => 'sometimes|nullable|string',
|
|
'graft' => 'sometimes|nullable|string'
|
|
];
|
|
}
|
|
|
|
public function messages()
|
|
{
|
|
return [
|
|
'before.image' => 'The before image must be an image file.',
|
|
'before.mimes' => 'The before image must be a file of type: jpeg, png, jpg, gif.',
|
|
|
|
'after.image' => 'The after image must be an image file.',
|
|
'after.mimes' => 'The after image must be a file of type: jpeg, png, jpg, gif.',
|
|
|
|
// '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.',
|
|
|
|
'grade.string' => 'The grade field must be a string.',
|
|
|
|
'graft.string' => 'The graft field must be a string.',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
}
|