Class AbstractIntervalFormValidator<T>
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.runtime.parameter.DefaultValidator
org.ametys.plugins.forms.question.validators.AbstractIntervalFormValidator<T>
- Type Parameters:
T
- the generic type to compare
- All Implemented Interfaces:
Validator
,PluginAware
,Configurable
,LogEnabled
,Serviceable
- Direct Known Subclasses:
DateTimeIntervalFormValidator
,LocalDateIntervalFormValidator
,NumberIntervalFormValidator
An interval validator for generic type
-
Field Summary
Fields inherited from class org.ametys.runtime.parameter.DefaultValidator
_invalidText, _isMandatory, _pluginName, _regexp, _smanager
-
Constructor Summary
ConstructorDescriptionAbstractIntervalFormValidator
(String regexp, boolean mandatory, T min, T max) The constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
addIntervalError
(Errors errors, T min, T max) Add an error when the max value is less than the min valueprotected abstract boolean
isLessThan
(T n1, T n2) Test if the first number is less than the second one.protected abstract boolean
isMoreThan
(T n1, T n2) Test if the first number is more than the second one.protected void
validateArrayValues
(Object[] values, Errors errors) Validates a array of values.protected void
validateSingleValue
(Object value, Errors errors) Validates a single value.Methods inherited from class org.ametys.runtime.parameter.DefaultValidator
configure, equals, getConfiguration, hashCode, service, setPluginInfo, validate
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
_min
The min value -
_max
The max value
-
-
Constructor Details
-
AbstractIntervalFormValidator
The constructor- Parameters:
regexp
- the regexpmandatory
- mandatorymin
- the min valuemax
- the max value
-
-
Method Details
-
validateSingleValue
Description copied from class:DefaultValidator
Validates a single value.- Overrides:
validateSingleValue
in classDefaultValidator
- Parameters:
value
- the value to validate (can benull
).errors
- the structure to populate if the validation failed.
-
validateArrayValues
Description copied from class:DefaultValidator
Validates a array of values.- Overrides:
validateArrayValues
in classDefaultValidator
- Parameters:
values
- the values to validateerrors
- the structure to populate if the validation failed.
-
isLessThan
Test if the first number is less than the second one.- Parameters:
n1
- The first number to compare.n2
- The second number to compare.- Returns:
- true if the first number is less than the first, false otherwise.
-
isMoreThan
Test if the first number is more than the second one.- Parameters:
n1
- The first number to compare.n2
- The second number to compare.- Returns:
- true if the first number is more than the first, false otherwise.
-
addIntervalError
Add an error when the max value is less than the min value- Parameters:
errors
- The list of errorsmin
- The min valuemax
- The max value
-