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

  • Home
  • SEARCH
  • 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 602987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:52:57+00:00 2026-05-13T16:52:57+00:00

I have an Address object that I am trying to validate data against using

  • 0

I have an Address object that I am trying to validate data against using EntLib:

Given the following method:

<ValidatorComposition(CompositionType.And, Ruleset:="FraudAnalysis")> _
<NotNullValidator(MessageTemplate:="Billing address is required.", Ruleset:="FraudAnalysis")> _
<TypeConversionValidator(GetType(Address), MessageTemplate:="Billing address must be an address object.", Ruleset:="FraudAnalysis")> _
Public Property BillingAddress() As Address
    Get
        Return _BillingAddress
    End Get
    Set(ByVal value As Address)
        _BillingAddress = value
    End Set
End Property

I create an address object:

            Address thisAddress = new Address();
            thisAddress.Address1 = "12312 Long Street";
            thisAddress.City = "Los Angeles";
            thisAddress.State = "CA";
            thisAddress.Zip = "93322";
            // set billing address to address
            cardX.BillingAddress = thisAddress;

So now at cardX.billingAddress = thisAddress, the BillingAddress property validator (GetType(Address)) should fire. It seems to fire, but returns this error:

Value to validate is not of the expected type: expected System.String but got Address instead.

Can anyone see the issue here / suggest a fix?

Thanks.

  • 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-13T16:52:57+00:00Added an answer on May 13, 2026 at 4:52 pm

    I would just get rid of the ValidatorComposition and TypeConversionValidator declarations as I think they are redundant here. That would get rid of your error and a couple of lines of code too.

    The property is already strongly-typed to the Address class so there is no way you can set it in code to an object that isn’t an Address or isn’t polymorphic with Address – having an extra validator to check this is redundant.

    The default composition of validators is logical AND anyway, you only need to specify validator composition when you want to OR a group, or use more complex groups that combine AND / OR.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 297k
  • Answers 297k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Check out DOMDocument. Example #1 Creating a Document <?php $doc… May 13, 2026 at 7:15 pm
  • Editorial Team
    Editorial Team added an answer I suppose a solution would be to start by getting… May 13, 2026 at 7:15 pm
  • Editorial Team
    Editorial Team added an answer You're animating the .width element, but stopping the .track-version element.… May 13, 2026 at 7:14 pm

Related Questions

Platform: C# 2.0 Using: Castle.DynamicProxy2 I have been struggling for about a week now
I have the following classes. For testing purpose, I would like to get all
Trying to avoid re-inventing the wheel here. I have a Google Web Toolkit page
Sorry, that's the best subject I can come up with, if I understood the
I have this XML that I am trying to read into an object hierarchy:

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.