Skip to content

[✨feat] InternshipAnnouncementUrl VO 구현 #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: feat/#60
Choose a base branch
from

Conversation

jsoonworld
Copy link
Member

📄 Work Description

  • 인턴십 공고 상세 페이지 URL을 표현하는 VO InternshipAnnouncementUrl을 구현했습니다.
  • http 또는 https로 시작하는 URL만 유효한 값으로 허용하며, 그렇지 않으면 InternshipException을 발생시킵니다.
  • VO는 불변 객체로 설계되었고, JPA 내장 타입으로 사용될 수 있도록 @Embeddable을 적용했습니다.
  • 예외 처리 일관성을 위해 InternshipErrorCodeINVALID_ANNOUNCEMENT_URL 항목을 추가했습니다.

💭 Thoughts

  • 문자열 URL을 도메인 내 VO로 감싸도록 하여 유효하지 않은 값이 진입하는 것을 방지하고자 했습니다.
  • 도메인 유효성 검증 책임을 VO 내부로 넣어 신뢰 가능한 객체만 다루도록 했습니다.
  • 기존의 VO 패턴과 동일하게 구조화하여 일관성과 재사용성을 확보했습니다.

✅ Testing Result

스크린샷 2025-05-20 오후 11 49 25


🗂 Related Issue

http 또는 https로 시작하는 유효한 URL만 허용하는 InternshipAnnouncementUrl 값을 구현했습니다.
JPA 내장 타입으로 사용할 수 있도록 @embeddable을 적용하고,
유효성 검증 및 equals, hashCode, toString 메서드를 정의했습니다.
InternshipAnnouncementUrl VO에서 사용할 INVALID_ANNOUNCEMENT_URL 오류 코드를 추가했습니다.
http/https로 시작하지 않는 URL 입력 시 예외를 발생시키는 데 사용됩니다.
http/https로 시작하는 경우 객체가 정상 생성되는지 검증하고,
그 외의 경우 예외가 발생하는지 테스트를 통해 확인했습니다.
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements the value object InternshipAnnouncementUrl to enforce that only URLs beginning with http or https are accepted, thereby ensuring domain-level data integrity.

  • Adds the InternshipAnnouncementUrl VO with built-in URL validation and immutability.
  • Implements corresponding tests to verify valid and invalid URL behavior.
  • Updates the InternshipErrorCode enum with an INVALID_ANNOUNCEMENT_URL entry to standardize error handling.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/test/kotlin/com/terning/server/kotlin/domain/internshipAnnouncement/InternshipAnnouncementUrlTest.kt Tests validate proper creation and exception throwing for URL inputs.
src/main/kotlin/com/terning/server/kotlin/domain/internshipAnnouncement/InternshipErrorCode.kt Adds error code for announcement URLs supporting consistent exception handling.
src/main/kotlin/com/terning/server/kotlin/domain/internshipAnnouncement/InternshipAnnouncementUrl.kt Introduces the VO with embedded URL validation logic.

fun from(value: String): InternshipAnnouncementUrl = InternshipAnnouncementUrl(value)

private fun validateUrl(value: String) {
if (!value.startsWith("http")) {
Copy link
Preview

Copilot AI May 20, 2025

Choose a reason for hiding this comment

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

[nitpick] The URL validation check using startsWith("http") might be too permissive, as it could unintentionally allow strings like 'httpdummy'. Consider explicitly checking for 'http://' or 'https://' to ensure only valid URLs are accepted.

Suggested change
if (!value.startsWith("http")) {
if (!(value.startsWith("http://") || value.startsWith("https://"))) {

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant