Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

Validating Boolean Values

$
0
0

Using WebApi 2, I have a model that contains a Boolean value:

[Display(Name = "notify")]
[DataMember]
public bool notify
        { get; set; }

The input format is JSON.  ModelState will reject any value other than lower case "true" / "false."   Therefore, if a user sends in "FALSE" or "False" or "1" then there is a fail.  Is there a noted way to accept these values without 1) changing the "notify" field to string and 2) without having to write custom code?

Thanks,

cj


Viewing all articles
Browse latest Browse all 4850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>