-
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.
- Loading branch information
Showing
25 changed files
with
327 additions
and
14 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
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
27 changes: 27 additions & 0 deletions
27
src/main/java/com/moddy/server/common/validation/prefer_regions/PreferRegionsValidator.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,27 @@ | ||
package com.moddy.server.common.validation.prefer_regions; | ||
|
||
import jakarta.validation.ConstraintValidator; | ||
import jakarta.validation.ConstraintValidatorContext; | ||
|
||
import java.util.HashSet; | ||
import java.util.List; | ||
|
||
public class PreferRegionsValidator implements ConstraintValidator<ValidPreferRegions, List<Long>> { | ||
|
||
@Override | ||
public void initialize(ValidPreferRegions constraintAnnotation) { | ||
} | ||
|
||
@Override | ||
public boolean isValid(List<Long> preferRegions, ConstraintValidatorContext context) { | ||
|
||
if (preferRegions == null || preferRegions.isEmpty()) return false; | ||
if (preferRegions.size() > 3 ) return false; | ||
if (preferRegions.size() != new HashSet<>(preferRegions).size()) return false; | ||
if (preferRegions.stream().filter(p -> p == 0).count() == 1 && preferRegions.stream().anyMatch(p -> p != 0)) return false; | ||
if (!preferRegions.stream().allMatch(p -> p >= 0 && p <= 25)) return false; | ||
|
||
return true; | ||
|
||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/moddy/server/common/validation/prefer_regions/ValidPreferRegions.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_regions; | ||
|
||
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 = PreferRegionsValidator.class) | ||
@Target({ElementType.FIELD, ElementType.PARAMETER}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface ValidPreferRegions { | ||
|
||
String message() default "preferRegions는 0은 1개만, 1~25사이의 값은 3개까지 올 수 있습니다."; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
Class<? extends Payload>[] payload() default {}; | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/moddy/server/common/validation/unique_dayofweek/UniqueDayOfWeek.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,19 @@ | ||
package com.moddy.server.common.validation.unique_dayofweek; | ||
|
||
import jakarta.validation.Constraint; | ||
import jakarta.validation.Payload; | ||
|
||
import java.lang.annotation.*; | ||
|
||
|
||
@Documented | ||
@Constraint(validatedBy = UniqueDayOfWeekValidator.class) | ||
@Target({ElementType.FIELD}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface UniqueDayOfWeek { | ||
String message() default "List elements must be unique"; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
Class<? extends Payload>[] payload() default {}; | ||
} |
23 changes: 23 additions & 0 deletions
23
...in/java/com/moddy/server/common/validation/unique_dayofweek/UniqueDayOfWeekValidator.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.unique_dayofweek; | ||
|
||
import com.moddy.server.domain.day_off.DayOfWeek; | ||
import jakarta.validation.ConstraintValidator; | ||
import jakarta.validation.ConstraintValidatorContext; | ||
|
||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class UniqueDayOfWeekValidator implements ConstraintValidator<UniqueDayOfWeek, List<DayOfWeek>> { | ||
|
||
@Override | ||
public void initialize(UniqueDayOfWeek constraintAnnotation) { | ||
} | ||
|
||
@Override | ||
public boolean isValid(List<DayOfWeek> dayOfWeeks, ConstraintValidatorContext context) { | ||
Set<DayOfWeek> uniqueDays = new HashSet<>(dayOfWeeks); | ||
return uniqueDays.size() == dayOfWeeks.size(); | ||
|
||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...om/moddy/server/common/validation/unique_prefer_offer_condition/UniqueOfferCondition.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,18 @@ | ||
package com.moddy.server.common.validation.unique_prefer_offer_condition; | ||
|
||
import jakarta.validation.Constraint; | ||
import jakarta.validation.Payload; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Documented | ||
@Constraint(validatedBy = UniqueOfferConditionValidator.class) | ||
@Target({ElementType.FIELD}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface UniqueOfferCondition { | ||
String message() default "List elements must be unique"; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
Class<? extends Payload>[] payload() default {}; | ||
} |
23 changes: 23 additions & 0 deletions
23
...server/common/validation/unique_prefer_offer_condition/UniqueOfferConditionValidator.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.unique_prefer_offer_condition; | ||
|
||
import com.moddy.server.domain.day_off.DayOfWeek; | ||
import com.moddy.server.domain.prefer_offer_condition.OfferCondition; | ||
import jakarta.validation.ConstraintValidator; | ||
import jakarta.validation.ConstraintValidatorContext; | ||
|
||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class UniqueOfferConditionValidator implements ConstraintValidator<UniqueOfferCondition, List<OfferCondition>> { | ||
@Override | ||
public void initialize(UniqueOfferCondition constraintAnnotation) { | ||
} | ||
|
||
@Override | ||
public boolean isValid(List<OfferCondition> offerConditions, ConstraintValidatorContext context) { | ||
Set<OfferCondition> uniqueConditions = new HashSet<>(offerConditions); | ||
return uniqueConditions.size() == offerConditions.size(); | ||
|
||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/moddy/server/common/validation/year/ValidYear.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.year; | ||
|
||
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 = YearValidator.class) | ||
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface ValidYear { | ||
|
||
String message() default "Year는 오늘의 년도보다 큰 년도일 수 없어요."; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
Class<? extends Payload>[] payload() default {}; | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/com/moddy/server/common/validation/year/YearValidator.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,29 @@ | ||
package com.moddy.server.common.validation.year; | ||
|
||
import jakarta.validation.ConstraintValidator; | ||
import jakarta.validation.ConstraintValidatorContext; | ||
|
||
import java.text.ParseException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Calendar; | ||
import java.util.Date; | ||
|
||
public class YearValidator implements ConstraintValidator<ValidYear, String> { | ||
|
||
@Override | ||
public void initialize(ValidYear constraintAnnotation) { | ||
} | ||
|
||
@Override | ||
public boolean isValid(String year, ConstraintValidatorContext context) { | ||
try { | ||
int parsedYear = Integer.parseInt(year); | ||
int currentYear = Calendar.getInstance().get(Calendar.YEAR); | ||
|
||
return parsedYear >= 1900 && parsedYear <= currentYear; | ||
|
||
} catch (NumberFormatException e) { | ||
return false; | ||
} | ||
} | ||
} |
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
9 changes: 8 additions & 1 deletion
9
src/main/java/com/moddy/server/controller/auth/dto/request/PhoneNumberRequestDto.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 |
---|---|---|
@@ -1,4 +1,11 @@ | ||
package com.moddy.server.controller.auth.dto.request; | ||
|
||
public record PhoneNumberRequestDto(String phoneNumber) { | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.Pattern; | ||
|
||
public record PhoneNumberRequestDto( | ||
@Schema(example = "01020000000") | ||
@Pattern(regexp = "^010[0-9]{8}$", message = "phoneNumber는 01011112222형태입니다.") | ||
String phoneNumber | ||
) { | ||
} |
12 changes: 11 additions & 1 deletion
12
src/main/java/com/moddy/server/controller/auth/dto/request/VerifyCodeRequestDto.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 |
---|---|---|
@@ -1,4 +1,14 @@ | ||
package com.moddy.server.controller.auth.dto.request; | ||
|
||
public record VerifyCodeRequestDto(String phoneNumber, String verifyCode) { | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.Pattern; | ||
|
||
public record VerifyCodeRequestDto( | ||
@Schema(example = "01020000000") | ||
@Pattern(regexp = "^010[0-9]{8}$", message = "phoneNumber는 01011112222형태입니다.") | ||
String phoneNumber, | ||
@Schema(example = "123456") | ||
@Pattern(regexp = "[0-9]{6}$", message = "verifyCode는 123456형태입니다.") | ||
String verifyCode | ||
) { | ||
} |
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
8 changes: 8 additions & 0 deletions
8
src/main/java/com/moddy/server/controller/designer/dto/HairShopDto.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
6 changes: 6 additions & 0 deletions
6
src/main/java/com/moddy/server/controller/designer/dto/PortfolioDto.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 |
---|---|---|
@@ -1,14 +1,20 @@ | ||
package com.moddy.server.controller.designer.dto; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Pattern; | ||
import lombok.*; | ||
|
||
|
||
@Builder | ||
public record PortfolioDto( | ||
@Schema(example = "http://instagram") | ||
@NotBlank | ||
@Pattern(regexp = "^[^\\s]+$", message = "url에는 공백(whitespaces)이 들어갈 수 없습니다.") | ||
String instagramUrl, | ||
@Schema(example = "http://naver") | ||
@NotBlank | ||
@Pattern(regexp = "^[^\\s]+$", message = "url에는 공백(whitespaces)이 들어갈 수 없습니다.") | ||
String naverPlaceUrl | ||
) { | ||
} |
Oops, something went wrong.