用户名非数字参数验证

提问

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;
    }

参考

https://blog.csdn.net/woflyoycm/article/details/110631626

posted @ 2023-04-06 11:27  喜爱糖葫芦  阅读(11)  评论(0编辑  收藏  举报