Class AbstractRegularExpressionValidator<V>
- Type Parameters:
V
- The value type this validator supports.
- All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable
,com.globalmentor.beans.PropertyConstrainable
,Validator<V>
- Direct Known Subclasses:
RegularExpressionCharArrayValidator
,RegularExpressionStringValidator
- Author:
- Garret Wilson
-
Field Summary
Fields inherited from class com.globalmentor.beans.BoundPropertyObject
NO_PROPERTY_CHANGE_LISTENERS, NO_VETOABLE_CHANGE_LISTENERS
Fields inherited from interface io.guise.framework.validator.Validator
INVALID_VALUE_MESSAGE_PROPERTY, VALUE_REQUIRED_MESSAGE_PROPERTY, VALUE_REQUIRED_PROPERTY
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractRegularExpressionValidator
(String regularExpression) Constructs a string regular expression validator from a regular expression string, without requiring a non-null
value..AbstractRegularExpressionValidator
(String regularExpression, boolean valueRequired) Constructs a string regular expression validator from a regular expression string.Constructs a string regular expression validator from a regular expression pattern, without requiring a non-null
value.AbstractRegularExpressionValidator
(Pattern pattern, boolean valueRequired) Constructs a string regular expression validator from a regular expression pattern. -
Method Summary
Methods inherited from class io.guise.framework.validator.AbstractValidator
getInvalidValueMessage, getValueRequiredMessage, isValid, isValueRequired, setInvalidValueMessage, setValueRequired, setValueRequiredMessage, throwInvalidValueValidationException, throwValueRequiredValidationException
Methods inherited from class io.guise.framework.event.GuiseBoundPropertyObject
getSession
Methods inherited from class com.globalmentor.beans.BoundPropertyObject
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPostponedPropertyChangeEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getForwardPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getRepeatPropertyChangeListener, getRepeatVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, getVetoableChangeSupport, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.globalmentor.beans.PropertyBindable
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
Methods inherited from interface io.guise.framework.validator.Validator
getSession
-
Constructor Details
-
AbstractRegularExpressionValidator
Constructs a string regular expression validator from a regular expression string, without requiring a non-null
value..- Parameters:
regularExpression
- The regular expression against which to validate string values.- Throws:
NullPointerException
- if the given regular expression isnull
.
-
AbstractRegularExpressionValidator
Constructs a string regular expression validator from a regular expression string.- Parameters:
regularExpression
- The regular expression against which to validate string values.valueRequired
- Whether the value must be non-null
in order to be considered valid.- Throws:
NullPointerException
- if the given regular expression isnull
.
-
AbstractRegularExpressionValidator
Constructs a string regular expression validator from a regular expression pattern, without requiring a non-null
value.- Parameters:
pattern
- The regular expression pattern against which to validate string values.- Throws:
NullPointerException
- if the given regular expression pattern isnull
.
-
AbstractRegularExpressionValidator
Constructs a string regular expression validator from a regular expression pattern.- Parameters:
pattern
- The regular expression pattern against which to validate string values.valueRequired
- Whether the value must be non-null
in order to be considered valid.- Throws:
NullPointerException
- if the given regular expression pattern isnull
.
-
-
Method Details
-
getPattern
- Returns:
- The regular expression pattern against which to validate string values.
-
toString
Description copied from class:AbstractValidator
Retrieves a string representation of the given value appropriate for error messages. This implementation returns theObject.toString()
string representation of the value.- Overrides:
toString
in classAbstractValidator<V>
- Parameters:
value
- The value for which a string representation should be returned.- Returns:
- A string representation of the given value.
-
validate
Description copied from class:AbstractValidator
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
Validator.isValid(Object)
may be overridden to provide optimized fast-fail determinations, adding new logic toValidator.isValid(Object)
cannot be used in place of overriding this method.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
AbstractValidator.isValid(Object)
may be overridden to provide optimized fast-fail determinations, adding new logic toAbstractValidator.isValid(Object)
cannot be used in place of overriding this method.- Specified by:
validate
in interfaceValidator<V>
- Overrides:
validate
in classAbstractValidator<V>
- Parameters:
value
- The value to validate, which may benull
.- Throws:
ValidationException
- if the provided value is not valid.- See Also:
-