Custom validator, and smack whoever wanted decimal months on the back of the hand with a ruler.
--- Christopher Schultz <[EMAIL PROTECTED]> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > All, > > This is probably a question for the > commons-validator list, but, hey, > I'm already a member of this list and I'm sure > someone knows the answer. > > I have a form that contains 4 fields: year and month > for both min and > max age. (So, I have min years, min months, max > years, max months). > > I have a validWhen comparison that checks to see > that the combination of > years and months is actually smaller than the > combination entered for > max years and months (basically, to prevent you from > entering 1y1m as > the min and 0y1m as the max). > > Here is the test for "minAgeYears" (the other fields > need no tests; this > one covers them all) > > ( > (*this* < maxAgeYears) > or > ( > (*this* == maxAgeYears) > and > (minAgeMonths < maxAgeMonths) > ) > ) > > It works beautifully when the data entered are > integers. > > I have recently been asked to allow decimals in the > "months" fields, and > it appears that validWhen gets confused when the > data are (intended to > be) decimals. > > The documentation for the validWhen validator > (http://struts.apache.org/1.3.8/faqs/validator.html) > says "If both items > to be compared are convertable to ints, a numeric > comparison is done, > otherwise a string comparison is done." > > I'm guessing I'm just out of luck using validWhen > for this type of > check. Any ideas? > > Thanks, > - -chris > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.7 (MingW32) > Comment: Using GnuPG with Mozilla - > http://enigmail.mozdev.org > > iD8DBQFG4WtF9CaO5/Lv0PARAlXJAJ4hPbSy8N65g/Pta9D0e6wJ/D3TlACeNLmv > R9z1nkCsxY+fsDPdgW32uP0= > =qyWc > -----END PGP SIGNATURE----- > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]