Package com.vaadin.flow.component.shared
Interface HasValidationProperties
- All Superinterfaces:
HasElement
,HasValidation
,Serializable
- All Known Implementing Classes:
AbstractNumberField
,BigDecimalField
,Checkbox
,CheckboxGroup
,ComboBox
,ComboBoxBase
,CustomField
,DatePicker
,DateTimePicker
,EmailField
,IntegerField
,MultiSelectComboBox
,NumberField
,PasswordField
,RadioButtonGroup
,Select
,TextArea
,TextField
,TextFieldBase
,TimePicker
Mixin interface for components that provide properties for setting invalid
state and error message string to show when invalid.
- Author:
- Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptiondefault String
Gets the error message displayed for all constraint violations if it has been set withsetErrorMessage(String)
.default boolean
Gets whether the component is currently in invalid state.default void
setErrorMessage
(String errorMessage) Sets a single error message to display for all constraint violations.default void
setInvalid
(boolean invalid) Sets the invalid state of the component.Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
Methods inherited from interface com.vaadin.flow.component.HasValidation
setManualValidation
-
Method Details
-
setErrorMessage
Sets a single error message to display for all constraint violations. The error message will only appear when the component is flagged as invalid, either as a result of constraint validation or by the developer throughsetInvalid(boolean)
if manual validation mode is enabled.- Specified by:
setErrorMessage
in interfaceHasValidation
- Parameters:
errorMessage
- the error message to set, ornull
to clear
-
getErrorMessage
Gets the error message displayed for all constraint violations if it has been set withsetErrorMessage(String)
. Otherwise, gets the current i18n error message if the value is currently invalid.- Specified by:
getErrorMessage
in interfaceHasValidation
- Returns:
- the error message
-
setInvalid
default void setInvalid(boolean invalid) Sets the invalid state of the component.NOTE: If you need to manually control the invalid state, enable manual validation mode with
HasValidation.setManualValidation(boolean)
to avoid potential conflicts between your custom validation and the component's constraint validation.- Specified by:
setInvalid
in interfaceHasValidation
- Parameters:
invalid
-true
for invalid,false
for valid
-
isInvalid
default boolean isInvalid()Gets whether the component is currently in invalid state.- Specified by:
isInvalid
in interfaceHasValidation
- Returns:
true
for invalid,false
for valid
-