]> source.dussan.org Git - vaadin-framework.git/commitdiff
Does not choke on null:s anymore, fixes #151
authorMarc Englund <marc.englund@itmill.com>
Mon, 25 Feb 2008 10:16:28 +0000 (10:16 +0000)
committerMarc Englund <marc.englund@itmill.com>
Mon, 25 Feb 2008 10:16:28 +0000 (10:16 +0000)
svn changeset:3910/svn branch:trunk

src/com/itmill/toolkit/data/validator/StringLengthValidator.java

index b622ea08eda0f64ade676033045f12b0c5ec165a..05fc6b610cf5cc29f9189a40237a7c6eeae88ea2 100644 (file)
@@ -67,12 +67,20 @@ public class StringLengthValidator implements Validator {
      *                 if the value was invalid.
      */
     public void validate(Object value) throws Validator.InvalidValueException {
-        if (value == null && !allowNull) {
-            throw new Validator.InvalidValueException(errorMessage);
+        if (value == null) {
+            if (allowNull) {
+                return;
+            } else {
+                throw new Validator.InvalidValueException(errorMessage);
+            }
         }
         final String s = value.toString();
-        if (s == null && !allowNull) {
-            throw new Validator.InvalidValueException(errorMessage);
+        if (s == null) {
+            if (allowNull) {
+                return;
+            } else {
+                throw new Validator.InvalidValueException(errorMessage);
+            }
         }
         final int len = s.length();
         if ((minLength >= 0 && len < minLength)
@@ -89,12 +97,12 @@ public class StringLengthValidator implements Validator {
      * @return <code>true</code> for valid value, otherwise <code>false</code>.
      */
     public boolean isValid(Object value) {
-        if (value == null && !allowNull) {
-            return true;
+        if (value == null) {
+            return allowNull;
         }
         final String s = value.toString();
-        if (s == null && !allowNull) {
-            return true;
+        if (s == null) {
+            return allowNull;
         }
         final int len = s.length();
         if ((minLength >= 0 && len < minLength)