missing also in validation.xml
something like this:

<field property="plz" depends="exact">
  <arg0 key="prompt.plz"/>
  <arg1 name="exact" key="${var:exact}" resource="false"/>
  <var>
    <var-name>exact</var-name>
    <var-value>5</var-value>
  </var>
</field>

cheers,


> -----Original Message-----
> From: Matthias Wessendorf [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, April 27, 2004 1:41 PM
> To: 'Struts Developers List'
> Subject: Adding method to FieldChecks (was [Bug 28623] New: - 
> validateExcatLength()-method in FieldChecks ?)
> 
> 
> moving to struts-dev with it,
> to become perhaps more discussion :)
> 
> any ideas, comments on such a method ?
> 
> the only thing is missing is a correspondent java_script_method
> 
> 
> 
> of course, the "if (value.length() != exact)"-statement can
> be moved to GenericValidator.excatLength()
> 
> 
> 
> and of course isString() of FieldChecks can be used also
> like in all other methods of FieldChecks.
> 
> and whats with unit_tests ? :-)
> 
> Cheers, Matthias
> 
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, April 27, 2004 1:42 PM
> > To: [EMAIL PROTECTED]
> > Subject: DO NOT REPLY [Bug 28623] New: - 
> > validateExcatLength()-method in FieldChecks ?
> > 
> > 
> > DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
> > RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT 
> > <http://issues.apache.org/bugzilla/show_bug.cgi?id=28623>.
> > ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
> > INSERTED IN THE BUG DATABASE.
> > 
> > http://issues.apache.org/bugzilla/show_bug.cgi?id=28623
> > 
> > validateExcatLength()-method in FieldChecks ?
> > 
> >            Summary: validateExcatLength()-method in FieldChecks ?
> >            Product: Struts
> >            Version: Nightly Build
> >           Platform: Other
> >         OS/Version: Other
> >             Status: NEW
> >           Severity: Enhancement
> >           Priority: Other
> >          Component: Validator Framework
> >         AssignedTo: [EMAIL PROTECTED]
> >         ReportedBy: [EMAIL PROTECTED]
> > 
> > 
> > Hi,
> > i need sometimes for (german)-zip codes
> > minLength and maxLength. so i wrote an excatLength()-Method.
> > 
> > would it be usful, to have such a method in FieldChecks?
> > 
> > here it is:
> > 
> > public static boolean validateExactLength(
> >   Object bean,
> >   ValidatorAction va,
> >   Field field,
> >   ActionMessages errors,
> >   HttpServletRequest request) {
> > 
> >    String value =
> >     ValidatorUtils.getValueAsString(bean, field.getProperty());
> > 
> >     if (value != null) {
> >       try {
> >    int exact = Integer.parseInt(field.getVarValue("exact"));
> > 
> >     if (value.length() != exact) {
> >       errors.add(
> >              field.getKey(),
> >              Resources.getActionMessage(request, va, field));
> > 
> >    return false; }
> >       } catch (Exception e) {
> >       errors.add(
> >              field.getKey(),
> >              Resources.getActionMessage(request, va, field));
> >                     
> >       return false;  }
> >             }  
> >       return true;
> > }
> > 
> > in validator-rules.xml i added this:
> > 
> > <validator classname="net.wessendorf.j2ee.struts.utils.Validator"
> > method="validateExactLength"
> >  methodParams="java.lang.Object,
> >   org.apache.commons.validator.ValidatorAction,
> >   org.apache.commons.validator.Field,
> >   org.apache.struts.action.ActionErrors,
> >   javax.servlet.http.HttpServletRequest"
> >  msg="errors.exact" depends="required" name="exact"/>
> > 
> > 
> ---------------------------------------------------------------------
> > 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]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to