Either ErrorMessageString or ErrorMessageResourceName must be set, but not both error using CreditCardAttribute

前端 未结 8 1959
囚心锁ツ
囚心锁ツ 2020-12-24 04:44

This is my model:

namespace MvcApplication2.Models
{
    public class CreditCard
    {
        [CreditCard(ErrorMessageResourceType = typeof(Messages), Error         


        
8条回答
  •  醉话见心
    2020-12-24 05:32

    I had this same problem on a property that I was localizing. I had defined the ErrorMessageResourceType and then the ErrorMessageResourceName but by mistake put the ErrorMessage atrtribute on as well which threw the exception

    [NotEqualTo("User_Name", ErrorMessageResourceType = typeof(LROResources.Global), ErrorMessageResourceName = "UserPasswordCannotBeUsername", ErrorMessage = "The password cannot be the same as your Username.")]
    

    So in my case by just removing ErrorMessage I fixed the problem.

提交回复
热议问题