T
- BigDecimal, BigInteger, Long, Integer and String that represents BigDecimal value with current locale@Component(value="ui_DecimalMaxValidator") @Scope(value="prototype") public class DecimalMaxValidator<T> extends AbstractValidator<T>
For error message it uses template 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 configuration class, for example:
@Bean("ui_DecimalMaxValidator") @Scope(BeanDefinition.SCOPE_PROTOTYPE) @Primary protected DecimalMaxValidator decimalMaxValidator(BigDecimal max) { return new CustomDecimalMaxValidator(max); }
Modifier and Type | Field and Description |
---|---|
protected boolean |
inclusive |
protected java.math.BigDecimal |
max |
currentAuthentication, datatypeRegistry, message, messages, substitutor
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)
Checks a value.
|
protected void |
fireValidationException(T value) |
protected java.lang.String |
getDefaultMessage() |
java.math.BigDecimal |
getMax() |
boolean |
isInclusive() |
void |
setCurrentAuthentication(io.jmix.core.security.CurrentAuthentication currentAuthentication) |
protected void |
setDatatypeRegistry(io.jmix.core.metamodel.datatype.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(io.jmix.core.Messages messages) |
void |
setStringSubstitutor(StringSubstitutor substitutor) |
formatValue, getMessage, getTemplateErrorMessage, setMessage
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@Autowired protected void setMessages(io.jmix.core.Messages messages)
@Autowired protected void setDatatypeRegistry(io.jmix.core.metamodel.datatype.DatatypeRegistry datatypeRegistry)
@Autowired public void setCurrentAuthentication(io.jmix.core.security.CurrentAuthentication currentAuthentication)
@Autowired public void setStringSubstitutor(StringSubstitutor substitutor)
@StudioProperty(name="value", required=true) 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 option@StudioProperty public void setInclusive(boolean inclusive)
inclusive
- inclusive optionpublic boolean isInclusive()
public void accept(T value) throws ValidationException
Validator
value
- a valueValidationException
protected java.lang.String getDefaultMessage()
protected void fireValidationException(T value)