[ 
https://issues.apache.org/jira/browse/WW-5816?focusedWorklogId=1050007&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1050007
 ]

ASF GitHub Bot logged work on WW-5816:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 25/Oct/26 08:50
            Start Date: 25/Oct/26 08:50
    Worklog Time Spent: 10m 
      Work Description: lukaszlenart opened a new pull request, #2060:
URL: https://github.com/apache/struts/pull/2060

   Fixes [WW-5816](https://issues.apache.org/jira/browse/WW-5816)
   
   ## Problem
   
   `DateRangeFieldValidator` (`date`) is a `RangeValidatorSupport<Date>`. On a 
`java.time.LocalDate` property it compares the value against `java.util.Date` 
bounds and throws `ClassCastException`, so a `LocalDate` field has no working 
range validation. Conversion and the date tags have supported `LocalDate` for a 
while; the validators had not.
   
   ## Change
   
   - **Validator:** `LocalDateRangeFieldValidator extends 
RangeValidatorSupport<LocalDate>`, registered as `localdate` in the default 
validators.
     - Bounds are `min`/`max` as ISO dates, or `minExpression`/`maxExpression`.
     - Both bounds are inclusive, and a null value is skipped (left to a 
`required` validator), all inherited from `RangeValidatorSupport`.
   - **XML params:** an XML `<param name="min">2026-01-01</param>` reaches the 
generic `setMin(T)` as a `LocalDate` through the usual parameter conversion. 
That was the open question in the ticket, and a test pins it.
   - **Annotation:** `@LocalDateRangeFieldValidator` mirrors 
`@DateRangeFieldValidator` without `dateFormat`, since `LocalDate` bounds are 
ISO only. It is processed on a method and inside `@Validations` via the new 
`localDateRangeFields()` member, whose empty default keeps existing code 
compiling.
   - **Malformed bounds:** the builder parses annotation bounds with 
`LocalDate.parse`, so a malformed bound fails when the validators are built 
instead of passing through as a string.
   - **Unchanged:** `DateRangeFieldValidator`. `LocalDateTime`/`LocalTime` can 
follow on demand.
   
   ## Tests
   
   - `LocalDateRangeFieldValidatorTest`:
     - inside the range, on both bounds, below and above the range, null value 
skipped, bounds from expressions
     - the `localdate` registration
     - ISO string params converted to `LocalDate` when the validator is built 
from configuration
   - `AnnotationValidationConfigurationBuilderTest`:
     - method-level and `@Validations` annotations produce `localdate` 
validators with `LocalDate` bounds
     - a non-ISO bound fails with `DateTimeParseException`
   - Full core suite on JDK 17 and JDK 25, plus the spring, junit, convention 
and json plugins on JDK 17, all green.
   
   ## Follow-ups
   
   - struts-site validator reference for `localdate`.
   - WW-5811 maps this validator's bounds to HTML5 `min`/`max` on `date` 
controls.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   




Issue Time Tracking
-------------------

            Worklog Id:     (was: 1050007)
    Remaining Estimate: 0h
            Time Spent: 10m

> Add a range validator for java.time.LocalDate properties
> --------------------------------------------------------
>
>                 Key: WW-5816
>                 URL: https://issues.apache.org/jira/browse/WW-5816
>             Project: Struts 2
>          Issue Type: New Feature
>          Components: Annotations, XML Validators
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Major
>             Fix For: 7.5.0
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> h2. Problem
> {{DateRangeFieldValidator}} ({{date}}) is a {{RangeValidatorSupport<Date>}}. 
> On a {{java.time.LocalDate}} property it compares the {{LocalDate}} value 
> against a {{java.util.Date}} bound, which throws {{ClassCastException}}, so a 
> {{LocalDate}} field has no working range validation. {{DateConverter}} and 
> the date tags have supported {{LocalDate}} for some time (WW-5016, WW-5530, 
> WW-5810); the validators have not.
> h2. Proposal
> A separate validator, following the one-class-per-type pattern of the 
> existing range validators:
> * {{LocalDateRangeFieldValidator extends RangeValidatorSupport<LocalDate>}}, 
> registered as {{localdate}} in the default validators
> * {{min}} / {{max}} as ISO dates ({{2026-01-01}}), plus {{minExpression}} / 
> {{maxExpression}}
> * annotation {{@LocalDateRangeFieldValidator}}, a {{localDateRangeFields()}} 
> member on {{@Validations}} (with an empty default, so existing code keeps 
> compiling), and processing in {{AnnotationValidationConfigurationBuilder}}
> * {{LocalDate}} only; {{LocalDateTime}} / {{LocalTime}} can follow on demand
> {{DateRangeFieldValidator}} stays unchanged. The removed legacy client-side 
> validation never supported {{date}}, so nothing is needed there.
> Before implementing, check how a string {{min}} / {{max}} param from XML 
> reaches the generic {{setMin(T)}} / {{setMax(T)}} of 
> {{RangeValidatorSupport}}, and that it ends up as a {{LocalDate}}.
> h2. Requirements
> * Tests: XML and annotation configuration, inclusive bounds, null value 
> skipped, expressions
> * Validator reference docs on struts-site
> Related: WW-5811 (HTML5 {{min}}/{{max}} for {{date}} controls), which will 
> map this validator's bounds directly to {{min="yyyy-MM-dd"}}.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to