Skip to content

Commit

Permalink
fix: defense nullpointexception
Browse files Browse the repository at this point in the history
  • Loading branch information
yhames committed Aug 2, 2024
1 parent 1502090 commit b7d9af2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package gg.agenda.api.user.agenda.controller.request;

import com.fasterxml.jackson.annotation.JsonFormat;
import java.time.LocalDateTime;

import javax.validation.constraints.Future;
Expand All @@ -21,6 +22,7 @@
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

@Getter
@AgendaCapacityValid
Expand All @@ -34,15 +36,15 @@ public class AgendaCreateReqDto {
@NotBlank
private String agendaContent;

@NotNull
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Seoul")
@Future(message = "마감일은 현재 시간 이후여야 합니다.")
private LocalDateTime agendaDeadLine;

@NotNull
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Seoul")
@Future(message = "시작 시간은 현재 시간 이후여야 합니다.")
private LocalDateTime agendaStartTime;

@NotNull
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Seoul")
@Future(message = "종료 시간은 현재 시간 이후여야 합니다.")
private LocalDateTime agendaEndTime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public boolean isValid(AgendaCreateReqDto value, ConstraintValidatorContext cont
if (Objects.isNull(value)) {
return true;
}
if (Objects.isNull(value.getAgendaDeadLine())
|| Objects.isNull(value.getAgendaStartTime())
|| Objects.isNull(value.getAgendaEndTime())) {
return false;
}
return mustHaveValidSchedule(value);
}

Expand Down

0 comments on commit b7d9af2

Please sign in to comment.