Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Validation only greaterThan

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, i want validate a integer field but only it�s necessary greaterThan 0. It�s not necessary a maximum. If i write:

<field property="numberpositive" depends="required,integer,intRange">
<arg0 key="campo.numberpositive"/>
<arg1 name="intRange" key="${var:min}" resource="false"/>
<var>
<var-name>min</var-name>
<var-value>0</var-value>
</var>

and throws error, the error shows: It�s not in range between 0 and NULL.

Any solution? I use Struts 1.2.4
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems like this should be a standard validation rule. Maybe it is by now. I am still using Struts 1.1. I find it interesting that in your example you left off the max value. Does that seem to work for you? Below is my solution for a similar problem (using longRange). Basically I am testing the range between 1 and max long and using the "XXX is required" message.

<constant>
<constant-name>maxLongRange</constant-name>
<constant-value>9223372036854775807</constant-value>
</constant>

<field property="equipmentId" depends="longRange">
<msg name="longRange" key="errors.required" />
<arg0 key="Field.EquipmentName" />
<var>
<var-name>min</var-name>
<var-value>1</var-value>
</var>
<var>
<var-name>max</var-name>
<var-value>${maxLongRange}</var-value>
</var>
</field>

- Brent
 
reply
    Bookmark Topic Watch Topic
  • New Topic