This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
ModelStateDictionary.CanAddErrors
and MaxAllowedErrors
do not match their descriptions
#1891
Comments
We should fix Fix doc comment for MaxAllowedErrors (or add a remark). The others are by design. |
Combine it when you fix the other MaxModelErrors issue |
rynowak
added a commit
that referenced
this issue
Jan 27, 2015
Changes here are all focused around MaxModelErrors on ModelStateDictionary. MaxAllowedErrors now defaults to 200 (same as options). This means that constructing a new ModelStateDictionary with the default constructor will use this default. There's a new constructor for creating a MaxAllowedErrors with a non-default value. The ControllerActionArgumentBinder is now responsible for setting the value from options onto ActionContext.ModelState. This results in better layering and guarantees the option is respected if someone uses extensibility to call model binding. ModelStateDictionary.CanAddErrors is renamed to MaxErrorsReached. We wanted to change the behavior of this property, but realized that it's very useful inside the model validation code, so opted to renamed. There's also a bunch of doc cleanup inside ModelStateDictionary to simplify things and improve clarity.
rynowak
added a commit
that referenced
this issue
Jan 27, 2015
Changes here are all focused around MaxModelErrors on ModelStateDictionary. MaxAllowedErrors now defaults to 200 (same as options). This means that constructing a new ModelStateDictionary with the default constructor will use this default. There's a new constructor for creating a MaxAllowedErrors with a non-default value. The ControllerActionArgumentBinder is now responsible for setting the value from options onto ActionContext.ModelState. This results in better layering and guarantees the option is respected if someone uses extensibility to call model binding. ModelStateDictionary.CanAddErrors is renamed to MaxErrorsReached. We wanted to change the behavior of this property, but realized that it's very useful inside the model validation code, so opted to renamed. There's also a bunch of doc cleanup inside ModelStateDictionary to simplify things and improve clarity.
rynowak
added a commit
that referenced
this issue
Jan 28, 2015
Changes here are all focused around MaxModelErrors on ModelStateDictionary. MaxAllowedErrors now defaults to 200 (same as options). This means that constructing a new ModelStateDictionary with the default constructor will use this default. There's a new constructor for creating a MaxAllowedErrors with a non-default value. The ControllerActionArgumentBinder is now responsible for setting the value from options onto ActionContext.ModelState. This results in better layering and guarantees the option is respected if someone uses extensibility to call model binding. ModelStateDictionary.CanAddErrors is renamed to MaxErrorsReached. We wanted to change the behavior of this property, but realized that it's very useful inside the model validation code, so opted to renamed. There's also a bunch of doc cleanup inside ModelStateDictionary to simplify things and improve clarity.
rynowak
added a commit
that referenced
this issue
Jan 29, 2015
Changes here are all focused around MaxModelErrors on ModelStateDictionary. MaxAllowedErrors now defaults to 200 (same as options). This means that constructing a new ModelStateDictionary with the default constructor will use this default. There's a new constructor for creating a MaxAllowedErrors with a non-default value. The ControllerActionArgumentBinder is now responsible for setting the value from options onto ActionContext.ModelState. This results in better layering and guarantees the option is respected if someone uses extensibility to call model binding. ModelStateDictionary.CanAddErrors is renamed to MaxErrorsReached. We wanted to change the behavior of this property, but realized that it's very useful inside the model validation code, so opted to renamed. There's also a bunch of doc cleanup inside ModelStateDictionary to simplify things and improve clarity.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
a few inconsistencies in the
ModelStateDictionary
implementation and doc comments:TryAddModelError()
adds up toMaxAllowedErrors
total, including the finalTooManyModelErrorsException
errorMaxAllowedErrors
doc comments state you can callTryAddModelError()
this many times "after which an error is thrown for further invocations". "after which" is off by one.CanAddErrors
is implemented so thattrue
means the nextTryAddModelError()
call will change the number of errors, either because there's room for another error or because the next call will result in theTooManyModelErrorsException
error. sotrue
does not mean the call will definitely add the expected error.CanAddErrors
doc comments correctly state it isa flag that determines if the total number of added errors (given by <see cref="ErrorCount"/>) is fewer than <see cref="MaxAllowedErrors"/>.
however the name implies something different.The text was updated successfully, but these errors were encountered: