T
- BigDecimal, BigInteger, Long, Integer and String that represents BigDecimal value with current locale@Component(value="cuba_DecimalMaxValidator") @Scope(value="prototype") public class DecimalMaxValidator<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_DecimalMaxValidator" class="com.haulmont.cuba.gui.components.validation.DecimalMaxValidator" scope="prototype"/>Use
BeanLocator
when creating the validator programmatically.Modifier and Type | Field and Description |
---|---|
protected boolean |
inclusive |
protected java.math.BigDecimal |
max |
static java.lang.String |
NAME |
datatypeRegistry, message, messages, userSessionSource
Constructor and Description |
---|
DecimalMaxValidator(java.math.BigDecimal max)
Constructor with default error message.
|
DecimalMaxValidator(java.math.BigDecimal 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.math.BigDecimal |
getMax() |
boolean |
isInclusive() |
protected void |
setDatatypeRegistry(DatatypeRegistry datatypeRegistry) |
void |
setInclusive(boolean inclusive)
Set to true if the value must be less than or equal to the specified maximum.
|
void |
setMax(java.math.BigDecimal max)
Sets max value.
|
void |
setMax(java.math.BigDecimal 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.math.BigDecimal max
protected boolean inclusive
public DecimalMaxValidator(java.math.BigDecimal max)
max
- max valuepublic DecimalMaxValidator(java.math.BigDecimal max, java.lang.String message)
Example: "Value '$value' should be less 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.math.BigDecimal max)
max
- max valuepublic java.math.BigDecimal getMax()
public void setMax(java.math.BigDecimal 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)