Skip to content

explain ModelState validation option ValidateModelState #487

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

Merged
merged 2 commits into from
Apr 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion docs/usage/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ services.AddJsonApi<AppDbContext>(options => {

## Custom Query Parameters

If you would like to use custom query params (parameters not reserved by the json:api specification), you can set AllowCustomQueryParameters = true. The default behavior is to return an HTTP 400 Bad Request for unknown query parameters.
If you would like to use custom query params (parameters not reserved by the json:api specification), you can set `AllowCustomQueryParameters = true`. The default behavior is to return an HTTP 400 Bad Request for unknown query parameters.

```c#
services.AddJsonApi<AppDbContext>(options => {
Expand All @@ -78,3 +78,13 @@ If you want to change the default serializer settings, you can:
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
options.SerializerSettings.ContractResolver = new DasherizedResolver();
```

## Enable ModelState Validation

If you would like to use ModelState validation into your controllers when creating / updating resources you set `ValidateModelState = true`. By default, no model validation is performed.

```c#
services.AddJsonApi<AppDbContext>(options => {
options.ValidateModelState = true;
});
```