From: Marc Englund Date: Mon, 25 Feb 2008 10:16:28 +0000 (+0000) Subject: Does not choke on null:s anymore, fixes #151 X-Git-Tag: 6.7.0.beta1~5027 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9db16de4a74823f733f62dc9a213cc851d911260;p=vaadin-framework.git Does not choke on null:s anymore, fixes #151 svn changeset:3910/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/data/validator/StringLengthValidator.java b/src/com/itmill/toolkit/data/validator/StringLengthValidator.java index b622ea08ed..05fc6b610c 100644 --- a/src/com/itmill/toolkit/data/validator/StringLengthValidator.java +++ b/src/com/itmill/toolkit/data/validator/StringLengthValidator.java @@ -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 true for valid value, otherwise false. */ 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)