api.so-manager-dev.com/app/Http/Requests/Api/RefundRequest.php
Your Name f139a3f608
All checks were successful
Deploy api / deploy (push) Successful in 22s
支払いAPI実装
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 20:02:25 +09:00

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));
}
}