Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
[Fix] Password 검증 annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-KoKo committed Feb 5, 2024
1 parent 7dc76e7 commit d93094f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package fc.be.app.common.authentication.controller.dto.request;

import fc.be.app.domain.member.controller.validation.Password;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;

public record ModifyLostPasswordRequest(
@NotBlank
String token,
@Email
@NotNull
String email,
@Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*[!@#$%^&*()])(?=.*[0-9]).{8,16}$")
@NotBlank
@Password
String newPassword
) {
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package fc.be.app.common.authentication.controller.dto.request;

import fc.be.app.domain.member.controller.validation.Password;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;

public record ModifyPasswordRequest(
@NotBlank
String token,
@Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*[!@#$%^&*()])(?=.*[0-9]).{8,16}$")
@NotBlank
@Password
String newPassword
) {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fc.be.app.common.authentication.controller.dto.request;

import fc.be.app.domain.member.controller.validation.Password;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
Expand All @@ -11,7 +12,7 @@ public record RegisterMemberRequest(
@Email
@NotNull
String email,
@Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*[!@#$%^&*()])(?=.*[0-9]).{8,16}$")
@Password
String password,
@NotBlank
String nickname,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package fc.be.app.domain.member.controller.dto.request;

import jakarta.validation.constraints.Pattern;
import fc.be.app.domain.member.controller.validation.Password;

public record DeleteMemberRequest(
@Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*[!@#$%^&*()])(?=.*[0-9]).{8,16}$")
@Password
String password
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package fc.be.app.domain.member.controller.validation;

import jakarta.validation.Constraint;
import jakarta.validation.Payload;
import jakarta.validation.ReportAsSingleViolation;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@NotNull
@Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*[!@#$%^&*()])(?=.*\\d).{8,16}$")
@Documented
@Constraint(validatedBy = {})
@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE})
@Retention(RUNTIME)
@ReportAsSingleViolation
public @interface Password {
String message() default "유효하지 않은 비밀번호 폼입니다";

Class<?>[] groups() default {};

Class<? extends Payload>[] payload() default {};
}

0 comments on commit d93094f

Please sign in to comment.