adamsaghy commented on code in PR #5288:
URL: https://github.com/apache/fineract/pull/5288#discussion_r2676069321


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/serialization/LoanProductDataValidator.java:
##########
@@ -2800,15 +2803,26 @@ private void validateLoanScheduleType(final String 
transactionProcessingStrategy
         
baseDataValidator.reset().parameter(LoanProductConstants.LOAN_SCHEDULE_TYPE).value(loanScheduleType)
                 .isOneOfEnumValues(LoanScheduleType.class);
 
-        if 
(!LoanScheduleType.PROGRESSIVE.equals(LoanScheduleType.valueOf(loanScheduleType))
+        if (loanScheduleType == null || baseDataValidator.hasError()) {
+            return;
+        }
+
+        LoanScheduleType scheduleType;
+        try {
+            scheduleType = LoanScheduleType.valueOf(loanScheduleType);
+        } catch (IllegalArgumentException e) {
+            throw new 
GeneralPlatformDomainRuleException("error.msg.invalid.loan.schedule.type", 
"Invalid loan schedule type");
+        }
+
+        if (!LoanScheduleType.PROGRESSIVE.equals(scheduleType)

Review Comment:
   Not needed. 
   If the value is `NULL` just throw new PlatformApiDataValidationException...
   
   Something like this:
   ```
   Index: 
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/serialization/LoanProductDataValidator.java
   IDEA additional info:
   Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
   <+>UTF-8
   ===================================================================
   diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/serialization/LoanProductDataValidator.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/serialization/LoanProductDataValidator.java
   --- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/serialization/LoanProductDataValidator.java
  (revision dff889be29032cd75f18d2d418f28989f53c3cf5)
   +++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/serialization/LoanProductDataValidator.java
  (date 1767962780072)
   @@ -2797,8 +2797,9 @@
        private void validateLoanScheduleType(final String 
transactionProcessingStrategyCode, final DataValidatorBuilder baseDataValidator,
                final JsonElement element) {
            final String loanScheduleType = 
this.fromApiJsonHelper.extractStringNamed(LoanProductConstants.LOAN_SCHEDULE_TYPE,
 element);
   -        
baseDataValidator.reset().parameter(LoanProductConstants.LOAN_SCHEDULE_TYPE).value(loanScheduleType)
   -                .isOneOfEnumValues(LoanScheduleType.class);
   +        
baseDataValidator.reset().parameter(LoanProductConstants.LOAN_SCHEDULE_TYPE).value(loanScheduleType).notNull();
   +        baseDataValidator.throwValidationErrors();
   +        
baseDataValidator.reset().parameter(LoanProductConstants.LOAN_SCHEDULE_TYPE).value(loanScheduleType).isOneOfEnumValues(LoanScheduleType.class);
    
            if 
(!LoanScheduleType.PROGRESSIVE.equals(LoanScheduleType.valueOf(loanScheduleType))
                    && 
AdvancedPaymentScheduleTransactionProcessor.ADVANCED_PAYMENT_ALLOCATION_STRATEGY
   
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to