Package com.vaadin.flow.component
Interface HasValidation
- All Superinterfaces:
Serializable
- All Known Subinterfaces:
HasValidationProperties
- All Known Implementing Classes:
AbstractNumberField
,BigDecimalField
,CheckboxGroup
,ComboBox
,ComboBoxBase
,CustomField
,DatePicker
,DateTimePicker
,EmailField
,IntegerField
,MultiSelectComboBox
,NumberField
,PasswordField
,RadioButtonGroup
,Select
,TextArea
,TextField
,TextFieldBase
,TimePicker
A component that supports input validation.
- Since:
- 1.0.
- Author:
- Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptionGets current error message from the component.boolean
Returnstrue
if component input is invalid,false
otherwise.void
setErrorMessage
(String errorMessage) Sets an error message to the component.void
setInvalid
(boolean invalid) Sets the validity of the component input.
-
Method Details
-
setErrorMessage
Sets an error message to the component.The Web Component is responsible for deciding when to show the error message to the user, and this is usually triggered by triggering the invalid state for the Web Component. Which means that there is no need to clean up the message when component becomes valid (otherwise it may lead to undesired visual effects).
- Parameters:
errorMessage
- a new error message
-
getErrorMessage
String getErrorMessage()Gets current error message from the component.- Returns:
- current error message
-
setInvalid
void setInvalid(boolean invalid) Sets the validity of the component input.When component becomes valid it hides the error message by itself, so there is no need to clean up the error message via the
setErrorMessage(String)
call.- Parameters:
invalid
- new value for component input validity
-
isInvalid
boolean isInvalid()Returnstrue
if component input is invalid,false
otherwise.- Returns:
- whether the component input is valid
-