Skip to content

Commit

Permalink
Merge pull request rengwuxian#188 from GavinDBrown/master
Browse files Browse the repository at this point in the history
Added support for pre-compiled patterns in RegexpValidator
  • Loading branch information
rengwuxian committed Dec 30, 2015
2 parents b817073 + 67419cc commit 11d5e7d
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public RegexpValidator(@NonNull String errorMessage, @NonNull String regex) {
pattern = Pattern.compile(regex);
}

public RegexpValidator(@NonNull String errorMessage, @NonNull Pattern pattern) {
super(errorMessage);
this.pattern = pattern;
}

@Override
public boolean isValid(@NonNull CharSequence text, boolean isEmpty) {
return pattern.matcher(text).matches();
Expand Down

0 comments on commit 11d5e7d

Please sign in to comment.