[英]Is there an model validation attribute to check parameter types without using custom code?
I have a webapi where I want to validate if the used parameter is of type int
.我有一个 webapi,我想在其中验证使用的参数是否为
int
类型。 I know of the attribute DataTypesAttribute
but it doesn't support the simple types.我知道属性
DataTypesAttribute
但它不支持简单类型。 I do not want to create a custom attribute for this.我不想为此创建自定义属性。
Take a look at here , as mentioned when you desalinize from a json
string to object the value type must be int
, if not the desalinization will fail.看看这里,正如您在从
json
字符串脱盐到对象时提到的,值类型必须是int
,否则脱盐将失败。 model validation as it's name suggests is mostly for domain driven and business related validations not type specific.顾名思义,模型验证主要用于域驱动和业务相关的验证,而不是特定于类型的验证。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.