Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core 不完全验证_Asp.net Core_Asp.net Web Api - Fatal编程技术网

Asp.net core 不完全验证

Asp.net core 不完全验证,asp.net-core,asp.net-web-api,Asp.net Core,Asp.net Web Api,有一个模型: public class Model { [Required(AllowEmptyStrings = false)] public string Code { get; set; } [Required(AllowEmptyStrings = false)] public string Name { get; set; } [MaxLength(6), MinLength(6)]

有一个模型:

public class Model
    {
        [Required(AllowEmptyStrings = false)]
        public string Code { get; set; }
        [Required(AllowEmptyStrings = false)]
        public string Name { get; set; }
        [MaxLength(6), MinLength(6)]
        public string Color { get; set; }
        [MaxLength(3)]
        public string Text { get; set; }
        [Required]
        public int? User { get; set; }
    }
如果我在用户、颜色和文本字段中传递空数据,那么答案是:

{
    "code": "VALIDATION",
    "fields": [
        {
            "field": "user",
            "error": "REQUIRED"
        }
    ]
}

为什么我得不到所需字段的完整列表?

因为您有一些自定义的验证过滤器/中间件或一些返回response@RomanMarusyk是的,你有。谁被设置为代码验证?它不是用于验证的默认asp.net响应模型。显示startup.cs和来自控制器的操作