[
https://issues.apache.org/jira/browse/WW-5816?focusedWorklogId=1050010&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1050010
]
ASF GitHub Bot logged work on WW-5816:
--------------------------------------
Author: ASF GitHub Bot
Created on: 25/Oct/26 08:56
Start Date: 25/Oct/26 08:56
Worklog Time Spent: 10m
Work Description: Copilot commented on code in PR #2060:
URL: https://github.com/apache/struts/pull/2060#discussion_r4370246712
##########
core/src/main/java/org/apache/struts2/validator/validators/LocalDateRangeFieldValidator.java:
##########
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.validator.validators;
+
+import java.time.LocalDate;
+
+/**
+ * <!
Issue Time Tracking
-------------------
Worklog Id: (was: 1050010)
Time Spent: 40m (was: 0.5h)
> 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: 40m
> 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)