From 4ea7d44f805d7acb1c896fe2f4a33a4ae93c97f2 Mon Sep 17 00:00:00 2001 From: Alexandru Bucur Date: Sun, 24 Mar 2019 17:39:18 +0200 Subject: [PATCH 1/2] explain ModelState validation option ValidateModelState This should make it clearer for people on how to have nice validation when creating / updating requests. --- docs/usage/options.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/usage/options.md b/docs/usage/options.md index d613fe16f4..5cf5687036 100644 --- a/docs/usage/options.md +++ b/docs/usage/options.md @@ -61,7 +61,7 @@ services.AddJsonApi(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(options => { @@ -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`. The default behavior is to try creating the database entries. + +```c# +services.AddJsonApi(options => { + options.ValidateModelState = true; +}); +``` From e0ccca9f943b484c5e945fc69642eb9ea4e82bc4 Mon Sep 17 00:00:00 2001 From: Alexandru Bucur Date: Fri, 5 Apr 2019 20:26:57 +0300 Subject: [PATCH 2/2] updated explanation of the ModelState Validation --- docs/usage/options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage/options.md b/docs/usage/options.md index 5cf5687036..8716a27ab2 100644 --- a/docs/usage/options.md +++ b/docs/usage/options.md @@ -81,7 +81,7 @@ 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`. The default behavior is to try creating the database entries. +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(options => {