Author: sebb
Date: Wed Apr 13 21:33:43 2016
New Revision: 1739009
URL: http://svn.apache.org/viewvc?rev=1739009&view=rev
Log:
Cheaper to check the length, so do it before the regex check
Modified:
commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/CodeValidator.java
Modified:
commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/CodeValidator.java
URL:
http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/CodeValidator.java?rev=1739009&r1=1739008&r2=1739009&view=diff
==============================================================================
---
commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/CodeValidator.java
(original)
+++
commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/CodeValidator.java
Wed Apr 13 21:33:43 2016
@@ -246,6 +246,12 @@ public final class CodeValidator impleme
return null;
}
+ // check the length
+ if ((minLength >= 0 && code.length() < minLength) ||
+ (maxLength >= 0 && code.length() > maxLength)) {
+ return null;
+ }
+
// validate/reformat using regular expression
if (regexValidator != null) {
code = regexValidator.validate(code);
@@ -254,12 +260,6 @@ public final class CodeValidator impleme
}
}
- // check the length
- if ((minLength >= 0 && code.length() < minLength) ||
- (maxLength >= 0 && code.length() > maxLength)) {
- return null;
- }
-
// validate the check digit
if (checkdigit != null && !checkdigit.isValid(code)) {
return null;