Comments (5)
The problem is that in the EmailAddressAttribute the error message is assigned in the contructor, so it's like the error message is specified as a data annotation.. and it is not created in the database because of this:
// -----------------------------
// specified a message, do nothing
if (attr.ErrorMessage != null && attr.ErrorMessage != WorkaroundMarker)
{
validators.Add(new DataAnnotationsModelValidator(metadata, context, attr));
continue;
}
// -----------------------------
Here the code by microsoft:
namespace System.ComponentModel.DataAnnotations
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
public sealed class EmailAddressAttribute : DataTypeAttribute
{
private static Regex regex = new Regex("^((([a-z]|\d|[!#$%&'*+-/=?^{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_
{|}]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+))|((\x22)((((\x20|\x09)(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))(((\x20|\x09)(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|.|_||[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))).)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))).?$", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Compiled);
public EmailAddressAttribute() : base(DataType.EmailAddress)
{
base.ErrorMessage = DataAnnotationsResources.EmailAddressAttribute_Invalid;
}
public override bool IsValid(object value)
{
if (value == null)
{
return true;
}
string text = value as string;
return text != null && EmailAddressAttribute._regex.Match(text).Length > 0;
}
}
}
from griffin.mvccontrib.
I'm also facing the same issue
from griffin.mvccontrib.
I love the inconsistnency. If they just could stick to one solution to make it easier to localize the attributes.
from griffin.mvccontrib.
I'm giving up. I can fix it without using more ASP.NET MVC hacks. I've started to work on an alternative validation library for MVC which will be an drop in replacement.
from griffin.mvccontrib.
hats off...
from griffin.mvccontrib.
Related Issues (20)
- LocalizedModelValidatorProvider does not contain a constructor that takes 1 arguments HOT 6
- Using EmbeddedFileProvider for plugin css/js files HOT 6
- Client validation for custom validation attributes doesn't work HOT 7
- System.Web.Mvc.CompareAttribute not working HOT 1
- RavenDB localization provider setup HOT 12
- Overwritting of texts in RavenDB on site refresh HOT 1
- RemoteAttribute Unobstrusive Text HOT 3
- Admin section - edit, delete icon do not show up HOT 2
- Problem with select html helper HOT 4
- Error HOT 1
- Caching of the ViewLocalizer HOT 2
- FileLocalizedTypeRepository loads json file for every translation HOT 2
- Localizing text for ModelState.AddModelError()
- data-val-number attribute is missing HOT 1
- Caching of RepositoryStringProvider results
- GriffinCaching : Closed Connection
- Web API support?
- No constructor for LocalizedModelValidatorProvider takes 1 argument
- Pull request for update to MVC5 and AppVeyor HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from griffin.mvccontrib.