Re: DoubleRangeFieldValidator missing in the Validations Container

Lukasz Lenart <[email protected]> Fri, 17 Oct 2025 08:06:30 +0200
Newsgroups gmane.comp.jakarta.struts.user
Message-ID <CAMopvkN7SURGn=YLFVuRP==JXhbcvHKg6JTt6s0LVMGhEcLgQQ@mail.gmail.com>
czw., 16 pa=C5=BA 2025 o 20:44 <[email protected]> napisa=C5=82(a):
>
> Hi,
> is there a reason why I can not use @DoubleRangeFieldValidator in the @Va=
lidations Container?
>
> I chose the way of validating with Annotations in the Action class and us=
ed
>         @Validations(
>                 requiredStrings =3D {@RequiredStringValidator...},
>                 requiredFields =3D {@RequiredFieldValidator...},
>                 stringLengthFields =3D {@StringLengthFieldValidator...},
>                 regexFields =3D {@RegexFieldValidator...},
>                 intRangeFields =3D {@IntRangeFieldValidator...},
>                 longRangeFields =3D {@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:
```
=E2=8F=BA Perfect! I've confirmed the issue. Both @DoubleRangeFieldValidato=
r
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):
  - =E2=9D=8C doubleRangeFields
  - =E2=9D=8C shortRangeFields

  Why This Happened

  Looking at core/src/main/java/org/apache/struts2/validator/AnnotationVali=
dationConfigurationBuilder.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.j=
ava:170-180
only includes intRangeFields and longRangeFields.

  Your Options

  Option 1: Use standalone annotations (current workaround)
  @DoubleRangeFieldValidator(fieldName =3D "price", minInclusive =3D
"0.0", maxInclusive =3D "999.99",
                             message =3D "Price must be between
${minInclusive} and ${maxInclusive}")
  @Validations(
      requiredStrings =3D {...},
      intRangeFields =3D {...}
  )
  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
=C5=81ukasz