From 128d41b5e5aede44d988964403b02ef88b34b041 Mon Sep 17 00:00:00 2001 From: sinkyoungdeok Date: Sun, 4 Feb 2024 14:32:36 +0900 Subject: [PATCH] =?UTF-8?q?[FO-897]=20=ED=94=84=EB=A1=9C=ED=95=84=20?= =?UTF-8?q?=EC=A0=84=EC=B2=B4=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EA=B2=80?= =?UTF-8?q?=EC=A6=9D=20API=20=EC=9E=AC=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/service/ValidateProfileService.kt | 13 +++++++++++++ .../controller/ValidateJobOpeningControllerTest.kt | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/server/src/main/kotlin/com/fone/profile/domain/service/ValidateProfileService.kt b/server/src/main/kotlin/com/fone/profile/domain/service/ValidateProfileService.kt index 6f1b7bd2..111917ad 100644 --- a/server/src/main/kotlin/com/fone/profile/domain/service/ValidateProfileService.kt +++ b/server/src/main/kotlin/com/fone/profile/domain/service/ValidateProfileService.kt @@ -5,6 +5,7 @@ import com.fone.profile.presentation.dto.ValidateProfileDto import com.fone.user.domain.repository.UserRepository import org.hibernate.validator.internal.constraintvalidators.hv.URLValidator import org.springframework.stereotype.Service +import java.time.LocalDate @Service class ValidateProfileService( @@ -32,6 +33,18 @@ class ValidateProfileService( email: String, request: ValidateProfileDto.DetailPageValidation, ) { + if (request.birthday != null) { + if (request.birthday.year < 1920) { + throw RequestValidationException("100세 이상의 나이는 입력할 수 없습니다.") + } + } + + if (request.birthday != null) { + if (request.birthday.isAfter(LocalDate.now())) { + throw RequestValidationException("미래의 날짜를 입력할 수 없습니다.") + } + } + if (request.gender == null) { throw RequestValidationException("성별을 선택해 주세요.") } diff --git a/server/src/test/kotlin/com/fone/jobOpening/presentation/controller/ValidateJobOpeningControllerTest.kt b/server/src/test/kotlin/com/fone/jobOpening/presentation/controller/ValidateJobOpeningControllerTest.kt index 39e026f3..2b5eefdc 100644 --- a/server/src/test/kotlin/com/fone/jobOpening/presentation/controller/ValidateJobOpeningControllerTest.kt +++ b/server/src/test/kotlin/com/fone/jobOpening/presentation/controller/ValidateJobOpeningControllerTest.kt @@ -54,7 +54,7 @@ class ValidateJobOpeningControllerTest(client: WebTestClient) : CustomDescribeSp null, null, Salary.HOURLY, - null + -2 ) client.doPost("$url/project-details", request, accessToken) .expectStatus().isOk.expectBody() @@ -70,7 +70,7 @@ class ValidateJobOpeningControllerTest(client: WebTestClient) : CustomDescribeSp null, null, Salary.HOURLY, - null + -2 ) client.doPost("$url/project-details", request, accessToken).expectStatus().isBadRequest.expectBody() .consumeWith { println(it) }.jsonPath("$.result").isEqualTo("FAIL")