validwhen will let you create validation rules in terms of the *relationship* between the property being validated and other properties. I don't believe you can use it to conditionally apply *other* rules.
A common example is the ol' password/confirmPassword pattern where the user enters the password twice and the two properties must match:
That rule says the confirmPassword property is valid only when it matches the password property. Since neither is required there, the match would also be satisfied when they're both empty. This might be suitable for a 'change password' feature which is activated only when there is input, but you'd want to apply rules to the password property regarding length, etc.
afik, there isn't a way to make *other* validation rules be conditional based on a validwhen expression.
An approach that would work is to create separate action mappings for create and modify, then applying the appropriate validations for each of those mappings.
If you had separate mappings for '/createUserRegistration' and '/modifyUserRegistration', you could then use a DynaValidatorActionForm, for example, to allow your validation to differ between those two mappings.
Those mappings could still use the same ActionForm, jsps/tiles, forwards as they do now, but the validation would be dependent on the mapping that was used.
When using DynaValidatorActionForm, the value of the validation 'form' element's 'name' attribute is the action mapping name instead of the form:
If anyone has a suggestion about conditional validation with validwhen (ie: apply a set of rules conditionally based on the test), I'd also love to hear them. I posted a similar question last week and got no response.