Package io.jmix.ui.component.validation
Class MinValidator<T extends Number>
java.lang.Object
io.jmix.ui.component.validation.AbstractValidator<T>
io.jmix.ui.component.validation.MinValidator<T>
- Type Parameters:
T
- BigDecimal, BigInteger, Long, Integer
@Component("ui_MinValidator")
@Scope("prototype")
public class MinValidator<T extends Number>
extends AbstractValidator<T>
Min validator checks that value must be greater than or equal to the specified minimum.
For error message it uses template string and it is possible to use '${value}' and '${min}' 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_MinValidator") @Scope(BeanDefinition.SCOPE_PROTOTYPE) @Primary protected MinValidator minValidator(long min) { return new CustomMinValidator(min); }
-
Field Summary
Fields inherited from class io.jmix.ui.component.validation.AbstractValidator
currentAuthentication, datatypeRegistry, message, messages, substitutor
-
Constructor Summary
ConstructorDescriptionMinValidator
(long min) MinValidator
(long min, String message) Constructor with custom error message. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Checks a value.long
getMin()
void
setCurrentAuthentication
(CurrentAuthentication currentAuthentication) protected void
setDatatypeRegistry
(DatatypeRegistry datatypeRegistry) protected void
setMessages
(Messages messages) void
setMin
(long min) Sets min value.void
setStringSubstitutor
(StringSubstitutor substitutor) Methods inherited from class io.jmix.ui.component.validation.AbstractValidator
formatValue, getMessage, getTemplateErrorMessage, setMessage
-
Field Details
-
min
protected long min
-
-
Constructor Details
-
MinValidator
public MinValidator(long min) -
MinValidator
Constructor with custom error message. This message can contain '${value}' and '${min}' keys for formatted output.Example: "Value '${value}' should be greater than or equal to '${min}'".
- Parameters:
min
- min valuemessage
- error message
-
-
Method Details
-
setMessages
-
setDatatypeRegistry
-
setCurrentAuthentication
-
setStringSubstitutor
-
setMin
Sets min value.- Parameters:
min
- min value
-
getMin
public long getMin()- Returns:
- min value
-
accept
Description copied from interface:Validator
Checks a value.- Parameters:
value
- a value- Throws:
ValidationException
-