JSON.Net架构错误消息

时间:2015-07-27 15:50:57

标签: .net validation json.net

我正在使用JSON.Net架构,我想知道是否有办法自定义从IsValid函数返回的错误消息。

返回的错误消息是:

"Message": "Float 1.2 exceeds maximum value of 1. Path 'fields.Indirect_Cost_Rate', line 4, position 40."

我想说错误信息:

"Message": "Indirect_Cost_Rate must be a number between 0 and 1 with a maximum of 4 decimal places. Path 'fields.Indirect_Cost_Rate', line 4, position 40."

使用.Net,我可以将其添加到属性中:

<Range(0, 1, ErrorMessage:="Indirect_Cost_Rate must be a number between 0 and 1 with a maximum of 4 decimal places.")>

谢谢,AD

0 个答案:

没有答案