fix(core,board,ecommerce): 조건부 검증 결함 패밀리 일괄 수정 및 실패 안내 노출
여러 화면에서 조건부(FormRequest) 검증이 우회되거나 과도하게 제한되던 결함을 한 계열로 묶어 수정한다. - 검증 규칙 확장 필터 이름 10개를 나머지 92개와 동일 규칙으로 통일 - 설명 길이를 바이트가 아닌 글자 수로 계산(한글 오검출 해소) - 비활성 언어팩 번역 보존한 채 수정 허용 - 알림 템플릿 제목 nullable 존중, 미지원 발송 수단 저장 차단 - 일정/실행 이력 목록 조회 검증 정합 - 게시판 첨부 미사용 시 빈 확장자 통과, new_display_hours/최소 길이 0 허용, 일괄 적용 override_values 범위 검증(SSoT) - 이커머스 클레임 사유 조회 검증, 용어 정정 - 원문 i18n 키 노출 다수 해소, 저장/삭제 실패 시 사유 화면 노출 - 아이콘 크기/다크모드 대비 회귀 수정 번들 확장(모듈3·플러그인6·템플릿2·언어팩5) 버전 new-bump 및 CHANGELOG 반영, ja 언어팩 동기.
This commit is contained in:
1 parent
c001b30a87
commit
7f8fb6870f
288 files changed
+5339
-1049
No files matched your search
@@ -10,12 +10,14 @@ use App\Rules\TranslatableField;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\Validator;
|
||||
use Modules\Sirsoft\Board\Http\Requests\Concerns\ReadsBoardLimits;
|
||||
use Modules\Sirsoft\Board\Http\Requests\Concerns\ValidatesLengthRange;
|
||||
use Modules\Sirsoft\Board\Rules\BoardTypeValidationRule;
|
||||
use Modules\Sirsoft\Board\Rules\PermissionRolesRequiredRule;
|
||||
|
||||
class UpdateBoardRequest extends FormRequest
|
||||
{
|
||||
use ReadsBoardLimits;
|
||||
use ValidatesLengthRange;
|
||||
|
||||
/**
|
||||
@@ -77,43 +79,51 @@ class UpdateBoardRequest extends FormRequest
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
* slug는 수정 불가하므로 제외됩니다.
|
||||
* 부분 업데이트를 지원하기 위해 sometimes 규칙을 적용합니다.
|
||||
*
|
||||
* `sometimes` 는 "요청에 그 키가 없을 때만" 검증을 건너뛴다. 관리자 폼은 조회 응답
|
||||
* 전체를 그대로 PUT 하므로 키는 항상 존재하며, 따라서 sometimes 만으로는 조건부
|
||||
* 배제가 되지 않는다. 다른 필드 값에 따라 검증을 배제해야 하는 항목은 `exclude_if`
|
||||
* 를 규칙 배열 첫 번째에 두어야 한다 (allowed_extensions 참조).
|
||||
*
|
||||
* @return array<string, mixed> 검증 규칙 배열
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
// config에서 제한값 가져오기
|
||||
$limits = config('sirsoft-board.limits', []);
|
||||
$perPageMin = $limits['per_page_min'] ?? 5;
|
||||
$perPageMax = $limits['per_page_max'] ?? 100;
|
||||
$maxFileSizeMax = $limits['max_file_size_max'] ?? 200; // MB
|
||||
$maxFileCountMax = $limits['max_file_count_max'] ?? 20;
|
||||
$categoryMax = $limits['category_max'] ?? 50;
|
||||
// config 기준 제한값 (폴백 기본치는 ReadsBoardLimits 트레이트가 단일 관리)
|
||||
$limits = $this->boardLimits();
|
||||
$perPageMin = $limits['per_page_min'];
|
||||
$perPageMax = $limits['per_page_max'];
|
||||
$maxFileSizeMax = $limits['max_file_size_max']; // MB
|
||||
$maxFileCountMax = $limits['max_file_count_max'];
|
||||
$categoryMax = $limits['category_max'];
|
||||
|
||||
// 제목 길이 제한
|
||||
$minTitleLengthMin = $limits['min_title_length_min'] ?? 0;
|
||||
$minTitleLengthMax = $limits['min_title_length_max'] ?? 200;
|
||||
$maxTitleLengthMin = $limits['max_title_length_min'] ?? 1;
|
||||
$maxTitleLengthMax = $limits['max_title_length_max'] ?? 200;
|
||||
$minTitleLengthMin = $limits['min_title_length_min'];
|
||||
$minTitleLengthMax = $limits['min_title_length_max'];
|
||||
$maxTitleLengthMin = $limits['max_title_length_min'];
|
||||
$maxTitleLengthMax = $limits['max_title_length_max'];
|
||||
|
||||
// 내용 길이 제한
|
||||
$minContentLengthMin = $limits['min_content_length_min'] ?? 0;
|
||||
$minContentLengthMax = $limits['min_content_length_max'] ?? 10000;
|
||||
$maxContentLengthMin = $limits['max_content_length_min'] ?? 1;
|
||||
$maxContentLengthMax = $limits['max_content_length_max'] ?? 50000;
|
||||
$minContentLengthMin = $limits['min_content_length_min'];
|
||||
$minContentLengthMax = $limits['min_content_length_max'];
|
||||
$maxContentLengthMin = $limits['max_content_length_min'];
|
||||
$maxContentLengthMax = $limits['max_content_length_max'];
|
||||
|
||||
// 댓글 길이 제한
|
||||
$minCommentLengthMin = $limits['min_comment_length_min'] ?? 0;
|
||||
$minCommentLengthMax = $limits['min_comment_length_max'] ?? 1000;
|
||||
$maxCommentLengthMin = $limits['max_comment_length_min'] ?? 1;
|
||||
$maxCommentLengthMax = $limits['max_comment_length_max'] ?? 1000;
|
||||
$minCommentLengthMin = $limits['min_comment_length_min'];
|
||||
$minCommentLengthMax = $limits['min_comment_length_max'];
|
||||
$maxCommentLengthMin = $limits['max_comment_length_min'];
|
||||
$maxCommentLengthMax = $limits['max_comment_length_max'];
|
||||
|
||||
// 답글/대댓글 깊이 제한
|
||||
$maxReplyDepthMin = $limits['max_reply_depth_min'] ?? 1;
|
||||
$maxReplyDepthMax = $limits['max_reply_depth_max'] ?? 10;
|
||||
$maxCommentDepthMin = $limits['max_comment_depth_min'] ?? 0;
|
||||
$maxCommentDepthMax = $limits['max_comment_depth_max'] ?? 10;
|
||||
$maxReplyDepthMin = $limits['max_reply_depth_min'];
|
||||
$maxReplyDepthMax = $limits['max_reply_depth_max'];
|
||||
$maxCommentDepthMin = $limits['max_comment_depth_min'];
|
||||
$maxCommentDepthMax = $limits['max_comment_depth_max'];
|
||||
|
||||
// NEW 배지 표시 기간 (0 = 표시 안 함)
|
||||
$newDisplayHoursMin = $limits['new_display_hours_min'];
|
||||
$newDisplayHoursMax = $limits['new_display_hours_max'];
|
||||
|
||||
$rules = [
|
||||
// 기본 정보 (slug 제외, name/description은 다국어 필드)
|
||||
@@ -142,7 +152,7 @@ class UpdateBoardRequest extends FormRequest
|
||||
'use_reply' => ['sometimes', 'required', 'boolean'],
|
||||
'use_report' => ['sometimes', 'required', 'boolean'],
|
||||
'comment_order' => ['sometimes', 'required', 'in:ASC,DESC'],
|
||||
'new_display_hours' => ['sometimes', 'nullable', 'integer', 'min:1', 'max:720'],
|
||||
'new_display_hours' => ['sometimes', 'nullable', 'integer', "min:{$newDisplayHoursMin}", "max:{$newDisplayHoursMax}"],
|
||||
|
||||
// 제목 길이 제한
|
||||
'min_title_length' => ['sometimes', 'nullable', 'integer', "min:{$minTitleLengthMin}", "max:{$minTitleLengthMax}"],
|
||||
@@ -160,12 +170,18 @@ class UpdateBoardRequest extends FormRequest
|
||||
'use_file_upload' => ['sometimes', 'required', 'boolean'],
|
||||
'max_file_size' => ['sometimes', 'nullable', 'integer', 'min:1', "max:{$maxFileSizeMax}"],
|
||||
'max_file_count' => ['sometimes', 'nullable', 'integer', 'min:1', "max:{$maxFileCountMax}"],
|
||||
// 허용 확장자: 전송되면 최소 1개 필수 (빈 배열 저장 시 전 파일 거부되던 버그 방지).
|
||||
// 부분 수정을 위해 sometimes 유지, nullable 제거.
|
||||
'allowed_extensions' => ['sometimes', 'array', 'min:1'],
|
||||
// 허용 확장자: 첨부 사용 게시판만 최소 1개 필수 (빈 값 저장 시 전 파일 거부되던 버그 방지).
|
||||
// 첨부 미사용 게시판은 exclude_if 로 검증 자체에서 배제한다 — 관리자 폼이 조회 응답
|
||||
// 전체를 그대로 PUT 하므로 요청에는 항상 이 키가 존재하고, sometimes 는 보호가 되지 않는다.
|
||||
// exclude_if 는 배열 첫 번째여야 한다. 앞선 규칙이 먼저 실패하면 배제되어도 메시지가 남는다.
|
||||
'allowed_extensions' => ['exclude_if:use_file_upload,false', 'sometimes', 'required', 'array', 'min:1'],
|
||||
'allowed_extensions.*' => ['string', 'max:10'],
|
||||
|
||||
// 관리자 설정 (관리자는 최소 1명 필수, 스텝은 선택적)
|
||||
// audit:allow formrequest-sometimes-array-min-inert reason: 관리자 0명은 유효한 상태가 아니다.
|
||||
// board_manager_ids 는 역할 멤버십에서 파생되므로(BoardResource::getBoardRoleData) 관리자 계정이
|
||||
// 삭제되면 빈 배열이 될 수 있는데, 이때는 저장을 막고 관리자를 다시 지정하도록 안내하는 것이 맞다.
|
||||
// allowed_extensions 처럼 "비어 있음"이 정상 상태인 필드와 다르다.
|
||||
'board_manager_ids' => ['sometimes', 'required', 'array', 'min:1'],
|
||||
'board_manager_ids.*' => ['uuid', Rule::exists(User::class, 'uuid')],
|
||||
'board_step_ids' => ['sometimes', 'nullable', 'array'],
|
||||
@@ -218,7 +234,7 @@ class UpdateBoardRequest extends FormRequest
|
||||
public function attributes(): array
|
||||
{
|
||||
$attributes = [
|
||||
'blocked_keywords' => __('sirsoft-board::admin.form.fields.blocked_keywords.label'),
|
||||
'blocked_keywords' => __('sirsoft-board::validation.attributes.board.blocked_keywords'),
|
||||
'add_to_menu' => __('sirsoft-board::validation.attributes.board.add_to_menu'),
|
||||
];
|
||||
|
||||
@@ -349,6 +365,7 @@ class UpdateBoardRequest extends FormRequest
|
||||
'max_file_size.max' => __('sirsoft-board::validation.max_file_size.max'),
|
||||
'max_file_count.min' => __('sirsoft-board::validation.max_file_count.min'),
|
||||
'max_file_count.max' => __('sirsoft-board::validation.max_file_count.max'),
|
||||
'allowed_extensions.required' => __('sirsoft-board::validation.allowed_extensions.min'),
|
||||
'allowed_extensions.min' => __('sirsoft-board::validation.allowed_extensions.min'),
|
||||
|
||||
// 관리자 설정 검증 메시지
|
||||
|
||||
Reference in new issue
Block a user