Skip to content

feat: validate semantic decorator conflict rules#235

Merged
yuchem2 merged 2 commits into
developfrom
CARGO-430
Jun 23, 2026
Merged

feat: validate semantic decorator conflict rules#235
yuchem2 merged 2 commits into
developfrom
CARGO-430

Conversation

@yuchem2

@yuchem2 yuchem2 commented Jun 18, 2026

Copy link
Copy Markdown
Member

논의에서 결정된 의미적인 충돌 규칙 검증을 추가합니다.

  • @Optional + @Default (값 부재 처리 전략은 하나만)
  • @Type / @List / @Enum 중복 (필드당 type-helper 하나만)
  • @With / @Without 자기 자신 참조
  • @Enum + @Transform (Enum이 자체 transformer 보유)

Add field-level rule checkers for decorator combinations that are syntactically valid but semantically conflicting:

- `@Optional` + `@Default` (single missing-value strategy)
- `@Type` / `@List` / `@Enum` duplication (single type-helper per field)
- `@With` / `@Without` self-reference
- `@Enum` + `@Transform` (Enum owns its transformer)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이번 풀 리퀘스트는 @with@without 데코레이터가 자기 자신을 참조하는 것을 방지하고, 중복된 타입 헬퍼(@type, @list, @enum), 누락 처리기(@optional, @default), 그리고 @enum@Transform이 함께 사용되는 것을 방지하는 다양한 스키마 검증 규칙을 추가합니다. 리뷰어는 missingHandler.ts에서 Set을 사용하여 데코레이터 이름을 고유화할 경우 동일한 데코레이터가 중복 적용된 상황(예: @optional() @optional())을 감지하지 못하는 버그를 지적했습니다. 이를 해결하기 위해 필터링된 배열의 길이를 직접 체크하는 방식으로 개선할 것을 제안했습니다.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +3 to +8
const optionalWithDefault: FieldRuleFn = s => {
const handlerNames = new Set(s.appliedSelf.filter(d => d.category === 'missing-handler').map(d => d.name))
return handlerNames.size > 1
? `${[...handlerNames].map(n => `@${n}`).join(' + ')} cannot be combined; pick a single missing-value strategy`
: null
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

현재 구현에서는 Set을 사용하여 데코레이터 이름의 중복을 제거하고 있습니다. 이로 인해 동일한 데코레이터가 중복해서 적용된 경우(예: @Optional() @Optional() 또는 @Default(1) @Default(2))를 감지하지 못하는 버그가 발생합니다.\n\n값 부재 처리 전략은 필드당 하나만 존재해야 하므로, Set의 크기 대신 필터링된 배열의 길이를 직접 체크하는 것이 더 안전합니다. 이는 typeHelperDuplication.ts에 구현된 방식과도 일관성을 유지할 수 있는 개선 방향입니다.

const optionalWithDefault: FieldRuleFn = s => {\n    const handlers = s.appliedSelf.filter(d => d.category === 'missing-handler')\n    return handlers.length > 1\n        ? `${handlers.map(d => `@${d.name}`).join(' + ')} cannot be combined; pick a single missing-value strategy`\n        : null\n}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이번 작업 자체는 Default와 Optional 두개의 혼합 사용을 막는 규칙을 추가한 것 인지만, 해당 규칙의 실질 의도는 같은 카테고리의 데코레이터 중복을 막는 것이기때문에 반여하도록 하겠습니다.

@yuchem2 yuchem2 self-assigned this Jun 18, 2026
@yuchem2 yuchem2 requested a review from laggu June 18, 2026 07:20
@yuchem2 yuchem2 merged commit 626ac72 into develop Jun 23, 2026
3 checks passed
@yuchem2 yuchem2 deleted the CARGO-430 branch June 23, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants