com.opensymphony.xwork2.validator.validators
Class IntRangeFieldValidator
java.lang.Object
com.opensymphony.xwork2.validator.validators.ValidatorSupport
com.opensymphony.xwork2.validator.validators.FieldValidatorSupport
com.opensymphony.xwork2.validator.validators.AbstractRangeValidator<Integer>
com.opensymphony.xwork2.validator.validators.IntRangeFieldValidator
- All Implemented Interfaces:
- FieldValidator, ShortCircuitableValidator, Validator
public class IntRangeFieldValidator
- extends AbstractRangeValidator<Integer>
Field Validator that checks if the integer specified is within a certain range.
- fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required
- min - the minimum value (if none is specified, it will not be checked)
- max - the maximum value (if none is specified, it will not be checked)
The min / max value can be specified as an expression, but then you must also enable parsing it by specifying parse param
as in the example below.
WARNING! Do not use ${min} and ${max} as an expression as this will turn into infinitive loop!
<validators>
<!-- Plain Validator Syntax -->
<validator type="int">
<param name="fieldName">age</param>
<param name="min">20</param>
<param name="max">50</param>
<message>Age needs to be between ${min} and ${max}</message>
</validator>
<!-- Field Validator Syntax -->
<field name="age">
<field-validator type="int">
<param name="min">20</param>
<param name="max">50</param>
<message>Age needs to be between ${min} and ${max}</message>
</field-validator>
</field>
<!-- Field Validator Syntax with expression -->
<field name="age">
<field-validator type="int">
<param name="parse">true</param>
<param name="${minValue}">20</param> <!-- will be evaluated as: Integer getMinValue() -->
<param name="${maxValue}">50</param> <!-- will be evaluated as: Integer getMaxValue() -->
<message>Age needs to be between ${min} and ${max}</message>
</field-validator>
</field>
</validators>
- Version:
- $Date: 2012-10-11 21:32:48 +0200 (Thu, 11 Oct 2012) $ $Id: IntRangeFieldValidator.java 1397252 2012-10-11 19:32:48Z lukaszlenart $
- Author:
- Jason Carreira
Methods inherited from class com.opensymphony.xwork2.validator.validators.ValidatorSupport |
addActionError, addFieldError, conditionalParse, getDefaultMessage, getFieldValue, getMessage, getMessageKey, getMessageParameters, getParse, getValidatorContext, isShortCircuit, setDefaultMessage, setMessageKey, setMessageParameters, setParse, setShortCircuit, setValidatorContext, setValueStack |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IntRangeFieldValidator
public IntRangeFieldValidator()
setMax
public void setMax(String max)
getMax
public String getMax()
getMaxComparatorValue
public Integer getMaxComparatorValue()
- Specified by:
getMaxComparatorValue
in class AbstractRangeValidator<Integer>
setMin
public void setMin(String min)
getMin
public String getMin()
getMinComparatorValue
public Integer getMinComparatorValue()
- Specified by:
getMinComparatorValue
in class AbstractRangeValidator<Integer>
Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.