Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support attributes required for JSON.net deserialization #15

Open
sbl03 opened this issue Aug 13, 2014 · 1 comment
Open

Support attributes required for JSON.net deserialization #15

sbl03 opened this issue Aug 13, 2014 · 1 comment

Comments

@sbl03
Copy link
Contributor

sbl03 commented Aug 13, 2014

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.


Relevant SO.
WebAPI Validation.

@sbl03 sbl03 added this to the Beta milestone Aug 13, 2014
@sbl03 sbl03 added bug labels Aug 13, 2014
@lroling8350
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants