You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ut...@web.de.INVALID on 2025/10/16 18:42:35 UTC
DoubleRangeFieldValidator missing in the Validations Container
Hi,
is there a reason why I can not use @DoubleRangeFieldValidator in the @Validations Container?
I chose the way of validating with Annotations in the Action class and used
@Validations(
requiredStrings = {@RequiredStringValidator...},
requiredFields = {@RequiredFieldValidator...},
stringLengthFields = {@StringLengthFieldValidator...},
regexFields = {@RegexFieldValidator...},
intRangeFields = {@IntRangeFieldValidator...},
longRangeFields = {@LongRangeFieldValidator...})
But I can not find a way to do the same for the DoubleRangeFieldValidator.
(I can do with xml, scattering the validations on several places.)
This is what I checked so far:
- https://struts.apache.org/core-developers/validations-annotation
- org.apache.struts2.validator.annotations.Validations.java
Thx Ute
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: DoubleRangeFieldValidator missing in the Validations Container
Posted by Łukasz Lenart <lu...@gmail.com>.
PR is ready
https://github.com/apache/struts/pull/1390
pt., 17 paź 2025 o 09:12 Łukasz Lenart <lu...@gmail.com> napisał(a):
>
> Ok
> https://issues.apache.org/jira/browse/WW-5579
>
> pt., 17 paź 2025 o 08:44 Ute Kaiser <ut...@web.de.invalid> napisał(a):
> >
> > Yeah, fixing is the best idea :-)
> >
> > Thx Ute
> > (I do not have a Jira account)
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: DoubleRangeFieldValidator missing in the Validations Container
Posted by Łukasz Lenart <lu...@gmail.com>.
Ok
https://issues.apache.org/jira/browse/WW-5579
pt., 17 paź 2025 o 08:44 Ute Kaiser <ut...@web.de.invalid> napisał(a):
>
> Yeah, fixing is the best idea :-)
>
> Thx Ute
> (I do not have a Jira account)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: DoubleRangeFieldValidator missing in the Validations Container
Posted by Ute Kaiser <ut...@web.de.INVALID>.
Yeah, fixing is the best idea :-)
Thx Ute
(I do not have a Jira account)
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: DoubleRangeFieldValidator missing in the Validations Container
Posted by Lukasz Lenart <lu...@apache.org>.
czw., 16 paź 2025 o 20:44 <ut...@web.de.invalid> napisał(a):
>
> Hi,
> is there a reason why I can not use @DoubleRangeFieldValidator in the @Validations Container?
>
> I chose the way of validating with Annotations in the Action class and used
> @Validations(
> requiredStrings = {@RequiredStringValidator...},
> requiredFields = {@RequiredFieldValidator...},
> stringLengthFields = {@StringLengthFieldValidator...},
> regexFields = {@RegexFieldValidator...},
> intRangeFields = {@IntRangeFieldValidator...},
> longRangeFields = {@LongRangeFieldValidator...})
>
> But I can not find a way to do the same for the DoubleRangeFieldValidator.
> (I can do with xml, scattering the validations on several places.)
>
> This is what I checked so far:
> - https://struts.apache.org/core-developers/validations-annotation
> - org.apache.struts2.validator.annotations.Validations.java
Good point, it's a bug. CC finds this:
```
⏺ Perfect! I've confirmed the issue. Both @DoubleRangeFieldValidator
and @ShortRangeFieldValidator are missing from the @Validations
container, even though they exist as standalone annotations.
Current State
Available in @Validations:
- intRangeFields
- longRangeFields
- dateRangeFields
Missing from @Validations (but work as standalone):
- ❌ doubleRangeFields
- ❌ shortRangeFields
Why This Happened
Looking at core/src/main/java/org/apache/struts2/validator/AnnotationValidationConfigurationBuilder.java,
the builder correctly processes both validators when used standalone,
but the @Validations container annotation in
core/src/main/java/org/apache/struts2/validator/annotations/Validations.java:170-180
only includes intRangeFields and longRangeFields.
Your Options
Option 1: Use standalone annotations (current workaround)
@DoubleRangeFieldValidator(fieldName = "price", minInclusive =
"0.0", maxInclusive = "999.99",
message = "Price must be between
${minInclusive} and ${maxInclusive}")
@Validations(
requiredStrings = {...},
intRangeFields = {...}
)
public String execute() { ... }
Option 2: Fix the framework (recommended)
I can implement the missing functionality by:
1. Adding doubleRangeFields() and shortRangeFields() to the
@Validations annotation
2. Adding processing logic in AnnotationValidationConfigurationBuilder
3. Updating documentation and tests
Would you like me to implement this fix? It's a straightforward
enhancement that would bring consistency to all the range validators.
```
Feel free to report this as a bug in JIRA
https://issues.apache.org/jira/browse/WW
Thanks in advance
Łukasz
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org