Skip to content
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

[feat] : Pipe 로 전송과 검증을 하기 #5

Closed
2 tasks done
wochae opened this issue May 29, 2023 · 6 comments
Closed
2 tasks done

[feat] : Pipe 로 전송과 검증을 하기 #5

wochae opened this issue May 29, 2023 · 6 comments

Comments

@wochae
Copy link
Owner

wochae commented May 29, 2023

  • Data Transformation
  • Validation

파이프를 사용할 때
핸들러 레벨
파라미터 레벨
글로벌 레벨 이렇게 단계별로 존재한다.

@wochae
Copy link
Owner Author

wochae commented May 29, 2023

npm install class-validator class-transformer --save

@wochae
Copy link
Owner Author

wochae commented May 29, 2023

이전에는 없는 게시물을 찾을 때 반환하는 에러메시지,
이번에는 없는 게시물을 삭제하려할 때 반환하는 에러메시지.

@wochae
Copy link
Owner Author

wochae commented May 29, 2023

어떤 타입이던간에 배열 안에 filter 함수를 사용하면 그 안에 매개인자는 표현식? ( Arrow function ) 을 넣어서 찾을 수가 있나보다.
find도 마찬가지
filter & find

@wochae
Copy link
Owner Author

wochae commented May 29, 2023

커스텀 파이프 구현
기존에 핸들러 레벨에 파이프를 넣은 게 아닌
파라미터(status)레벨에 대한 파이프를 넣어줬다

@wochae
Copy link
Owner Author

wochae commented May 29, 2023

지금 코드에서는 필수 요소가 하나 빠졌다. status 값은 { PUBLIC, PRIVATE } 값만 들어올 수 있기 때문에 이것을 위한 validation 처리를 해야한다.

@wochae
Copy link
Owner Author

wochae commented May 29, 2023

indexOf() 함수는 찾는 인덱스의 값이 없으면 -1 값을 뱉는다. 그걸로 에러 처리를 하면 된다. index !==-1 이 false 라면
if (!함수) 절에서 조건 충족으로 에러 메시지 반환

@wochae wochae closed this as completed May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant