com.vaadin.data.validator.
Class StringLengthValidator
java.lang.Object
com.vaadin.data.validator.AbstractValidator
com.vaadin.data.validator.StringLengthValidator
All Implemented Interfaces:
- extends AbstractValidator
public class StringLengthValidator
This StringLengthValidator
is used to validate the length of
strings.
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 | |
---|---|
StringLengthValidator(String errorMessage)
Creates a new StringLengthValidator with a given error message. |
|
StringLengthValidator(String errorMessage,
int minLength,
int maxLength,
boolean allowNull)
Creates a new StringLengthValidator with a given error message, permissable lengths and null-string allowance. |
Method Summary | |
---|---|
int |
getMaxLength()
Gets the maximum permissible length of the string. |
int |
getMinLength()
Gets the minimum permissible length of the string. |
boolean |
isNullAllowed()
Deprecated. |
boolean |
isValid(Object value)
Checks if the given value is valid. |
void |
setMaxLength(int maxLength)
Sets the maximum permissible length of the string. |
void |
setMinLength(int minLength)
Sets the minimum permissible length. |
void |
setNullAllowed(boolean allowNull)
Deprecated. |
Methods inherited from class com.vaadin.data.validator.AbstractValidator |
---|
getErrorMessage, setErrorMessage, validate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
StringLengthValidator
public StringLengthValidator(String errorMessage)
- Parameters:
errorMessage
- the message to display in case the value does not validate.
Creates a new StringLengthValidator with a given error message.
StringLengthValidator
public StringLengthValidator(String errorMessage,
int minLength,
int maxLength,
boolean allowNull)
- Parameters:
errorMessage
- the message to display in case the value does not validate.minLength
- the minimum permissible length of the string.maxLength
- the maximum permissible length of the string.allowNull
- Are null strings permissible? This can be handled better by setting a field as required or not.
Creates a new StringLengthValidator with a given error message, permissable lengths and null-string allowance.
Method Detail |
---|
isValid
public boolean isValid(Object value)
- Parameters:
value
- the value to validate.- Returns:
true
for valid value, otherwisefalse
.
Checks if the given value is valid.
isNullAllowed
@Deprecated
public final boolean isNullAllowed()
- Returns:
true
if allows null string, otherwisefalse
.
Deprecated.
Returns true
if null strings are allowed.
getMaxLength
public final int getMaxLength()
- Returns:
- the maximum length of the string.
Gets the maximum permissible length of the string.
getMinLength
public final int getMinLength()
- Returns:
- the minimum length of the string.
Gets the minimum permissible length of the string.
setNullAllowed
@Deprecated
public void setNullAllowed(boolean allowNull)
Deprecated.
Sets whether null-strings are to be allowed. This can be better handled by setting a field as required or not.
setMaxLength
public void setMaxLength(int maxLength)
- Parameters:
maxLength
- the length to set.
Sets the maximum permissible length of the string.
setMinLength
public void setMinLength(int minLength)
- Parameters:
minLength
- the length to set.
Sets the minimum permissible length.