Is there any way to validate information across two fields in Struts2? For example, lets say I want to enforce the rule fieldX must be less than fieldY. Is there any way to add an XML rule that says this?
You *can* do pretty much anything with the expression validator, although anything more complicated than simple comparisons etc. may be better off inside a validate() method. Note that manual and XML- or annotation-based validation can work in concert w/ a call to super.validate().
Can it be done in XML or do I need to create a custom validator class? I like all the validations I have in place via the XML, I just want to add the additional rule comparing two fields.
That said, using an action's validate() method doesn't require making a custom validator class; it requires calling super.validate(), writing a compare, and adding a field error message on failure.