Thanks for reply
What's the best practice for this situation?
Thanks in advance
Blazor validation not working when using Metadata class!
Hamed Vaziri
136
Reputation points
I am using blazore Server side. Form validation is not working when using Metadata class. I am using scaffolding and my DB models are oftern automatically generated. If i modify the it wipes out all my Dataannotation validations.
Here is the class that i am using :
public partial class ContactUs_Product_ProductRequests
{
[Key]
public int ProductRequestID { get; set; }
[StringLength(50)]
public string CompanyName { get; set; }
public int? CompanyTypeID { get; set; }
[StringLength(50)]
public string AgentName { get; set; }
[StringLength(50)]
public string AgentRole { get; set; }
[StringLength(50)]
public string AgentTel { get; set; }
[StringLength(50)]
public string AgentMobile { get; set; }
[StringLength(50)]
public string AgentEmail { get; set; }
public string Description { get; set; }
[StringLength(10)]
public string RequestDate { get; set; }
}
public class ContactUs_Product_ProductRequestsMetadata
{
[Required]
public string AgentName { get; set; }
}
[MetadataType(typeof(ContactUs_Product_ProductRequestsMetadata))]
public partial class ContactUs_Product_ProductRequests
{
}
2 answers
Sort by: Newest
-
Hamed Vaziri 136 Reputation points
2021-05-25T06:28:14.773+00:00 -
Yinqiu Yao-MSFT 236 Reputation points
2021-05-24T01:59:45.363+00:00 It seems it is not yet supported for Blazor.
You can see the github issue.
MetadataTypeAttribute doesn't influence DataAnnotations validation result
Best Regards,
Yinqiu Yao