Bob, Niall is completely right that you generally don't want to do this as it is a security hazard, however he is wrong that it cannot be done. You just need to use a custom ValidatorForm rather than relying solely on the validation config file. To do this, make the ActionForm that the ccnum property resides in a ValidatorForm instead. Then you override the validate method and inside of that method you have complete access to the credit card number they entered and can create an ActionError with whatever message you want. A complete example:
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request){ //First do the default validation ActionErrors oldErrors = super.validate(mapping, request); ActionErrors newErrors = ActionErrors(); for(ActionError error : errors){ if(error.getKey().equals("errors.creditCard.number")){ newErrors.add("errors.creditCard.number", this.getCcnum()); } else { newErrors.add(error.getKey(), error.getValues()); } } return newErrors; }<http://struts.apache.org/1.1/api/org/apache/struts/action/ActionErrors.html> On 8/25/06, Robert Harrison <[EMAIL PROTECTED]> wrote:
I can't find an example of how to insert an invalid credit card number into the error message "errors.creditcard={0} is an invalid credit card number". I'm using Struts 1.2.8 Here's my validation.xml snippet: <field property="ccnum" depends="required, creditCard"> <var> <var-name>cCard</var-name> <var-value>${ccnum}</var-value> </var> <arg position="0" name="required" key="errors.creditCard.number" /> <arg key="${var:cCard}" name="creditCard" resource="false" position="0" /> </field> With the above snippet, the error message produced is: "${ccnum} is an invalid credit card number." Can someone give me an example of how to pass the "ccnum" to arg0? Thanks, Bob -- "In theory there is no difference between theory and practice. In practice there is." Yogi Berra