This is my model:
namespace MvcApplication2.Models
{
public class CreditCard
{
[CreditCard(ErrorMessageResourceType = typeof(Messages), Error
I had this problem because I had implemented a RequiredAttributeAdapter, which was setting the ErrorMessageResourceName property automatically.
You can fix it by checking to see if the ErrorMessage property has been set before setting the ErrorMessageResourceName:
///
/// Creates a new instance of the RequiredAttributeAdapter, used for switching the default required message
/// format
///
public CustomMessageRequiredAttributeAdapter(
ModelMetadata metadata,
ControllerContext context,
RequiredAttribute attribute
)
: base(metadata, context, attribute)
{
if (string.IsNullOrEmpty(attribute.ErrorMessage))
{
attribute.ErrorMessageResourceType = typeof (ValidationMessages);
attribute.ErrorMessageResourceName = "PropertyValueRequired";
}
}