T
- BigDecimal, BigInteger, Long, Integer@Component(value="cuba_MinValidator") @Scope(value="prototype") public class MinValidator<T extends java.lang.Number> extends AbstractValidator<T>
For error message it uses Groovy 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 web-spring.xml
,
for example:
<bean id="MinValidator" class="com.haulmont.cuba.gui.components.validation.MinValidator" scope="prototype"/>Use
BeanLocator
when creating the validator programmatically.Modifier and Type | Field and Description |
---|---|
protected long |
min |
static java.lang.String |
NAME |
datatypeRegistry, message, messages, userSessionSource
Constructor and Description |
---|
MinValidator(long min) |
MinValidator(long min,
java.lang.String message)
Constructor with custom error message.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(T value) |
long |
getMin() |
protected void |
setDatatypeRegistry(DatatypeRegistry datatypeRegistry) |
protected void |
setMessages(Messages messages) |
void |
setMin(long min)
Sets min value.
|
protected void |
setUserSessionSource(UserSessionSource userSessionSource) |
formatValue, getMessage, getTemplateErrorMessage, setMessage
public static final java.lang.String NAME
protected long min
public MinValidator(long min)
public MinValidator(long min, java.lang.String message)
Example: "Value '$value' should be greater than or equal to '$min'".
min
- min valuemessage
- error message@Inject protected void setMessages(Messages messages)
@Inject protected void setDatatypeRegistry(DatatypeRegistry datatypeRegistry)
@Inject protected void setUserSessionSource(UserSessionSource userSessionSource)
public void setMin(long min)
min
- min valuepublic long getMin()
public void accept(T value) throws ValidationException
ValidationException