Validation: One property validation should fire if other property isn't null

Topics: Validation Application Block
Jun 1, 2009 at 2:54 PM


Say I have a class with two properties, ContactName and ContactPhone. Is it possible to have a check that if ContactName isn't null, ContactPhone must not also be null?

something like:

public class Contact
    public string ContactPersonName { get; set; }
    public string ContactPersonPhone { get; set; }

Is it possible?

Best regards,

Jun 2, 2009 at 5:45 AM


I think you can do this using the SelfValidation of the Validation Application Block. - self validation tutorial.

Related Link:

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.