And Composite Validator Message

Topics: Validation Application Block
Jun 15, 2007 at 3:18 PM
Edited Jun 15, 2007 at 3:20 PM
Hi

Im sure this has been covered, but I checked and couldnt find it.

If I have a And Composite Validator with 2 child rules how do I signal to the validation block to use a common error message? For example (generic pseudocode example)


[Composite And]
[StringLengthValidator Min=10 Max=20 ErrorMessage="Invalid Entry" /]
[PatternValidator Pattern="^\d{10,20}$" ErrorMessage="Invalid Entry" /]
[/Composite]

When I call verify, "Invalid Entry" is added to the error list twice. Is there a way to specify a single message at a higher level?

Thanks
Joe
Jun 19, 2007 at 7:59 AM
I think the Composite Or works like you describe, but Composite And will return all failing validators messages. It's by design.