-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
#149 [feat] 지원서 작성 Validation
- Loading branch information
Showing
6 changed files
with
70 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
.../java/com/moddy/server/common/validation/prefer_hair_style/PreferHairStylesValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.moddy.server.common.validation.prefer_hair_style; | ||
|
||
import com.moddy.server.domain.prefer_hair_style.PreferHairStyle; | ||
import jakarta.validation.ConstraintValidator; | ||
import jakarta.validation.ConstraintValidatorContext; | ||
|
||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class PreferHairStylesValidator implements ConstraintValidator<ValidPreferHairStyles, List<PreferHairStyle>> { | ||
|
||
@Override | ||
public void initialize(ValidPreferHairStyles constraintAnnotation) { | ||
} | ||
|
||
@Override | ||
public boolean isValid(List<PreferHairStyle> preferHairStyles, ConstraintValidatorContext context) { | ||
|
||
Set<PreferHairStyle> uniquePreferHairStyles = new HashSet<>(preferHairStyles); | ||
if(uniquePreferHairStyles.size() != preferHairStyles.size()) return false; | ||
if (preferHairStyles.isEmpty() || preferHairStyles == null) return false; | ||
|
||
return true; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...main/java/com/moddy/server/common/validation/prefer_hair_style/ValidPreferHairStyles.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.moddy.server.common.validation.prefer_hair_style; | ||
|
||
import jakarta.validation.Constraint; | ||
import jakarta.validation.Payload; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Documented | ||
@Constraint(validatedBy = PreferHairStylesValidator.class) | ||
@Target({ElementType.FIELD, ElementType.PARAMETER}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface ValidPreferHairStyles { | ||
|
||
String message() default "preferHairStyles는 필수 선택, 최소 1개부터 최대 6개 선택 가능합니다."; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
Class<? extends Payload>[] payload() default {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 13 additions & 2 deletions
15
src/main/java/com/moddy/server/controller/model/dto/request/ModelApplicationRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters