Class AbstractValidator<T>
java.lang.Object
io.jmix.flowui.component.validation.AbstractValidator<T>
- Type Parameters:
T
- value type
- All Implemented Interfaces:
Validator<T>
,Consumer<T>
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.InitializingBean
,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
DateTimeRangeValidator
,DecimalMaxValidator
,DecimalMinValidator
,DigitsValidator
,DoubleMaxValidator
,DoubleMinValidator
,EmailValidator
,FutureOrPresentValidator
,FutureValidator
,GroovyScriptValidator
,MaxValidator
,MinValidator
,NegativeOrZeroValidator
,NegativeValidator
,NotBlankValidator
,NotEmptyValidator
,NotNullValidator
,OutputFileNameValidator
,PastOrPresentValidator
,PastValidator
,PositiveOrZeroValidator
,PositiveValidator
,RegexpValidator
,ReportCollectionValidator
,ReportParamAliasValidator
,ReportParamFieldValidator
,SizeValidator
public abstract class AbstractValidator<T>
extends Object
implements Validator<T>, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean
Main class for validators.
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.springframework.context.ApplicationContext
protected CurrentAuthentication
protected DatatypeRegistry
protected String
protected String
protected Messages
protected StringSubstitutor
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
protected void
fireValidationException
(String errorMessage) protected void
fireValidationException
(String errorMessage, Map<String, Object> map) protected String
formatValue
(Object value) protected String
getTemplateErrorMessage
(String errorMessage, Map<String, Object> valuesMap) void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) void
setMessage
(String message) Sets custom error message that will be used instead of default message.
-
Field Details
-
messages
-
currentAuthentication
-
datatypeRegistry
-
substitutor
-
applicationContext
protected org.springframework.context.ApplicationContext applicationContext -
message
-
defaultMessage
-
-
Constructor Details
-
AbstractValidator
public AbstractValidator()
-
-
Method Details
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
getMessage
- Returns:
- custom error message
-
setMessage
Sets custom error message that will be used instead of default message. For error message it uses template string and it is possible to use values in message. Each validator has its own value keys for formatted output. See JavaDocs for specific validator.- Parameters:
message
- error message
-
getTemplateErrorMessage
protected String getTemplateErrorMessage(@Nullable String errorMessage, Map<String, Object> valuesMap) - Parameters:
errorMessage
- error messagevaluesMap
- values map- Returns:
- message with inserted values
-
formatValue
-
fireValidationException
-
fireValidationException
-