T
- Double and String that represents Double value with current locale@Component(value="ui_DoubleMaxValidator") @Scope(value="prototype") public class DoubleMaxValidator<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_DoubleMaxValidator") @Scope(BeanDefinition.SCOPE_PROTOTYPE) @Primary protected DoubleMaxValidator doubleMaxValidator(Double max) { return new CustomDoubleMaxValidator(max); }
Modifier and Type | Field and Description |
---|---|
protected boolean |
inclusive |
protected java.lang.Double |
max |
currentAuthentication, datatypeRegistry, message, messages, substitutor
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() |
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 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(io.jmix.core.Messages messages) |
void |
setStringSubstitutor(StringSubstitutor substitutor) |
formatValue, getMessage, getTemplateErrorMessage, setMessage
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@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)
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)