Hi,
I'm not sure whether this is a bug that was introduced in 4.5.9 or that was fixed in 4.5.9.
Basically we've got a Web API that our MVC Application post's to, both with the same version of NewtonsoftJSON. This was version 4.5.7 but we've recently done an upgrade to 4.5.11.
At it's core we've got a Enum validator that extends the Required validator, we've had this on an Enum that goes from 0-3 that's passed between our MVC application and our Web Api application this has been working fine but with update 4.5.9 it now fails on the Required validator only for the Enum value that's 0.
What happens is this now throws an exception during Validating:
Required property 'x' not found in JSON. Path '', line x, position x.
Is this intentional?
Some Technical Snippets.
On the WCF Web Service we've got a Controller/Action that looks like this:
public HttpResponseMessage Post(PublishRequest) {
...
}
The PublishRequest looks like
public class PublishRequest {
[EnumRequired(ErrorMessage="Blah")]
public StructureEnum SalaryStructureEnum { get; set; }
}
Our StructureEnum looks like:
public enum StructureEnum {
Annual = 0,
AnnualAndCommission = 1,
CommissionOnly = 2,
HourlyRate = 3
}
and our Enum Required attribute is:
public class EnumRequiredAttribute : RequiredAttribute {
public override bool IsValid(object value) {
return Enum.IsDefined(value.GetType(), value);
}
}