JamesNK/Newtonsoft.Json — pull request #145 by chris-peterson (2013-10-18 23:24:16+00:00)
Title: Add a property to disallow accepting of integer values.

Add a new property to StringEnumConverter to disallow integers. For backward compatibility, AllowIntegerValues defaults to true.

When using WebApi, enum types are oftentimes used in contract models. Typically, we'd do this to force the client to provide a value that falls in a set of values. If integers are allowed, however, not only does that defeat the intended encapsulation, it also can result in errant behavior...

Example contract types:
```C#
enum Behavior
{
Behavior1,
Behavior2
}

class ContractModel
{
Behavior Behavior { get; set;}
}
```

In this example, the client can pass in { "Behavior" : 99 }.

Json.NET defers to the .NET type system (in which enums are syntactical sugar around other integral primitives) which does not balk at this and is happy to store 99 in the target ContractModel.Behavior.

This causes unforeseen problems if there's code elsewhere like this:

```C#
switch (_model.Behavior)
{
case Behavior1:
// do something
case Behavior2:
// do something else
default:
// oh no! I'll actually get here
}
```