用户名非数字参数验证
提问
WebApi接口如何用户名非数字参数验证
回答
[RegularExpression(pattern: @"^\D*$", ErrorMessage = "numeric user names not supported")][FromHeader(Name = "user_name")] string user_name,
[HttpPost]
[Route("token", Name = nameof(Authentication))]
[ProducesResponseType(typeof(TokenResponse), StatusCodes.Status200OK)]
[CustomHeader]
public IActionResult Authentication([RegularExpression(pattern: @"^\D*$", ErrorMessage = "numeric user names not supported")][FromHeader(Name = "user_name")] string user_name, [FromHeader(Name = "password")] string password)
{
//TODO;
}