T
- Double and String that represents Double value with current locale@Component(value="cuba_DoubleMaxValidator") @Scope(value="prototype") public class DoubleMaxValidator<T> extends AbstractValidator<T>
For error message it uses Groovy string and it is possible to use '$value' and '$max' keys for formatted output.
In order to provide your own implementation globally, create a subclass and register it in web-spring.xml
,
for example:
<bean id="cuba_DoubleMaxValidator" class="com.haulmont.cuba.gui.components.validation.DoubleMaxValidator" scope="prototype"/>Use
BeanLocator
when creating the validator programmatically.Modifier and Type | Field and Description |
---|---|
protected boolean |
inclusive |
protected java.lang.Double |
max |
static java.lang.String |
NAME |
datatypeRegistry, message, messages, userSessionSource
Constructor and Description |
---|
DoubleMaxValidator(java.lang.Double max)
Constructor with default error message.
|
DoubleMaxValidator(java.lang.Double max,
java.lang.String message)
Constructor with custom error message.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(T value) |
protected void |
fireValidationException(T value) |
protected java.lang.String |
getDefaultMessage() |
java.lang.Double |
getMax() |
boolean |
isInclusive() |
protected void |
setDatatypeRegistry(DatatypeRegistry datatypeRegistry) |
void |
setInclusive(boolean inclusive)
Set to true if the value must be greater than or equal to the specified maximum.
|
void |
setMax(java.lang.Double max)
Sets max value.
|
void |
setMax(java.lang.Double max,
boolean inclusive)
Sets max value and inclusive option.
|
protected void |
setMessages(Messages messages) |
protected void |
setUserSessionSource(UserSessionSource userSessionSource) |
formatValue, getMessage, getTemplateErrorMessage, setMessage
public static final java.lang.String NAME
protected java.lang.Double max
protected boolean inclusive
public DoubleMaxValidator(java.lang.Double max)
max
- max valuepublic DoubleMaxValidator(java.lang.Double max, java.lang.String message)
Example: "Value '$value' should be greater than or equal to '$max'".
max
- max valuemessage
- error message@Inject protected void setMessages(Messages messages)
@Inject protected void setDatatypeRegistry(DatatypeRegistry datatypeRegistry)
@Inject protected void setUserSessionSource(UserSessionSource userSessionSource)
public void setMax(java.lang.Double max)
max
- max valuepublic java.lang.Double getMax()
public void setMax(java.lang.Double max, boolean inclusive)
max
- max valueinclusive
- inclusive optionpublic void setInclusive(boolean inclusive)
inclusive
- inclusive optionpublic boolean isInclusive()
public void accept(T value) throws ValidationException
ValidationException
protected java.lang.String getDefaultMessage()
protected void fireValidationException(T value)