0
我希望能夠讀取傳遞到自定義驗證屬性的ErrorMessage
字符串,以便我可以在其上執行一些string.Format()
。但我似乎無法找到它?從自定義驗證屬性中訪問ErrorMessage
因此,例如,我有一個自定義屬性:
[IsDateBeforeFixedDate(4, 0, 0, ErrorMessage = "*The departure date should be between 4 days and 11 months")]
decalred爲:
public sealed class IsDateBeforeFixedDateAttribute : ValidationAttribute, IClientValidatable
{
public IsDateBeforeFixedDateAttribute(int days, int months, int years) : base(days, months, years)
{
//I want to read the ErrorMessage string here! (i.e. "*The departure date should be between 4 days and 11 months")
}
}
ErrorMessageString
不包含它或ErrorMessage