error management

This commit is contained in:
2024-10-27 20:06:51 +01:00
parent 19177eefdf
commit f404ad3088
14 changed files with 93 additions and 72 deletions
@@ -28,6 +28,7 @@ public class PasswordModelValidator implements Validator {
public static final String SYSTEM_PROPERTY_PASSWORD_RULE_WHITESPACE = "password.rule.whitespace";
public static final String SYSTEM_PROPERTY_PASSWORD_RULE_LENGTH = "password.rule.length";
public static final String SYSTEM_PROPERTY_PASSWORD_RULE_LOWERCASE = "password.rule.lowercase";
public static final String SYSTEM_PROPERTY_PASSWORD_RULE_UPPERCASE = "password.rule.uppercase";
public static final String SYSTEM_PROPERTY_PASSWORD_RULE_DIGIT = "password.rule.digit";
public static final String SYSTEM_PROPERTY_PASSWORD_RULE_SPECIAL = "password.rule.special";
@@ -52,6 +53,11 @@ public class PasswordModelValidator implements Validator {
rules.add(new LengthRule(length, 4096));
}
int lowercase = systemPropertyManager.getInteger(SYSTEM_PROPERTY_PASSWORD_RULE_LOWERCASE, 1);
if (lowercase > 0) {
rules.add(new CharacterRule(EnglishCharacterData.LowerCase, lowercase));
}
int uppercase = systemPropertyManager.getInteger(SYSTEM_PROPERTY_PASSWORD_RULE_UPPERCASE, 1);
if (uppercase > 0) {
rules.add(new CharacterRule(EnglishCharacterData.UpperCase, uppercase));
@@ -73,7 +79,7 @@ public class PasswordModelValidator implements Validator {
if (!result.isValid()) {
for (RuleResultDetail ruleResultDetail : result.getDetails()) {
errors.rejectValue("password", ruleResultDetail.getErrorCode());
errors.rejectValue("password", ruleResultDetail.getErrorCode(), ruleResultDetail.getValues(), null);
}
}
@@ -32,11 +32,11 @@ public class TurnoverValidator implements Validator {
}
if (turnover.getPrice() < 0) {
errors.rejectValue("price", "POSITIVE_VALUE");
errors.rejectValue("price", "MIN");
}
if (turnover.getGiftcardPrice() != null && turnover.getGiftcardPrice() < 0) {
errors.rejectValue("giftcardPrice", "POSITIVE_VALUE");
errors.rejectValue("giftcardPrice", "MIN");
} else if (turnover.getGiftcardPrice() != null && turnover.getGiftcardPrice() > turnover.getPrice()) {
errors.rejectValue("giftcardPrice", "GREATER_THAN_PRICE");
}