Skip to content

Commit

Permalink
Added support for pre-compiled patterns in RegexpValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
GavinDBrown committed May 15, 2015
1 parent d003866 commit 67419cc
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 67419cc

Please sign in to comment.