diff options
-rw-r--r-- | server/src/main/java/com/vaadin/data/Binder.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/server/src/main/java/com/vaadin/data/Binder.java b/server/src/main/java/com/vaadin/data/Binder.java index d417944f80..3fb2d75c89 100644 --- a/server/src/main/java/com/vaadin/data/Binder.java +++ b/server/src/main/java/com/vaadin/data/Binder.java @@ -627,6 +627,31 @@ public class Binder<BEAN> implements Serializable { * field's value is not equal to what {@link HasValue#getEmptyValue()} * returns</li> * </ol> + * <p> + * For setting an error message, use {@link #asRequired(String)}. + * <p> + * For localizing the error message, use + * {@link #asRequired(ErrorMessageProvider)}. + * + * @see #asRequired(String) + * @see #asRequired(ErrorMessageProvider) + * @see HasValue#setRequiredIndicatorVisible(boolean) + * @see HasValue#isEmpty() + * @return this binding, for chaining + * @since 8.2 + */ + public default BindingBuilder<BEAN, TARGET> asRequired() { + return asRequired(context -> ""); + } + + /** + * Sets the field to be required. This means two things: + * <ol> + * <li>the required indicator will be displayed for this field</li> + * <li>the field value is validated for not being empty, i.e. that the + * field's value is not equal to what {@link HasValue#getEmptyValue()} + * returns</li> + * </ol> * * @see HasValue#setRequiredIndicatorVisible(boolean) * @see HasValue#isEmpty() |