Aleksey Kulikov 2025-05-21 19:08:55 +03:00
parent 86b832d03c
commit d5349a6e5e

View file

@ -103,26 +103,28 @@ public final class ValidateSymbolsRule<R> implements IValidationRule<ImdgValidat
String forHash = validationSymbols.stream().map(ValidationSymbols::getSymbols).collect(Collectors.joining());
Integer hash = forHash.hashCode();
if (!Objects.equals(allowedSymbolsHash.get(), hash)) {
Matcher matcher = rangePattern.matcher(forHash);
Set<Character> currAllowedSymbols = new HashSet<>();
while (matcher.find()) {
String part = matcher.group();
if (part.length() == 3 && part.charAt(1) == '-') {
char start = part.charAt(0);
char end = part.charAt(2);
if (start > end) {
log.warn("Invalid character range: {}, skipped", part);
continue;
for (ValidationSymbols symbols : validationSymbols) {
Matcher matcher = rangePattern.matcher(symbols.getSymbols());
Set<Character> currAllowedSymbols = new HashSet<>();
while (matcher.find()) {
String part = matcher.group();
if (part.length() == 3 && part.charAt(1) == '-') {
char start = part.charAt(0);
char end = part.charAt(2);
if (start > end) {
log.warn("Invalid character range: {}, skipped", part);
continue;
}
for (char c = start; c <= end; c++) {
currAllowedSymbols.add(c);
}
} else {
currAllowedSymbols.add(part.charAt(0));
}
for (char c = start; c <= end; c++) {
currAllowedSymbols.add(c);
}
} else {
currAllowedSymbols.add(part.charAt(0));
}
allowedSymbols.set(currAllowedSymbols);
allowedSymbolsHash.set(hash);
}
allowedSymbols.set(currAllowedSymbols);
allowedSymbolsHash.set(hash);
}
}