We use cookies to serve our customers and website visitors in the best possible way. Cookies are used for the proper functioning of the website and for improving the user experience, monitoring visitor traffic and marketing purposes. By continuing to browse the site, you agree to our use of cookies. You can read more about cookies here.
com.vaadin.data.validator.
Class NullValidator
java.lang.Object
com.vaadin.data.validator.NullValidator
All Implemented Interfaces:
This validator is used for validating properties that do or do not allow null values. By default, nulls are not allowed.
Since:
3.0
Version:
6.8.18
Author:
Vaadin Ltd.
See Also:
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.vaadin.data.Validator |
---|
Validator.EmptyValueException, Validator.InvalidValueException |
Constructor Summary | |
---|---|
NullValidator(String errorMessage,
boolean onlyNullAllowed)
Creates a new NullValidator. |
Method Summary | |
---|---|
String |
getErrorMessage()
Gets the error message that is displayed in case the value is invalid. |
boolean |
isNullAllowed()
Returns true if nulls are allowed otherwise
false . |
boolean |
isValid(Object value)
Tests if the given value is valid. |
void |
setErrorMessage(String errorMessage)
Sets the error message to be displayed on invalid value. |
void |
setNullAllowed(boolean onlyNullAllowed)
Sets if nulls (and only nulls) are to be allowed. |
void |
validate(Object value)
Validates the data given in value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
NullValidator
public NullValidator(String errorMessage,
boolean onlyNullAllowed)
- Parameters:
errorMessage
- the error message to display on invalidation.onlyNullAllowed
- Are only nulls allowed?
Creates a new NullValidator.
Method Detail |
---|
validate
public void validate(Object value)
throws Validator.InvalidValueException
- Parameters:
value
- the value to validate.- Throws:
Validator.InvalidValueException
- if the value was invalid.
Validates the data given in value.
isValid
public boolean isValid(Object value)
- Parameters:
value
- the value to validate.- Returns:
true
if the value is valid,false
otherwise.
Tests if the given value is valid.
isNullAllowed
public final boolean isNullAllowed()
Returns true
if nulls are allowed otherwise
false
.
setNullAllowed
public void setNullAllowed(boolean onlyNullAllowed)
- Parameters:
onlyNullAllowed
- If true, only nulls are allowed. If false only non-nulls are allowed. Do we allow nulls?
Sets if nulls (and only nulls) are to be allowed.
getErrorMessage
public String getErrorMessage()
- Returns:
- the Error Message.
Gets the error message that is displayed in case the value is invalid.
setErrorMessage
public void setErrorMessage(String errorMessage)
- Parameters:
errorMessage
- the Error Message to set.
Sets the error message to be displayed on invalid value.