summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/data
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2013-01-14 13:22:54 +0200
committerHenri Sara <hesara@vaadin.com>2013-01-14 13:22:54 +0200
commit1f3656e0dcdd59c323a9ab7d9b962e42250f0aa3 (patch)
tree2e24fc8c53c7696a5d8af297fac5edeebd2bb61b /server/src/com/vaadin/data
parentcc9cc89865d7378a06497fa4ec08c30311b9f83a (diff)
downloadvaadin-framework-1f3656e0dcdd59c323a9ab7d9b962e42250f0aa3.tar.gz
vaadin-framework-1f3656e0dcdd59c323a9ab7d9b962e42250f0aa3.zip
Most validators should accept null or empty string (#10561, #10713).
Change-Id: I1e8d6015aefdc184af6383cb22cdf3e13be351cf
Diffstat (limited to 'server/src/com/vaadin/data')
-rw-r--r--server/src/com/vaadin/data/validator/EmailValidator.java21
-rw-r--r--server/src/com/vaadin/data/validator/RangeValidator.java3
-rw-r--r--server/src/com/vaadin/data/validator/RegexpValidator.java8
3 files changed, 16 insertions, 16 deletions
diff --git a/server/src/com/vaadin/data/validator/EmailValidator.java b/server/src/com/vaadin/data/validator/EmailValidator.java
index 2217b3cf2c..aa7a921d51 100644
--- a/server/src/com/vaadin/data/validator/EmailValidator.java
+++ b/server/src/com/vaadin/data/validator/EmailValidator.java
@@ -23,6 +23,12 @@ package com.vaadin.data.validator;
* See {@link com.vaadin.data.validator.AbstractStringValidator} for more
* information.
*
+ * <p>
+ * An empty string or a null is always accepted - use the required flag on
+ * fields or a separate validator (or override {@link #isValidValue(String)}) to
+ * fail on empty values.
+ * </p>
+ *
* @author Vaadin Ltd.
* @since 5.4
*/
@@ -41,19 +47,4 @@ public class EmailValidator extends RegexpValidator {
"^([a-zA-Z0-9_\\.\\-+])+@(([a-zA-Z0-9-])+\\.)+([a-zA-Z0-9]{2,4})+$",
true, errorMessage);
}
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.vaadin.data.validator.AbstractValidator#isValidValue(java.lang.Object
- * )
- */
- @Override
- protected boolean isValidValue(String value) {
- if (value == null || value.isEmpty()) {
- return true;
- }
- return super.isValidValue(value);
- }
}
diff --git a/server/src/com/vaadin/data/validator/RangeValidator.java b/server/src/com/vaadin/data/validator/RangeValidator.java
index d92e259cf6..5e82a37b51 100644
--- a/server/src/com/vaadin/data/validator/RangeValidator.java
+++ b/server/src/com/vaadin/data/validator/RangeValidator.java
@@ -154,7 +154,8 @@ public class RangeValidator<T extends Comparable> extends AbstractValidator<T> {
*/
@Override
protected boolean isValidValue(T value) {
- if (value == null) {
+ if (value == null
+ || (String.class.equals(getType()) && "".equals(value))) {
return true;
}
diff --git a/server/src/com/vaadin/data/validator/RegexpValidator.java b/server/src/com/vaadin/data/validator/RegexpValidator.java
index ea659fcfe2..f85bce9281 100644
--- a/server/src/com/vaadin/data/validator/RegexpValidator.java
+++ b/server/src/com/vaadin/data/validator/RegexpValidator.java
@@ -30,6 +30,11 @@ import java.util.regex.Pattern;
* See {@link com.vaadin.data.validator.AbstractStringValidator} for more
* information.
* </p>
+ * <p>
+ * An empty string or a null is always accepted - use the required flag on
+ * fields or a separate validator (or override {@link #isValidValue(String)}) to
+ * fail on empty values.
+ * </p>
*
* @author Vaadin Ltd.
* @since 5.4
@@ -81,6 +86,9 @@ public class RegexpValidator extends AbstractStringValidator {
*/
@Override
protected boolean isValidValue(String value) {
+ if (value == null || value.isEmpty()) {
+ return true;
+ }
if (complete) {
return getMatcher(value).matches();
} else {