Interface Validator<V>
- Type Parameters:
V
- The value type this validator supports.
- All Superinterfaces:
com.globalmentor.beans.PropertyBindable
- All Known Subinterfaces:
RangeValidator<V>
- All Known Implementing Classes:
AbstractComparableRangeValidator
,AbstractRangeValidator
,AbstractRegularExpressionValidator
,AbstractValidator
,DateRangeValidator
,DecimalRangeValidator
,IntegerRangeValidator
,LongRangeValidator
,PANValidator
,RegularExpressionCharArrayValidator
,RegularExpressionStringValidator
,ResourceImportValidator
,ValueRequiredValidator
- Author:
- Garret Wilson
- See Also:
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Determines whether a given value is valid.void
setInvalidValueMessage
(String newInvalidValueMessage) Sets the text of the invalid value message.void
setValueRequiredMessage
(String newValueRequiredMessage) Sets the text of the value required message.void
Checks whether a given value is valid, and throws an exception if not.Methods inherited from interface com.globalmentor.beans.PropertyBindable
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Field Details
-
INVALID_VALUE_MESSAGE_PROPERTY
The invalid value message bound property. -
VALUE_REQUIRED_MESSAGE_PROPERTY
The value required message bound property. -
VALUE_REQUIRED_PROPERTY
The value required bound property.
-
-
Method Details
-
getInvalidValueMessage
String getInvalidValueMessage()- Returns:
- The invalid value message text, which may include a resource reference.
-
setInvalidValueMessage
Sets the text of the invalid value message. This is a bound property.- Parameters:
newInvalidValueMessage
- The new text of the invalid value message, which may include a resource reference.- Throws:
NullPointerException
- if the given message isnull
.- See Also:
-
getValueRequiredMessage
String getValueRequiredMessage()- Returns:
- The value required message text, which may include a resource reference.
-
setValueRequiredMessage
Sets the text of the value required message. This is a bound property.- Parameters:
newValueRequiredMessage
- The new text of the value required message, which may include a resource reference..- Throws:
NullPointerException
- if the given message isnull
.- See Also:
-
getSession
GuiseSession getSession()- Returns:
- The Guise session that owns this validator.
-
validate
Checks whether a given value is valid, and throws an exception if not.The message of the thrown exception should be appropriate for display to the user, although it may include string resource references. If a child class has no specific message to return, that class may call
AbstractValidator.throwInvalidValueValidationException(Object)
as a convenience. A child class may also callAbstractValidator.throwValueRequiredValidationException(Object)
as a convenience, but this is usually not required if this version of the method, which provides a missing value check, is called first.This version checks whether a value is provided if values are required. Child classes should call this version as a convenience for checking non-
null
and required status.Adding new validation logic always requires overriding this method. Although
isValid(Object)
may be overridden to provide optimized fast-fail determinations, adding new logic toisValid(Object)
cannot be used in place of overriding this method.- Parameters:
value
- The value to validate, which may benull
.- Throws:
ValidationException
- if the provided value is not valid.- See Also:
-
isValid
Determines whether a given value is valid. This convenience version callsvalidate(Object)
, returningfalse
only if an exception is thrown. Although this method may be overridden to provide optimized fast-fail determinations, adding new logic to this method cannot be used in place of overridingvalidate(Object)
.- Parameters:
value
- The value to validate.- Returns:
true
if a value is given and the value is valid; or a value is not required, elsefalse
.
-