public class DoubleRangeFieldValidator extends FieldValidatorSupport
<validators> <!-- Plain Validator Syntax --> <validator type="double"> <param name="fieldName">percentage</param> <param name="minInclusive">20.1</param> <param name="maxInclusive">50.1</param> <message>Age needs to be between ${minInclusive} and ${maxInclusive} (inclusive)</message> </validator> <!-- Field Validator Syntax --> <field name="percentage"> <field-validator type="double"> <param name="minExclusive">0.123</param> <param name="maxExclusive">99.98</param> <message>Percentage needs to be between ${minExclusive} and ${maxExclusive} (exclusive)</message> </field-validator> </field> <!-- Field Validator Syntax with expression --> <field name="percentage"> <field-validator type="double"> <param name="minExclusiveExpression">${minExclusiveValue}</param> <!-- will be evaluated as: Double getMinExclusiveValue() --> <param name="maxExclusiveExpression">${maxExclusiveValue}</param> <!-- will be evaluated as: Double getMaxExclusiveValue() --> <message>Percentage needs to be between ${minExclusive} and ${maxExclusive} (exclusive)</message> </field-validator> </field> </validators>
currentValue, fieldName, type
defaultMessage, EMPTY_STRING, messageKey, stack, textProviderFactory
Constructor and Description |
---|
DoubleRangeFieldValidator() |
Modifier and Type | Method and Description |
---|---|
Double |
getMaxExclusive() |
Double |
getMaxInclusive() |
Double |
getMinExclusive() |
Double |
getMinInclusive() |
void |
setMaxExclusive(Double maxExclusive) |
void |
setMaxExclusiveExpression(String maxExclusiveExpression) |
void |
setMaxInclusive(Double maxInclusive) |
void |
setMaxInclusiveExpression(String maxInclusiveExpression) |
void |
setMinExclusive(Double minExclusive) |
void |
setMinExclusiveExpression(String minExclusiveExpression) |
void |
setMinInclusive(Double minInclusive) |
void |
setMinInclusiveExpression(String minInclusiveExpression) |
void |
validate(Object object)
The validation implementation must guarantee that setValidatorContext will
be called with a non-null ValidatorContext before validate is called.
|
protected void |
validateCollection(Double maxInclusiveToUse,
Double minInclusiveToUse,
Double maxExclusiveToUse,
Double minExclusiveToUse,
Collection values) |
protected void |
validateValue(Object obj,
Double maxInclusiveToUse,
Double minInclusiveToUse,
Double maxExclusiveToUse,
Double minExclusiveToUse) |
getCurrentValue, getFieldName, getValidatorType, setFieldName, setValidatorType
addActionError, addFieldError, getDefaultMessage, getFieldValue, getMessage, getMessageKey, getMessageParameters, getValidatorContext, isShortCircuit, parse, setDefaultMessage, setMessageKey, setMessageParameters, setShortCircuit, setTextProviderFactory, setValidatorContext, setValueStack
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDefaultMessage, getMessage, getMessageKey, getMessageParameters, getValidatorContext, setDefaultMessage, setMessageKey, setMessageParameters, setValidatorContext, setValueStack
public void validate(Object object) throws ValidationException
Validator
object
- the object to be validated.ValidationException
- is thrown if there is validation error(s).protected void validateCollection(Double maxInclusiveToUse, Double minInclusiveToUse, Double maxExclusiveToUse, Double minExclusiveToUse, Collection values)
protected void validateValue(Object obj, Double maxInclusiveToUse, Double minInclusiveToUse, Double maxExclusiveToUse, Double minExclusiveToUse)
public void setMaxInclusive(Double maxInclusive)
public Double getMaxInclusive()
public void setMinInclusive(Double minInclusive)
public Double getMinInclusive()
public void setMinExclusive(Double minExclusive)
public Double getMinExclusive()
public void setMaxExclusive(Double maxExclusive)
public Double getMaxExclusive()
public void setMinInclusiveExpression(String minInclusiveExpression)
public void setMaxInclusiveExpression(String maxInclusiveExpression)
public void setMinExclusiveExpression(String minExclusiveExpression)
public void setMaxExclusiveExpression(String maxExclusiveExpression)
Copyright © 2000–2020 Apache Software Foundation. All rights reserved.