-
Notifications
You must be signed in to change notification settings - Fork 0
[✨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
base: feat/#58
Are you sure you want to change the base?
Conversation
http 또는 https로 시작하는 유효한 URL만 허용하는 CompanyLogoUrl 값을 객체로 정의했습니다. JPA 내장 타입으로 사용할 수 있도록 @embeddable을 적용했으며, 도메인 유효성 검증과 equals, hashCode, toString을 함께 구현했습니다.
CompanyLogoUrl 값 객체에서 사용할 INVALID_COMPANY_LOGO_URL 오류 코드를 추가했습니다. http/https로 시작하지 않는 URL에 대해 예외를 발생시킬 때 사용됩니다.
http/https로 시작하는 경우 객체가 정상 생성되는지 확인하고, 그 외의 경우 예외가 발생하는지 테스트를 통해 검증했습니다.
There was a problem hiding this 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")) { |
There was a problem hiding this comment.
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'.
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.
📄 Work Description
CompanyLogoUrl
을 구현했습니다.http
또는https
로 시작하는 주소만 허용하며, 이를 만족하지 않으면InternshipException
을 발생시킵니다.@Embeddable
을 적용했습니다.InternshipErrorCode
에INVALID_COMPANY_LOGO_URL
항목을 추가했습니다.💭 Thoughts
InternshipAnnouncement
관련 VO들과 동일한 패턴을 적용하여 일관성을 유지했습니다.✅ Testing Result
🗂 Related Issue