• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Struts conditional/dependent validation

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to create a validation rule (validation.xml) that will apply a set of other rules to a given form property depending on the value of another form property?

I'm using Struts 1.2.4, and am aware of (and using) validwhen for dependent validation where a rule is expressed in terms of another property's value and a boolean expression.

I want to make the application of certain rulesets conditional on the value of another property.

One example is an industry-specific credit card that has a different format from the standard CreditCardValidator's (which is the commons validator that Struts uses out of the box for credit card).

Given a 'type' property and a 'cardNumber' property, I'd want to apply the stock CreditCardValidator rules only when the type is not the known industry-specific type code, otherwise I want to apply a simple regexp mask.

Short of creating another CreditCardType-implementing class and wiring it into my own validator rule, can this sort of thing be done in the xml validation def?
 
A wop bop a lu bob a womp bam boom. Tutti frutti ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic