All checks were successful
Deploy api / deploy (push) Successful in 22s
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
43 lines
1.0 KiB
PHP
43 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Api;
|
|
|
|
use Illuminate\Contracts\Validation\Validator;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Http\Exceptions\HttpResponseException;
|
|
|
|
/**
|
|
* 返金リクエストバリデーション
|
|
*/
|
|
class RefundRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* バリデーションルール
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'SyunoRecvNum' => ['required', 'string', 'max:20', 'regex:/^[a-zA-Z0-9]+$/'],
|
|
'refundAmount' => ['nullable', 'integer', 'min:1'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* バリデーション失敗時のJSONエラーレスポンス
|
|
*/
|
|
protected function failedValidation(Validator $validator): void
|
|
{
|
|
throw new HttpResponseException(response()->json([
|
|
'error' => [
|
|
'code' => 'INVALID_REQUEST',
|
|
'message' => $validator->errors()->first(),
|
|
]
|
|
], 400));
|
|
}
|
|
}
|