Class NullValidator
java.lang.Object
com.vaadin.featurepack.data.validator.NullValidator
- All Implemented Interfaces:
Validator,Serializable
This validator is used for validating properties that do or do not allow null
values. By default, nulls are not allowed.
- Author:
- Vaadin Ltd.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.vaadin.featurepack.data.Validator
Validator.EmptyValueException, Validator.InvalidValueException -
Constructor Summary
ConstructorsConstructorDescriptionNullValidator(String errorMessage, boolean onlyNullAllowed) Creates a new NullValidator. -
Method Summary
Modifier and TypeMethodDescriptionGets the error message that is displayed in case the value is invalid.final booleanReturnstrueif nulls are allowed otherwisefalse.voidsetErrorMessage(String errorMessage) Sets the error message to be displayed on invalid value.voidsetNullAllowed(boolean onlyNullAllowed) Sets if nulls (and only nulls) are to be allowed.voidValidates the data given in value.
-
Constructor Details
-
NullValidator
Creates a new NullValidator.- Parameters:
errorMessage- the error message to display on invalidation.onlyNullAllowed- Are only nulls allowed?
-
-
Method Details
-
validate
Validates the data given in value.- Specified by:
validatein interfaceValidator- Parameters:
value- the value to validate.- Throws:
Validator.InvalidValueException- if the value was invalid.
-
isNullAllowed
public final boolean isNullAllowed()Returnstrueif nulls are allowed otherwisefalse. -
setNullAllowed
public void setNullAllowed(boolean onlyNullAllowed) Sets if nulls (and only nulls) are to be allowed.- Parameters:
onlyNullAllowed- If true, only nulls are allowed. If false only non-nulls are allowed. Do we allow nulls?
-
getErrorMessage
Gets the error message that is displayed in case the value is invalid.- Returns:
- the Error Message.
-
setErrorMessage
Sets the error message to be displayed on invalid value.- Parameters:
errorMessage- the Error Message to set.
-