Skip to content

[✨feat] CompanyImageUrl VO 구현 #61

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/#58
Choose a base branch
from
Open

[✨feat] CompanyImageUrl VO 구현 #61

wants to merge 3 commits into from

Conversation

jsoonworld
Copy link
Member

📄 Work Description

  • 기업 로고 이미지 주소를 표현하는 VO CompanyLogoUrl을 구현했습니다.
  • 유효성 검증을 통해 http 또는 https로 시작하는 주소만 허용하며, 이를 만족하지 않으면 InternshipException을 발생시킵니다.
  • 도메인 일관성을 위해 기존 VO들과 동일한 방식(불변성, 정적 팩토리 메서드, equals/hashCode 재정의 등)으로 구성하였으며, JPA 내장 타입으로 사용하기 위해 @Embeddable을 적용했습니다.
  • 예외 처리를 위해 InternshipErrorCodeINVALID_COMPANY_LOGO_URL 항목을 추가했습니다.

💭 Thoughts

  • 도메인 내부에서 신뢰할 수 있는 상태로 URL을 다루기 위해 값을 VO로 감쌌습니다.
  • 단순 문자열이 아닌 객체로 다룸으로써 이후 로직에서 의미를 명확히 하고, 추후 URL 규칙 변경에도 대응이 쉬운 구조를 갖추었습니다.
  • 기존 InternshipAnnouncement 관련 VO들과 동일한 패턴을 적용하여 일관성을 유지했습니다.

✅ Testing Result

스크린샷 2025-05-20 오후 11 43 10


🗂 Related Issue

http 또는 https로 시작하는 유효한 URL만 허용하는 CompanyLogoUrl 값을 객체로 정의했습니다.
JPA 내장 타입으로 사용할 수 있도록 @embeddable을 적용했으며,
도메인 유효성 검증과 equals, hashCode, toString을 함께 구현했습니다.
CompanyLogoUrl 값 객체에서 사용할 INVALID_COMPANY_LOGO_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 introduces a new value object (VO) for representing a company's logo URL along with its corresponding error handling and tests.

  • Implemented CompanyLogoUrl as an immutable VO with URL validation using a simple prefix check.
  • Added a new error code INVALID_COMPANY_LOGO_URL to support the case of invalid URL formats.
  • Provided tests to verify proper instantiation for valid URLs and exception throwing for invalid URLs.

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/CompanyLogoUrlTest.kt Added tests for URL creation and exception handling.
src/main/kotlin/com/terning/server/kotlin/domain/internshipAnnouncement/InternshipErrorCode.kt Introduced a new error code constant for invalid company logo URLs.
src/main/kotlin/com/terning/server/kotlin/domain/internshipAnnouncement/CompanyLogoUrl.kt Implemented the CompanyLogoUrl VO with URL validation logic.

fun from(value: String): CompanyLogoUrl = CompanyLogoUrl(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] Consider using a more robust URL validation method (such as a regex-based check or Java's URL class constructor) to ensure that the URL adheres to a proper format beyond just starting with 'http'.

Suggested change
if (!value.startsWith("http")) {
try {
java.net.URL(value) // Attempt to parse the URL
} catch (e: java.net.MalformedURLException) {

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