support loan product validation messages.
This commit is contained in:
@@ -144,6 +144,23 @@ public class DataValidatorBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder zeroOrPositiveAmount() {
|
||||
if (value == null && ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (value != null) {
|
||||
BigDecimal number = BigDecimal.valueOf(Double.valueOf(value.toString()));
|
||||
if (number.compareTo(BigDecimal.ZERO) < 0) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".not.zero.or.greater");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" must be greater than or equal to 0.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, number, 0);
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder greaterThanZero() {
|
||||
if (value == null && ignoreNullValue) {
|
||||
return this;
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosng.data.ConfigurationData;
|
||||
import org.mifosng.data.command.OrganisationCurrencyCommand;
|
||||
import org.mifosng.platform.api.commands.OrganisationCurrencyCommand;
|
||||
import org.mifosng.platform.api.infrastructure.ApiJSONFormattingService;
|
||||
import org.mifosng.platform.configuration.service.ConfigurationReadPlatformService;
|
||||
import org.mifosng.platform.configuration.service.ConfigurationWritePlatformService;
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement
|
||||
public class OrganisationCurrencyCommand implements Serializable {
|
||||
|
||||
private String[] currencies;
|
||||
|
||||
public OrganisationCurrencyCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public OrganisationCurrencyCommand(final List<String> selectedCurrencyCodes) {
|
||||
this.currencies = selectedCurrencyCodes.toArray(new String[selectedCurrencyCodes.size()]);
|
||||
}
|
||||
|
||||
public String[] getCurrencies() {
|
||||
return currencies;
|
||||
}
|
||||
|
||||
public void setCurrencies(String... currencies) {
|
||||
this.currencies = currencies;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package org.mifosng.platform.configuration.service;
|
||||
|
||||
import org.mifosng.data.command.OrganisationCurrencyCommand;
|
||||
import org.mifosng.platform.api.commands.OrganisationCurrencyCommand;
|
||||
|
||||
public interface ConfigurationWritePlatformService {
|
||||
|
||||
|
||||
+1
-1
@@ -6,8 +6,8 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.mifosng.data.ApiParameterError;
|
||||
import org.mifosng.data.command.OrganisationCurrencyCommand;
|
||||
import org.mifosng.platform.DataValidatorBuilder;
|
||||
import org.mifosng.platform.api.commands.OrganisationCurrencyCommand;
|
||||
import org.mifosng.platform.currency.domain.ApplicationCurrency;
|
||||
import org.mifosng.platform.currency.domain.ApplicationCurrencyRepository;
|
||||
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ public class LoanProductCommandValidator {
|
||||
baseDataValidator.reset().parameter("digitsAfterDecimal").value(command.getDigitsAfterDecimalValue()).ignoreIfNull().notNull().inMinMaxRange(0, 6);
|
||||
|
||||
baseDataValidator.reset().parameter("principal").value(command.getPrincipalValue()).ignoreIfNull().notNull().positiveAmount();
|
||||
baseDataValidator.reset().parameter("inArrearsTolerance").value(command.getInArrearsToleranceValue()).ignoreIfNull().positiveAmount();
|
||||
baseDataValidator.reset().parameter("inArrearsTolerance").value(command.getInArrearsToleranceValue()).ignoreIfNull().notNull().zeroOrPositiveAmount();
|
||||
|
||||
baseDataValidator.reset().parameter("repaymentFrequencyType").value(command.getRepaymentFrequencyType()).ignoreIfNull().notNull().inMinMaxRange(0, 3);
|
||||
|
||||
@@ -66,7 +66,7 @@ public class LoanProductCommandValidator {
|
||||
baseDataValidator.reset().parameter("digitsAfterDecimal").value(command.getDigitsAfterDecimalValue()).notNull().inMinMaxRange(0, 6);
|
||||
|
||||
baseDataValidator.reset().parameter("principal").value(command.getPrincipalValue()).notNull().positiveAmount();
|
||||
baseDataValidator.reset().parameter("inArrearsTolerance").value(command.getInArrearsToleranceValue()).positiveAmount();
|
||||
baseDataValidator.reset().parameter("inArrearsTolerance").value(command.getInArrearsToleranceValue()).notNull().zeroOrPositiveAmount();
|
||||
|
||||
baseDataValidator.reset().parameter("repaymentFrequencyType").value(command.getRepaymentFrequencyType()).notNull().inMinMaxRange(0, 3);
|
||||
baseDataValidator.reset().parameter("repaymentEvery").value(command.getRepaymentEveryValue()).notNull().greaterThanZero();
|
||||
|
||||
-2
@@ -25,8 +25,6 @@ public class RoleCommandValidator {
|
||||
baseDataValidator.reset().parameter("description").value(command.getDescription()).notBlank().notExceedingLengthOf(500);
|
||||
baseDataValidator.reset().parameter("permissions").value(command.getPermissions()).arrayNotEmpty();
|
||||
|
||||
baseDataValidator.reset().anyOfNotNull(command.getName(), command.getDescription(), command.getPermissions());
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user