Remove min length regex, the guard is too weak to be meaningful

This commit is contained in:
Viktor Lofgren 2023-01-30 10:43:53 +01:00
parent 2e4532ca90
commit 4a6a1308b0

View File

@ -19,9 +19,6 @@ public class GuardedRegexFactory {
public static GuardedRegex contains(String substring, @Language("RegExp") String regex) {
return new GuardedRegexContains(substring, regex);
}
public static GuardedRegex minLength(int minLength, @Language("RegExp") String regex) {
return new GuardedRegexMinLength(minLength, regex);
}
private record GuardedRegexContains(String contains, Pattern pattern) implements GuardedRegex {
public GuardedRegexContains(String contains, String pattern) {
@ -32,15 +29,6 @@ public class GuardedRegexFactory {
return s.contains(contains) && pattern.matcher(s).find();
}
}
private record GuardedRegexMinLength(int minLength, Pattern pattern) implements GuardedRegex {
public GuardedRegexMinLength(int minLength, String pattern) {
this(minLength, Pattern.compile(pattern));
}
public boolean test(String s) {
return s.length() >= minLength && pattern.matcher(s).find();
}
}
private record GuardedRegexStartsWith(String start, Pattern pattern) implements GuardedRegex {
public GuardedRegexStartsWith(String start, String pattern) {
this(start, Pattern.compile(pattern));