T
- BigDecimal, BigInteger, Long, Integer@Component(value="ui_MaxValidator") @Scope(value="prototype") public class MaxValidator<T extends java.lang.Number> 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_MaxValidator") @Scope(BeanDefinition.SCOPE_PROTOTYPE) @Primary protected MaxValidator maxValidator(long max) { return new CustomMaxValidator(max); }
Modifier and Type | Field and Description |
---|---|
protected long |
max |
currentAuthentication, datatypeRegistry, message, messages, substitutor
Constructor and Description |
---|
MaxValidator(long max) |
MaxValidator(long max,
java.lang.String message)
Constructor for custom error message.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(T value)
Checks a value.
|
long |
getMax() |
void |
setCurrentAuthentication(io.jmix.core.security.CurrentAuthentication currentAuthentication) |
protected void |
setDatatypeRegistry(io.jmix.core.metamodel.datatype.DatatypeRegistry datatypeRegistry) |
void |
setMax(long max)
Sets max value.
|
protected void |
setMessages(io.jmix.core.Messages messages) |
void |
setStringSubstitutor(StringSubstitutor substitutor) |
formatValue, getMessage, getTemplateErrorMessage, setMessage
public MaxValidator(long max)
public MaxValidator(long 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(long max)
max
- max valuepublic long getMax()
public void accept(T value) throws ValidationException
Validator
value
- a valueValidationException