With the Struts-Validator Framework i want to validate a Date.
This works fine, but if the field i want to validate is not a required field and may
be empty, the validator always reports an error, even if if i remove the
depends="required".
Do i have to implement the Validator-class in a way that it doesnt validate empty
dates or is there any declarative way to solve this?
Thanks for any help.
Axel
This is my validation-rules.xml:
<validator name="date"
classname="org.apache.struts.util.StrutsValidator"
method="validateDate"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest"
depends="required"
msg="errors.date"
jsFunctionName="DateValidations">
and the validation.xml:
<field property="beginEmployment" depends="date">
<arg0 key="personal.data.beginEmployment" />
<var>
<var-name>datePattern</var-name>
<var-value>dd.MM.yyyy</var-value>
</var>
</field>