-
Notifications
You must be signed in to change notification settings - Fork 78
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
6주차 과제 - 로그인 구현하기 #70
Changes from 1 commit
50766c1
6974c98
3f6ec78
e500054
a3bb4f6
6caff11
c32ae97
df8f01e
a1ecba0
93ff275
2c04eae
90f9e60
a8d90b9
05db189
7efccfe
c833de7
c793d25
7930ef9
a64d3c4
324f9db
042eaaa
ea2588a
0699e11
1f1b99f
1888b60
522ac8f
7760d3f
5cb2b86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.codesoom.assignment.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.github.dozermapper.core.Mapping; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.Size; | ||
|
||
@Getter | ||
public class UserLoginData { | ||
@NotBlank | ||
@Size(min = 3) | ||
@Mapping("email") | ||
private final String email; | ||
|
||
@NotBlank | ||
@Size(min = 4, max = 1024) | ||
Comment on lines
+21
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 한번 경험삼아 메시지를 커스텀 해보는 것은 어떨까요?! 메시지를 커스텀하는 행위는 아주 일반적이니까요! 아니면 나아가서 커스텀 Validator를 만들어보는 겁니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. {
"message": null,
"status": "BAD_REQUEST",
"errors": [
"[password] 크기가 4에서 1024 사이여야 합니다",
"[email] 크기가 3에서 2147483647 사이여야 합니다"
]
} 일단 검증 실패 시 검증 정보를 위와 같이 반환하게 수정해봤습니다 커스텀 Validator는 내일 진행해보겠습니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
각 유효성검증마다 메시지를 바꿀 수 있는 것이 좋지 않을까요! |
||
@Mapping("password") | ||
private final String password; | ||
|
||
@JsonCreator | ||
public UserLoginData(@JsonProperty("email") String email, | ||
@JsonProperty("password") String password){ | ||
this.email = email; | ||
this.password = password; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package com.codesoom.assignment.errors; | ||
|
||
public class UserNotFoundException extends RuntimeException { | ||
public UserNotFoundException(Long id) { | ||
public UserNotFoundException(Object id) { | ||
super("User not found: " + id); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.codesoom.assignment.errors; | ||
|
||
public class WrongPasswordException extends RuntimeException{ | ||
|
||
} |
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.
이런식으로 메소드를 추출해본다면 어떨까요? 구현을 감추면 좀 더 가독성이 좋을 것 같아요!
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.
데이터를 요청하지 말고 작업을 요청해라 명심하겠습니다.