I\'m using the web api to build an API and when receiving the posted values and binding them to my model I get an error that seems out of place.
I have a simple mod
The reason this validation is there is because for reference-typed members, whenever the member is deserialized WebAPI can check that the member is not null. For value types, there is no null value so it's up to the formatter to check that the value is present in the request body. Unfortunately, our XML formatter doesn't support the [Required] attribute so it won't raise a model state error if the member is missing.
If you're OK with certain formatters not raising model state errors for the missing value-typed members, you can use this line to remove the validation:
config.Services.RemoveAll(typeof(ModelValidatorProvider), (provider) => provider is InvalidModelValidatorProvider);