You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, all the validation attributes are made for validation with ASP.NET WebAPI. They come from the System.ComponentModel.DataAnnotations namespace. To make the attributes work when deserializing with JSON.net, the attributes must be under the JsonProperty attribute.
Example: Currently, a required attribute looks like this:
[Required()]
To be deserializable with JSON.net, it must look like this:
[JsonProperty(Required=Required.Always)]
An option should be given to decide which set of attributes to use.
I don't believe this will work. The JsonProperty can't be used to wrap the DataAnnotations namespace. The JsonProperty also does not support all the validation types, it only supports required.
Currently, all the validation attributes are made for validation with ASP.NET WebAPI. They come from the
System.ComponentModel.DataAnnotations
namespace. To make the attributes work when deserializing with JSON.net, the attributes must be under theJsonProperty
attribute.Example: Currently, a required attribute looks like this:
To be deserializable with JSON.net, it must look like this:
An option should be given to decide which set of attributes to use.
Relevant SO.
WebAPI Validation.
The text was updated successfully, but these errors were encountered: