Package io.jmix.ui.component.validation
Class NegativeOrZeroValidator<T extends Number>
java.lang.Object
io.jmix.ui.component.validation.AbstractValidator<T>
io.jmix.ui.component.validation.NegativeOrZeroValidator<T>
- Type Parameters:
T
- BigDecimal, BigInteger, Long, Integer, Double, Float
@Component("ui_NegativeOrZeroValidator")
@Scope("prototype")
public class NegativeOrZeroValidator<T extends Number>
extends AbstractValidator<T>
NegativeOrZero validator checks that value should be a less than or equal 0.
For error message it uses template string and it is possible to use '${value}' key for formatted output.
In order to provide your own implementation globally, create a subclass and register it in configuration class, for example:
@Bean("ui_NegativeOrZeroValidator") @Scope(BeanDefinition.SCOPE_PROTOTYPE) @Primary protected NegativeOrZeroValidator negativeOrZeroValidator() { return new CustomNegativeOrZeroValidator(); }
-
Field Summary
Fields inherited from class io.jmix.ui.component.validation.AbstractValidator
currentAuthentication, datatypeRegistry, message, messages, substitutor
-
Constructor Summary
ConstructorDescriptionNegativeOrZeroValidator
(String message) Constructor for custom error message. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Checks a value.void
setCurrentAuthentication
(CurrentAuthentication currentAuthentication) protected void
setDatatypeRegistry
(DatatypeRegistry datatypeRegistry) protected void
setMessages
(Messages messages) void
setStringSubstitutor
(StringSubstitutor substitutor) Methods inherited from class io.jmix.ui.component.validation.AbstractValidator
formatValue, getMessage, getTemplateErrorMessage, setMessage
-
Constructor Details
-
NegativeOrZeroValidator
public NegativeOrZeroValidator() -
NegativeOrZeroValidator
Constructor for custom error message. This message can contain '${value}' key for formatted output.Example: "Value '${value}' should be less than or equal to 0".
- Parameters:
message
- error message
-
-
Method Details
-
setMessages
-
setDatatypeRegistry
-
setCurrentAuthentication
-
setStringSubstitutor
-
accept
Description copied from interface:Validator
Checks a value.- Parameters:
value
- a value- Throws:
ValidationException
-