Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- ajax 사용 예시
- TAILWIND
- scroll
- 스크롤 이벤트
- route
- mysql if
- 검색
- 옵저버블
- Ionic modal
- 앵귤러 모달
- 아이오닉 스크롤 이벤트
- angular route
- flex-1
- prisma
- 모달
- Angular Router
- Router
- ApexChart
- angular animation
- modal
- 스크롤 이벤트 감지
- angular button
- summary
- 앵귤러 애니메이션
- angular modal
- 호버
- Oracle LISTAGG 사용 예시
- 셀렉트박스 커스텀
- egov spring ajax 사용 예시
- formgroup
Archives
- Today
- Total
깜놀하는 해므찌로
Nestjs 비밀번호 / 비밀번호 확인과 같이 클래스 내 다른 property와 일치한 지 검증하고 싶을 때 본문
반응형
SMALL
import {registerDecorator, ValidationArguments, ValidationOptions} from 'class-validator';
export function IsEqual(property: string, validationOptions: ValidationOptions) {
return function (object: object, propertyName: string) {
registerDecorator({
name: 'isEqual',
target: object.constructor,
propertyName,
constraints: [property],
options: validationOptions,
validator: {
validate(value: any, args: ValidationArguments) {
const [relatedPropertyName] = args.constraints;
const relatedValue = (args.object as any)[relatedPropertyName];
return value === relatedValue;
},
},
})
}
}
export class RegisterUserDTO {
@ApiProperty()
@IsNotEmpty({message: '이메일을 입력해 주세요.'})
@IsEmail({}, {message: '이메일 형식이 올바르지 않습니다.'})
email: string;
@ApiProperty()
@IsNotEmpty({message: '비밀번호를 입력해 주세요.'})
password: string;
@ApiProperty()
@IsNotEmpty({message: '비밀번호를 다시 한 번 입력해 주세요.'})
@IsEqual('password', {message: '비밀번호가 일치하지 않습니다.'})
passwordConfirm: string;
}
반응형
LIST
'IT' 카테고리의 다른 글
Angular 컴포넌트 cli 생성 시 앞에 이름 / prefix 수정하기 (0) | 2023.08.15 |
---|---|
CSS tag 예시 / tailwind 태그 줄바꿈 (0) | 2023.08.14 |
Nx nest Angular Guard 활용 예시 JWT Bearer (0) | 2023.08.11 |
Angular NX Interceptor 활용 예시 / JWT Bearer (0) | 2023.08.10 |
@Prisma Client 활용 예시 / type (0) | 2023.08.10 |