com.vaadin.data.validator.
Class AbstractStringValidator
java.lang.Object
com.vaadin.data.validator.AbstractValidator
com.vaadin.data.validator.AbstractStringValidator
All Implemented Interfaces:
Direct Known Subclasses:
- extends AbstractValidator
public abstract class AbstractStringValidator
Validator base class for validating strings. See
AbstractValidator
for more information.
To include the value that failed validation in the exception message you can
use "{0}" in the error message. This will be replaced with the failed value
(converted to string using Object.toString()
) or "null" if the value is
null.
Since:
5.4
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 | |
---|---|
AbstractStringValidator(String errorMessage)
Constructs a validator for strings. |
Method Summary | |
---|---|
boolean |
isValid(Object value)
Tests if the given value is a valid string. |
protected abstract boolean |
isValidString(String value)
Checks if the given string is valid. |
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 |
---|
AbstractStringValidator
public AbstractStringValidator(String errorMessage)
- Parameters:
errorMessage
- the message to be included in anInvalidValueException
(with "{0}" replaced by the value that failed validation).
Constructs a validator for strings.
Null and empty string values are always accepted. To reject empty values, set the field being validated as required.
Method Detail |
---|
isValid
public boolean isValid(Object value)
- Parameters:
value
- the value to check- Returns:
- true if the value (or its toString()) is a valid string, false otherwise
Tests if the given value is a valid string.
Null values are always accepted. Values that are not String
s are
converted using Object.toString()
. Then isValidString(String)
is used to validate the value.
isValidString
protected abstract boolean isValidString(String value)
- Parameters:
value
- String to check. Can never be null.- Returns:
- true if the string is valid, false otherwise
Checks if the given string is valid.