Package io.jmix.ui.component.validation
Class DecimalMinValidator<T>
java.lang.Object
io.jmix.ui.component.validation.AbstractValidator<T>
io.jmix.ui.component.validation.DecimalMinValidator<T>
- Type Parameters:
T
- BigDecimal, BigInteger, Long, Integer and String that represents BigDecimal value with current locale
@Component("ui_DecimalMinValidator")
@Scope("prototype")
public class DecimalMinValidator<T>
extends AbstractValidator<T>
DecimalMin 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_DecimalMinValidator") @Scope(BeanDefinition.SCOPE_PROTOTYPE) @Primary protected DecimalMinValidator decimalMinValidator(BigDecimal min) { return new CustomDecimalMinValidator(min); }
-
Field Summary
Fields inherited from class io.jmix.ui.component.validation.AbstractValidator
currentAuthentication, datatypeRegistry, message, messages, substitutor
-
Constructor Summary
ConstructorDescriptionConstructor with default error message.DecimalMinValidator
(BigDecimal min, String message) Constructor with custom error message. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Checks a value.protected void
fireValidationException
(T value) protected String
getMin()
boolean
void
setCurrentAuthentication
(CurrentAuthentication currentAuthentication) protected void
setDatatypeRegistry
(DatatypeRegistry datatypeRegistry) void
setInclusive
(boolean inclusive) Set to true if the value must be greater than or equal to the specified minimum.protected void
setMessages
(Messages messages) void
setMin
(BigDecimal min) Sets min value.void
setMin
(BigDecimal min, boolean inclusive) Sets min value and inclusive option.void
setStringSubstitutor
(StringSubstitutor substitutor) Methods inherited from class io.jmix.ui.component.validation.AbstractValidator
formatValue, getMessage, getTemplateErrorMessage, setMessage
-
Field Details
-
min
-
inclusive
protected boolean inclusive
-
-
Constructor Details
-
DecimalMinValidator
Constructor with default error message.- Parameters:
min
- min value
-
DecimalMinValidator
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
- Returns:
- min value
-
setMin
Sets min value and inclusive option.- Parameters:
min
- min valueinclusive
- inclusive option
-
setInclusive
Set to true if the value must be greater than or equal to the specified minimum. Default value is true.- Parameters:
inclusive
- inclusive option
-
isInclusive
public boolean isInclusive()- Returns:
- true if the value must be greater than or equal to the specified minimum
-
accept
Description copied from interface:Validator
Checks a value.- Parameters:
value
- a value- Throws:
ValidationException
-
getDefaultMessage
-
fireValidationException
-