com.opensymphony.xwork2.validator.validators

## Class DoubleRangeFieldValidator

- java.lang.Object
- - com.opensymphony.xwork2.validator.validators.ValidatorSupport
  - - com.opensymphony.xwork2.validator.validators.FieldValidatorSupport
    - - com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator

- All Implemented Interfaces:
    FieldValidator, ShortCircuitableValidator, Validator

      public class DoubleRangeFieldValidator
      extends FieldValidatorSupport

  Field Validator that checks if the double specified is within a certain range.
  - fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required
  - minInclusive - the minimum inclusive value in FloatValue format specified by Java language (if none is specified, it will not be checked)
  - maxInclusive - the maximum inclusive value in FloatValue format specified by Java language (if none is specified, it will not be checked)
  - minExclusive - the minimum exclusive value in FloatValue format specified by Java language (if none is specified, it will not be checked)
  - maxExclusive - the maximum exclusive value in FloatValue format specified by Java language (if none is specified, it will not be checked)
  - minInclusiveExpression - the minimum inclusive value specified as a OGNL expression (if none is specified, it will not be checked)
  - maxInclusiveExpression - the maximum inclusive value specified as a OGNL expression (if none is specified, it will not be checked)
  - minExclusiveExpression - the minimum exclusive value specified as a OGNL expression (if none is specified, it will not be checked)
  - maxExclusiveExpression - the maximum exclusive value specified as a OGNL expression (if none is specified, it will not be checked)
  You can specify either minInclusive, maxInclusive, minExclusive and maxExclusive or minInclusiveExpression, maxInclusiveExpression, minExclusiveExpression and maxExclusiveExpression as a OGNL expression, see example below. You can always try to mix params but be aware that such behaviour was not tested. Do not use ${minInclusiveExpression}, ${maxInclusiveExpression}, ${minExclusiveExpressionExpression} and ${maxExclusive} as an expression as this will turn into infinitive loop!

       <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>

  Author:
    Rainer Hermanns, Rene Gielen

- - ### Field Summary

    - ### Fields inherited from class com.opensymphony.xwork2.validator.validators.FieldValidatorSupport

      `currentValue, fieldName, type`

    - ### Fields inherited from class com.opensymphony.xwork2.validator.validators.ValidatorSupport

      `defaultMessage, EMPTY_STRING, messageKey, stack, textProviderFactory`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DoubleRangeFieldValidator()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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)`

    - ### Methods inherited from class com.opensymphony.xwork2.validator.validators.FieldValidatorSupport

      `getCurrentValue, getFieldName, getValidatorType, setFieldName, setValidatorType`

    - ### Methods inherited from class com.opensymphony.xwork2.validator.validators.ValidatorSupport

      `addActionError, addFieldError, getDefaultMessage, getFieldValue, getMessage, getMessageKey, getMessageParameters, getValidatorContext, isShortCircuit, parse, setDefaultMessage, setMessageKey, setMessageParameters, setShortCircuit, setTextProviderFactory, setValidatorContext, setValueStack`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.opensymphony.xwork2.validator.Validator

      `getDefaultMessage, getMessage, getMessageKey, getMessageParameters, getValidatorContext, setDefaultMessage, setMessageKey, setMessageParameters, setValidatorContext, setValueStack`

- - ### Constructor Detail

    - #### DoubleRangeFieldValidator

          public DoubleRangeFieldValidator()

  - ### Method Detail

    - #### validate

          public void validate(Object object)
                        throws ValidationException

      Description copied from interface: `Validator`
      The validation implementation must guarantee that setValidatorContext will be called with a non-null ValidatorContext before validate is called.
      Parameters:
        `object` - the object to be validated.
      Throws:
        `ValidationException` - is thrown if there is validation error(s).

    - #### validateCollection

          protected void validateCollection(Double maxInclusiveToUse,
                                            Double minInclusiveToUse,
                                            Double maxExclusiveToUse,
                                            Double minExclusiveToUse,
                                            Collection values)

    - #### validateValue

          protected void validateValue(Object obj,
                                       Double maxInclusiveToUse,
                                       Double minInclusiveToUse,
                                       Double maxExclusiveToUse,
                                       Double minExclusiveToUse)

    - #### setMaxInclusive

          public void setMaxInclusive(Double maxInclusive)

    - #### getMaxInclusive

          public Double getMaxInclusive()

    - #### setMinInclusive

          public void setMinInclusive(Double minInclusive)

    - #### getMinInclusive

          public Double getMinInclusive()

    - #### setMinExclusive

          public void setMinExclusive(Double minExclusive)

    - #### getMinExclusive

          public Double getMinExclusive()

    - #### setMaxExclusive

          public void setMaxExclusive(Double maxExclusive)

    - #### getMaxExclusive

          public Double getMaxExclusive()

    - #### setMinInclusiveExpression

          public void setMinInclusiveExpression(String minInclusiveExpression)

    - #### setMaxInclusiveExpression

          public void setMaxInclusiveExpression(String maxInclusiveExpression)

    - #### setMinExclusiveExpression

          public void setMinExclusiveExpression(String minExclusiveExpression)

    - #### setMaxExclusiveExpression

          public void setMaxExclusiveExpression(String maxExclusiveExpression)

Copyright © 2000–2023 Apache Software Foundation. All rights reserved.