lukaszlenart opened a new pull request, #1390:
URL: https://github.com/apache/struts/pull/1390

   ## Summary
   This PR fixes [WW-5579](https://issues.apache.org/jira/browse/WW-5579) by 
adding support for `@DoubleRangeFieldValidator` and `@ShortRangeFieldValidator` 
annotations within the `@Validations` container annotation.
   
   ## Problem
   Both `@DoubleRangeFieldValidator` and `@ShortRangeFieldValidator` 
annotations exist and work as standalone annotations, but they were completely 
missing from the `@Validations` container annotation interface definition. This 
forced developers to either:
   1. Use these validators as standalone annotations (limiting to one per 
method)
   2. Fall back to XML-based validation configuration
   3. Scatter validations across multiple locations
   
   The infrastructure to support these validators already existed - the 
processing methods were implemented, the validators worked standalone - only 
the container fields and processing loops were missing.
   
   ## Changes Made
   
   ### 1. Updated `Validations.java`
   - Added `DoubleRangeFieldValidator[] doubleRangeFields() default {};` method
   - Added `ShortRangeFieldValidator[] shortRangeFields() default {};` method
   - Updated JavaDoc parameters table to include entries for `longRangeFields`, 
`doubleRangeFields`, and `shortRangeFields`
   - Added example usage of `doubleRangeFields` in the JavaDoc code example
   
   ### 2. Updated `AnnotationValidationConfigurationBuilder.java`
   - Added processing loop for `doubleRangeFields` in 
`processValidationAnnotation()` method
   - Added processing loop for `shortRangeFields` in 
`processValidationAnnotation()` method
   - Both loops follow the exact same pattern as existing `intRangeFields` and 
`longRangeFields` loops
   
   ### 3. Added Test Coverage
   - Created `AnnotationValidationsContainerAction.java` test class 
demonstrating proper usage
   - Added `testValidationsContainerWithRangeValidators()` test method to 
verify the implementation
   - Tests validate that multiple validators of each type are processed 
correctly with proper field names, min/max values, and messages
   
   ## Example Usage (After Fix)
   
   ```java
   @Validations(
       doubleRangeFields = {
           @DoubleRangeFieldValidator(fieldName = "price", minInclusive = 
"0.01", maxInclusive = "999999.99",
                   message = "Price must be between 0.01 and 999999.99"),
           @DoubleRangeFieldValidator(fieldName = "discount", minInclusive = 
"0.0", maxInclusive = "100.0",
                   message = "Discount must be between 0.0 and 100.0")
       },
       shortRangeFields = {
           @ShortRangeFieldValidator(fieldName = "quantity", min = "1", max = 
"1000",
                   message = "Quantity must be between 1 and 1000"),
           @ShortRangeFieldValidator(fieldName = "priority", min = "1", max = 
"10",
                   message = "Priority must be between 1 and 10")
       }
   )
   public String execute() {
       return SUCCESS;
   }
   ```
   
   ## Test Results
   ✅ All tests pass successfully:
   - `testValidationAnnotation()` - Standalone validator annotations
   - `testValidationAnnotationExpParams()` - Validators with expression 
parameters
   - `testValidationsContainerWithRangeValidators()` - **NEW** Container 
annotation with doubleRangeFields and shortRangeFields
   
   ## Impact
   - **Low Risk**: The infrastructure for these validators already exists; 
we're just adding container support
   - **No Breaking Changes**: Existing code continues to work; this only adds 
new functionality
   - **Consistent API**: Follows the exact same pattern as other range 
validators
   
   ## Related Issues
   - JIRA: [WW-5579](https://issues.apache.org/jira/browse/WW-5579)
   - Historical context: WW-4004 (2013) and WW-4011 (2013) improved these 
validators but didn't add container support
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to