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
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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
{
}
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
Thanks for reply
What's the best practice for this situation?
Thanks in advance