How about using a regexp? <field property="phone" depends="required, mask"> <arg0 key="Daytime Phone box 3" resource="false"/> <var> <var-name>mask</var-name> <var-value>^\d{4}$</var-value> </var> </field>
HTH Robert > -----Ursprüngliche Nachricht----- > Von: David Graham [mailto:[EMAIL PROTECTED] > Gesendet: Mittwoch, 18. Juni 2003 23:13 > An: [EMAIL PROTECTED] > Betreff: Re: Validator problem with integers > > > An integer validation is not the same as a "are all > characters numeric" > validation. I don't think the validator currently has a > numeric check but > patches are welcome. > > David > > > >Hi folks, > > > >Using struts-RC2, when using Validator with a dependency > >on "integer" validation, I have a problem with the validator > >assuming that any integer starting with zero "0" is > >necessarily octal. In one example, I have a form where > >people enter phone numbers. Which is split up into 3 text > >boxes. Area code, 3 digits, last 4 digits. A fairly common > >way to break it up. > > > >Here is the validation.xml entry for one such field: > > > ><field > > property="dayPhone3" > > depends="required, integer, minlength, maxlength"> > > <arg0 key="Daytime Phone box 3" resource="false"/> > > <arg1 name="minlength" key="${var:minlength}" resource="false"/> > > <arg2 name="maxlength" key="${var:maxlength}" resource="false"/> > > <var> > > <var-name>maxlength</var-name> > > <var-value>4</var-value> > > </var> > > <var> > > <var-name>minlength</var-name> > > <var-value>4</var-value> > > </var> > ></field> > > > >Numbers like "0897" will cause the "... must be an integer" message. > >Obviously it is not a valid octal number, and I know that the format > >of these numbers would appear as an attempt at an octal number. > > > >How do you prevent octal interpretation but still ensure that > >the field is numeric? I'm being a tad lazy here, because I > >know I could always write my own pluggable validator, but > >I'd like to use what already exists if possible. > > > > > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > _________________________________________________________________ > Protect your PC - get McAfee.com VirusScan Online > http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 > > > --------------------------------------------------------------------- > 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]