That isn't possible with the default mask validator. 
I've recently added a min and max length validation to
nightly builds though.  Or you could either write your
own mask validation method that accepts multiple
inputs or you can define the mask validator again
under a different name like mask2.

<validator name="mask2"
        
classname="com.wintecinc.struts.validation.StrutsValidator"
         method="validateMask"
         depends="required"
         msg="errors.invalid">


 <field    property="lastName"
           depends="required,mask,mask2">
             <msg name="mask"
key="registrationForm.lastname.maskmsg"/>
             <msg name="mask2"
key="registrationForm.lastname.mask2msg"/>
             <arg0
key="registrationForm.lastname.displayname"/>
             <arg1 name="maxlength" key="${var:maxlength}"
resource="false"/>
             <var>
               <var-name>mask</var-name>
               <var-value>^[a-z]*$</var-value>
             </var>                
             <var>
               <var-name>mask2</var-name>
               <var-value>^[A-Z]*$</var-value>
             </var>                
             <var>
               <var-name>maxlength</var-name>
               <var-value>16</var-value>
             </var>
 </field>


David

--- Paul Darling <[EMAIL PROTECTED]> wrote:
> Is is possible to use multiple 'mask' validators
> that apply different
> expressions?  
> 
> For instance, in addition to checking that a string
> contains only a-z or A-Z
> characters, you might want to validate the string
> length.  It's possible to
> use an expression that combines the types of
> validation (e.g.
> ^[a-zA-Z0-9]{,16}$), but then it's not possible to
> use an error message that
> is specific to whether the validation failed due to
> the character content or
> the length.
> 
> Paul 
> 
> -----Original Message-----
> From: David Winterfeldt
> [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, October 11, 2001 1:17 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Questions About Struts Validator
> 
> 
> This is what you were asking about though? 
> Everything
> makes sense now?
> 
> David
> 
> --- Vaughan Jackson <[EMAIL PROTECTED]>
> wrote:
> > David,
> > 
> > I am sorry, I hadn't understood this before.
> > 
> > Thanks again,
> > Vaughan.
> > 
> > > -----Original Message-----
> > > From: David Winterfeldt
> > [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, October 11, 2001 12:17 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: RE: Questions About Struts Validator
> > > 
> > > 
> > > For Q2:
> > > You can override the default validator's error
> > message
> > > by specifying a msg element or you can change
> the
> > > defult of course.
> > > 
> > >  <field    property="lastName"
> > >      depends="required,mask">
> > >        <msg name="mask"
> > > key="registrationForm.lastname.maskmsg"/>
> > >        <arg0
> > > key="registrationForm.lastname.displayname"/>
> > >              <var>
> > >                <var-name>mask</var-name>
> > >               
> <var-value>^[a-zA-Z]*$</var-value>
> > >              </var>                  
> > >  </field>
> > > 
> > > You can also specify different arguments to go
> > with
> > > different errors.
> > > 
> > >  <field    property="integer"
> > >      depends="required,integer,range">
> > >        <arg0
> key="typeForm.integer.displayname"/>
> > >        <arg1 name="range" key="${var:min}"
> > > resource="false"/>
> > >        <arg2 name="range" key="${var:max}"
> > > resource="false"/>
> > >              <var>
> > >                <var-name>min</var-name>
> > >                <var-value>10</var-value>
> > >              </var>                  
> > >              <var>
> > >                <var-name>max</var-name>
> > >                <var-value>20</var-value>
> > >              </var>                  
> > >  </field>
> > > 
> > > David
> > > 
> > > 
> > > --- Vaughan Jackson
> > <[EMAIL PROTECTED]>
> > > wrote:
> > > > David,
> > > > 
> > > > Thanks for your feedback. 
> > > > 
> > > > I will try out the technique you describe for
> > Q1. 
> > > > 
> > > > I could have phrased Q2 better: "... and have
> a
> > > > different 
> > > > error message resulting according to which
> > rule(s)
> > > > is/are
> > > > broken?".
> > > > 
> > > > Yes, you have told me what I wanted to know
> for
> > Q3.
> > > > 
> > > > Vaughan.
> > > > 
> > > > > -----Original Message-----
> > > > > From: David Winterfeldt
> > > > [mailto:[EMAIL PROTECTED]]
> > > > > Sent: Thursday, October 11, 2001 10:36 AM
> > > > > To: [EMAIL PROTECTED]
> > > > > Subject: Re: Questions About Struts
> Validator
> > > > > 
> > > > > 
> > > > > 
> > > > > --- Vaughan Jackson
> > > > <[EMAIL PROTECTED]>
> > > > > wrote:
> > > > > > Hi,
> > > > > > 
> > > > > > Three questions in fact. Some variants on
> > these
> > > > came
> > > > > > up earlier,
> > > > > > but we would like to know whether the
> > > > > > Struts1.0-compatible version
> > > > > > makes any of the below possible, or
> whether
> > > > support
> > > > > > for them is coming.
> > > > > The 7/2/2001 was the last build compatible
> > with
> > > > the
> > > > > Struts 1.0 release.  It can be downloaded
> from
> > > > > http://home.earthlink.net/~dwinterfeldt/.
> > > > > 
> > > > > > 
> > > > > > 1. Is there any way to have multiple
> > > > > > validation.xml-type files 
> > > > > >    associated with a single web
> application?
> > > > > Yes, but it isn't a build in feature.  The
> > > > > ValidatorServlet calls
> > > > ValidatorResourcesInitializer
> > > > > which has an initialize method which returns
> a
> > > > > ValidatorResources object and then the
> > > > > ValidatorResources object is put into
> > application
> > > > > scope.  When the ValidatorForm's validate
> > method
> > > > is
> > > > > called the resource is retrieved and set
> along
> > > > with
> > > > > some other variables to configure the
> > Validator
> > > > class.
> > > > >  So you would just have to write something
> > that
> > > > loads
> > > > > multiple validation files and puts them
> > somewhere
> > > > in
> > > > > scope.  Then the ActionForm/ValidatorForm
> > > > (whichever
> > > > > you subclass) would need to know which
> > > > > ValidatorResources to retrieve from scope. 
> > > > Otherwise
> > > > > the code would be the same.
> > > > > 
> > > > > > 2. Is there any way to associate more than
> > one
> > > > > > (server-side) 
> > > > > >     validation rule with the same field?
> > > > > The depends attribute can have as many
> > > > > validation/validator references you want.
> > > > > 
> > > > >  <field    property="zipPostal"
> > > > >          depends="required,mask"
> > > > >            page="2">
> > > > >            <arg0
> > > > >
> key="registrationForm.zippostal.displayname"/>
> > > > >              <var>
> > > > >                <var-name>mask</var-name>
> > > > >                <var-value>${zip}</var-value>
> 
=== message truncated ===


__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

Reply via email to