T
- The numeric type tested by the validator.public abstract class AbstractNumberIntervalValidator<T extends Number> extends AbstractIntervalValidator<T>
ContentValidator
validating the content by comparing one or more couples of numerical values.
For each couple of values, the identified max value should be greater than or equal to the identified min value.
The max and min values to compare are identified in validator's configuration by the metadata path as follows:
<min path="path/to/metadata/min"/>
<max path="path/to/metadata/max"/>
If the path of metadata can contain one or more repeaters.Constructor and Description |
---|
AbstractNumberIntervalValidator() |
Modifier and Type | Method and Description |
---|---|
protected void |
addErrorEmpty(Errors errors,
MetadataDefinition minDefinition,
MetadataDefinition maxDefinition,
I18nizableText emptyLabel)
Add an error when the max or the min value is empty but the interval is mandatory
|
protected void |
addIntervalError(Errors errors,
MetadataDefinition minDefinition,
MetadataDefinition maxDefinition,
T min,
T max)
Add an error when the max value is less than the min value
|
protected String |
configureMaxPath(Configuration configuration)
Get the metadata max path from the configuration
|
protected String |
configureMinPath(Configuration configuration)
Get the metadata min path from the configuration
|
protected boolean |
isSupportedType(MetadataType type)
Test if the metadata type is one expected by the validator
|
_validateInterval, configure, getEmptyValue, getValues, isLessThan, service, validate, validate
getContentType, setContentType
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
public AbstractNumberIntervalValidator()
protected String configureMinPath(Configuration configuration) throws ConfigurationException
AbstractIntervalValidator
configureMinPath
in class AbstractIntervalValidator<T extends Number>
configuration
- The configurationConfigurationException
- If an error occursprotected String configureMaxPath(Configuration configuration) throws ConfigurationException
AbstractIntervalValidator
configureMaxPath
in class AbstractIntervalValidator<T extends Number>
configuration
- The configurationConfigurationException
- If an error occursprotected boolean isSupportedType(MetadataType type)
AbstractIntervalValidator
isSupportedType
in class AbstractIntervalValidator<T extends Number>
type
- The metadata typeprotected void addIntervalError(Errors errors, MetadataDefinition minDefinition, MetadataDefinition maxDefinition, T min, T max)
AbstractIntervalValidator
addIntervalError
in class AbstractIntervalValidator<T extends Number>
errors
- The list of errorsminDefinition
- The min definitionmaxDefinition
- The max definitionmin
- The min valuemax
- The max valueprotected void addErrorEmpty(Errors errors, MetadataDefinition minDefinition, MetadataDefinition maxDefinition, I18nizableText emptyLabel)
AbstractIntervalValidator
addErrorEmpty
in class AbstractIntervalValidator<T extends Number>
errors
- The list of errorsminDefinition
- The min definitionmaxDefinition
- The max definitionemptyLabel
- The label of the empty field