vidakovic commented on code in PR #6034: URL: https://github.com/apache/fineract/pull/6034#discussion_r3747988295
########## fineract-provider/src/main/java/org/apache/fineract/portfolio/account/data/StandingInstructionRequestDataValidator.java: ########## @@ -0,0 +1,203 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.account.data; + +import static org.apache.fineract.portfolio.account.AccountDetailConstants.transferTypeParamName; +import static org.apache.fineract.portfolio.account.api.StandingInstructionApiConstants.amountParamName; +import static org.apache.fineract.portfolio.account.api.StandingInstructionApiConstants.instructionTypeParamName; +import static org.apache.fineract.portfolio.account.api.StandingInstructionApiConstants.nameParamName; +import static org.apache.fineract.portfolio.account.api.StandingInstructionApiConstants.priorityParamName; +import static org.apache.fineract.portfolio.account.api.StandingInstructionApiConstants.recurrenceFrequencyParamName; +import static org.apache.fineract.portfolio.account.api.StandingInstructionApiConstants.recurrenceIntervalParamName; +import static org.apache.fineract.portfolio.account.api.StandingInstructionApiConstants.recurrenceOnMonthDayParamName; +import static org.apache.fineract.portfolio.account.api.StandingInstructionApiConstants.recurrenceTypeParamName; +import static org.apache.fineract.portfolio.account.api.StandingInstructionApiConstants.statusParamName; +import static org.apache.fineract.portfolio.account.api.StandingInstructionApiConstants.validFromParamName; +import static org.apache.fineract.portfolio.account.api.StandingInstructionApiConstants.validTillParamName; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.MonthDay; +import java.util.ArrayList; +import java.util.List; +import org.apache.fineract.infrastructure.core.data.ApiParameterError; +import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder; +import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; +import org.apache.fineract.portfolio.account.PortfolioAccountType; +import org.apache.fineract.portfolio.account.api.StandingInstructionApiConstants; +import org.apache.fineract.portfolio.account.data.request.StandingInstructionCreationRequest; +import org.apache.fineract.portfolio.account.data.request.StandingInstructionRequestParser; +import org.apache.fineract.portfolio.account.data.request.StandingInstructionUpdatesRequest; +import org.apache.fineract.portfolio.account.domain.AccountTransferRecurrenceType; +import org.apache.fineract.portfolio.account.domain.AccountTransferType; +import org.apache.fineract.portfolio.account.domain.StandingInstructionType; +import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType; +import org.springframework.stereotype.Component; + +/** + * Validates the typed standing instruction request DTOs. Replaces the legacy {@code JsonCommand}-based + * {@code StandingInstructionDataValidator}: the same field-level and cross-field integrity checks now run against the + * typed {@link StandingInstructionCreationRequest} / {@link StandingInstructionUpdatesRequest}. + */ +@Component +public class StandingInstructionRequestDataValidator { Review Comment: Can we create a proper Jakarta Validation validator at least? I think some of these checks done here could be replaced by simple Jakarta annotations (preferred, because easier to read and understand). Whatever is left then and too complex to cover can go into a validator extension. -- 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]
