This repository was 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
Discuss adding server side validation to value type model properties by default. #2776
Comments
Decision here is to bring back the implicit
|
rynowak
added a commit
that referenced
this issue
Aug 11, 2015
rynowak
added a commit
that referenced
this issue
Aug 11, 2015
rynowak
added a commit
that referenced
this issue
Aug 12, 2015
We've done more investigation here, and the data above isn't correct about MVC 5's behavior. In MVC 5 the absence of a field does not result in a validation error for a value type property. You only get the validation error if you submit an empty value. This is critical for compatibility because Create views that scaffolding generates will omit the |
rynowak
added a commit
that referenced
this issue
Aug 14, 2015
some more tests. This change reverts the behavior change from a6ce9ab and adds more tests around the scneario that was actually broken. The right behavior is that unconvertable values result in a validation error. There's no special behavior around value types and required values.
rynowak
added a commit
that referenced
this issue
Aug 16, 2015
some more tests. This change reverts the behavior change from a6ce9ab and adds more tests around the scneario that was actually broken. The right behavior is that unconvertable values result in a validation error. There's no special behavior around value types and required values.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Today in MVC6 having the following model:
Will result in client side validation with 0 server side validation (unless specifying
BindingBehaviorAttribute
withBindingBehavior.Required
).This differs from what happened in MVC5; model state would be invalid due to server side validation opting in
ValueType
properties. However, in WebAPI not providing a value for aValueType
property when model binding was 100% ok and did not result in anyModelState
errors.Given the different behavior in the old MVC/WebAPI systems we should discuss the right approach for this in MVC6.
Related conversation that spurred this: #2720 (comment)
/cc @rynowak @Eilon @dougbu
The text was updated successfully, but these errors were encountered: