struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ferruh Zamangör <ferruh.zamang...@nterra.com>
Subject Struts Validation Problems
Date Mon, 23 Apr 2007 12:17:21 GMT
Hi,

I have some problems with using the following regular expression in the validation framework
from Struts. 

<field property="projectNumber" depends="required,mask">
			<msg name="mask" key="errors.format"/>
			<arg key="projectNumber" />		
			<arg key="GB-XXXXXX-AA-BB-CC-DD-EE" resource="false" position="1"/>
			<var>
	        	<var-name>mask</var-name>
	        	<var-value>^\w{2}-\w{6}(-\w{2}){0,5}$ | ^[0-9]{4,6}$</var-value>
	        </var>
	     </field>	

I have tested with the following scenarios:

333 ==> validation works and a validation message is displayed.
6666 ==> validation OK
1234567 ==> validation does not work, no validation error is displayed

When I use the same pattern in a java class it works fine???


String input = "1234567";
String pattern = "^\\w{2}-\\w{6}(-\\w{2}){0,5}|([0-9]{4,6})$";
Pattern p = Pattern.compile(pattern);
Matcher match = p.matcher(input);
boolean result = match.matches();


Can anybody tell me what is wrong in the above definition of the field ??

Regards
Ferruh

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message