Package io.jmix.ui.component.validation
Class DoubleMinValidator<T>
java.lang.Object
io.jmix.ui.component.validation.AbstractValidator<T>
io.jmix.ui.component.validation.DoubleMinValidator<T>
- Type Parameters:
T
- Double and String that represents BigDouble value with current locale
@Component("ui_DoubleMinValidator")
@Scope("prototype")
public class DoubleMinValidator<T>
extends AbstractValidator<T>
Double 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_DoubleMinValidator") @Scope(BeanDefinition.SCOPE_PROTOTYPE) @Primary protected DoubleMinValidator doubleMinValidator(Double min) { return new CustomDoubleMinValidator(min); }
-
Field Summary
Fields inherited from class io.jmix.ui.component.validation.AbstractValidator
currentAuthentication, datatypeRegistry, message, messages, substitutor
-
Constructor Summary
ConstructorDescriptionDoubleMinValidator
(Double min) Constructor with default error message.DoubleMinValidator
(Double 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
Sets min value.void
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
-
DoubleMinValidator
Constructor with default error message.- Parameters:
min
- min value
-
DoubleMinValidator
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
-