我有以下代码:
public void Foo(
[Required(ErrorMessage = "Null not allowed")]
[ModelValidation] //custom validation
UserModel user
)
{
//Do some code
}
有没有一种方法,调用此方法可以根据数据注释验证输入?
答案 0 :(得分:0)
要向最终用户显示文档,您可以使用<param>
注释作为输入参数,如下所示-
/// <summary>
/// This method validates and submits your report for processing
/// </summary>
/// <param name="ReportName">This is the name of your report</param>
/// <param name="ReportTotalUSD">This is the total amount in USD</param>
/// <param name="ReportDate">This is the date you incurred expenses</param>
[AllowAnonymous]
[HttpPost]
[ResponseType(typeof(List<int>))]
public IHttpActionResult SubmitReport(string ReportName, decimal ReportTotalUSD, DateTime ReportDate)