Skip to content

Commit

Permalink
[Feat] #39 - 로그 Validation 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
0lynny committed Jan 9, 2024
1 parent a91005a commit 631beec
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.moonshot.server.domain.log.controller;

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.moonshot.server.domain.log.dto.request.LogCreateRequestDto;
import org.moonshot.server.domain.log.service.LogService;
Expand All @@ -21,7 +22,7 @@ public class LogController {
private final LogService logService;

@PostMapping
public ApiResponse<?> create(Principal principal, @RequestBody LogCreateRequestDto logCreateRequestDto) {
public ApiResponse<?> create(Principal principal, @RequestBody @Valid LogCreateRequestDto logCreateRequestDto) {
logService.createRecordLog(JwtTokenProvider.getUserIdFromPrincipal(principal), logCreateRequestDto);
return ApiResponse.success(SuccessType.POST_LOG_SUCCESS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

public class LimitValueValidator implements ConstraintValidator<ValidTargetNumber, Long> {
public class LimitValueValidator implements ConstraintValidator<ValidLimitValue, Long> {

private final long MAX_LIMIT = 99999999999L;

Expand All @@ -12,7 +12,7 @@ public boolean isValid(Long value, ConstraintValidatorContext context) {
if (value == null) {
return true;
} else {
return value <= MAX_LIMIT;
return value > 0 && value <= MAX_LIMIT;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import lombok.extern.slf4j.Slf4j;

public class TargetNumberValidator implements ConstraintValidator<ValidTargetNumber, Long> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = TargetNumberValidator.class)
@Constraint(validatedBy = LimitValueValidator.class)
public @interface ValidLimitValue {

String message() default "수치는 99,999,999,999까지만 가능합니다.";
Expand Down

0 comments on commit 631beec

Please sign in to comment.