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 8528649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:51:01+00:00 2026-06-11T08:51:01+00:00

I am already using Enterprise Library 5 Validation for my model (which is used

  • 0

I am already using Enterprise Library 5 Validation for my model (which is used also in WCF methods), so I decided that I would like to avoid redundant validators from ASP.NET 4 MVC with DataAnnotations.

But it seems, Enterprise Library Validators are not picked up automatically by MVC.

if I use MVC DataAnnotations:

[RegularExpression(MyValidationExpressions.Email, ErrorMessage = MyValidationMessages.InvalidEmailMessage)]
public virtual string Email { get; set; }

HTML contains data-val-regex-pattern and the field is being validated client-side.

But if I use the existing EL based validation:

 [RegexValidator(MyValidationExpressions.Email, MessageTemplate = MyValidationMessages.EmptyFieldMessage))]
 public virtual string Email { get; set; }

it does not display validation errors client-side, and the generated HTML does not have any validation attributes.

What am I missing here, how do I force MVC to use the existing EL validators both client-side and server-side?

Solution:

I accepted the solution to move completely to DataAnnotations. It is the easiest way and it works fine with both EntLib 5 and MVC 4. But there is a little catch with ValidationFactory – I had to replace CreateValidatorFromAttributes with CreateValidator and specific flags. See this article for explanation about how DataAnnotations work with ValidationFactory:

CreateValidatorFromAttributes doesn’t use DataAnnotations Attributes

Also DataAnnotations have the [Required] attribute which deals nicely with empty strings and strings which contain only spaces. There were some problems on VAB with that.

  • 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-06-11T08:51:02+00:00Added an answer on June 11, 2026 at 8:51 am

    The reason why this doesn’t work is because VAB’s RegexValidatorAttribute does not inherit from System.ComponentModel.DataAnnotations.RegularExpressionAttribute, but directly from ValidationAttribute. Because of this MVC doesn’t know how to handle it.

    There is a way to change the way MVC does this handling, but I don’t know how. But why don’t you just replace the usage of the RegexValidatorAttribute with DataAnnotations’ RegularExpressionAttribute? Validation Application Block 5 is able to handle DataAnnotations` attributes, so if the DataAnnotations attributes are working, just use them.

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

Sidebar

Related Questions

We are using the Enterprise Library as a standard DAL. Now, I would like
I'm already using :before_filter :authenticate_user! from devise but I would like to add another
I'm already using salted hashing to store passwords in my database, which means that
I can already do: using System.Windows.Forms; Button b; or: System.Windows.Forms.Button b; but I would
Our team is growing, but we're also growing specialized. We've already been using ticketing/bug
I am logging messages using Enterprise Library. I want some of these (typically errors
In using Enterprise Library, there was an issue with having to manually close db
I have a BIG client-serve application that uses Enterprise Library v4.0 It uses the
I'm building an ASP.NET web application using C#, Enterprise Library and Oracle for a
I'm trying to write a custom trace listener for Enterprise Library Logging which sends

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.