Skip to content

Commit

Permalink
replace FormatValidator with Predicate
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Apr 15, 2023
1 parent 4f03b1a commit c1df36c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand All @@ -33,7 +34,7 @@ final class StringSchema
final String constValue;
final Set<String> enumValues;

final FormatValidator formatValidator;
final Predicate<String> formatValidator;

StringSchema(JSONObject input) {
super(input);
Expand Down Expand Up @@ -169,7 +170,7 @@ public ValidateResult validate(Object value) {
}

if (formatValidator != null) {
if (!formatValidator.isValid(str)) {
if (!formatValidator.test(str)) {
return new ValidateResult(false, "format not match, expect %s, but %s", format, str);
}
}
Expand Down

0 comments on commit c1df36c

Please sign in to comment.