[FO] 수량과 단위의 valid 추가
This commit is contained in:
@@ -21,6 +21,24 @@ public class CreateDailyExpenseValidator implements Validator {
|
||||
public void validate(Object target, Errors errors) {
|
||||
CreateDailyExpenseReqVO vo = (CreateDailyExpenseReqVO) target;
|
||||
|
||||
if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) {
|
||||
errors.rejectValue(
|
||||
"quantity", "valid.common.required",
|
||||
"수량을 입력해 주세요.");
|
||||
}
|
||||
|
||||
if (vo.getQuantity() != null && StringUtils.isBlank(vo.getUnitCode())) {
|
||||
errors.rejectValue(
|
||||
"unitCode", "valid.common.required",
|
||||
"단위를 선택해 주세요.");
|
||||
}
|
||||
|
||||
if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) {
|
||||
errors.rejectValue(
|
||||
"unitSelf", "valid.common.required",
|
||||
"단위를 입력해 주세요.");
|
||||
}
|
||||
|
||||
if (vo.getPrice() == null && vo.getEstimatedValue() == null) {
|
||||
errors.rejectValue(
|
||||
"price", "valid.common.required",
|
||||
@@ -29,11 +47,5 @@ public class CreateDailyExpenseValidator implements Validator {
|
||||
"estimatedValue", "valid.common.required",
|
||||
"현금 또는 현물평가액을 입력해 주세요.");
|
||||
}
|
||||
|
||||
if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) {
|
||||
errors.rejectValue(
|
||||
"unitSelf", "valid.common.required",
|
||||
"단위를 입력해 주세요.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,24 @@ public class CreateDailyFarmingValidator implements Validator {
|
||||
"생산물을 입력해 주세요.");
|
||||
}
|
||||
|
||||
if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) {
|
||||
errors.rejectValue(
|
||||
"quantity", "valid.common.required",
|
||||
"수량을 입력해 주세요.");
|
||||
}
|
||||
|
||||
if (vo.getQuantity() != null && StringUtils.isBlank(vo.getUnitCode())) {
|
||||
errors.rejectValue(
|
||||
"unitCode", "valid.common.required",
|
||||
"단위를 선택해 주세요.");
|
||||
}
|
||||
|
||||
if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) {
|
||||
errors.rejectValue(
|
||||
"unitSelf", "valid.common.required",
|
||||
"단위를 입력해 주세요.");
|
||||
}
|
||||
|
||||
if (vo.getEstimatedValue() == null) {
|
||||
errors.rejectValue(
|
||||
"estimatedValue", "valid.common.required",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package app.module.front.usecase.daily.forestry.adapters.web.validator;
|
||||
|
||||
import app.module.front.config.constants.CommonConstants;
|
||||
import app.module.front.usecase.daily.forestry.adapters.web.model.CreateDailyForestryReqVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.tika.utils.StringUtils;
|
||||
@@ -20,6 +21,24 @@ public class CreateDailyForestryValidator implements Validator {
|
||||
public void validate(Object target, Errors errors) {
|
||||
CreateDailyForestryReqVO vo = (CreateDailyForestryReqVO) target;
|
||||
|
||||
if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) {
|
||||
errors.rejectValue(
|
||||
"quantity", "valid.common.required",
|
||||
"수량을 입력해 주세요.");
|
||||
}
|
||||
|
||||
if (vo.getQuantity() != null && StringUtils.isBlank(vo.getUnitCode())) {
|
||||
errors.rejectValue(
|
||||
"unitCode", "valid.common.required",
|
||||
"단위를 선택해 주세요.");
|
||||
}
|
||||
|
||||
if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) {
|
||||
errors.rejectValue(
|
||||
"unitSelf", "valid.common.required",
|
||||
"단위를 입력해 주세요.");
|
||||
}
|
||||
|
||||
if (vo.getEstimatedValue() == null) {
|
||||
errors.rejectValue(
|
||||
"estimatedValue", "valid.common.required",
|
||||
|
||||
@@ -21,6 +21,24 @@ public class CreateDailyIncomeValidator implements Validator {
|
||||
public void validate(Object target, Errors errors) {
|
||||
CreateDailyIncomeReqVO vo = (CreateDailyIncomeReqVO) target;
|
||||
|
||||
if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) {
|
||||
errors.rejectValue(
|
||||
"quantity", "valid.common.required",
|
||||
"수량을 입력해 주세요.");
|
||||
}
|
||||
|
||||
if (vo.getQuantity() != null && StringUtils.isBlank(vo.getUnitCode())) {
|
||||
errors.rejectValue(
|
||||
"unitCode", "valid.common.required",
|
||||
"단위를 선택해 주세요.");
|
||||
}
|
||||
|
||||
if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) {
|
||||
errors.rejectValue(
|
||||
"unitSelf", "valid.common.required",
|
||||
"단위를 입력해 주세요.");
|
||||
}
|
||||
|
||||
if (vo.getPrice() == null && vo.getEstimatedValue() == null) {
|
||||
errors.rejectValue(
|
||||
"price", "valid.common.required",
|
||||
@@ -29,11 +47,5 @@ public class CreateDailyIncomeValidator implements Validator {
|
||||
"estimatedValue", "valid.common.required",
|
||||
"현금 또는 현물평가액을 입력해 주세요.");
|
||||
}
|
||||
|
||||
if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) {
|
||||
errors.rejectValue(
|
||||
"unitSelf", "valid.common.required",
|
||||
"단위를 입력해 주세요.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user