You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@struts.apache.org by "lukaszlenart (via GitHub)" <gi...@apache.org> on 2025/10/17 08:17:03 UTC

[PR] WW-5579 Add missing DoubleRangeFieldValidator and ShortRangeFieldValidator to @Validations container [struts]

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: notifications-unsubscribe@struts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] WW-5579 Add missing DoubleRangeFieldValidator and ShortRangeFieldValidator to @Validations container [struts]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #1390:
URL: https://github.com/apache/struts/pull/1390#issuecomment-3414388491

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=1390) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=1390&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=1390&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_struts&pullRequest=1390&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [83.3% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=1390&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=1390&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=1390)
   
   


-- 
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: notifications-unsubscribe@struts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] WW-5579 Add missing DoubleRangeFieldValidator and ShortRangeFieldValidator to @Validations container [struts]

Posted by "lukaszlenart (via GitHub)" <gi...@apache.org>.
lukaszlenart merged PR #1390:
URL: https://github.com/apache/struts/pull/1390


-- 
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: notifications-unsubscribe@struts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org