You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Kelly.Graus" <Ke...@toltech.net> on 2008/04/14 18:53:58 UTC

[S2] Matching string validator

Hello,

Does struts 2 have a built in validator that will allow me to make sure two
fields match (ie, two password fields).  From looking around, it seems that
struts 1 had validatewhen which could be used, but I haven't been able to
find anything for struts 2.

Thanks!

Kelly
-- 
View this message in context: http://www.nabble.com/-S2--Matching-string-validator-tp16679023p16679023.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] Matching string validator

Posted by "Kelly.Graus" <Ke...@toltech.net>.

Kelly.Graus wrote:
> 
> Thanks for the reply!  I'm using field validators, so I did this:
> 
> <field-validator type="fieldexpression">
>        	<![CDATA[#password1.equals( password2 )]]>
>       	<message>The passwords do not match!</message>
> </field-validator>
> 
> Which works perfectly.  Thanks!
> 
> Kelly
> 
Actually, it should be:

<field-validator type="fieldexpression">
       	<![CDATA[password1.equals( password2 )]]>
      	<message>The passwords do not match!</message>
</field-validator>

-- 
View this message in context: http://www.nabble.com/-S2--Matching-string-validator-tp16679023p16688626.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] Matching string validator

Posted by "Kelly.Graus" <Ke...@toltech.net>.

Guillaume Bilodeau wrote:
> 
> Sure, you can use an ExpressionValidator annotation with an OGNL
> expression like this:
> 
> @ExpressionValidator(expression = "password1.equals(password2)", ...)
> 
> Cheers,
> GB
> 

Thanks for the reply!  I'm using field validators, so I did this:

<field-validator type="fieldexpression">
       	<![CDATA[#password1.equals( password2 )]]>
      	<message>The passwords do not match!</message>
</field-validator>

Which works perfectly.  Thanks!

Kelly
-- 
View this message in context: http://www.nabble.com/-S2--Matching-string-validator-tp16679023p16680522.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] Matching string validator

Posted by Guillaume Bilodeau <gb...@yahoo.com>.
Sure, you can use an ExpressionValidator annotation with an OGNL expression
like this:

@ExpressionValidator(expression = "password1.equals(password2)", ...)

Cheers,
GB


Kelly.Graus wrote:
> 
> Hello,
> 
> Does struts 2 have a built in validator that will allow me to make sure
> two fields match (ie, two password fields).  From looking around, it seems
> that struts 1 had validatewhen which could be used, but I haven't been
> able to find anything for struts 2.
> 
> Thanks!
> 
> Kelly
> 

-- 
View this message in context: http://www.nabble.com/-S2--Matching-string-validator-tp16679023p16679912.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] Matching string validator

Posted by Dave Newton <ne...@yahoo.com>.
--- "Kelly.Graus" <Ke...@toltech.net> wrote:
> Does struts 2 have a built in validator that will allow me to make sure two
> fields match (ie, two password fields).  From looking around, it seems that
> struts 1 had validatewhen which could be used, but I haven't been able to
> find anything for struts 2.

http://struts.apache.org/2.x/docs/expression-validator.html
http://struts.apache.org/2.x/docs/fieldexpression-validator.html

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org