fix #3414 : RegularExpressionAttribute generates wrong data-val-regex message
This commit is contained in:
parent
380a93d370
commit
454ff9f52a
|
|
@ -52,16 +52,15 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
|
||||||
throw new ArgumentNullException(nameof(modelMetadata));
|
throw new ArgumentNullException(nameof(modelMetadata));
|
||||||
}
|
}
|
||||||
|
|
||||||
var displayName = modelMetadata.GetDisplayName();
|
|
||||||
if (_stringLocalizer != null &&
|
if (_stringLocalizer != null &&
|
||||||
!string.IsNullOrEmpty(Attribute.ErrorMessage) &&
|
!string.IsNullOrEmpty(Attribute.ErrorMessage) &&
|
||||||
string.IsNullOrEmpty(Attribute.ErrorMessageResourceName) &&
|
string.IsNullOrEmpty(Attribute.ErrorMessageResourceName) &&
|
||||||
Attribute.ErrorMessageResourceType == null)
|
Attribute.ErrorMessageResourceType == null)
|
||||||
{
|
{
|
||||||
return _stringLocalizer[displayName];
|
return _stringLocalizer[Attribute.ErrorMessage];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Attribute.FormatErrorMessage(displayName);
|
return Attribute.FormatErrorMessage(modelMetadata.GetDisplayName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ namespace LocalizationWebSite.Models
|
||||||
{
|
{
|
||||||
public class User
|
public class User
|
||||||
{
|
{
|
||||||
[MinLength(4, ErrorMessage = "Name")]
|
[MinLength(4, ErrorMessage = "NameError")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
public Product Product { get; set; }
|
public Product Product { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@
|
||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<data name="Name" xml:space="preserve">
|
<data name="NameError" xml:space="preserve">
|
||||||
<value>Nom non valide. Longueur minimale de nom est 4</value>
|
<value>Nom non valide. Longueur minimale de nom est 4</value>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Loading…
Reference in New Issue