Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6185151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:39:45+00:00 2026-05-24T01:39:45+00:00

I have an implementation of INotifyDataErrorInfo , which works as I expect it to

  • 0

I have an implementation of INotifyDataErrorInfo, which works as I expect it to with Data Annotations, but what I really want to know is how I can do a conditional validation.

Let’s say I have 3 textboxes, Name, Email and Address. I have Name as a required field, but I only require Email OR Address to be entered, and so the validation rule(s) need to check if one of those two properties has a value or not.

Hopefully that makes sense and someone will be able to guide me in the right direction.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:39:46+00:00Added an answer on May 24, 2026 at 1:39 am

    Add the attribute:

    [Required(AllowEmptyStrings = true)]
    

    to the property declarations for Email and Address in the metadata definition of your class. This will allow the string to be empty but when it’s not the normal validation rules will kick in. So if you add the class validator:

    [CustomValidation(typeof(MyValidator), "ValidationMethod")]
    

    this can then in this method check that one of these two values has been set.

    public static ValidationResult ValidationMethod(MyClass person, ValidationContext context)
    {
        if (person!= null)
        {
            if (string.IsNullOrWhiteSpace(person.Email) &&
                string.IsNullOrWhiteSpace(person.Address)
            {
                return new ValidationResult(....);
            }
        }
        return ValidationResult.Success;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Main menu in WP7 and audio player have the implementation. But how can i
I know that it's OK for a pure virtual function to have an implementation.
I figure out I can have the implementation of parts of a class in
Note:I don't mean some theoretical question which don't have any implementation just languages that
I have made a simple implementation of INotifyDataErrorInfo in a WPF 4.5 project. This
Someone said you can have (implementation inheritance) with Rebol using get. So I tried:
I have written my own java.util.List implementation, and now i want to store it
Let's say we have an interface 'IA' for which we have an implementation 'A'.
Does anyone have base32 implementation in Delphi? I found: http://cc.embarcadero.com/item/21566 but it is not
I want to recognize uppercase letters using objective-c. I have an implementation now that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.