1 write to ModelState
Microsoft.AspNetCore.Mvc.Abstractions (1)
Formatters\InputFormatterContext.cs (1)
76
ModelState
= modelState;
68 references to ModelState
Microsoft.AspNetCore.Mvc.Abstractions (1)
Formatters\InputFormatterContext.cs (1)
98
/// Gets the name of the model. Used as the key or key prefix for errors added to <see cref="
ModelState
"/>.
Microsoft.AspNetCore.Mvc.Core (3)
Formatters\SystemTextJsonInputFormatter.cs (2)
74
context.
ModelState
.TryAddModelError(path, modelStateException, context.Metadata);
85
context.
ModelState
.TryAddModelError(string.Empty, exception, context.Metadata);
Formatters\TextInputFormatter.cs (1)
46
context.
ModelState
.AddModelError(context.ModelName, exception, context.Metadata);
Microsoft.AspNetCore.Mvc.Core.Test (29)
Formatters\JsonInputFormatterTestBase.cs (15)
148
formatterContext.
ModelState
.OrderBy(k => k.Key),
175
formatterContext.
ModelState
.OrderBy(k => k.Key),
203
formatterContext.
ModelState
.OrderBy(k => k.Key),
326
Assert.Collection(formatterContext.
ModelState
.OrderBy(k => k.Key),
352
Assert.Collection(formatterContext.
ModelState
.OrderBy(k => k.Key),
379
Assert.Collection(formatterContext.
ModelState
.OrderBy(k => k.Key),
405
formatterContext.
ModelState
.OrderBy(k => k.Key),
424
formatterContext.
ModelState
.MaxAllowedErrors = 3;
425
formatterContext.
ModelState
.AddModelError("key1", "error1");
426
formatterContext.
ModelState
.AddModelError("key2", "error2");
434
Assert.False(formatterContext.
ModelState
.ContainsKey("age"));
435
var error = Assert.Single(formatterContext.
ModelState
[""].Errors);
486
Assert.Collection(formatterContext.
ModelState
.OrderBy(k => k.Key),
511
formatterContext.
ModelState
.OrderBy(k => k.Key),
534
Assert.Single(formatterContext.
ModelState
["Person.Name"].Errors);
Formatters\SystemTextJsonInputFormatterTest.cs (11)
80
formatterContext.
ModelState
.OrderBy(k => k),
103
Assert.False(formatterContext.
ModelState
.IsValid);
104
var kvp = Assert.Single(formatterContext.
ModelState
);
124
Assert.False(formatterContext.
ModelState
.IsValid);
125
var kvp = Assert.Single(formatterContext.
ModelState
);
154
Assert.True(!formatterContext.
ModelState
.IsValid);
155
Assert.True(formatterContext.
ModelState
.ContainsKey(modelStateKey));
157
var modelError = formatterContext.
ModelState
[modelStateKey].Errors.Single();
176
Assert.True(!formatterContext.
ModelState
.IsValid);
177
Assert.True(formatterContext.
ModelState
.ContainsKey("$"));
179
var modelError = formatterContext.
ModelState
["$"].Errors.Single();
Formatters\TextInputFormatterTest.cs (3)
34
Assert.True(context.
ModelState
.ContainsKey("something"));
35
Assert.Single(context.
ModelState
["something"].Errors);
37
var error = context.
ModelState
["something"].Errors[0];
Microsoft.AspNetCore.Mvc.NewtonsoftJson (1)
NewtonsoftJsonInputFormatter.cs (1)
309
context.
ModelState
.TryAddModelError(key, modelStateException, metadata);
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (34)
NewtonsoftJsonInputFormatterTest.cs (18)
170
Assert.False(formatterContext.
ModelState
.IsValid);
172
var message = formatterContext.
ModelState
.Values.First().Errors[0].ErrorMessage;
247
Assert.True(!formatterContext.
ModelState
.IsValid);
248
Assert.True(formatterContext.
ModelState
.ContainsKey(modelStateKey));
250
var modelError = formatterContext.
ModelState
[modelStateKey].Errors.Single();
272
formatterContext.
ModelState
.OrderBy(k => k.Key),
302
Assert.True(!formatterContext.
ModelState
.IsValid);
303
Assert.True(formatterContext.
ModelState
.ContainsKey(string.Empty));
305
var modelError = formatterContext.
ModelState
[string.Empty].Errors.Single();
335
Assert.True(!formatterContext.
ModelState
.IsValid);
336
Assert.True(formatterContext.
ModelState
.ContainsKey(string.Empty));
338
var modelError = formatterContext.
ModelState
[string.Empty].Errors.Single();
367
Assert.False(formatterContext.
ModelState
.IsValid);
369
var modelError = Assert.Single(formatterContext.
ModelState
["dateValue"].Errors);
398
Assert.False(formatterContext.
ModelState
.IsValid);
400
var modelError = Assert.Single(formatterContext.
ModelState
["shortValue"].Errors);
429
Assert.False(formatterContext.
ModelState
.IsValid);
431
var modelError = Assert.Single(formatterContext.
ModelState
["Complex.WithPrimitives[0].shortValue"].Errors);
NewtonsoftJsonPatchInputFormatterTest.cs (1)
219
Assert.Contains(exceptionMessage, formatterContext.
ModelState
[""].Errors[0].ErrorMessage);
src\Mvc\Mvc.Core\test\Formatters\JsonInputFormatterTestBase.cs (15)
148
formatterContext.
ModelState
.OrderBy(k => k.Key),
175
formatterContext.
ModelState
.OrderBy(k => k.Key),
203
formatterContext.
ModelState
.OrderBy(k => k.Key),
326
Assert.Collection(formatterContext.
ModelState
.OrderBy(k => k.Key),
352
Assert.Collection(formatterContext.
ModelState
.OrderBy(k => k.Key),
379
Assert.Collection(formatterContext.
ModelState
.OrderBy(k => k.Key),
405
formatterContext.
ModelState
.OrderBy(k => k.Key),
424
formatterContext.
ModelState
.MaxAllowedErrors = 3;
425
formatterContext.
ModelState
.AddModelError("key1", "error1");
426
formatterContext.
ModelState
.AddModelError("key2", "error2");
434
Assert.False(formatterContext.
ModelState
.ContainsKey("age"));
435
var error = Assert.Single(formatterContext.
ModelState
[""].Errors);
486
Assert.Collection(formatterContext.
ModelState
.OrderBy(k => k.Key),
511
formatterContext.
ModelState
.OrderBy(k => k.Key),
534
Assert.Single(formatterContext.
ModelState
["Person.Name"].Errors);