public class StringLengthValidator extends AbstractStringValidator
StringLengthValidator is used to validate the length of
strings.Validator.EmptyValueException, Validator.InvalidValueException| Constructor and Description |
|---|
StringLengthValidator(String errorMessage)
Creates a new StringLengthValidator with a given error message.
|
StringLengthValidator(String errorMessage,
Integer minLength,
Integer maxLength,
boolean allowNull)
Creates a new StringLengthValidator with a given error message and
minimum and maximum length limits.
|
| Modifier and Type | Method and Description |
|---|---|
Integer |
getMaxLength()
Gets the maximum permissible length of the string.
|
Integer |
getMinLength()
Gets the minimum permissible length of the string.
|
boolean |
isNullAllowed()
Deprecated.
|
protected boolean |
isValidValue(String value)
Checks if the given value is valid.
|
void |
setMaxLength(Integer maxLength)
Sets the maximum permissible length of the string.
|
void |
setMinLength(Integer minLength)
Sets the minimum permissible length.
|
void |
setNullAllowed(boolean allowNull)
Deprecated.
|
getTypegetErrorMessage, isValid, isValidType, setErrorMessage, validatepublic StringLengthValidator(String errorMessage)
errorMessage - the message to display in case the value does not validate.public StringLengthValidator(String errorMessage, Integer minLength, Integer maxLength, boolean allowNull)
errorMessage - the message to display in case the value does not validate.minLength - the minimum permissible length of the string or null for no
limit. A negative value for no limit is also supported for
backwards compatibility.maxLength - the maximum permissible length of the string or null for no
limit. A negative value for no limit is also supported for
backwards compatibility.allowNull - Are null strings permissible? This can be handled better by
setting a field as required or not.protected boolean isValidValue(String value)
isValidValue in class AbstractValidator<String>value - the value to validate.true for valid value, otherwise false.@Deprecated public final boolean isNullAllowed()
true if null strings are allowed.true if allows null string, otherwise
false.public Integer getMaxLength()
public Integer getMinLength()
@Deprecated public void setNullAllowed(boolean allowNull)
public void setMaxLength(Integer maxLength)
maxLength - the maximum length to accept or null for no limitpublic void setMinLength(Integer minLength)
minLength - the minimum length to accept or null for no limitCopyright © 2019 Vaadin Ltd. All rights reserved.